Skip to content
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

factor notehead offset into stem length calculations #19558

Merged
merged 2 commits into from
Oct 5, 2023

Conversation

miiizen
Copy link
Contributor

@miiizen miiizen commented Sep 29, 2023

Resolves: #19488
Stems no longer extend when changing notehead offset.

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)

@oktophonie oktophonie added the vtests This PR produces approved changes to vtest results label Sep 29, 2023
@zacjansheski
Copy link
Contributor

Stems still extend when they are beamed

video1431782670.mp4

@@ -1420,7 +1420,7 @@ double Chord::calcDefaultStemLength()
// when the chord's magnitude is < 1, the stem length with mag can find itself below the middle line.
// in those cases, we have to add the extra amount to it to bring it to a minimum.
double upValue = m_up ? -1. : 1.;
double stemStart = startNote->pos().y();
double stemStart = startNote->pos().y() - startNote->offset().y();
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as https://github.com/musescore/MuseScore/pull/19559/files#r1341666459; startNote->layoutData()->pos() would be a more direct way of getting the desired value

@miiizen
Copy link
Contributor Author

miiizen commented Oct 2, 2023

I've prevented the beamed notes stems from extending by subtracting the notehead offset in the value returned by BeamTremoloLayout::chordBeamAnchorY. This also prevents beams moving with the notehead offset. However this is less consistent with BeamTremoloLayout::chordBeamAnchorX, as this includes offset in the value it returns. Would subtracting the offset each time BeamTremoloLayout::chordBeamAnchor is called be preferred?

@zacjansheski
Copy link
Contributor

I've prevented the beamed notes stems from extending by subtracting the notehead offset in the value returned by BeamTremoloLayout::chordBeamAnchorY. This also prevents beams moving with the notehead offset. However this is less consistent with BeamTremoloLayout::chordBeamAnchorX, as this includes offset in the value it returns. Would subtracting the offset each time BeamTremoloLayout::chordBeamAnchor is called be preferred?

The current solution seems good to me. Are there any anticipated problems related to the BeamTremoloLayout::chordBeamAnchorX inconsistency?

@cbjeukendrup
Copy link
Contributor

I think it's fine; actually it's not that inconsistent, because if I'm not mistaken, the implementation of chordBeamAnchorX does ultimately not work with notes at all and thus doesn't take any note offset into account anyway.

@cbjeukendrup
Copy link
Contributor

@zacjansheski Shall we merge it in that case?
(@miiizen Any objections?)

@cbjeukendrup
Copy link
Contributor

Oh, wait a minute, a rebase is needed as layoutData has been renamed to ldata!

@miiizen
Copy link
Contributor Author

miiizen commented Oct 4, 2023

@cbjeukendrup no, as long as you're happy with it go ahead!

@cbjeukendrup cbjeukendrup merged commit 339ab2b into musescore:master Oct 5, 2023
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vtests This PR produces approved changes to vtest results
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vertical offset of notehead extends stem
4 participants