Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify editor "ternary button" structure #31462

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Jan 9, 2025

As I look into re-implementing the ability to choose combo colour for an object (also known as "colourhax") from the editor UI, I stumble upon these wretched ternary items again and sigh a deep sigh of annoyance.

The structure is overly rigid. TernaryItem does nothing that DrawableTernaryItem couldn't, except make it more annoying to add specific sub-variants of DrawableTernaryItem that could do more things like have a colour selector on the right of it.

Yes you could sprinkle more levels of virtuals to CreateDrawableButton() or something, but after all, as Saint Exupéry says, "perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away." So I'm leaning for taking one step towards perfection.

Most of this diff is mechanical with the exception of SampleBankTernaryButton, which was already starting to contort the rigid structure, and now is mostly freed of it (although it did take some non-trivial changes to achieve this).

(EditorRadioButtonCollection, one day you're getting this treatment, too.)

As I look into re-implementing the ability to choose combo colour for an
object (also known as "colourhax") from the editor UI, I stumble upon
these wretched ternary items again and sigh a deep sigh of annoyance.

The structure is overly rigid. `TernaryItem` does nothing that
`DrawableTernaryItem` couldn't, except make it more annoying to add
specific sub-variants of `DrawableTernaryItem` that could do more
things.

Yes you could sprinkle more levels of virtuals to
`CreateDrawableButton()` or something, but after all, as Saint Exupéry
says, "perfection is finally attained not when there is no longer
anything to add, but when there is no longer anything to take away."
So I'm leaning for taking one step towards perfection.
@smoogipoo smoogipoo merged commit 38d95ab into ppy:master Jan 10, 2025
7 of 10 checks passed
@peppy
Copy link
Member

peppy commented Jan 10, 2025

Requested review of this one since I originally made this class. I agree with this direction, it was clearly over-engineered for what it ended up being used for.

@bdach bdach deleted the ternary-button-is-bad branch January 10, 2025 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants