Skip to content

Commit

Permalink
update for Jump and Marker elements
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Feb 25, 2013
1 parent a873ef1 commit d846e3d
Show file tree
Hide file tree
Showing 20 changed files with 762 additions and 482 deletions.
5 changes: 3 additions & 2 deletions libmscore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ if (SCRIPT_INTERFACE)
rest.h segment.h shadownote.h simpletext.h slur.h spacer.h spanner.h
stafftext.h stem.h symbol.h system.h tempotext.h textframe.h text.h
textline.h timesig.h tremolobar.h tremolo.h trill.h tuplet.h volta.h
score.h cursor.h page.h part.h staff.h mscore.h staffstate.h
score.h cursor.h page.h part.h staff.h mscore.h staffstate.h marker.h
jump.h
)
endif (SCRIPT_INTERFACE)

Expand Down Expand Up @@ -73,7 +74,7 @@ add_library (
property.cpp range.cpp elementmap.cpp notedot.cpp imageStore.cpp
qzip.cpp audio.cpp splitMeasure.cpp joinMeasure.cpp midifile.cpp
exportmidi.cpp cursor.cpp read114.cpp sparm.cpp paste.cpp
bsymbol.cpp
bsymbol.cpp marker.cpp jump.cpp
)
if (SCRIPT_INTERFACE)
set_target_properties (
Expand Down
2 changes: 2 additions & 0 deletions libmscore/element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
#include "notedot.h"
#include "textframe.h"
#include "image.h"
#include "marker.h"
#include "jump.h"

// extern bool showInvisible;

Expand Down
201 changes: 201 additions & 0 deletions libmscore/jump.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2002-2013 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================

#include "jump.h"
#include "score.h"

//---------------------------------------------------------
// JumpTypeTable
//---------------------------------------------------------

struct JumpTypeTable {
JumpType type;
const char* text;
const char* jumpTo;
const char* playUntil;
const char* continueAt;
};

static const JumpTypeTable jumpTypeTable[] = {
{ JumpType::DC, "D.C.", "start", "end", "" },
{ JumpType::DC_AL_FINE, "D.C. al Fine", "start", "fine", "" },
{ JumpType::DC_AL_CODA, "D.C. al Coda", "start", "coda", "codab" },
{ JumpType::DS_AL_CODA, "D.S. al Coda", "segno", "coda", "codab" },
{ JumpType::DS_AL_FINE, "D.S. al Fine", "segno", "fine", "" },
{ JumpType::DS, "D.S.", "segno", "end", "" }
};

//---------------------------------------------------------
// Jump
//---------------------------------------------------------

Jump::Jump(Score* s)
: Text(s)
{
setFlags(ELEMENT_MOVABLE | ELEMENT_SELECTABLE);
setTextStyle(s->textStyle(TEXT_STYLE_REPEAT));
}

//---------------------------------------------------------
// setJumpType
//---------------------------------------------------------

void Jump::setJumpType(JumpType t)
{
for (const JumpTypeTable& p : jumpTypeTable) {
if (p.type == t) {
setText(p.text);
setJumpTo(p.jumpTo);
setPlayUntil(p.playUntil);
setContinueAt(p.continueAt);
break;
}
}
}

//---------------------------------------------------------
// jumpType
//---------------------------------------------------------

JumpType Jump::jumpType() const
{
for (const JumpTypeTable& t : jumpTypeTable) {
if (_jumpTo == t.jumpTo && _playUntil == t.playUntil && _continueAt == t.continueAt)
return t.type;
}
return JumpType::USER;
}

//---------------------------------------------------------
// read
//---------------------------------------------------------

void Jump::read(XmlReader& e)
{
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "jumpTo")
_jumpTo = e.readElementText();
else if (tag == "playUntil")
_playUntil = e.readElementText();
else if (tag == "continueAt")
_continueAt = e.readElementText();
else if (!Text::readProperties(e))
e.unknown();
}
setTextStyle(score()->textStyle(TEXT_STYLE_REPEAT_RIGHT));
}

//---------------------------------------------------------
// write
//---------------------------------------------------------

void Jump::write(Xml& xml) const
{
xml.stag(name());
Text::writeProperties(xml);
xml.tag("jumpTo", _jumpTo);
xml.tag("playUntil", _playUntil);
xml.tag("continueAt", _continueAt);
xml.etag();
}

//---------------------------------------------------------
// undoSetJumpTo
//---------------------------------------------------------

void Jump::undoSetJumpTo(const QString& s)
{
score()->undoChangeProperty(this, P_JUMP_TO, s);
}

//---------------------------------------------------------
// undoSetPlayUntil
//---------------------------------------------------------

void Jump::undoSetPlayUntil(const QString& s)
{
score()->undoChangeProperty(this, P_PLAY_UNTIL, s);
}

//---------------------------------------------------------
// undoSetContinueAt
//---------------------------------------------------------

void Jump::undoSetContinueAt(const QString& s)
{
score()->undoChangeProperty(this, P_CONTINUE_AT, s);
}

//---------------------------------------------------------
// getProperty
//---------------------------------------------------------

QVariant Jump::getProperty(P_ID propertyId) const
{
switch (propertyId) {
case P_JUMP_TO:
return jumpTo();
case P_PLAY_UNTIL:
return playUntil();
case P_CONTINUE_AT:
return continueAt();
default:
break;
}
return Text::getProperty(propertyId);
}

//---------------------------------------------------------
// setProperty
//---------------------------------------------------------

bool Jump::setProperty(P_ID propertyId, const QVariant& v)
{
switch (propertyId) {
case P_JUMP_TO:
setJumpTo(v.toString());
break;
case P_PLAY_UNTIL:
setPlayUntil(v.toString());
break;
case P_CONTINUE_AT:
setContinueAt(v.toString());
break;
default:
if (!Text::setProperty(propertyId, v))
return false;
break;
}
score()->setLayoutAll(true);
return true;
}

//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------

QVariant Jump::propertyDefault(P_ID propertyId) const
{
switch (propertyId) {
case P_JUMP_TO:
case P_PLAY_UNTIL:
case P_CONTINUE_AT:
return QString();

default:
break;
}
return Text::propertyDefault(propertyId);
}


85 changes: 85 additions & 0 deletions libmscore/jump.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
// $Id: repeat.h 5516 2012-04-02 20:25:43Z wschweer $
//
// Copyright (C) 2002-2013 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================

#ifndef __JUMP_H__
#define __JUMP_H__

#include "text.h"

//---------------------------------------------------------
// JumpType
//---------------------------------------------------------

enum class JumpType {
DC,
DC_AL_FINE,
DC_AL_CODA,
DS_AL_CODA,
DS_AL_FINE,
DS,
USER
};

//---------------------------------------------------------
// @@ Jump
/// Jump label
//
// @P jumpTo QString
// @P playUntil QString
// @P continueAt QString
//---------------------------------------------------------

class Jump : public Text {
Q_OBJECT

Q_PROPERTY(QString jumpTo READ jumpTo WRITE undoSetJumpTo)
Q_PROPERTY(QString playUntil READ playUntil WRITE undoSetPlayUntil)
Q_PROPERTY(QString continueAt READ continueAt WRITE undoSetContinueAt)

QString _jumpTo;
QString _playUntil;
QString _continueAt;

public:
Jump(Score*);

void setJumpType(JumpType t);
JumpType jumpType() const;

virtual Jump* clone() const { return new Jump(*this); }
virtual ElementType type() const { return JUMP; }

virtual void read(XmlReader&);
virtual void write(Xml& xml) const;

QString jumpTo() const { return _jumpTo; }
QString playUntil() const { return _playUntil; }
QString continueAt() const { return _continueAt; }
void setJumpTo(const QString& s) { _jumpTo = s; }
void setPlayUntil(const QString& s) { _playUntil = s; }
void setContinueAt(const QString& s) { _continueAt = s; }
void undoSetJumpTo(const QString& s);
void undoSetPlayUntil(const QString& s);
void undoSetContinueAt(const QString& s);

virtual bool systemFlag() const { return true; }

virtual QVariant getProperty(P_ID propertyId) const;
virtual bool setProperty(P_ID propertyId, const QVariant&);
virtual QVariant propertyDefault(P_ID) const;
};

Q_DECLARE_METATYPE(JumpType)

#endif

Loading

0 comments on commit d846e3d

Please sign in to comment.