Skip to content

Commit

Permalink
Merge pull request #1205 from MarcSabatella/29506-pedal-one
Browse files Browse the repository at this point in the history
more layout fixes for short textlines including pedal
  • Loading branch information
lasconic committed Aug 23, 2014
2 parents d8e177f + a726b9c commit 5a9faeb
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
10 changes: 7 additions & 3 deletions libmscore/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,17 @@ QPointF SLine::linePos(GripLine grip, System** sys) const
case Spanner::Anchor::SEGMENT:
{
ChordRest* cr;
if (grip == GripLine::START)
if (grip == GripLine::START) {
cr = static_cast<ChordRest*>(startElement());
}
else {
cr = static_cast<ChordRest*>(endElement());
if (type() == Element::Type::OTTAVA) {
// lay out to right edge of note (including dots)
if (cr)
x += cr->segment()->width();
}
else if (type() == Element::Type::HAIRPIN || type() == Element::Type::TRILL) {
else if (type() == Element::Type::HAIRPIN || type() == Element::Type::TRILL || type() == Element::Type::TEXTLINE) {
// lay out all the way to next CR or (almost to) barline
if (cr && endElement()->parent() && endElement()->parent()->type() == Element::Type::SEGMENT) {
qreal x2 = 0.0;
Expand All @@ -484,7 +485,7 @@ QPointF SLine::linePos(GripLine grip, System** sys) const
Segment* seg = static_cast<Segment*>(endElement()->parent())->next();
for ( ; seg; seg = seg->next()) {
if (seg->segmentType() == Segment::Type::ChordRest) {
if (t!= -1 && !seg->element(t)) {
if (t != -1 && !seg->element(t)) {
continue;
}
x2 = seg->x() - sp; // 1sp shy of next chord
Expand All @@ -504,6 +505,9 @@ QPointF SLine::linePos(GripLine grip, System** sys) const
}
}

if (cr && cr->durationType() == TDuration::DurationType::V_MEASURE)
x -= cr->x();

int t = grip == GripLine::START ? tick() : tick2();
Measure* m = cr ? cr->measure() : score()->tick2measure(t);

Expand Down
2 changes: 2 additions & 0 deletions libmscore/pedal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ QPointF Pedal::linePos(GripLine grip, System** sys) const
if (c) {
s = c->segment()->system();
x = c->pos().x() + c->segment()->pos().x() + c->segment()->measure()->pos().x();
if (c && c->durationType() == TDuration::DurationType::V_MEASURE)
x -= c->x();
}
}
if (!s) {
Expand Down
7 changes: 5 additions & 2 deletions libmscore/textline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ void TextLineSegment::draw(QPainter* painter) const
else
endHookWidth = 0;

painter->drawLine(QLineF(pp1.x(), pp1.y(), pp2.x(), pp2.y()));
// don't draw backwards lines (or hooks) if text is longer than nominal line length
if (pp1.x() < pp2.x())
painter->drawLine(QLineF(pp1.x(), pp1.y(), pp2.x(), pp2.y()));

if (tl->beginHook()
&& (spannerSegmentType() == SpannerSegmentType::SINGLE
Expand All @@ -134,7 +136,8 @@ void TextLineSegment::draw(QPainter* painter) const
qreal hh = tl->beginHookHeight().val() * _spatium;
painter->drawLine(QLineF(pp1.x(), pp1.y(), pp1.x() - beginHookWidth, pp1.y() + hh));
}
if (tl->endHook()

if (tl->endHook() && pp1.x() < pp2.x()
&& (spannerSegmentType() == SpannerSegmentType::SINGLE
|| spannerSegmentType() == SpannerSegmentType::END)
) {
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ else
emmentaler-3 bravura-3 emmentaler-4 bravura-4 emmentaler-5 bravura-5\
emmentaler-6 bravura-6 emmentaler-7 bravura-7\
emmentaler-8 bravura-8 emmentaler-9 bravura-9 emmentaler-10 bravura-10\
emmentaler-11 bravura-11 frametext ottava slurs-1 slurs-2 hairpins-1 pedal-1\
emmentaler-11 bravura-11 frametext ottava slurs-1 slurs-2 hairpins-1 pedal-1 line-1\
chord-layout-1 chord-layout-2 chord-layout-3 chord-layout-4 chord-layout-5\
chord-layout-6 chord-layout-7 chord-layout-8 chord-layout-9 chord-layout-10\
chord-layout-11 chord-layout-12 chord-layout-13 chord-layout-14\
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set SRC=mmrest-1,bravura-mmrest,mmrest-2,mmrest-4,mmrest-5,mmrest-6,mmrest-7,mmr
emmentaler-3,bravura-3,emmentaler-4,bravura-4,emmentaler-5,bravura-5, ^
emmentaler-6,bravura-6,emmentaler-7,bravura-7, ^
emmentaler-8,bravura-8,emmentaler-9,bravura-9,emmentaler-10,bravura-10, ^
emmentlar-11,bravura-11,frametext,ottava,slurs-1,slurs-2,hairpins-1,pedal-1 ^
emmentlar-11,bravura-11,frametext,ottava,slurs-1,slurs-2,hairpins-1,pedal-1,line-1, ^
chord-layout-1,chord-layout-2,chord-layout-3,chord-layout-4,chord-layout-5, ^
chord-layout-6,chord-layout-7,chord-layout-8,chord-layout-9,chord-layout-10, ^
chord-layout-11,chord-layout-12,chord-layout-13,chord-layout-13, ^
Expand Down
Binary file added vtest/line-1-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vtest/line-1.mscz
Binary file not shown.

0 comments on commit 5a9faeb

Please sign in to comment.