Skip to content

Commit

Permalink
updates for Glissando
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Feb 28, 2013
1 parent 7c1c220 commit 9907048
Show file tree
Hide file tree
Showing 24 changed files with 660 additions and 112 deletions.
2 changes: 2 additions & 0 deletions awl/colorlabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace Awl {

class ColorLabel : public QFrame {
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor)

QColor _color;
QPixmap* _pixmap;

Expand Down
1 change: 1 addition & 0 deletions libmscore/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,7 @@ Element* Chord::drop(const DropData& data)

case CHORDLINE:
e->setParent(this);
e->setTrack(track());
score()->undoAddElement(e);
break;

Expand Down
13 changes: 11 additions & 2 deletions libmscore/element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ void Element::undoSetPlacement(Placement v)

QVariant Element::getProperty(P_ID propertyId) const
{
switch(propertyId) {
switch (propertyId) {
case P_COLOR: return _color;
case P_VISIBLE: return _visible;
case P_SELECTED: return _selected;
Expand Down Expand Up @@ -1499,7 +1499,16 @@ bool Element::setProperty(P_ID propertyId, const QVariant& v)
QVariant Element::propertyDefault(P_ID id) const
{
switch(id) {
case P_PLACEMENT: return BELOW;
case P_VISIBLE:
return true;
case P_COLOR:
return MScore::defaultColor;
case P_PLACEMENT:
return BELOW;
case P_SELECTED:
return false;
case P_USER_OFF:
return QPointF();
default: // not all properties have a default
break;
}
Expand Down
117 changes: 108 additions & 9 deletions libmscore/glissando.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,33 @@
Glissando::Glissando(Score* s)
: Element(s)
{
_subtype = GLISS_STRAIGHT;
setFlags(ELEMENT_MOVABLE | ELEMENT_SELECTABLE);
_text = "gliss.";
_showText = true;

_subtype = GlissandoType::STRAIGHT;
_text = "gliss.";
_showText = true;
qreal _spatium = spatium();
setSize(QSizeF(_spatium * 2, _spatium * 4)); // for use in palettes
}

Glissando::Glissando(const Glissando& g)
: Element(g)
{
_subtype = g._subtype;
line = g.line;
_text = g._text;
_showText = g._showText;
}

//---------------------------------------------------------
// layout
//---------------------------------------------------------

void Glissando::layout()
{
Chord* chord = static_cast<Chord*>(parent());
if (chord == 0) {
if (chord == 0)
return;
}
Note* anchor2 = chord->upNote();
Segment* s = chord->segment();
s = s->prev1();
Expand Down Expand Up @@ -107,7 +116,7 @@ void Glissando::write(Xml& xml) const
xml.stag("Glissando");
if (_showText && !_text.isEmpty())
xml.tag("text", _text);
xml.tag("subtype", _subtype);
xml.tag("subtype", int(_subtype));
Element::writeProperties(xml);
xml.etag();
}
Expand All @@ -126,7 +135,7 @@ void Glissando::read(XmlReader& e)
_text = e.readElementText();
}
else if (tag == "subtype")
_subtype = e.readInt();
_subtype = GlissandoType(e.readInt());
else if (!Element::readProperties(e))
e.unknown();
}
Expand Down Expand Up @@ -154,10 +163,10 @@ void Glissando::draw(QPainter* painter) const
qreal wi = asin(-h / l) * 180.0 / M_PI;
painter->rotate(-wi);

if (subtype() == GLISS_STRAIGHT) {
if (subtype() == GlissandoType::STRAIGHT) {
painter->drawLine(QLineF(0.0, 0.0, l, 0.0));
}
else if (subtype() == GLISS_WAVY) {
else if (subtype() == GlissandoType::WAVY) {
qreal mags = magS();
QRectF b = symbols[score()->symIdx()][trillelementSym].bbox(mags);
qreal w = symbols[score()->symIdx()][trillelementSym].width(mags);
Expand Down Expand Up @@ -197,3 +206,93 @@ void Glissando::setSize(const QSizeF& s)
setbbox(QRectF(QPointF(), s));
}

//---------------------------------------------------------
// undoSetSubtype
//---------------------------------------------------------

void Glissando::undoSetSubtype(GlissandoType t)
{
score()->undoChangeProperty(this, P_GLISS_TYPE, int(t));
}

//---------------------------------------------------------
// undoSetText
//---------------------------------------------------------

void Glissando::undoSetText(const QString& s)
{
score()->undoChangeProperty(this, P_GLISS_TEXT, s);
}

//---------------------------------------------------------
// undoSetShowText
//---------------------------------------------------------

void Glissando::undoSetShowText(bool f)
{
score()->undoChangeProperty(this, P_GLISS_SHOW_TEXT, f);
}

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

QVariant Glissando::getProperty(P_ID propertyId) const
{
switch (propertyId) {
case P_GLISS_TYPE:
return int(subtype());
case P_GLISS_TEXT:
return text();
case P_GLISS_SHOW_TEXT:
return showText();
default:
break;
}
return Element::getProperty(propertyId);
}

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

bool Glissando::setProperty(P_ID propertyId, const QVariant& v)
{
switch (propertyId) {
case P_GLISS_TYPE:
setSubtype(GlissandoType(v.toInt()));
break;
case P_GLISS_TEXT:
setText(v.toString());
break;
case P_GLISS_SHOW_TEXT:
setShowText(v.toBool());
break;
default:
if (!Element::setProperty(propertyId, v))
return false;
break;
}
score()->setLayoutAll(true);
return true;
}

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

QVariant Glissando::propertyDefault(P_ID propertyId) const
{
switch (propertyId) {
case P_GLISS_TYPE:
return int(GlissandoType::STRAIGHT);
case P_GLISS_TEXT:
return "gliss.";
case P_GLISS_SHOW_TEXT:
return true;
default:
break;
}
return Element::propertyDefault(propertyId);
}

31 changes: 25 additions & 6 deletions libmscore/glissando.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,40 @@

#include "element.h"

#define GLISS_STRAIGHT 0
#define GLISS_WAVY 1

class Note;

//---------------------------------------------------------
// GlissandoType
//---------------------------------------------------------

enum class GlissandoType {
STRAIGHT, WAVY
};

//---------------------------------------------------------
// @@ Glissando
//---------------------------------------------------------

class Glissando : public Element {
Q_OBJECT

int _subtype;
Q_PROPERTY(GlissandoType subtype READ subtype WRITE undoSetSubtype)
Q_PROPERTY(QString text READ text WRITE undoSetText)
Q_PROPERTY(bool showText READ showText WRITE undoSetShowText)

GlissandoType _subtype;
QLineF line;
QString _text;
bool _showText;

public:
Glissando(Score* s);
Glissando(const Glissando&);

virtual Glissando* clone() const { return new Glissando(*this); }
virtual ElementType type() const { return GLISSANDO; }
int subtype() const { return _subtype; }
void setSubtype(int v) { _subtype = v; }
GlissandoType subtype() const { return _subtype; }
void setSubtype(GlissandoType v) { _subtype = v; }
virtual Space space() const;

virtual void draw(QPainter*) const;
Expand All @@ -52,6 +63,14 @@ class Glissando : public Element {
void setText(const QString& t) { _text = t; }
bool showText() const { return _showText; }
void setShowText(bool v) { _showText = v; }

void undoSetSubtype(GlissandoType);
void undoSetText(const QString&);
void undoSetShowText(bool);

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

#endif
Expand Down
5 changes: 2 additions & 3 deletions libmscore/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,11 +1238,10 @@ Element* Note::drop(const DropData& data)
e->setParent(cr1);
// in TAB, use straight line with no text
if (staff()->isTabStaff()) {
(static_cast<Glissando*>(e))->setSubtype(GLISS_STRAIGHT);
(static_cast<Glissando*>(e))->setSubtype(GlissandoType::STRAIGHT);
(static_cast<Glissando*>(e))->setShowText(false);
}
}
score()->undoAddElement(e);
score()->setLayout(cr1->measure());
}
break;

Expand Down
4 changes: 4 additions & 0 deletions libmscore/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ static const PropertyData propertyList[] = {

{ P_REPEAT_FLAGS, false, 0, T_INT },

{ P_GLISS_TYPE, false, 0, T_INT },
{ P_GLISS_TEXT, false, 0, T_STRING },
{ P_GLISS_SHOW_TEXT, false, 0, T_BOOL },

{ P_END, false, "", T_INT }
};

Expand Down
4 changes: 4 additions & 0 deletions libmscore/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ enum P_ID {

P_REPEAT_FLAGS,

P_GLISS_TYPE,
P_GLISS_TEXT,
P_GLISS_SHOW_TEXT,

P_END
};

Expand Down
22 changes: 21 additions & 1 deletion libmscore/undo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include "rehearsalmark.h"
#include "excerpt.h"
#include "stafftext.h"
#include "chordline.h"

extern Measure* tick2measure(int tick);

Expand Down Expand Up @@ -806,6 +807,7 @@ void Score::undoAddElement(Element* element)
|| (et == Element::IMAGE && element->parent()->type() != Element::SEGMENT)
|| (et == Element::SYMBOL && element->parent()->type() != Element::SEGMENT)
|| et == Element::NOTE
|| et == Element::GLISSANDO
) {
Element* parent = element->parent();
LinkedElements* links = parent->links();
Expand All @@ -827,7 +829,9 @@ void Score::undoAddElement(Element* element)
return;
}

if (ostaff == 0 || (et != Element::ARTICULATION
if (ostaff == 0 || (
et != Element::ARTICULATION
&& et != Element::CHORDLINE
&& et != Element::SLUR
&& et != Element::TIE
&& et != Element::NOTE
Expand Down Expand Up @@ -902,6 +906,22 @@ void Score::undoAddElement(Element* element)
}
undo(new AddElement(na));
}
else if (element->type() == Element::CHORDLINE) {
ChordLine* a = static_cast<ChordLine*>(element);
Segment* segment = a->chord()->segment();
int tick = segment->tick();
Measure* m = score->tick2measure(tick);
Segment* seg = m->findSegment(Segment::SegChordRest, tick);
if (seg == 0) {
qDebug("undoAddSegment: segment not found");
break;
}
int ntrack = staffIdx * VOICES + a->voice();
ne->setTrack(ntrack);
ChordRest* ncr = static_cast<ChordRest*>(seg->element(ntrack));
ne->setParent(ncr);
undo(new AddElement(ne));
}
//
// elements with Segment as parent
//
Expand Down
5 changes: 3 additions & 2 deletions mscore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ QT4_WRAP_UI (ui_headers
rest.ui inspector_chord.ui omrpanel.ui startdialog.ui masterpalette.ui
inspector_group_element.ui inspector_image.ui stem.ui inspector_lasso.ui
inspector_volta.ui inspector_ottava.ui inspector_trill.ui inspector_hairpin.ui
box.ui pluginManager.ui inspector_jump.ui inspector_marker.ui
box.ui pluginManager.ui inspector_jump.ui inspector_marker.ui inspector_glissando.ui
${SCRIPT_UI}
)

Expand Down Expand Up @@ -92,7 +92,7 @@ QT4_WRAP_CPP (mocs
inspectorGroupElement.h inspectorImage.h waveview.h helpBrowser.h
inspectorLasso.h inspectorVolta.h inspectorOttava.h inspectorTrill.h
inspectorHairpin.h qmlplugin.h palettebox.h workspace.h pluginManager.h
inspectorJump.h inspectorMarker.h
inspectorJump.h inspectorMarker.h inspectorGlissando.h
${OMR_MOCS}
${SCRIPT_MOCS}
)
Expand Down Expand Up @@ -197,6 +197,7 @@ add_executable ( ${ExecutableName}
inspectorHairpin.cpp qmlplugin.cpp editlyrics.cpp
musicxmlsupport.cpp exportxml.cpp importxml.cpp importxmlfirstpass.cpp
savePositions.cpp pluginManager.cpp inspectorJump.cpp inspectorMarker.cpp
inspectorGlissando.cpp
${OMR_FILES}
${AUDIO}
${SCRIPT_FILES}
Expand Down
2 changes: 1 addition & 1 deletion mscore/exportly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ void ExportLy::buildGlissandoList(int strack, int etrack)
Element* prevel = seg->prev()->element(st); //(st);
Chord* prevchord = (Chord*)prevel;
glisstable[glisscount].chord = prevchord;
glisstable[glisscount].type = cd->glissando()->subtype();
glisstable[glisscount].type = int(cd->glissando()->subtype());
glisstable[glisscount].glisstext = cd->glissando()->text();
glisstable[glisscount].tick = prevchord->tick();
}
Expand Down
Loading

0 comments on commit 9907048

Please sign in to comment.