-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 MS #314800 Add Ledger Lines to Key Signatures #10488
Conversation
src/engraving/libmscore/keysig.cpp
Outdated
drawSymbol(SymId::legerLine, painter, PointF((ks.pos.x() - xshift), (_line * _spatium))); | ||
++_line; | ||
} | ||
while (_line >= 5) { |
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.
Here you assume that a staff has 5 lines, but that might not always be the case. Better use staff() ? staff()->staffTypeForElement(this)->lines() : 5
instead of 5
. As an optimization, you could take that out of the for-loop and store it in a variable.
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.
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.
Wouldn't staff() ? staff()->staffTypeForElement(this)->lineDistance().val() : 1.0;
help here?
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.
Scaling bug for ledger lines seems to be fxed now:
Found another bug, but it is not caused by this PR (already there in 3.6.2) - scaling misplaces accidentals in custom key signatures #10497
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.
Personally I would expect the distance between the ledger lines to be the same as the distance between the staff lines. That of course relates to the other bug you just discovered. If you would like to solve that bug yourself (while on it), I could assign it to you.
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.
Also, that VTest still seems to fail the same way as before... you will indeed need to use staff() ? staff()->staffTypeForElement(this)->lineDistance().val() : 1.0;
, as Jojo suggests.
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.
Yes, distance should be same, as distance between lines, but as you can see, ledger lines corresponds with accidentals. I will chek something. Thank You.
One question staff()->staffTypeForElement(this)->lineDistance().val()
or staff()->lineDistance(tick())
would be OK?
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.
The latter looks simpler, but for symmetry alone I'd rather use the former?
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.
The former contains a small optimization compared to the latter, because it avoids a call to tick()
in case there is only one staff type on that staff (which is the case in most scores, I'd think). For some elements, tick()
is a very trivial call, but for others, it involves a bit more.
src/engraving/libmscore/keysig.cpp
Outdated
qreal _spatium = spatium(); | ||
qreal xshift = (ks.sym == SymId::accidentalSharp) ? (_spatium * .15) : (_spatium * .25); | ||
int y = int(ks.spos.y()); | ||
int staffLines = staff() ? staff()->staffTypeForElement(this)->lines() : 5; |
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.
Maybe better move this line to before the for
loop?
0717dfc
to
d748d71
Compare
src/engraving/libmscore/keysig.cpp
Outdated
@@ -315,6 +315,19 @@ void KeySig::draw(mu::draw::Painter* painter) const | |||
painter->setPen(curColor()); | |||
for (const KeySym& ks: _sig.keySymbols()) { | |||
drawSymbol(ks.sym, painter, PointF(ks.pos.x(), ks.pos.y())); | |||
// draw ledgerLines | |||
qreal _spatium = spatium(); | |||
qreal xshift = (ks.sym == SymId::accidentalSharp) ? (_spatium * .15) : (_spatium * .25); |
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.
Maybe make this qreal x = ks.pos.x() - (ks.sym == SymId::accidentalSharp) ? (_spatium * .15) : (_spatium * .25);
and use that in the 2 drawSymbol() calls?
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.
In fact, they are never called both, every time just one of them, so what is the reason for this change? Pretyfng code?
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.
Ah, I missed that. but it won't harm anyway
I hope, finaly its fixed. |
Hmm, my backport to 3.x doesn't work well: Have a sample score to test this? Preferably for MuseScore 3? |
Somehow one line became wrong in Your backport. |
src/engraving/libmscore/keysig.cpp
Outdated
for (const KeySym& ks: _sig.keySymbols()) { | ||
drawSymbol(ks.sym, painter, PointF(ks.pos.x(), ks.pos.y())); | ||
// draw ledgerLines | ||
qreal x = ks.pos.x() - ((ks.sym == SymId::accidentalSharp) ? (_spatium * .15) : (_spatium * .25)); | ||
int i = int(ks.spos.y() / lineDist); |
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 kind of casts are frowned upon, in master at least, better use the more verbose static_cast<int>(...)
ee5bc8d
to
87f8a5f
Compare
87f8a5f
to
4ce902c
Compare
d653437
to
52a72ad
Compare
@cbjeukendrup may I kindly ask for vtest label? |
Added! |
52a72ad
to
677c8d2
Compare
I had another look at this today, and I thought, maybe we should not use the |
677c8d2
to
225a04f
Compare
Done! |
Resolves: (MS #314800)
Added ledger lines to key signatures. If accidental was above, or belove staff, ledger lines were missing and it was difficualt to recognize its position. Now it is fixed.
Possible conflicts with #10609, will need to rebase on top of it.Rebased on top of current master.