Skip to content

Fixes the X button in the editor UI's behavior for properties with default values#118

Open
isnotinvain wants to merge 1 commit intoffAudio:mainfrom
isnotinvain:fix-x-button-with-defaults
Open

Fixes the X button in the editor UI's behavior for properties with default values#118
isnotinvain wants to merge 1 commit intoffAudio:mainfrom
isnotinvain:fix-x-button-with-defaults

Conversation

@isnotinvain
Copy link
Contributor

For properties without default values, the X button moves through 3 states, and alwas moves from state 1 towards state 3: 1) Property is set to a value, eg height="7"
2) Property is set to empty string, eg height=""
3) Property is not set at all

This is nice behavior! But it doesn't work that way for properties with default value, like min-width and friends. Those properties just oscillate between states 1 and 2 and can't ever get to 3.

This PR fixes that -- I believe the issue has to do w/ callbacks triggering when we don't want them to.

This PR also makes a UI style change in that for properties in state 3, we grey out the text showing the user what default value is going to be applied. I think this makes it more clear that there is a default, here's what it is, no it's not set in your xml file explicitly. This also applies to values that were inherited -- you can see what's inherited but we make it clear that it's not set on this node.

…fault values.

For properties without default values, the X button moves through 3 states, and alwas moves from state 1 towards state 3:
1) Property is set to a value, eg height="7"
2) Property is set to empty string, eg height=""
3) Property is not set at all

This is nice behavior! But it doesn't work that way for properties with default value, like min-width and friends.
Those properties just oscillate between states 1 and 2 and can't ever get to 3.

This PR fixes that -- I believe the issue has to do w/ callbacks triggering when we don't want them to.

This PR also makes a UI style change in that for properties in state 3, we grey out the text showing the user what default value is going to be applied.
I think this makes it more clear that there is a default, here's what it is, no it's not set in your xml file explicitly.
This also applies to values that were inherited -- you can see what's inherited but we make it clear that it's not set on this node.
Copy link
Owner

@ffAudio ffAudio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for that solution.
I experienced the issue, but never had time to track it down.

if (auto* label = dynamic_cast<juce::Label*>(editor.get()))
{
juce::Value disconnected;
label->getTextValue().referTo (disconnected);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird that there is no other way to reset the value source.
Did you try this?

label->getTextValue().referTo({});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try that! I'm not familiar with most of this ecosystem so that's probably just my mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants