Skip to content

Commit

Permalink
Implement styleable tremolo placement property, add it to Inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrio95 committed Jun 10, 2019
1 parent 333ca7d commit 54ffcc5
Show file tree
Hide file tree
Showing 11 changed files with 342 additions and 142 deletions.
1 change: 1 addition & 0 deletions libmscore/property.cpp
Expand Up @@ -327,6 +327,7 @@ static constexpr PropertyMetaData propertyList[] = {
{ Pid::CHORD_LINE_TYPE, true, "subtype", P_TYPE::INT, DUMMY_QT_TRANSLATE_NOOP("propertyName", "chord line type") },
{ Pid::CHORD_LINE_STRAIGHT, true, "straight", P_TYPE::BOOL, DUMMY_QT_TRANSLATE_NOOP("propertyName", "straight chord line") },
{ Pid::TREMOLO_TYPE, true, "subtype", P_TYPE::INT, DUMMY_QT_TRANSLATE_NOOP("propertyName", "tremolo type") },
{ Pid::TREMOLO_PLACEMENT, false, "tremoloPlacement", P_TYPE::INT, DUMMY_QT_TRANSLATE_NOOP("propertyName", "tremolo placement") },

{ Pid::END, false, "++end++", P_TYPE::INT, DUMMY_QT_TRANSLATE_NOOP("propertyName", "<invalid property>") }
};
Expand Down
1 change: 1 addition & 0 deletions libmscore/property.h
Expand Up @@ -337,6 +337,7 @@ enum class Pid {
CHORD_LINE_TYPE,
CHORD_LINE_STRAIGHT,
TREMOLO_TYPE,
TREMOLO_PLACEMENT,

END
};
Expand Down
1 change: 1 addition & 0 deletions libmscore/style.cpp
Expand Up @@ -462,6 +462,7 @@ static const StyleType styleTypes[] {
{ Sid::tremoloBoxHeight, "tremoloBoxHeight", Spatium(0.65) },
{ Sid::tremoloStrokeWidth, "tremoloLineWidth", Spatium(0.5) }, // was 0.35
{ Sid::tremoloDistance, "tremoloDistance", Spatium(0.8) },
{ Sid::tremoloPlacement, "tremoloPlacement", int(TremoloPlacement::DEFAULT) },

{ Sid::linearStretch, "linearStretch", QVariant(qreal(1.5)) },
{ Sid::crossMeasureValues, "crossMeasureValues", QVariant(false) },
Expand Down
1 change: 1 addition & 0 deletions libmscore/style.h
Expand Up @@ -434,6 +434,7 @@ enum class Sid {
tremoloBoxHeight,
tremoloStrokeWidth,
tremoloDistance,
tremoloPlacement,
// TODO tremoloBeamLengthMultiplier,
// TODO tremoloMaxBeamLength,

Expand Down
22 changes: 18 additions & 4 deletions libmscore/tremolo.cpp
Expand Up @@ -23,6 +23,14 @@

namespace Ms {

//---------------------------------------------------------
// tremoloStyle
//---------------------------------------------------------

static const ElementStyle tremoloStyle {
{ Sid::tremoloPlacement, Pid::TREMOLO_PLACEMENT },
};

//---------------------------------------------------------
// Tremolo
//---------------------------------------------------------
Expand All @@ -42,6 +50,7 @@ static const char* tremoloName[] = {
Tremolo::Tremolo(Score* score)
: Element(score, ElementFlag::MOVABLE)
{
initElementStyle(&tremoloStyle);
setTremoloType(TremoloType::R8);
_chord1 = 0;
_chord2 = 0;
Expand Down Expand Up @@ -127,8 +136,7 @@ void Tremolo::setTremoloType(TremoloType t)

bool Tremolo::placeMidStem() const
{
const bool placeAllTremoloMidStem = true; // TODO: style setting
return tremoloType() == TremoloType::BUZZ_ROLL || placeAllTremoloMidStem;
return _tremoloPlacement == TremoloPlacement::STEM_CENTER;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -637,6 +645,8 @@ QVariant Tremolo::getProperty(Pid propertyId) const
switch(propertyId) {
case Pid::TREMOLO_TYPE:
return int(_tremoloType);
case Pid::TREMOLO_PLACEMENT:
return int (_tremoloPlacement);
default:
break;
}
Expand All @@ -653,10 +663,14 @@ bool Tremolo::setProperty(Pid propertyId, const QVariant& val)
case Pid::TREMOLO_TYPE:
setTremoloType(TremoloType(val.toInt()));
break;
default:
case Pid::TREMOLO_PLACEMENT:
_tremoloPlacement = TremoloPlacement(val.toInt());
break;
default:
return Element::setProperty(propertyId, val);
}
return Element::setProperty(propertyId, val);
triggerLayout();
return true;
}

//---------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions libmscore/tremolo.h
Expand Up @@ -27,6 +27,11 @@ enum class TremoloType : signed char {
C8, C16, C32, C64 // two note tremolo (change)
};

enum class TremoloPlacement : signed char {
DEFAULT = 0,
STEM_CENTER
};

//---------------------------------------------------------
// @@ Tremolo
//---------------------------------------------------------
Expand All @@ -39,6 +44,7 @@ class Tremolo final : public Element {
QPainterPath path;

int _lines; // derived from _subtype
TremoloPlacement _tremoloPlacement = TremoloPlacement::DEFAULT;

QPainterPath basePath() const;
void computeShape();
Expand Down
1 change: 1 addition & 0 deletions mscore/CMakeLists.txt
Expand Up @@ -183,6 +183,7 @@ QT5_WRAP_UI (ui_headers
inspector/inspector_bend.ui
inspector/inspector_arpeggio.ui
inspector/inspector_tremolo.ui
inspector/inspector_tremolobar.ui
inspector/inspector_caesura.ui
inspector/inspector_bracket.ui
inspector/inspector_iname.ui
Expand Down
20 changes: 20 additions & 0 deletions mscore/inspector/inspector.cpp
Expand Up @@ -304,6 +304,9 @@ void Inspector::update(Score* s)
case ElementType::BEND:
ie = new InspectorBend(this);
break;
case ElementType::TREMOLO:
ie = new InspectorTremolo(this);
break;
case ElementType::TREMOLOBAR:
ie = new InspectorTremoloBar(this);
break;
Expand Down Expand Up @@ -920,6 +923,23 @@ void InspectorTremoloBar::propertiesClicked()
score->endCmd();
}

//---------------------------------------------------------
// InspectorTremoloBar
//---------------------------------------------------------

InspectorTremolo::InspectorTremolo(QWidget* parent)
: InspectorElementBase(parent)
{
g.setupUi(addWidget());

const std::vector<InspectorItem> iiList = {
{ Pid::TREMOLO_PLACEMENT, 0, g.tremoloPlacement, g.resetTremoloPlacement },
};
const std::vector<InspectorPanel> ppList = { { g.title, g.panel } };

mapSignals(iiList, ppList);
}

//---------------------------------------------------------
// InspectorClef
//---------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions mscore/inspector/inspector.h
Expand Up @@ -42,6 +42,7 @@
#include "ui_inspector_text.h"
// #include "ui_inspector_fret.h"
#include "ui_inspector_tremolo.h"
#include "ui_inspector_tremolobar.h"
#include "ui_inspector_caesura.h"
#include "ui_inspector_bracket.h"
#include "ui_inspector_iname.h"
Expand Down Expand Up @@ -317,6 +318,19 @@ class InspectorTremoloBar : public InspectorElementBase {
InspectorTremoloBar(QWidget* parent);
};

//---------------------------------------------------------
// InspectorTremolo
//---------------------------------------------------------

class InspectorTremolo : public InspectorElementBase {
Q_OBJECT

Ui::InspectorTremolo g;

public:
InspectorTremolo(QWidget* parent);
};

//---------------------------------------------------------
// InspectorTempoText
//---------------------------------------------------------
Expand Down

0 comments on commit 54ffcc5

Please sign in to comment.