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

Ledger lines clear stems when voices overlap #19402

Merged
merged 5 commits into from Oct 10, 2023

Conversation

miiizen
Copy link
Contributor

@miiizen miiizen commented Sep 14, 2023

Resolves: #18724

  • 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 15, 2023
// Above stave
Note* topUpNote = upStemNotes.back();
Note* bottomDownNote = downStemNotes.front();
if (!bottomUpNote->chord()->noStem() && bottomUpNote->chord()->stem()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a particular reason to check noStem()? As far as I know, whenever noStem is true, the stem is (supposed to be) removed, based on the value of shouldHaveStem().

int sep = topUpNote->line() - bottomDownNote->line();
if (topDownNote->line() < -1 && topDownNote->line() < bottomUpNote->line() && sep > 1
&& bottomUpNote->line() - bottomUpStemLen <= firstLedgerAbove) {
upOffset += 0.15 * sp;
Copy link
Contributor

Choose a reason for hiding this comment

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

I see a hard-coded offset here, but the length of ledger lines can be varied using Sid::ledgerLineLength. Shouldn't that be taken into account?

int firstLedgerBelow = staff->lines(bottomUpNote->tick()) * 2;
// Don't adjust unisons or 2nds as these move anyway
int sep = topUpNote->line() - bottomDownNote->line();
if (bottomUpNote->line() > staff->lines(bottomUpNote->tick()) * 2 - 1 && topDownNote->line() < bottomUpNote->line()
Copy link
Contributor

Choose a reason for hiding this comment

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

What about using firstLedgerBelow here too?

Suggested change
if (bottomUpNote->line() > staff->lines(bottomUpNote->tick()) * 2 - 1 && topDownNote->line() < bottomUpNote->line()
if (bottomUpNote->line() > firstLedgerBelow - 1 && topDownNote->line() < bottomUpNote->line()

@miiizen
Copy link
Contributor Author

miiizen commented Oct 3, 2023

That review unearthed quite a few issues, apologies. After a bit of a refactor:

  • Moved code to a more correct place so we don't check separation twice
  • Hooks are considered properly - 0.15sp created from the edge of the hook glyph to adjacent ledger line, and 0.15sp created when downstem hooks moved to right of upstem note
  • Made adjustment 0.15sp from the end of the ledger line, taking into account Sid::ledgerLineLength
  • Differently sized noteheads taken into account
  • Prevent notehead and ledger line collisions
  • Tuck notes with hooks underneath higher notes when hook doesn't collide with notehead
  • Updated tests

@cbjeukendrup cbjeukendrup removed the request for review from RomanPudashkin October 8, 2023 19:52
@cbjeukendrup
Copy link
Contributor

@oktophonie This may need re-testing since there were quite some changes since your approval. But perhaps you already did, I'm not sure.

@cbjeukendrup cbjeukendrup merged commit 111ba8e into musescore:master Oct 10, 2023
10 of 11 checks passed
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Oct 10, 2023
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Oct 10, 2023
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.

Ledger lines should clear stems when voices overlap
3 participants