-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 #270337: True dotted lines #6349
Conversation
I guess you mean text lines, not staff lines? |
mscore/inspector/inspector_line.ui
Outdated
@@ -267,7 +267,7 @@ | |||
<double>20.000000000000000</double> | |||
</property> | |||
<property name="singleStep"> | |||
<double>1.000000000000000</double> | |||
<double>0.250000000000000</double> |
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 guess here old gap width steps are still appropriate?
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 think you are right. I'll update that.
(I am going to fix dotted slurs and search what else is missing. I think they should be fixed in this PR too).
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, agreed, slurs (and ties) should use the same
b2ce755
to
1b43ec5
Compare
libmscore/slur.cpp
Outdated
@@ -43,7 +43,9 @@ void SlurSegment::draw(QPainter* painter) const | |||
case 1: | |||
painter->setBrush(Qt::NoBrush); | |||
pen.setWidthF(score()->styleP(Sid::SlurDottedWidth) * mag); | |||
pen.setStyle(Qt::DotLine); | |||
pen.setStyle(Qt::CustomDashLine); | |||
pen.setDashPattern(QVector<qreal> {0.01, 2.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.
Shouldn't that 'magic' 2.5
rather be expressed in pen width units, pen.widthF()
(which in turn relate to Sid::SlurDottedWidth
and mag
)
See https://doc.qt.io/qt-5/qpen.html#setDashPattern
Seems the pen.setStyle(Qt::CustomDashLine)
is implicit, when using pen.setDashPattern()
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.
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 think the dashed and the wide dashed (and customer dashed) lines all should use a Qt::FlatCap
BTW, to not make themselves longer by their width.
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 will take a look at that pen.widthF() for comparison. About the space between dots, I went from 2.0 to 3.0 and ended up with 2.5 but It's a matter of deciding the design of this dotted "preset".
User can still set a custom dash pattern that looks like dotted and choose a gap - except, no rounded dots.
Ideally, Custom Dash might include an option to choose Round/Square/Flat caps (or maybe the whole thing so user can add rounded cap to solid lines) but either would require adding a property to be saved, and maybe options for Style... so I guess it might be an improvement for later.
Agree with flatCaps so dots in dash-dotted lines really look like dots. Trying this next.
EDIT: the values in the dash patterns (qreal) already refer to pen width, where 1.0 = 1 pen width, so dashes and gaps will scale with the pen (and with mag).
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 think we should be using FlatCap on all (dashed) lines and RoundCap on dots, but never SquareCap as it makes the lines longer than expexted
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.
1.5 indeed looks too dense, but 2.0 seems OK to me
libmscore/tie.cpp
Outdated
@@ -44,7 +44,9 @@ void TieSegment::draw(QPainter* painter) const | |||
case 1: | |||
painter->setBrush(Qt::NoBrush); | |||
pen.setWidthF(score()->styleP(Sid::SlurDottedWidth) * mag); | |||
pen.setStyle(Qt::DotLine); | |||
pen.setStyle(Qt::CustomDashLine); | |||
pen.setDashPattern(QVector<qreal> {0.01, 2.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.
same 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.
The problem with flat caps is that they trend to leave gaps in textline corners (hooks are separated lines so no use for joints here).
IMO, Qt lineStyles (dotted, dash dotted etc) are just internal pattern "presets" that are not well designed for caps other than flat. It would be cleaner and easier if MS just designed its own patterns for dotted/dashed dot/etc and defined them all together somewhere else, then always reference these custom internal patterns instead of using the generic Qt ones. (It would also be prettier than putting curly brackets with "magic" numbers all over the source files).
9f05247
to
06d4d4f
Compare
libmscore/tie.cpp
Outdated
break; | ||
case 2: | ||
painter->setBrush(Qt::NoBrush); | ||
pen.setWidthF(score()->styleP(Sid::SlurDottedWidth) * mag); | ||
pen.setStyle(Qt::DashLine); | ||
pen.setStyle(Qt::CustomDashLine); | ||
pen.setDashPattern(dashed); | ||
break; | ||
case 3: | ||
painter->setBrush(Qt::NoBrush); | ||
pen.setWidthF(score()->styleP(Sid::SlurDottedWidth) * mag); | ||
pen.setStyle(Qt::CustomDashLine); |
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.
same
libmscore/slur.cpp
Outdated
@@ -33,6 +33,10 @@ void SlurSegment::draw(QPainter* painter) const | |||
QPen pen(curColor()); | |||
qreal mag = staff() ? staff()->mag(slur()->tick()) : 1.0; | |||
|
|||
QVector<qreal> dotted = { 0.01, 1.99 }; // tighter than Qt Dotline equivalent { 0.01, 2.99 } | |||
QVector<qreal> dashed = { 3.00, 3.00 }; |
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 wonder whether here too we'd want to increase the gaps by the width to compensate for the SquareCap.
Just like you apparently do for the wide dashed line below
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 default Qt::DashLine is { 4.0, 2.0 }. To compensate for caps I changed it to { 3.0, 3.0 } already.
(I had first declared as { 3.01, 2.99 } but that felt a little too geeky since there are no dots involved. If it makes things clear I can do that).
libmscore/textlinebase.cpp
Outdated
|
||
//Replace generic Qt dash patterns with improved equivalents to show true dots | ||
QVector<qreal> dotted = { 0.01, 1.99 }; // tighter than Qt Dotline equivalent { 0.01, 2.99 } | ||
QVector<qreal> dashed = { 3.0, 3.0 }; |
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.
see above, compensating for SquareCap?
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.
same. I better add a comment there // Qt DashLine is { 4.0, 2.0 }
QVector<qreal> dashed = { 3.0, 3.0 }; | ||
QVector<qreal> dashDotted = { 3.01, 2.99, 0.01, 2.99 }; | ||
QVector<qreal> dashDotDotted = { 3.01, 2.99, 0.01, 2.99, 0.01, 2.99 }; | ||
QVector<qreal> customDashes = { tl->dashLineLen(), tl->dashGapLen() }; |
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 too, add one line width?
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.
Did better, { 3.0, 3.0 } is a dash with its gap (compensated already from {4,2}) and {0.01, 2.99} is a dot with its gap.
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.
{4.0, 2.0} is DashLine default. Compensated to {3.0, 3.0} for caps.
{1.0, 2.0} is DotLine default. Compensated for caps would be {0.0, 3.0} but zero doesn't work so I give 1 cent back from the gap to the dash - it would be { 0.1, 2.99} but our version of DotLine has smaller gaps { 0.01, 1.99}
The dashDotted and dashDotDotted use nominally 3.0 on every gaps. The 2.99 compensation for 0.01 dashes (ie. dots) is to keep the most consistent output along the line between dash/dashdot etc. so the gaps look aligned between styles when side to side.
Not that someone would tightly compare lines, but it looks neat if the composer wants to add instructions about lines somewhere.
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.
We can't have real dots for the dashDotted and dashDotDotted lines, can we?
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.
Only if we assume RoundCaps for the dashes on these two, leaving SquareCaps only in Dashed and continuous.
Ideally, a new PR could add Cap Style as an option in inspector / styles / etc...
A new property to save to files and deal with and more one decision for the engraver. Would that be overkill?
EDIT: I'd prefer not to offer both flatcaps and squarecaps to final users if that was an option. Behavior is already confusing for us devs.
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 any case, mixing straight dashes with round dots in the same line is not possible with Qt styles. Only if we create a method to calculate dashes and dots separately and then draws two overlapping lines. Just for this...
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.
Actually I had a simple idea to draw a line with mixed round dots and sharp dashes. Would it be worth it?
I'll give it a try.
These vtest fails are expected |
06d4d4f
to
800f6c1
Compare
I'll clarify a bit: When the vertical line intersects with the horizontal line, it looks like the corner dots are really close one to each other. Closer than the other dots at least. A solution for this would be to draw the line from the right, instead of from the left, to avoid that thin space. |
might be something for another PR though... |
It would be a good idea to draw the hook from the bottom and the line from the right but inverting that direction is not trivial. Also, no perfect solution because if there is a left hook it will have the same problem. Although the right hook is more "important" (more use cases). Maybe another PR indeed. |
Fix #270337: True dotted lines
800f6c1
to
3294093
Compare
Resolves: https://musescore.org/en/node/270337
Fixes true dotted lines for text lines (with round dots)
Also fixes:
Before

After

The problem is: the generic Qt DotLine style only shows dots properly when using FlatCaps, and FlatCaps are not always appropriate. Any square or round cap turns dots into short dashes.
This solution replaces default Qt lineStyles dash patterns with MuseScore's own patterns, so it allows real dots, round dots, and also allows the creation of MuseScore's specific dash styles instead of sticking to the generic Qt design.
Other changes:
Code review and feedback will be highly appreciated.