Skip to content

Fix autoplace of fret diagrams pushed onto next system #29132

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

Merged
merged 4 commits into from
Aug 21, 2025

Conversation

miiizen
Copy link
Contributor

@miiizen miiizen commented Aug 7, 2025

Resolves: #28894
Resolves: #29127
Chords and fretboard diagrams need to be laid out to calculate horizontal space. This is done in MeasureLayout. If a chord or fretboard diagram is pushed onto the next system, the layout call in MeasureLayout happens, but the autoplace call in SystemLayout is never made.

@miiizen miiizen requested a review from avvvvve August 12, 2025 16:11
@miiizen miiizen force-pushed the 28894-autoplace-fb branch from ffc1e27 to 963dd12 Compare August 13, 2025 14:53
@@ -1051,6 +1052,9 @@ void MeasureLayout::layoutMeasure(MeasureBase* currentMB, LayoutContext& ctx)
for (EngravingItem* e : segment.annotations()) {
if (e->isSymbol() || e->isHarmony() || e->isFretDiagram()) {
TLayout::layoutItem(e, ctx);
if ((e->isHarmony() || e->isFretDiagram()) && e->autoplace() && measure->system()) {
Autoplace::autoplaceSegmentElement(e, e->mutldata(), false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this call really necessary? If I'm not mistaken, when this function gets called the staff skyline doesn't even exist yet (at least on the first layout, and on the next layouts it will probably find the skyline from the previuos layout) so this call wouldn't do much. I'm also wondering if the same issue exists for all other textbased elements?

Copy link
Contributor Author

@miiizen miiizen Aug 18, 2025

Choose a reason for hiding this comment

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

Yes - in this situation the layout call above (which is necessary for horizontal spacing) resets the y position of the chord symbol causing a collision between the fret diagram and chord symbol. The measure containing the fret diagram gets moved to the next system, so the autoplace call in SystemLayout::layoutSystemElements is never reached and we get a collision between the fret diagram and chord symbol.

Although, maybe this means that we just need to layout the next system if a measure has been added to it. Thinking about this now, it seems like that should definitely be done?

@@ -192,6 +192,8 @@ void HarmonyLayout::layoutModifierParentheses(const Harmony* item)
const std::vector<HarmonyRenderItem*>& itemList = item->ldata()->renderItemList();
// Layout parentheses
std::vector<ChordSymbolParen*> openingParenStack;
double lastTsHeight = 0.0;
double lastTsTop = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

What does lastTs mean? For readability, let's try to avoid calling things with abbreviations unless they are obvious or well known

@avvvvve
Copy link

avvvvve commented Aug 20, 2025

Sorry for delay, but retested this case now that this PR is merged, and it looks to be fixed. Approved!

Previous buggy behavior with visibility:

Screen.Recording.2025-08-13.at.12.19.42.PM.mov

@miiizen miiizen force-pushed the 28894-autoplace-fb branch 2 times, most recently from bdcdc4a to 32d1912 Compare August 21, 2025 09:45
@miiizen miiizen force-pushed the 28894-autoplace-fb branch from 32d1912 to 4d8f315 Compare August 21, 2025 09:48
@miiizen miiizen merged commit 1a84584 into musescore:master Aug 21, 2025
13 checks passed
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.

Showing the beat grid (by holding shift) causes fretboard diagrams on next system to move Auto-place is inconsistent with fretboard diagrams
4 participants