Skip to content

Commit

Permalink
fix #141226: Can't change tie direction
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Nov 17, 2016
1 parent b7a53fc commit 6a0fb3f
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 53 deletions.
4 changes: 2 additions & 2 deletions libmscore/edit.cpp
Expand Up @@ -1797,8 +1797,8 @@ void Score::cmdFlip()
Direction dir = beam->up() ? Direction::DOWN : Direction::UP;
undoChangeProperty(beam, P_ID::STEM_DIRECTION, dir);
}
else if (e->isSlurSegment()) {
SlurTie* slur = toSlurSegment(e)->slurTie();
else if (e->isSlurSegment() || e->isTieSegment()) {
SlurTie* slur = static_cast<SlurTieSegment*>(e)->slurTie();
Direction dir = slur->up() ? Direction::DOWN : Direction::UP;
undoChangeProperty(slur, P_ID::SLUR_DIRECTION, dir);
}
Expand Down
2 changes: 1 addition & 1 deletion libmscore/property.cpp
Expand Up @@ -63,7 +63,7 @@ static const PropertyData propertyList[] = {
{ P_ID::STEM_DIRECTION, true, "StemDirection", P_TYPE::DIRECTION },

{ P_ID::NO_STEM, false, "noStem", P_TYPE::INT },
{ P_ID::SLUR_DIRECTION, false, "slurDirection", P_TYPE::DIRECTION },
{ P_ID::SLUR_DIRECTION, false, "up", P_TYPE::DIRECTION },

This comment has been minimized.

Copy link
@Jojo-Schmitz

Jojo-Schmitz Nov 17, 2016

Contributor

Wouldn't direction be a better tage name? <up>down</up> does looks quite strange, doesn't it?

This comment has been minimized.

Copy link
@wschweer

wschweer Nov 17, 2016

Author Contributor

yes, but i changed it just back to the old (2.x) name to make it work. I want to check if its possible to remove the property SLUR_DIRECTION (and other xxx_DIRECTION id's) with P_ID::DIRECTION and name all "direction". But first the backward-compatibility code has to be updated to be able to handle this.

This comment has been minimized.

Copy link
@Jojo-Schmitz

Jojo-Schmitz Nov 17, 2016

Contributor

Yes, of course backward compat must be done too. The old up tag use numbers though, not texts, e.g. <up>2</up> (for down), doesn't that cause an issue here?

{ P_ID::LEADING_SPACE, false, "leadingSpace", P_TYPE::SPATIUM },
{ P_ID::DISTRIBUTE, false, "distribute", P_TYPE::BOOL },
{ P_ID::MIRROR_HEAD, false, "mirror", P_TYPE::DIRECTION_H },
Expand Down
2 changes: 1 addition & 1 deletion libmscore/shape.h
Expand Up @@ -16,7 +16,7 @@
namespace Ms {

#ifndef NDEBUG
#define DEBUG_SHAPES // enable shape debugging
// #define DEBUG_SHAPES // enable shape debugging
#endif

class Segment;
Expand Down
29 changes: 7 additions & 22 deletions libmscore/slur.cpp
Expand Up @@ -114,11 +114,7 @@ bool SlurSegment::edit(MuseScoreView* viewer, Grip curGrip, int key, Qt::Keyboar
return true;
}

if (!((modifiers & Qt::ShiftModifier)
&& ((spannerSegmentType() == SpannerSegmentType::SINGLE)
|| (spannerSegmentType() == SpannerSegmentType::BEGIN && curGrip == Grip::START)
|| (spannerSegmentType() == SpannerSegmentType::END && curGrip == Grip::END)
)))
if (!((modifiers & Qt::ShiftModifier) && (isSingleType() || (isBeginType() && curGrip == Grip::START) || (isEndType() && curGrip == Grip::END))))
return false;

ChordRest* cr = 0;
Expand Down Expand Up @@ -151,7 +147,7 @@ bool SlurSegment::edit(MuseScoreView* viewer, Grip curGrip, int key, Qt::Keyboar
}
if (cr && cr != e1)
changeAnchor(viewer, curGrip, cr);
undoChangeProperty(P_ID::AUTOPLACE, false);
// undoChangeProperty(P_ID::AUTOPLACE, false);
return true;
}

Expand Down Expand Up @@ -326,32 +322,21 @@ void SlurSegment::editDrag(const EditData& ed)
if (note && note->isNote()
&& ((g == Grip::END && note->tick() > slurTie()->tick()) || (g == Grip::START && note->tick() < slurTie()->tick2()))
) {
if (g == Grip::END && spanner->isTie()) {
Tie* tie = toTie(spanner);
if (tie->startNote()->pitch() == note->pitch()
&& tie->startNote()->chord()->tick() < note->chord()->tick()) {
ed.view->setDropTarget(note);
if (note != tie->endNote()) {
changeAnchor(ed.view, ed.curGrip, note);
return;
}
}
}
else if (!spanner->isTie() && km != (Qt::ShiftModifier | Qt::ControlModifier)) {
if (km != (Qt::ShiftModifier | Qt::ControlModifier)) {
Chord* c = note->chord();
ed.view->setDropTarget(note);
if (c != spanner->endCR()) {
changeAnchor(ed.view, g, c);
slurTie()->layout();
}
}
}
else
ed.view->setDropTarget(0);
}
}
else if (ed.curGrip == Grip::BEZIER1 || ed.curGrip == Grip::BEZIER2)
else if (ed.curGrip == Grip::BEZIER1 || ed.curGrip == Grip::BEZIER2) {
computeBezier();
}
else if (ed.curGrip == Grip::SHOULDER) {
ups(ed.curGrip).off = QPointF();
computeBezier(ed.delta);
Expand Down Expand Up @@ -552,8 +537,8 @@ void SlurSegment::layoutSegment(const QPointF& p1, const QPointF& p2)
QList<Collision> pl; // skyline
qreal sdist = spatium() * 0.5; // minimum distance to slur

QPointF pp1 = ups(Grip::START).p + ups(Grip::START).off;
QPointF pp2 = ups(Grip::END).p + ups(Grip::END).off;
QPointF pp1 = ups(Grip::START).p;
QPointF pp2 = ups(Grip::END).p;
Segment* ls = system()->lastMeasure()->last();
Segment* fs = system()->firstMeasure()->first();

Expand Down
20 changes: 15 additions & 5 deletions libmscore/slurtie.cpp
Expand Up @@ -145,7 +145,7 @@ void SlurTieSegment::reset()
undoResetProperty(P_ID::SLUR_UOFF3);
undoResetProperty(P_ID::SLUR_UOFF4);
undoResetProperty(P_ID::AUTOPLACE);
parent()->reset();
slurTie()->reset();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -244,9 +244,8 @@ bool SlurTie::readProperties(XmlReader& e)
{
const QStringRef& tag(e.name());


if (tag == "slurDirection")
_slurDirection = Direction(e.readInt());
if (tag == "up" || tag == "slurDirection")
readProperty(e, P_ID::SLUR_DIRECTION);
else if (tag == "lineType")
_lineType = e.readInt();
else if (tag == "SlurSegment") {
Expand Down Expand Up @@ -323,7 +322,7 @@ QVariant SlurTie::propertyDefault(P_ID id) const
case P_ID::LINE_TYPE:
return 0;
case P_ID::SLUR_DIRECTION:
return Direction(Direction::AUTO);
return Direction_AUTO;
default:
return Spanner::propertyDefault(id);
}
Expand Down Expand Up @@ -479,5 +478,16 @@ void SlurTie::endEdit()
score()->setLayoutAll();
}

//---------------------------------------------------------
// reset
//---------------------------------------------------------

void SlurTie::reset()
{
Element::reset();
undoResetProperty(P_ID::SLUR_DIRECTION);
undoResetProperty(P_ID::LINE_TYPE);
}

}

2 changes: 2 additions & 0 deletions libmscore/slurtie.h
Expand Up @@ -117,6 +117,8 @@ class SlurTie : public Spanner {
virtual Element::Type type() const = 0;
bool up() const { return _up; }

virtual void reset() override;

Direction slurDirection() const { return _slurDirection; }
void setSlurDirection(Direction d) { _slurDirection = d; }
void undoSetSlurDirection(Direction d);
Expand Down
11 changes: 1 addition & 10 deletions libmscore/tie.cpp
Expand Up @@ -256,12 +256,11 @@ void TieSegment::editDrag(const EditData& ed)
//
if ((g == Grip::START && isSingleBeginType()) || (g == Grip::END && isSingleEndType())) {
Spanner* spanner = tie();
Qt::KeyboardModifiers km = qApp->keyboardModifiers();
Note* note = static_cast<Note*>(ed.view->elementNear(ed.pos));
if (note && note->isNote()
&& ((g == Grip::END && note->tick() > tie()->tick()) || (g == Grip::START && note->tick() < tie()->tick2()))
) {
if (g == Grip::END && spanner->isTie()) {
if (g == Grip::END) {
Tie* tie = toTie(spanner);
if (tie->startNote()->pitch() == note->pitch()
&& tie->startNote()->chord()->tick() < note->chord()->tick()) {
Expand All @@ -272,14 +271,6 @@ void TieSegment::editDrag(const EditData& ed)
}
}
}
else if (!spanner->isTie() && km != (Qt::ShiftModifier | Qt::ControlModifier)) {
Chord* c = note->chord();
ed.view->setDropTarget(note);
if (c != spanner->endCR()) {
changeAnchor(ed.view, g, c);
tie()->layout();
}
}
}
else
ed.view->setDropTarget(0);
Expand Down
7 changes: 4 additions & 3 deletions mscore/inspector/inspector.cpp
Expand Up @@ -234,7 +234,8 @@ void Inspector::setElements(const QList<Element*>& l)
ie = new InspectorTextLine(this);
break;
case Element::Type::SLUR_SEGMENT:
ie = new InspectorSlur(this);
case Element::Type::TIE_SEGMENT:
ie = new InspectorSlurTie(this);
break;
case Element::Type::BAR_LINE:
// if (_element->isEditable())
Expand Down Expand Up @@ -1044,10 +1045,10 @@ void InspectorStafftext::setElement()
}

//---------------------------------------------------------
// InspectorSlur
// InspectorSlurTie
//---------------------------------------------------------

InspectorSlur::InspectorSlur(QWidget* parent)
InspectorSlurTie::InspectorSlurTie(QWidget* parent)
: InspectorElementBase(parent)
{
s.setupUi(addWidget());
Expand Down
6 changes: 3 additions & 3 deletions mscore/inspector/inspector.h
Expand Up @@ -416,16 +416,16 @@ class Inspector : public QDockWidget {
};

//---------------------------------------------------------
// InspectorSlur
// InspectorSlurTie
//---------------------------------------------------------

class InspectorSlur : public InspectorElementBase {
class InspectorSlurTie : public InspectorElementBase {
Q_OBJECT

Ui::InspectorSlur s;

public:
InspectorSlur(QWidget* parent);
InspectorSlurTie(QWidget* parent);
};

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion mtest/testoves/bdat/slur 2.ove-ref.mscx
Expand Up @@ -111,7 +111,7 @@
</Rest>
<Slur id="2">
<track>0</track>
<slurDirection>up</slurDirection>
<up>up</up>
</Slur>
<Chord>
<BeamMode>no</BeamMode>
Expand Down
10 changes: 5 additions & 5 deletions mtest/testoves/bdat/slur.ove-ref.mscx
Expand Up @@ -111,7 +111,7 @@
</Rest>
<Slur id="2">
<track>0</track>
<slurDirection>up</slurDirection>
<up>up</up>
</Slur>
<Chord>
<BeamMode>no</BeamMode>
Expand Down Expand Up @@ -163,7 +163,7 @@
</Rest>
<Slur id="3">
<track>0</track>
<slurDirection>up</slurDirection>
<up>up</up>
</Slur>
<Chord>
<BeamMode>no</BeamMode>
Expand All @@ -190,7 +190,7 @@
</Chord>
<Slur id="4">
<track>0</track>
<slurDirection>up</slurDirection>
<up>up</up>
</Slur>
<Chord>
<BeamMode>no</BeamMode>
Expand Down Expand Up @@ -259,7 +259,7 @@
</Chord>
<Slur id="5">
<track>0</track>
<slurDirection>up</slurDirection>
<up>up</up>
</Slur>
<Chord>
<BeamMode>no</BeamMode>
Expand All @@ -277,7 +277,7 @@
<Measure number="6">
<Slur id="6">
<track>0</track>
<slurDirection>up</slurDirection>
<up>up</up>
</Slur>
<Chord>
<BeamMode>no</BeamMode>
Expand Down

0 comments on commit 6a0fb3f

Please sign in to comment.