forked from musescore/MuseScore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
762 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
Oops, something went wrong.