Skip to content

Commit

Permalink
ignore non autoplace dynamics/hairpins in layout autoplace calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jul 19, 2016
1 parent 38a4b21 commit 8710008
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 40 deletions.
42 changes: 26 additions & 16 deletions libmscore/hairpin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Spatium Hairpin::editHairpinHeight;
// return Dynamic at chord e position
//---------------------------------------------------------

static Dynamic* lookupDynamic(Element* e)
Dynamic* lookupDynamic(Element* e)
{
Dynamic* d = 0;
Segment* s = 0;
Expand All @@ -46,8 +46,12 @@ static Dynamic* lookupDynamic(Element* e)
}
}
}
if (d)
d->layout();
if (d) {
if (!d->autoplace())
d = 0;
else
d->layout();
}
return d;
}

Expand Down Expand Up @@ -118,13 +122,15 @@ void HairpinSegment::layout()
switch (spannerSegmentType()) {
case SpannerSegmentType::SINGLE: {
qreal x = 0.0;
sd = lookupDynamic(hairpin()->startElement());
if (sd)
x = sd->bbox().width();
ed = lookupDynamic(hairpin()->endElement());
if (ed) {
len -= ed->bbox().width();
ed->rUserXoffset() = _spatium * 4;
if (autoplace()) {
sd = lookupDynamic(hairpin()->startElement());
if (sd)
x = sd->bbox().width();
ed = lookupDynamic(hairpin()->endElement());
if (ed) {
len -= ed->bbox().width();
ed->rUserXoffset() = _spatium * 4;
}
}
l1.setLine(x + circledTipRadius * 2.0, 0.0, len, h1);
l2.setLine(x + circledTipRadius * 2.0, 0.0, len, -h1);
Expand All @@ -135,9 +141,11 @@ void HairpinSegment::layout()

case SpannerSegmentType::BEGIN: {
qreal x = 0.0;
sd = lookupDynamic(hairpin()->startElement());
if (sd)
x = sd->bbox().width();
if (autoplace()) {
sd = lookupDynamic(hairpin()->startElement());
if (sd)
x = sd->bbox().width();
}
l1.setLine(x + circledTipRadius * 2.0, 0.0, len, h1);
l2.setLine(x + circledTipRadius * 2.0, 0.0, len, -h1);
circledTip.setX(x + circledTipRadius );
Expand All @@ -152,9 +160,11 @@ void HairpinSegment::layout()
break;

case SpannerSegmentType::END: {
ed = lookupDynamic(hairpin()->endElement());
if (ed)
len -= ed->bbox().width();
if (autoplace()) {
ed = lookupDynamic(hairpin()->endElement());
if (ed)
len -= ed->bbox().width();
}
drawCircledTip = false;
l1.setLine(.0, h2, len, h1);
l2.setLine(.0, -h2, len, -h1);
Expand Down
2 changes: 2 additions & 0 deletions libmscore/hairpin.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ class Hairpin : public TextLine {
virtual QString accessibleInfo() const override;
};

extern Dynamic* lookupDynamic(Element* e);

} // namespace Ms

Q_DECLARE_METATYPE(Ms::Hairpin::Type);
Expand Down
25 changes: 1 addition & 24 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "systemdivider.h"
#include "hook.h"
#include "ambitus.h"
#include "hairpin.h"

namespace Ms {

Expand Down Expand Up @@ -2979,30 +2980,6 @@ static bool notTopBeam(ChordRest* cr)
return false;
}

//---------------------------------------------------------
// lookupDynamic
// return Dynamic at chord e position
//---------------------------------------------------------

static Dynamic* lookupDynamic(Element* e)
{
Dynamic* d = 0;
Segment* s = 0;
if (e && e->isChord())
s = toChord(e)->segment();
if (s) {
for (Element* ee : s->annotations()) {
if (ee->isDynamic() && ee->track() == e->track()) {
d = toDynamic(ee);
break;
}
}
}
if (d)
d->layout();
return d;
}

//---------------------------------------------------------
// collectSystem
//---------------------------------------------------------
Expand Down

0 comments on commit 8710008

Please sign in to comment.