-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix #305487: Invisible accidentals take space #6100
Fix #305487: Invisible accidentals take space #6100
Conversation
060a5b9
to
792110f
Compare
What would you think about changing those tests from visible() to addToSkyline()? Admittedly this isn’t the actual skyline, but also I probably didn’t choose the best name for that function, as I think I use it a couple of other places where it isn’t literally about the skyline. Anyhow the point is to also disable these same things if autoplace is turned off. The advantage would be allowing accidental on a note in one voice to tuck under/over notes in other voices (they already do for rests even without disabling autoplace). |
I think the point of #305487 is that invisible accidentals should not take space, but I could be wrong. Testing for addToSkyline() instead of visible() is not the answer, but I could see testing for both. |
Oh, I see. addToSkyline() returns false if the element is invisible. Very well then. I will modify this PR accordingly. |
792110f
to
9d82ad8
Compare
Of course I’ll want to test to make sure this really does work as expected, I hadn’t originally thought of maki g the change anywhere but layoutPitched(). I’ll look into this more later today. Originally I had punted in doing anything with that issue thinking it made more sense to wait for MuseScore 4, but this could actually be a good opportunity to do just this much and make a difference for those who care about such things. |
9d82ad8
to
116ccc9
Compare
@MarcSabatella What is "skyline"? |
The skyline is the heart and soul of autoplace. It’s the shape you get if you draw a zigzag line across the top of the staff, accounting for all elements that are above sticking out from the staff. We do most collision detection against this shape, not the individual elements themselves. |
I think we should also add a check in hasAccidental(), a static function in measure.cpp. Otherwise, if the first note of a measure has an invisible accidental, we use the barline-to-accidental style setting rather than barline-to-note. |
Dang it, I added some review comments, or so I thought, then apparently lost them somehow. Will re-add now. |
I don't understand how your current changes could possibly cause those mtest failures in the guitar pro tests? See https://travis-ci.org/github/musescore/MuseScore/jobs/689317166#L4353-L4917 Edit I see, #6101 seems the culprit, brown bag for me... (and for a quite stupid GP 3,4,5 import) |
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 left review comments. The most important is the one regarding the accidental stacking code - the PR as is will lose accidentals "completely" (as far as the layout is concerned) on reload.
libmscore/layout.cpp
Outdated
@@ -841,7 +841,7 @@ void Score::layoutChords3(std::vector<Note*>& notes, const Staff* staff, Segment | |||
for (int i = nNotes-1; i >= 0; --i) { | |||
Note* note = notes[i]; | |||
Accidental* ac = note->accidental(); | |||
if (ac && !note->fixed()) { | |||
if (ac && ac->addToSkyline() && !note->fixed()) { |
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.
This doesn't work correctly - it causes the layout to be skipped entirely. That means, among other things, the invisible or non-autoplaced accidental will disappear completely on save/reload.
Dealing with this will be tricky because of the interdependencies between accidentals on a single chord (which is what this code - some of the very first I contributed to MuseScore! - is dealing with). Ideally we want to still place the accidental where it would have been otherwise if it were visible and autoplaced, but we would not let this affect the position of other accidentals. But I'm not sure how feasible that is here.
The easiest answer would be to lose this particular change. This would be fine for chords with a single accidental.
But the downside would be, a single invisible accidental in the middle of a chord with multiple accidentals would leave a "gap" in the accidental stack, just as it does now.
Another possibility is to start the block so we still get the layout, but add an "if (!ac->visible()) continue;" right after the layout. Well, might be good to set some explicit x position, otherwise it will end up staying where it is when you first make it invisible, but then become 0 on save/reload. This wouldn't be acceptable for visible accidentals with autoplace turned off, though - they still need to stack normally.
Anything else would probably require deeper change to the accidental stacking algorithm further below, and I'm not even sure it would be possible to define a more sensible behavior.
@@ -3429,7 +3429,7 @@ Shape Note::shape() const | |||
Shape shape(r, name()); | |||
for (NoteDot* dot : _dots) | |||
shape.add(symBbox(SymId::augmentationDot).translated(dot->pos()), dot->name()); | |||
if (_accidental) | |||
if (_accidental && _accidental->addToSkyline()) |
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.
For the purpose of making sure accidentals can tuck over/under other notes, this is not needed. Which is to say, it could be visible() instead of addToSkyline(). As it is, this change means non-autoplaced accidentals can not only tuck over/under, they can also collide with previous notes. I guess that's expected, although not what I was originally thinking might be nice. I suppose it's more of a hack, though, so I'm fine leaving this as you have it. Just wanted to mention it in case it sparks any additional thoughts.
@@ -3442,7 +3442,7 @@ Shape Note::shape() const | |||
Shape shape(r); | |||
for (NoteDot* dot : _dots) | |||
shape.add(symBbox(SymId::augmentationDot).translated(dot->pos())); | |||
if (_accidental) | |||
if (_accidental && _accidental->addToSkyline()) |
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.
FWIW, I wonder if we could lose this NDEBUG duplication? Right now it buys us some better debug info on the shapes when compiling in debug mode, without a performance penalty otherwise. But maybe there is a less error-prone way of doing that? Way too easy for these two sections of code to get out of sync.
libmscore/note.cpp
Outdated
@@ -3442,7 +3442,7 @@ Shape Note::shape() const | |||
Shape shape(r); | |||
for (NoteDot* dot : _dots) | |||
shape.add(symBbox(SymId::augmentationDot).translated(dot->pos())); | |||
if (_accidental) | |||
if (_accidental && _accidental->addToSkyline()) | |||
shape.add(_accidental->bbox().translated(_accidental->pos())); | |||
for (auto e : _el) { | |||
if (e->autoplace() && e->visible()) { |
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.
Minor nit, not your code of course, but this could now be addToSkyline() too if we wanted.
FWIW, since I was implementing and testing my suggestions as I went along, here's my version. Main question to me would be what to actually assign as the x position for invisible accidentals. I used -width which places them just to left of the notehead. We could try to get fancy and leave a margin, account for ledger line, etc - or not. https://github.com/MarcSabatella/MuseScore/tree/noauto-accidentals |
116ccc9
to
0cd1b49
Compare
This skips allocating space for accidentals if marked invisible or no autoplace. For accidentals marked invisible, they also don't affect stacking of multiple accidentals.
0cd1b49
to
a881987
Compare
For some strange reason GitHub shows the Travis job as Pending, but that finished successfully |
Resolves: https://musescore.org/en/node/305487