Skip to content

Commit

Permalink
fix #25806
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jul 31, 2014
1 parent 75d7a05 commit 548fa0b
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 136 deletions.
7 changes: 7 additions & 0 deletions libmscore/articulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,13 @@ bool Articulation::setProperty(P_ID propertyId, const QVariant& v)
setTimeStretch(v.toDouble());
score()->fixTicks();
break;
case P_ID::USER_OFF:
setUserOff(v.toPointF());
if (_articulationType == ArticulationType::Tenuto) {
// moving a tenuto may move slurs:
score()->setLayoutAll(true);
}
return true;
default:
return Element::setProperty(propertyId, v);
}
Expand Down
10 changes: 6 additions & 4 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ void Score::endCmd()
}
}

if (MScore::debugMode)
qDebug("===endCmd() %d", undo()->current()->childCount());
bool noUndo = undo()->current()->childCount() <= 1;
if (!noUndo)
setDirty(true);
Expand Down Expand Up @@ -2037,7 +2039,7 @@ void Score::cmd(const QAction* a)
Element* el = selection().element();
if (cmd == "pitch-up") {
if (el && (el->type() == Element::Type::ARTICULATION || el->isText()))
undoMove(el, el->userOff() + QPointF(0.0, -MScore::nudgeStep * el->spatium()));
el->undoChangeProperty(P_ID::USER_OFF, el->userOff() + QPointF(0.0, -MScore::nudgeStep * el->spatium()));
else if (el && el->type() == Element::Type::REST)
cmdMoveRest(static_cast<Rest*>(el), MScore::Direction::UP);
else if (el && el->type() == Element::Type::LYRICS)
Expand All @@ -2047,7 +2049,7 @@ void Score::cmd(const QAction* a)
}
else if (cmd == "pitch-down") {
if (el && (el->type() == Element::Type::ARTICULATION || el->isText()))
undoMove(el, el->userOff() + QPointF(0.0, MScore::nudgeStep * el->spatium()));
el->undoChangeProperty(P_ID::USER_OFF, el->userOff() + QPointF(0.0, MScore::nudgeStep * el->spatium()));
else if (el && el->type() == Element::Type::REST)
cmdMoveRest(static_cast<Rest*>(el), MScore::Direction::DOWN);
else if (el && el->type() == Element::Type::LYRICS)
Expand Down Expand Up @@ -2076,13 +2078,13 @@ void Score::cmd(const QAction* a)
}
else if (cmd == "pitch-up-octave") {
if (el && (el->type() == Element::Type::ARTICULATION || el->isText()))
undoMove(el, el->userOff() + QPointF(0.0, -MScore::nudgeStep10 * el->spatium()));
el->undoChangeProperty(P_ID::USER_OFF, el->userOff() + QPointF(0.0, -MScore::nudgeStep10 * el->spatium()));
else
upDown(true, UpDownMode::OCTAVE);
}
else if (cmd == "pitch-down-octave") {
if (el && (el->type() == Element::Type::ARTICULATION || el->isText()))
undoMove(el, el->userOff() + QPointF(0.0, MScore::nudgeStep10 * el->spatium()));
el->undoChangeProperty(P_ID::USER_OFF, el->userOff() + QPointF(0.0, MScore::nudgeStep10 * el->spatium()));
else
upDown(false, UpDownMode::OCTAVE);
}
Expand Down
7 changes: 6 additions & 1 deletion libmscore/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static const PropertyData propertyList[] = {
{ P_ID::PLAY, false, "play", P_TYPE::BOOL },
{ P_ID::TIMESIG_NOMINAL, false, 0, P_TYPE::FRACTION },
{ P_ID::TIMESIG_ACTUAL, true, 0, P_TYPE::FRACTION },

{ P_ID::NUMBER_TYPE, false, "numberType", P_TYPE::INT },
{ P_ID::BRACKET_TYPE, false, "bracketType", P_TYPE::INT },
{ P_ID::NORMAL_NOTES, false, "normalNotes", P_TYPE::INT },
Expand Down Expand Up @@ -200,6 +200,11 @@ static const PropertyData propertyList[] = {

{ P_ID::ANCHOR, false, "anchor", P_TYPE::INT },

{ P_ID::SLUR_UOFF1, false, "o1", P_TYPE::POINT },
{ P_ID::SLUR_UOFF2, false, "o2", P_TYPE::POINT },
{ P_ID::SLUR_UOFF3, false, "o3", P_TYPE::POINT },
{ P_ID::SLUR_UOFF4, false, "o4", P_TYPE::POINT },

{ P_ID::END, false, "", P_TYPE::INT }
};

Expand Down
5 changes: 5 additions & 0 deletions libmscore/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ enum class P_ID : unsigned char {

ANCHOR,

SLUR_UOFF1,
SLUR_UOFF2,
SLUR_UOFF3,
SLUR_UOFF4,

END
};

Expand Down
1 change: 0 additions & 1 deletion libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ class Score : public QObject {
void undoRemoveStaff(Staff* staff, int idx);
void undoInsertStaff(Staff* staff, int idx);
void undoChangeInvisible(Element*, bool);
void undoMove(Element* e, const QPointF& pt);
void undoChangeBracketSpan(Staff* staff, int column, int span);
void undoChangeTuning(Note*, qreal);
void undoChangePageFormat(PageFormat*, qreal spatium, int);
Expand Down
134 changes: 122 additions & 12 deletions libmscore/slur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@

namespace Ms {

Element* SlurTie::editEndElement;
Element* SlurTie::editStartElement;
QList<SlurOffsets> SlurTie::editUps;

//---------------------------------------------------------
// SlurSegment
//---------------------------------------------------------
Expand Down Expand Up @@ -418,14 +422,11 @@ void SlurSegment::write(Xml& xml, int no) const
return;

xml.stag(QString("SlurSegment no=\"%1\"").arg(no));
if (!(ups[int(GripSlurSegment::START)].off.isNull()))
xml.tag("o1", ups[int(GripSlurSegment::START)].off);
if (!(ups[int(GripSlurSegment::BEZIER1)].off.isNull()))
xml.tag("o2", ups[int(GripSlurSegment::BEZIER1)].off);
if (!(ups[int(GripSlurSegment::BEZIER2)].off.isNull()))
xml.tag("o3", ups[int(GripSlurSegment::BEZIER2)].off);
if (!(ups[int(GripSlurSegment::END)].off.isNull()))
xml.tag("o4", ups[int(GripSlurSegment::END)].off);

writeProperty(xml, P_ID::SLUR_UOFF1);
writeProperty(xml, P_ID::SLUR_UOFF2);
writeProperty(xml, P_ID::SLUR_UOFF3);
writeProperty(xml, P_ID::SLUR_UOFF4);
Element::writeProperties(xml);
xml.etag();
}
Expand Down Expand Up @@ -1101,6 +1102,14 @@ QVariant SlurSegment::getProperty(P_ID propertyId) const
case P_ID::LINE_TYPE:
case P_ID::SLUR_DIRECTION:
return slurTie()->getProperty(propertyId);
case P_ID::SLUR_UOFF1:
return ups[int(GripSlurSegment::START)].off;
case P_ID::SLUR_UOFF2:
return ups[int(GripSlurSegment::BEZIER1)].off;
case P_ID::SLUR_UOFF3:
return ups[int(GripSlurSegment::BEZIER2)].off;
case P_ID::SLUR_UOFF4:
return ups[int(GripSlurSegment::END)].off;
default:
return SpannerSegment::getProperty(propertyId);
}
Expand All @@ -1116,9 +1125,22 @@ bool SlurSegment::setProperty(P_ID propertyId, const QVariant& v)
case P_ID::LINE_TYPE:
case P_ID::SLUR_DIRECTION:
return slurTie()->setProperty(propertyId, v);
case P_ID::SLUR_UOFF1:
ups[int(GripSlurSegment::START)].off = v.toPointF();
break;
case P_ID::SLUR_UOFF2:
ups[int(GripSlurSegment::BEZIER1)].off = v.toPointF();
break;
case P_ID::SLUR_UOFF3:
ups[int(GripSlurSegment::BEZIER2)].off = v.toPointF();
break;
case P_ID::SLUR_UOFF4:
ups[int(GripSlurSegment::END)].off = v.toPointF();
break;
default:
return SpannerSegment::setProperty(propertyId, v);
}
score()->setLayoutAll(true);
return true;
}

Expand All @@ -1132,6 +1154,11 @@ QVariant SlurSegment::propertyDefault(P_ID id) const
case P_ID::LINE_TYPE:
case P_ID::SLUR_DIRECTION:
return slurTie()->propertyDefault(id);
case P_ID::SLUR_UOFF1:
case P_ID::SLUR_UOFF2:
case P_ID::SLUR_UOFF3:
case P_ID::SLUR_UOFF4:
return QPointF();
default:
return SpannerSegment::propertyDefault(id);
}
Expand All @@ -1143,10 +1170,12 @@ QVariant SlurSegment::propertyDefault(P_ID id) const

void SlurSegment::reset()
{
score()->undoChangeProperty(this, P_ID::USER_OFF, QPointF());
score()->undo(new ChangeSlurOffsets(this, QPointF(), QPointF(), QPointF(), QPointF()));
for (int i = 0; i < int(GripSlurSegment::GRIPS); ++i)
ups[i].off = QPointF();
score()->undoChangeProperty(this, P_ID::USER_OFF, QPointF());
score()->undoChangeProperty(this, P_ID::SLUR_UOFF1, QPointF());
score()->undoChangeProperty(this, P_ID::SLUR_UOFF2, QPointF());
score()->undoChangeProperty(this, P_ID::SLUR_UOFF3, QPointF());
score()->undoChangeProperty(this, P_ID::SLUR_UOFF4, QPointF());

parent()->reset();
parent()->layout();
}
Expand Down Expand Up @@ -1461,5 +1490,86 @@ void SlurTie::fixupSegments(unsigned nsegs)
}
}
}

//---------------------------------------------------------
// startEdit
//---------------------------------------------------------

void SlurTie::startEdit(MuseScoreView* view, const QPointF& pt)
{
Spanner::startEdit(view, pt);

editStartElement = startElement();
editEndElement = endElement();

editUps.clear();
foreach (SpannerSegment* s, spannerSegments()) {
SlurOffsets o;
SlurSegment* ss = static_cast<SlurSegment*>(s);
o.o[0] = ss->getProperty(P_ID::SLUR_UOFF1).toPointF();
o.o[1] = ss->getProperty(P_ID::SLUR_UOFF2).toPointF();
o.o[2] = ss->getProperty(P_ID::SLUR_UOFF3).toPointF();
o.o[3] = ss->getProperty(P_ID::SLUR_UOFF4).toPointF();
editUps.append(o);
}
}

//---------------------------------------------------------
// endEdit
//---------------------------------------------------------

void SlurTie::endEdit()
{
Spanner::endEdit();
if (type() == Element::Type::SLUR) {
if ((editStartElement != startElement()) || (editEndElement != endElement())) {
//
// handle parts:
// search new start/end elements
//
for (Element* e : linkList()) {
Spanner* spanner = static_cast<Spanner*>(e);
if (spanner == this)
score()->undo()->push1(new ChangeStartEndSpanner(this, editStartElement, editEndElement));
else {
Element* se = 0;
Element* ee = 0;
if (startElement()) {
QList<Element*> sel = startElement()->linkList();
for (Element* e : sel) {
if (e->score() == spanner->score() && e->track() == spanner->track()) {
se = e;
break;
}
}
}
if (endElement()) {
QList<Element*> sel = endElement()->linkList();
for (Element* e : sel) {
if (e->score() == spanner->score() && e->track() == spanner->track2()) {
ee = e;
break;
}
}
}
score()->undo(new ChangeStartEndSpanner(spanner, se, ee));
}
}
}
}
if (spannerSegments().size() != editUps.size()) {
qDebug("SlurTie::endEdit(): segment size changed %d != %d", spannerSegments().size(), editUps.size());
return;
}
for (int i = 0; i < editUps.size(); ++i) {
SpannerSegment* ss = segments[i];
SlurOffsets o = editUps[i];
score()->undoPropertyChanged(ss, P_ID::SLUR_UOFF1, o.o[0]);
score()->undoPropertyChanged(ss, P_ID::SLUR_UOFF2, o.o[1]);
score()->undoPropertyChanged(ss, P_ID::SLUR_UOFF3, o.o[2]);
score()->undoPropertyChanged(ss, P_ID::SLUR_UOFF4, o.o[3]);
}
}

}

13 changes: 13 additions & 0 deletions libmscore/slur.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ struct UP {
}
};

struct SlurOffsets {
QPointF o[4];
};

//---------------------------------------------------------
// @@ SlurSegment
/// also used for Tie
Expand All @@ -68,6 +72,7 @@ class SlurSegment : public SpannerSegment {

protected:
struct UP ups[int(GripSlurSegment::GRIPS)];

QPainterPath path;
QPainterPath shapePath;
QPointF autoAdjustOffset;
Expand Down Expand Up @@ -115,6 +120,7 @@ class SlurSegment : public SpannerSegment {

friend class Tie;
friend class Slur;
friend class SlurTie;
};

//-------------------------------------------------------------------
Expand All @@ -131,6 +137,10 @@ class SlurTie : public Spanner {

int _lineType; // 0 = solid, 1 = dotted, 2 = dashed

static Element* editStartElement;
static Element* editEndElement;
static QList<SlurOffsets> editUps;

protected:
bool _up; // actual direction

Expand Down Expand Up @@ -170,6 +180,9 @@ class SlurTie : public Spanner {
virtual void slurPos(SlurPos*) = 0;
virtual void computeBezier(SlurSegment*, QPointF so = QPointF()) = 0;

virtual void startEdit(MuseScoreView*, const QPointF&) override;
virtual void endEdit() override;

virtual QVariant getProperty(P_ID propertyId) const;
virtual bool setProperty(P_ID propertyId, const QVariant&);
virtual QVariant propertyDefault(P_ID id) const;
Expand Down
Loading

0 comments on commit 548fa0b

Please sign in to comment.