Skip to content

Commit

Permalink
TremoloBar updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Apr 12, 2018
1 parent c88175f commit 9510ad6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 117 deletions.
6 changes: 6 additions & 0 deletions libmscore/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,11 @@ const std::vector<StyledProperty> fretStyle {
{ Sid::NOSTYLE, Pid::END } // end of list marker
};

const std::vector<StyledProperty> tremoloBarStyle {
{ Sid::tremoloBarLineWidth, Pid::LINE_WIDTH },
{ Sid::NOSTYLE, Pid::END } // end of list marker
};

const std::vector<StyledProperty> user1Style {
{ Sid::user1FontFace, Pid::FONT_FACE },
{ Sid::user1FontSize, Pid::FONT_SIZE },
Expand Down Expand Up @@ -1453,6 +1458,7 @@ static constexpr std::array<StyledPropertyListName, int(SubStyleId::SUBSTYLES)>
{ QT_TRANSLATE_NOOP("TextStyle", "Beam"), &beamStyle, SubStyleId::BEAM },
{ QT_TRANSLATE_NOOP("TextStyle", "Box"), &boxStyle, SubStyleId::BOX },
{ QT_TRANSLATE_NOOP("TextStyle", "FretDiagram"), &fretStyle, SubStyleId::FRET },
{ "TremoloBar", &tremoloBarStyle, SubStyleId::TREMOLO_BAR },

This comment has been minimized.

Copy link
@Jojo-Schmitz

Jojo-Schmitz Apr 12, 2018

Contributor

not QT_TRANSLATE_NOOP("TextStyle", "TremoloBar"),?

{ QT_TRANSLATE_NOOP("TextStyle", "User-1"), &user1Style, SubStyleId::USER1 },
{ QT_TRANSLATE_NOOP("TextStyle", "User-2"), &user2Style, SubStyleId::USER2 },
} };
Expand Down
1 change: 1 addition & 0 deletions libmscore/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ enum class SubStyleId {
BEAM,
BOX,
FRET,
TREMOLO_BAR,
USER1,
USER2,
SUBSTYLES
Expand Down
122 changes: 14 additions & 108 deletions libmscore/tremolobar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ namespace Ms {
//---------------------------------------------------------

TremoloBar::TremoloBar(Score* s)
: Element(s)
: Element(s, ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF)
{
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF);
setLineWidth(score()->styleS(Sid::tremoloBarLineWidth));
lineWidthStyle = PropertyFlags::STYLED;
initSubStyle(SubStyleId::TREMOLO_BAR);
}

//---------------------------------------------------------
Expand Down Expand Up @@ -109,42 +107,15 @@ void TremoloBar::read(XmlReader& e)
}
else if (tag == "mag")
_userMag = e.readDouble(0.1, 10.0);
else if (tag == "lineWidth")
setLineWidth(Spatium(e.readDouble()));
else if (readStyledProperty(e, tag))
;
else if (tag == "play")
setPlay(e.readInt());
else
e.unknown();
}
}

//---------------------------------------------------------
// undoSetUserMag
//---------------------------------------------------------

void TremoloBar::undoSetUserMag(qreal val)
{
undoChangeProperty(Pid::MAG, val);
}

//---------------------------------------------------------
// undoSetLineWidth
//---------------------------------------------------------

void TremoloBar::undoSetLineWidth(Spatium val)
{
undoChangeProperty(Pid::LINE_WIDTH, val);
}

//---------------------------------------------------------
// undoSetPlay
//---------------------------------------------------------

void TremoloBar::undoSetPlay(bool val)
{
undoChangeProperty(Pid::PLAY, val);
}

//---------------------------------------------------------
// getProperty
//---------------------------------------------------------
Expand All @@ -163,24 +134,6 @@ QVariant TremoloBar::getProperty(Pid propertyId) const
}
}

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

QVariant TremoloBar::propertyDefault(Pid propertyId) const
{
switch (propertyId) {
case Pid::LINE_WIDTH:
return score()->styleV(Sid::voltaLineWidth);
case Pid::MAG:
return 1.0;
case Pid::PLAY:
return true;
default:
return Element::propertyDefault(propertyId);
}
}

//---------------------------------------------------------
// setProperty
//---------------------------------------------------------
Expand All @@ -189,7 +142,6 @@ bool TremoloBar::setProperty(Pid propertyId, const QVariant& v)
{
switch (propertyId) {
case Pid::LINE_WIDTH:
lineWidthStyle = PropertyFlags::UNSTYLED;
setLineWidth(v.value<Spatium>());
break;
case Pid::MAG:
Expand All @@ -202,73 +154,27 @@ bool TremoloBar::setProperty(Pid propertyId, const QVariant& v)
default:
return Element::setProperty(propertyId, v);
}
score()->setLayoutAll();
triggerLayout();
return true;
}

//---------------------------------------------------------
// propertyStyle
//---------------------------------------------------------

PropertyFlags& TremoloBar::propertyFlags(Pid id)
{
switch (id) {
case Pid::LINE_WIDTH:
return lineWidthStyle;

default:
return Element::propertyFlags(id);
}
}

//---------------------------------------------------------
// resetProperty
// propertyDefault
//---------------------------------------------------------

void TremoloBar::resetProperty(Pid id)
QVariant TremoloBar::propertyDefault(Pid propertyId) const
{
switch (id) {
switch (propertyId) {
case Pid::LINE_WIDTH:
setProperty(id, propertyDefault(id));
lineWidthStyle = PropertyFlags::STYLED;
break;

return score()->styleV(Sid::tremoloBarLineWidth);
case Pid::MAG:
return 1.0;
case Pid::PLAY:
return true;
default:
return Element::resetProperty(id);
return Element::propertyDefault(propertyId);
}
}

//---------------------------------------------------------
// styleChanged
// reset all styled values to actual style
//---------------------------------------------------------

void TremoloBar::styleChanged()
{
if (lineWidthStyle == PropertyFlags::STYLED)
setLineWidth(score()->styleS(Sid::voltaLineWidth));
}

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

void TremoloBar::reset()
{
if (lineWidthStyle == PropertyFlags::UNSTYLED)
undoChangeProperty(Pid::LINE_WIDTH, propertyDefault(Pid::LINE_WIDTH), PropertyFlags::STYLED);
Element::reset();
}

//---------------------------------------------------------
// spatiumChanged
//---------------------------------------------------------

void TremoloBar::spatiumChanged(qreal oldValue, qreal newValue)
{
_lw *= (newValue / oldValue);
Element::spatiumChanged(oldValue, newValue);
}

}

9 changes: 0 additions & 9 deletions libmscore/tremolobar.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace Ms {

class TremoloBar final : public Element {
Spatium _lw;
PropertyFlags lineWidthStyle;
qreal _userMag { 1.0 }; // allowed 0.1 - 10.0
bool _play { true };

Expand All @@ -52,23 +51,15 @@ class TremoloBar final : public Element {
virtual QVariant getProperty(Pid propertyId) const override;
virtual bool setProperty(Pid propertyId, const QVariant&) override;
virtual QVariant propertyDefault(Pid) const override;
virtual PropertyFlags& propertyFlags(Pid id) override;
virtual void resetProperty(Pid id) override;
virtual void styleChanged() override;
virtual void reset() override;
virtual void spatiumChanged(qreal oldValue, qreal newValue) override;

qreal userMag() const { return _userMag; }
void setUserMag(qreal m) { _userMag = m; }
void undoSetUserMag(qreal val);

void setLineWidth(Spatium v) { _lw = v; }
Spatium lineWidth() const { return _lw; }
void undoSetLineWidth(Spatium);

bool play() const { return _play; }
void setPlay(bool val) { _play = val; }
void undoSetPlay(bool);
};


Expand Down

0 comments on commit 9510ad6

Please sign in to comment.