Skip to content

Commit

Permalink
add track2 to spanner
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Sep 27, 2013
1 parent b835131 commit eee9f5f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ include (GetCompilerVersion)
include (CreatePrecompiledHeader)

# for debugging the make system uncomment next line:
# set(CMAKE_VERBOSE_MAKEFILE ON)
#set(CMAKE_VERBOSE_MAKEFILE ON)

set(MSCORE_UNSTABLE TRUE) # mark as unstable

Expand Down
1 change: 1 addition & 0 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,7 @@ void Measure::read(XmlReader& e, int staffIdx)
Spanner* spanner = score()->findSpanner(id);
if (spanner) {
spanner->setTick2(e.tick());
spanner->setTrack2(e.track());
if (spanner->type() == OTTAVA) {
Ottava* o = static_cast<Ottava*>(spanner);
o->staff()->updateOttava(o);
Expand Down
3 changes: 2 additions & 1 deletion libmscore/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ static const PropertyData propertyList[] = {
{ P_TIMESIG_GLOBAL, false, 0, T_FRACTION },
{ P_SPANNER_TICK, true, "tick", T_INT },
{ P_SPANNER_TICK2, true, "tick2", T_INT },
{ P_SPANNER_TRACK2, true, "track2", T_INT },

{ P_USER_OFF2, false, "userOff2", T_POINT },
{ P_USER_OFF2, false, "userOff2", T_POINT },
{ P_BEGIN_TEXT_PLACE, false, "beginTextPlace", T_INT },
{ P_CONTINUE_TEXT_PLACE, false, "beginTextPlace", T_INT },
{ P_BEGIN_HOOK, false, "beginHook", T_BOOL },
Expand Down
1 change: 1 addition & 0 deletions libmscore/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ enum P_ID {
P_TIMESIG_GLOBAL,
P_SPANNER_TICK,
P_SPANNER_TICK2,
P_SPANNER_TRACK2,

P_USER_OFF2,
P_BEGIN_TEXT_PLACE,
Expand Down
2 changes: 2 additions & 0 deletions libmscore/read114.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ Score::FileError Score::read114(XmlReader& e)
s->setTick(e.tick());
else
e.setTick(s->tick()); // update current tick
if (s->track2() == -1)
s->setTrack2(s->track());
if (s->tick2() == -1) {
delete s;
qDebug("invalid spanner %s tick2: %d\n",
Expand Down
4 changes: 2 additions & 2 deletions libmscore/slur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,8 @@ void Slur::read(XmlReader& e)
setId(e.intAttribute("id"));
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "track2") // obsolete
e.readInt();
if (tag == "track2")
setTrack2(e.readInt());
else if (tag == "startTrack") // obsolete
setTrack(e.readInt());
else if (tag == "endTrack") // obsolete
Expand Down
15 changes: 11 additions & 4 deletions libmscore/spanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace Ms {

int Spanner::editTick;
int Spanner::editTick2;
int Spanner::editTrack2;
QList<QPointF> Spanner::userOffsets2;
QList<QPointF> Spanner::userOffsets;

Expand Down Expand Up @@ -230,6 +231,8 @@ void Spanner::startEdit(MuseScoreView*, const QPointF&)
{
editTick = _tick;
editTick2 = _tick2;
editTrack2 = _track2;

userOffsets.clear();
userOffsets2.clear();
foreach (SpannerSegment* ss, spannerSegments()) {
Expand All @@ -244,9 +247,10 @@ void Spanner::startEdit(MuseScoreView*, const QPointF&)

void Spanner::endEdit()
{
if (editTick != tick() || editTick2 != tick2()) {
if (editTick != tick() || editTick2 != tick2() || editTrack2 != track2()) {
score()->undoPropertyChanged(this, P_SPANNER_TICK, editTick);
score()->undoPropertyChanged(this, P_SPANNER_TICK2, editTick2);
score()->undoPropertyChanged(this, P_SPANNER_TRACK2, editTrack2);
score()->rebuildBspTree();
}

Expand Down Expand Up @@ -285,6 +289,8 @@ QVariant Spanner::getProperty(P_ID propertyId) const
return tick();
case P_SPANNER_TICK2:
return tick2();
case P_SPANNER_TRACK2:
return track2();
default:
break;
}
Expand All @@ -304,6 +310,9 @@ bool Spanner::setProperty(P_ID propertyId, const QVariant& v)
case P_SPANNER_TICK2:
setTick2(v.toInt());
break;
case P_SPANNER_TRACK2:
setTrack2(v.toInt());
break;
default:
if (!Element::setProperty(propertyId, v))
return false;
Expand Down Expand Up @@ -344,7 +353,6 @@ ChordRest* Score::findCR(int tick, int track) const

void Spanner::computeStartElement()
{
// _startElement = 0;
switch (_anchor) {
case ANCHOR_SEGMENT:
_startElement = score()->findCR(tick(), track());
Expand All @@ -366,10 +374,9 @@ void Spanner::computeStartElement()

void Spanner::computeEndElement()
{
// _endElement = 0;
switch (_anchor) {
case ANCHOR_SEGMENT:
_endElement = score()->findCR(tick2(), track());
_endElement = score()->findCR(tick2(), track2());
break;

case ANCHOR_MEASURE:
Expand Down
5 changes: 4 additions & 1 deletion libmscore/spanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ class Spanner : public Element {
Element* _startElement;
Element* _endElement;
int _tick, _tick2;
int _track2 = -1;
int _id; // used for xml serialization

static QList<QPointF> userOffsets;
static QList<QPointF> userOffsets2;

protected:
static int editTick, editTick2;
static int editTick, editTick2, editTrack2;

public:
Spanner(Score* = 0);
Expand All @@ -125,6 +126,8 @@ class Spanner : public Element {
int tickLen() const { return _tick2 - _tick; }
int tick2() const { return _tick2; }
void setTick2(int v) { _tick2 = v; }
int track2() const { return _track2; }
void setTrack2(int v) { _track2 = v; }

int id() const { return _id; }
void setId(int v) { _id = v; }
Expand Down

1 comment on commit eee9f5f

@Jojo-Schmitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit apparently broke the ability to add slurs, see #22911

Please sign in to comment.