-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Reset properties properly #28006
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
base: master
Are you sure you want to change the base?
Reset properties properly #28006
Conversation
@bakajikara This is great! To nitpick: the fix for #15771 is not yet perfect as - to use the example described in the issue - the 'Reset' option is still shown as enabled if you select two items of different types (e.g. a note and a dynamic), even if they both have default offsets (and the option is therefore disabled when you select either of them individually). Everything else seems good as far as I can tell! |
f63db2d
to
004b73a
Compare
…as a non-default value (fixes musescore#15771) The reset button should be enabled for unstyled elements because even if they've been manually set to the default value, they don't actually inherit the style default unless reset.
004b73a
to
c24a641
Compare
@oktophonie |
isModified = true; | ||
} | ||
|
||
if (isUndefined && isModified) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bakajikara! Great work! I think I am seeing a little problem here for something that is probably an edge case but still theoretically possible I guess: now that the loop is not exited as soon as isUndefined
becomes true
because we need to wait for isModified
to become true
as well, we risk setting isUndefined
back to false
in the subsequent iterations. I am imagining the following situation:
- User selects: element E1 of type T1, element E2 of type T2 and element E3 of type T1 (same as first).
- They all have a
height
property. - The default height for type T1 is
10
and the default height for type T2 is20
. - The height of E1 is 10. The height of E2 is 20. The height of E3 is also 10.
isUndefined
should betrue
because the three heights are not the same but it will end up beingfalse
.
I suggest changing line 715 to something like:
if (!isUndefined && propertyValue != elementCurrentValue) {
isUndefined = true;
}
Also lines 717-729 could be optimized a bit to not do anything if isModified
is already true
.
P.S. I was able to reproduce it with a "p" dynamic marking, note and a descrescendo marking. "p" comes with a default vertical offset of 2, the note with a default vertical offset of 0 and the descrescendo with a default vertical offset of 1.75. Change the 1.75 to 2 so it matches the "p" (but not the note). Select first the "p", then the note and then the descrescendo. The X offset shows 0 and the Y offset shows 2. Both should show "--" instead.
Resolves: #15758
Resolves: #15765
Resolves: #15771
Resolves: #22835
Previously, property resets were done by overwriting with a specific default value, but now they are done correctly.