-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix #21609: Implement highlighting hard chords #22997
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?
Conversation
Only for keyboards. Co-Authored-By: Maria Cartaxo <[email protected]>
Co-Authored-By: Maria Cartaxo <[email protected]>
Co-Authored-By: Maria Cartaxo <[email protected]>
Co-Authored-By: Maria Cartaxo <[email protected]>
Co-Authored-By: Maria Cartaxo <[email protected]>
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.
It looks like relatively complicated computations are being done here. As I explained before, the drawing code (i.e. TDraw
) is not the good place for that. This code is called every single time that the screen is redrawn, which means every single time that you scroll, click, drag, move to another window, etc., even when nothing has actually changed in the score. So if the drawing code contains any non-trivial computations, the whole app becomes slow.
As I also explained, the correct place to do it is TLayout
, because that code is called only when there are changes in the score. You can then store the results of the computations, for example using setIsImpossibleChord
. In the drawing code, you can reuse these results to do some trivial logic to determine the pen color for example.
|| (item->chord()->withUpNoteDistance(i) > 24) | ||
|| (item->chord()->withDownNoteDistance(i) > 24)) { | ||
item->chord()->setIsImpossibleChord(true); | ||
item->chord()->setColor(item->selected() ? config->criticalSelectedColor() : config->criticalColor()); |
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.
Calling chord()->setColor()
is unsafe, because it modifies the property of the chord itself but doesn't register that change in the undo stack. During drawing, all elements must be treated as read-only, so you shouldn't change properties of them. To still change the color, you can either change the color of the pen of the painter, or make changes to the curColor
method.
id: colorChordsNotesBox | ||
width: parent.width | ||
|
||
text: qsTrc("appshell/preferences", "Color chord notes outside of usable pitch range") |
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.
I'm not sure if this is good wording. This feature doesn't really have to do with "usable pitch range" ("range" implies that it would have something to do with the highest or lowest pitch that an instrument could possibly play but that is not what this is about).
How about something like just "Color unplayable chords"?
(I'd then also update the method names in the code everywhere to reflect how this feature is called in the UI, because otherwise it becomes confusing)
// withUpNoteDistance | ||
//--------------------------------------------------------- | ||
|
||
int Chord::withUpNoteDistance(int inPitch) const |
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.
From the name, I don't understand what this method does (I don't know very well either how to interpret the name at all). So:
- What does it do?
- How was the name supposed to explain that?
- Can we find a better name that explains that even better?
We have developed this feature. Because there have been discussions on whether to turn this feature into a plugin (or whether to add this feature at all), we opted by adding a checkbox in the preferences (note input) to turn this option on/off. We also implemented this feature only for keyboards, because implementing for the other instruments would demand information we unfortunately don't have access to.
Resolves: #21609