Skip to content

Commit

Permalink
fix autoplace interaction between lyrics and dynamics; impl. autoplac…
Browse files Browse the repository at this point in the history
…e for tempotext
  • Loading branch information
wschweer committed Aug 18, 2016
1 parent bb60410 commit 61ae4e7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
9 changes: 8 additions & 1 deletion libmscore/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,13 +1466,20 @@ Shape ChordRest::shape() const
for (Articulation* a : _articulations)
shape.add(a->bbox().translated(a->pos()));
qreal margin = spatium() * .5;
qreal x1 = 1000000.0;
qreal x2 = -1000000.0;
for (Lyrics* l : _lyrics) {
if (!l)
continue;
if (l->autoplace())
l->rUserYoffset() = 0.0;
shape.add(l->bbox().adjusted(-margin, 0.0, margin, 0.0).translated(l->pos()));

// for horizontal spacing we only need the lyrics width:
x1 = qMin(x1, l->bbox().x() - margin + l->pos().x());
x2 = qMax(x2, x1 + l->bbox().width() + margin);
}
if (x2 > x1)
shape.add(QRectF(x1, 0.0, x2-x1, 2.0));
return shape;
}
}
Expand Down
1 change: 1 addition & 0 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3402,6 +3402,7 @@ System* Score::collectSystem(LayoutContext& lc)
}
// lyrics shapes must be moved, so first remove them from segment
s.staffShape(staffIdx).remove(sh);

for (Lyrics* l : cr->lyrics()) {
if (l && l->autoplace()) {
qreal y = s.staffShape(staffIdx).minVerticalDistance(sh);
Expand Down
17 changes: 16 additions & 1 deletion libmscore/tempotext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ QVariant TempoText::propertyDefault(P_ID id) const

void TempoText::layout()
{
if (autoplace())
setUserOff(QPointF());
setPos(textStyle().offset(spatium()));
Text::layout1();

Expand All @@ -330,9 +332,22 @@ void TempoText::layout()

if (placement() == Element::Placement::BELOW)
rypos() = -rypos() + 4 * spatium();
adjustReadPos();

if (s && autoplace()) {
Shape s1 = s->staffShape(staffIdx()).translated(s->pos());
Shape s2 = shape().translated(s->pos());
qreal d = s2.minVerticalDistance(s1);
if (d > 0)
setUserOff(QPointF(0.0, -d));
}
if (!autoplace())
adjustReadPos();
}

//---------------------------------------------------------
// duration2userName
//---------------------------------------------------------

QString TempoText::duration2userName(const TDuration t)
{
QString dots;
Expand Down
11 changes: 3 additions & 8 deletions mscore/inspector/inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,22 +858,17 @@ void InspectorClef::valueChanged(int idx)
//---------------------------------------------------------

InspectorTempoText::InspectorTempoText(QWidget* parent)
: InspectorBase(parent)
: InspectorElementBase(parent)
{
e.setupUi(addWidget());
t.setupUi(addWidget());
tt.setupUi(addWidget());

iList = {
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
std::vector<InspectorItem> il = {
{ P_ID::TEXT_STYLE_TYPE, 0, 0, t.style, t.resetStyle },
{ P_ID::TEMPO, 0, 0, tt.tempo, tt.resetTempo },
{ P_ID::TEMPO_FOLLOW_TEXT, 0, 0, tt.followText, tt.resetFollowText }
};
mapSignals();
mapSignals(il);
connect(t.resetToStyle, SIGNAL(clicked()), SLOT(resetToStyle()));
connect(tt.followText, SIGNAL(toggled(bool)), tt.tempo, SLOT(setDisabled(bool)));
}
Expand Down
3 changes: 1 addition & 2 deletions mscore/inspector/inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,9 @@ class InspectorTremoloBar : public InspectorBase {
// InspectorTempoText
//---------------------------------------------------------

class InspectorTempoText : public InspectorBase {
class InspectorTempoText : public InspectorElementBase {
Q_OBJECT

UiInspectorElement e;
Ui::InspectorText t;
Ui::InspectorTempoText tt;

Expand Down

0 comments on commit 61ae4e7

Please sign in to comment.