From 6f6e86a03c7680301db5246ea4d7905c6f01c559 Mon Sep 17 00:00:00 2001 From: ws Date: Mon, 28 May 2018 14:20:42 +0200 Subject: [PATCH] fix #272366 There are no System Text properties --- libmscore/scoreElement.h | 9 ++++ libmscore/stafftext.cpp | 50 +++++++++++-------- libmscore/stafftext.h | 22 ++++++--- libmscore/systemtext.cpp | 6 +-- libmscore/systemtext.h | 4 +- mscore/events.cpp | 2 +- mscore/propertymenu.cpp | 88 +++++++++++++++------------------- mscore/stafftextproperties.cpp | 6 +-- mscore/stafftextproperties.h | 8 ++-- 9 files changed, 107 insertions(+), 88 deletions(-) diff --git a/libmscore/scoreElement.h b/libmscore/scoreElement.h index 68142490e5e2..3b2e5afa697a 100644 --- a/libmscore/scoreElement.h +++ b/libmscore/scoreElement.h @@ -130,6 +130,8 @@ class VibratoSegment; class PalmMute; class PalmMuteSegment; +class StaffTextBase; + enum class Pid : int; enum class PropertyFlags : char; enum class Sid : int; @@ -387,6 +389,9 @@ class ScoreElement { || isSLine() ; } + bool isStaffTextBase() const { + return isStaffText() || isSystemText(); + } }; //--------------------------------------------------- @@ -461,6 +466,10 @@ static inline TextBase* toTextBase(ScoreElement* e) { Q_ASSERT(e == 0 || e->isTextBase()); return (TextBase*)e; } +static inline StaffTextBase* toStaffTextBase(ScoreElement* e) { + Q_ASSERT(e == 0 || e->isStaffTextBase()); + return (StaffTextBase*)e; + } #define CONVERT(a) \ static inline a* to##a(ScoreElement* e) { Q_ASSERT(e == 0 || e->is##a()); return (a*)e; } \ diff --git a/libmscore/stafftext.cpp b/libmscore/stafftext.cpp index c99bc04e827f..3e755a5c3a2b 100644 --- a/libmscore/stafftext.cpp +++ b/libmscore/stafftext.cpp @@ -20,20 +20,15 @@ namespace Ms { //--------------------------------------------------------- -// StaffText +// StaffTextBase //--------------------------------------------------------- -StaffText::StaffText(Score* s) - : TextBase(s, ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF) - { - initSubStyle(SubStyleId::STAFF); - setSwingParameters(MScore::division / 2, 60); - } +// : TextBase(s, ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF) -StaffText::StaffText(SubStyleId ss, Score* s) - : TextBase(s, ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF) +StaffTextBase::StaffTextBase(Score* s, ElementFlags flags) + : TextBase(s, flags) { - initSubStyle(ss); +// initSubStyle(ss); setPlacement(Placement::ABOVE); // default setSwingParameters(MScore::division / 2, 60); } @@ -42,7 +37,7 @@ StaffText::StaffText(SubStyleId ss, Score* s) // write //--------------------------------------------------------- -void StaffText::write(XmlWriter& xml) const +void StaffTextBase::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; @@ -81,7 +76,7 @@ void StaffText::write(XmlWriter& xml) const // read //--------------------------------------------------------- -void StaffText::read(XmlReader& e) +void StaffTextBase::read(XmlReader& e) { for (int voice = 0; voice < VOICES; ++voice) _channelNames[voice].clear(); @@ -96,7 +91,7 @@ void StaffText::read(XmlReader& e) // readProperties //--------------------------------------------------------- -bool StaffText::readProperties(XmlReader& e) +bool StaffTextBase::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); @@ -164,7 +159,7 @@ bool StaffText::readProperties(XmlReader& e) // clearAeolusStops //--------------------------------------------------------- -void StaffText::clearAeolusStops() +void StaffTextBase::clearAeolusStops() { for (int i = 0; i < 4; ++i) aeolusStops[i] = 0; @@ -174,7 +169,7 @@ void StaffText::clearAeolusStops() // setAeolusStop //--------------------------------------------------------- -void StaffText::setAeolusStop(int group, int idx, bool val) +void StaffTextBase::setAeolusStop(int group, int idx, bool val) { if (val) aeolusStops[group] |= (1 << idx); @@ -186,7 +181,7 @@ void StaffText::setAeolusStop(int group, int idx, bool val) // getAeolusStop //--------------------------------------------------------- -bool StaffText::getAeolusStop(int group, int idx) const +bool StaffTextBase::getAeolusStop(int group, int idx) const { return aeolusStops[group] & (1 << idx); } @@ -195,7 +190,7 @@ bool StaffText::getAeolusStop(int group, int idx) const // layout //--------------------------------------------------------- -void StaffText::layout() +void StaffTextBase::layout() { Staff* s = staff(); qreal y = placeAbove() ? styleP(Sid::staffTextPosAbove) : styleP(Sid::staffTextPosBelow) + (s ? s->height() : 0.0); @@ -208,10 +203,10 @@ void StaffText::layout() // segment //--------------------------------------------------------- -Segment* StaffText::segment() const +Segment* StaffTextBase::segment() const { if (!parent()->isSegment()) { - qDebug("StaffText parent %s\n", parent()->name()); + qDebug("parent %s", parent()->name()); return 0; } Segment* s = toSegment(parent()); @@ -222,7 +217,7 @@ Segment* StaffText::segment() const // propertyDefault //--------------------------------------------------------- -QVariant StaffText::propertyDefault(Pid id) const +QVariant StaffTextBase::propertyDefault(Pid id) const { switch(id) { case Pid::SUB_STYLE: @@ -236,5 +231,20 @@ QVariant StaffText::propertyDefault(Pid id) const } } +//--------------------------------------------------------- +// StaffText +//--------------------------------------------------------- + +StaffText::StaffText(Score* s) + : StaffTextBase(s, ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF) + { + initSubStyle(SubStyleId::STAFF); + } + +StaffText::StaffText(SubStyleId ss, Score* s) + : StaffTextBase(s, ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF) + { + initSubStyle(ss); + } } diff --git a/libmscore/stafftext.h b/libmscore/stafftext.h index 7ef93b5083cb..3651d8306f0c 100644 --- a/libmscore/stafftext.h +++ b/libmscore/stafftext.h @@ -29,10 +29,10 @@ struct ChannelActions { }; //--------------------------------------------------------- -// @@ StaffText +// StaffTextBase //--------------------------------------------------------- -class StaffText final : public TextBase { +class StaffTextBase : public TextBase { QString _channelNames[4]; QList _channelActions; SwingParameters _swingParameters; @@ -41,10 +41,7 @@ class StaffText final : public TextBase { bool _swing { false }; public: - StaffText(Score* = 0); - StaffText(SubStyleId, Score* = 0); - virtual StaffText* clone() const { return new StaffText(*this); } - virtual ElementType type() const { return ElementType::STAFF_TEXT; } + StaffTextBase(Score* = 0, ElementFlags = ElementFlag::NOTHING); virtual void write(XmlWriter& xml) const override; virtual void read(XmlReader&) override; @@ -70,5 +67,18 @@ class StaffText final : public TextBase { bool swing() const { return _swing; } }; +//--------------------------------------------------------- +// SystemText +//--------------------------------------------------------- + +class StaffText final : public StaffTextBase { + public: + StaffText(Score* score); + StaffText(SubStyleId, Score* = 0); + virtual StaffText* clone() const override { return new StaffText(*this); } + virtual ElementType type() const override { return ElementType::STAFF_TEXT; } + }; + + } // namespace Ms #endif diff --git a/libmscore/systemtext.cpp b/libmscore/systemtext.cpp index 8bb78e07b8a1..8a4792cb7230 100644 --- a/libmscore/systemtext.cpp +++ b/libmscore/systemtext.cpp @@ -19,13 +19,13 @@ namespace Ms { //--------------------------------------------------------- SystemText::SystemText(Score* s) - : TextBase(s, ElementFlag::SYSTEM) + : StaffTextBase(s, ElementFlag::SYSTEM) { initSubStyle(SubStyleId::SYSTEM); } -SystemText::SystemText(SubStyleId ss, Score* s) - : TextBase(s, ElementFlag::SYSTEM) +SystemText::SystemText(SubStyleId ss, Score* s, ElementFlags flags) + : StaffTextBase(s, flags) { initSubStyle(ss); } diff --git a/libmscore/systemtext.h b/libmscore/systemtext.h index 391f1faa2f2e..02c3e5ae0dd8 100644 --- a/libmscore/systemtext.h +++ b/libmscore/systemtext.h @@ -21,10 +21,10 @@ namespace Ms { // SystemText //--------------------------------------------------------- -class SystemText final : public TextBase { +class SystemText final : public StaffTextBase { public: SystemText(Score* score); - SystemText(SubStyleId, Score* = 0); + SystemText(SubStyleId, Score* = 0, ElementFlags = ElementFlag::NOTHING); virtual SystemText* clone() const override { return new SystemText(*this); } virtual ElementType type() const override { return ElementType::SYSTEM_TEXT; } Segment* segment() const { return (Segment*)parent(); } diff --git a/mscore/events.cpp b/mscore/events.cpp index 5ec27e9799e4..dc33dad2da60 100644 --- a/mscore/events.cpp +++ b/mscore/events.cpp @@ -400,8 +400,8 @@ void ScoreView::mousePressEvent(QMouseEvent* ev) } else { if (!editData.element->canvasBoundingRect().contains(editData.startMove)) { - editData.element = e; changeState(ViewState::NORMAL); + editData.element = e; mousePressEventNormal(ev); } else { diff --git a/mscore/propertymenu.cpp b/mscore/propertymenu.cpp index 159394ec169d..e33420ded816 100644 --- a/mscore/propertymenu.cpp +++ b/mscore/propertymenu.cpp @@ -122,38 +122,34 @@ void ScoreView::genPropertyMenuText(Element* e, QMenu* popup) void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) { - if (e->type() == ElementType::BAR_LINE) { + if (e->isBarLine()) genPropertyMenu1(e, popup); - } - else if (e->type() == ElementType::ARTICULATION) { + else if (e->isArticulation()) { genPropertyMenu1(e, popup); popup->addAction(tr("Articulation Properties..."))->setData("a-props"); } - else if (e->type() == ElementType::BEAM) { + else if (e->isBeam()) popup->addAction(getAction("flip")); - } - else if (e->type() == ElementType::STEM) { + else if (e->isStem()) popup->addAction(getAction("flip")); - } - else if (e->type() == ElementType::HOOK) { + else if (e->isHook()) popup->addAction(getAction("flip")); - } - else if (e->type() == ElementType::BEND) { + else if (e->isBend()) { genPropertyMenu1(e, popup); popup->addAction(tr("Bend Properties..."))->setData("b-props"); } - else if (e->type() == ElementType::TREMOLOBAR) { + else if (e->isTremoloBar()) { genPropertyMenu1(e, popup); popup->addAction(tr("Tremolo Bar Properties..."))->setData("tr-props"); } - else if (e->type() == ElementType::HBOX) { + else if (e->isHBox()) { QMenu* textMenu = popup->addMenu(tr("Add")); // borrow translation info from global actions // but create new actions with local handler textMenu->addAction(getAction("frame-text")->text())->setData("frame-text"); textMenu->addAction(getAction("picture")->text())->setData("picture"); } - else if (e->type() == ElementType::VBOX) { + else if (e->isVBox()) { QMenu* textMenu = popup->addMenu(tr("Add")); // borrow translation info from global actions // but create new actions with local handler @@ -166,10 +162,9 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) textMenu->addAction(getAction("insert-hbox")->text())->setData("insert-hbox"); textMenu->addAction(getAction("picture")->text())->setData("picture"); } - else if (e->type() == ElementType::VOLTA_SEGMENT) { + else if (e->isVoltaSegment()) genPropertyMenu1(e, popup); - } - else if (e->type() == ElementType::TIMESIG) { + else if (e->isTimeSig()) { genPropertyMenu1(e, popup); TimeSig* ts = static_cast(e); int _track = ts->track(); @@ -187,7 +182,7 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) popup->addAction(tr("Time Signature Properties..."))->setData("ts-props"); } } - else if (e->type() == ElementType::CLEF) { + else if (e->isClef()) { genPropertyMenu1(e, popup); Clef* clef = static_cast(e); // if the clef is not generated (= not courtesy) add the specific menu item @@ -198,29 +193,28 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) a->setData("clef-courtesy"); } } - else if (e->type() == ElementType::STAFF_TEXT) { + else if (e->isStaffText()) { genPropertyMenuText(e, popup); - Text* t = static_cast(e); - if (t->systemFlag()) - popup->addAction(tr("System Text Properties..."))->setData("st-props"); - else - popup->addAction(tr("Staff Text Properties..."))->setData("st-props"); - } - else if (e->type() == ElementType::TEXT - || e->type() == ElementType::REHEARSAL_MARK - || e->type() == ElementType::MARKER - || e->type() == ElementType::JUMP - || e->type() == ElementType::LYRICS - || e->type() == ElementType::FIGURED_BASS) { + popup->addAction(tr("Staff Text Properties..."))->setData("st-props"); + } + else if (e->isSystemText()) { + genPropertyMenuText(e, popup); + popup->addAction(tr("System Text Properties..."))->setData("st-props"); + } + else if (e->isText() + || e->isSystemText() + || e->isRehearsalMark() + || e->isMarker() + || e->isJump() + || e->isLyrics() + || e->isFiguredBass()) { genPropertyMenuText(e, popup); } - else if (e->type() == ElementType::HARMONY) { + else if (e->isHarmony()) genPropertyMenu1(e, popup); - } - else if (e->type() == ElementType::TEMPO_TEXT) { + else if (e->isTempoText()) genPropertyMenu1(e, popup); - } - else if (e->type() == ElementType::KEYSIG) { + else if (e->isKeySig()) { genPropertyMenu1(e, popup); KeySig* ks = static_cast(e); if (!e->generated() && ks->measure() != score()->firstMeasure()) { @@ -230,13 +224,13 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) a->setData("key-courtesy"); } } - else if (e->type() == ElementType::STAFF_STATE && static_cast(e)->staffStateType() == StaffStateType::INSTRUMENT) { + else if (e->isStaffState() && toStaffState(e)->staffStateType() == StaffStateType::INSTRUMENT) { popup->addAction(tr("Change Instrument Properties..."))->setData("ss-props"); } - else if (e->type() == ElementType::SLUR_SEGMENT) { + else if (e->isSlurSegment()) { genPropertyMenu1(e, popup); } - else if (e->type() == ElementType::REST) { + else if (e->isRest()) { QAction* b = popup->actions()[0]; QAction* a = popup->insertSeparator(b); a->setText(tr("Staff")); @@ -252,10 +246,9 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) a->setEnabled(!static_cast(e)->segment()->measure()->isMMRest()); popup->insertAction(b, a); - genPropertyMenu1(e, popup); } - else if (e->type() == ElementType::NOTE) { + else if (e->isNote()) { QAction* b = popup->actions()[0]; QAction* a = popup->insertSeparator(b); a->setText(tr("Staff")); @@ -279,19 +272,16 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) if (enableExperimental) popup->addAction(tr("Chord Articulation..."))->setData("articulation"); } - else if (e->type() == ElementType::LAYOUT_BREAK && static_cast(e)->layoutBreakType() == LayoutBreak::Type::SECTION) { + else if (e->isLayoutBreak() && toLayoutBreak(e)->layoutBreakType() == LayoutBreak::Type::SECTION) popup->addAction(tr("Section Break Properties..."))->setData("break-props"); - } - else if (e->type() == ElementType::INSTRUMENT_CHANGE) { + else if (e->isInstrumentChange()) { genPropertyMenu1(e, popup); popup->addAction(tr("Change Instrument..."))->setData("ch-instr"); } - else if (e->type() == ElementType::FRET_DIAGRAM) { + else if (e->isFretDiagram()) popup->addAction(tr("Fretboard Diagram Properties..."))->setData("fret-props"); - } - else if (e->type() == ElementType::INSTRUMENT_NAME) { + else if (e->isInstrumentName()) popup->addAction(tr("Staff Properties..."))->setData("staff-props"); - } else genPropertyMenu1(e, popup); } @@ -405,10 +395,10 @@ void ScoreView::elementPropertyAction(const QString& cmd, Element* e) e->undoChangeProperty(Pid::SHOW_COURTESY, show); } else if (cmd == "st-props") { - StaffTextProperties rp(static_cast(e)); + StaffTextProperties rp(toStaffTextBase(e)); if (rp.exec()) { Score* score = e->score(); - StaffText* nt = rp.staffText()->clone(); + StaffTextBase* nt = toStaffTextBase(rp.staffTextBase()->clone()); nt->setScore(score); score->undoChangeElement(e, nt); score->masterScore()->updateChannel(); diff --git a/mscore/stafftextproperties.cpp b/mscore/stafftextproperties.cpp index 26450cd625a8..ec439bd1b8c2 100644 --- a/mscore/stafftextproperties.cpp +++ b/mscore/stafftextproperties.cpp @@ -34,7 +34,7 @@ namespace Ms { // initChannelCombo //--------------------------------------------------------- -static void initChannelCombo(QComboBox* cb, StaffText* st) +static void initChannelCombo(QComboBox* cb, StaffTextBase* st) { Part* part = st->staff()->part(); int tick = static_cast(st->parent())->tick(); @@ -50,7 +50,7 @@ static void initChannelCombo(QComboBox* cb, StaffText* st) // StaffTextProperties //--------------------------------------------------------- -StaffTextProperties::StaffTextProperties(const StaffText* st, QWidget* parent) +StaffTextProperties::StaffTextProperties(const StaffTextBase* st, QWidget* parent) : QDialog(parent) { setObjectName("StaffTextProperties"); @@ -70,7 +70,7 @@ StaffTextProperties::StaffTextProperties(const StaffText* st, QWidget* parent) //if (!enableExperimental) tabWidget->removeTab(tabWidget->indexOf(tabMIDIAction)); } setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); - _staffText = static_cast(st->clone()); + _staffText = static_cast(st->clone()); vb[0][0] = voice1_1; vb[0][1] = voice1_2; diff --git a/mscore/stafftextproperties.h b/mscore/stafftextproperties.h index 25cc83c170a9..a3c40bdd7b3a 100644 --- a/mscore/stafftextproperties.h +++ b/mscore/stafftextproperties.h @@ -25,7 +25,7 @@ namespace Ms { -class StaffText; +class StaffTextBase; //--------------------------------------------------------- // StaffTextProperties @@ -35,7 +35,7 @@ class StaffText; class StaffTextProperties : public QDialog, public Ui::StaffTextProperties { Q_OBJECT - StaffText* _staffText; + StaffTextBase* _staffText; QToolButton* vb[4][4]; QComboBox* channelCombo[4]; QPushButton* stops[4][16]; @@ -51,10 +51,10 @@ class StaffTextProperties : public QDialog, public Ui::StaffTextProperties { void setSwingControls(bool); public: - StaffTextProperties(const StaffText*, QWidget* parent = 0); + StaffTextProperties(const StaffTextBase*, QWidget* parent = 0); ~StaffTextProperties(); - const StaffText* staffText() const { return _staffText; } + const StaffTextBase* staffTextBase() const { return _staffText; } }; }