Skip to content

Commit

Permalink
Merge pull request #16369 from bakajikara/textline-properties
Browse files Browse the repository at this point in the history
Textline properties: reintroduce missing text edit field
  • Loading branch information
RomanPudashkin committed Jul 5, 2023
2 parents 7a20137 + 46865cd commit 548dd7b
Show file tree
Hide file tree
Showing 35 changed files with 157 additions and 196 deletions.
12 changes: 7 additions & 5 deletions src/engraving/libmscore/hairpin.cpp
Expand Up @@ -504,23 +504,25 @@ PropertyValue Hairpin::propertyDefault(Pid id) const

case Pid::BEGIN_TEXT:
if (_hairpinType == HairpinType::CRESC_LINE) {
return String(u"cresc.");
return style().styleV(Sid::hairpinCrescText);
}
if (_hairpinType == HairpinType::DECRESC_LINE) {
return String(u"dim.");
return style().styleV(Sid::hairpinDecrescText);
}
return String();

case Pid::CONTINUE_TEXT:
case Pid::END_TEXT:
if (_hairpinType == HairpinType::CRESC_LINE) {
return String(u"(cresc.)");
return style().styleV(Sid::hairpinCrescContText);
}
if (_hairpinType == HairpinType::DECRESC_LINE) {
return String(u"(dim.)");
return style().styleV(Sid::hairpinDecrescContText);
}
return String();

case Pid::END_TEXT:
return String();

case Pid::BEGIN_TEXT_PLACE:
case Pid::CONTINUE_TEXT_PLACE:
return TextPlace::LEFT;
Expand Down
1 change: 1 addition & 0 deletions src/engraving/libmscore/letring.cpp
Expand Up @@ -143,6 +143,7 @@ PropertyValue LetRing::propertyDefault(Pid propertyId) const
case Pid::LINE_VISIBLE:
return true;

case Pid::BEGIN_TEXT_OFFSET:
case Pid::CONTINUE_TEXT_OFFSET:
case Pid::END_TEXT_OFFSET:
return PropertyValue::fromValue(PointF(0, 0));
Expand Down
1 change: 1 addition & 0 deletions src/engraving/libmscore/palmmute.cpp
Expand Up @@ -167,6 +167,7 @@ PropertyValue PalmMute::propertyDefault(Pid propertyId) const
case Pid::LINE_VISIBLE:
return true;

case Pid::BEGIN_TEXT_OFFSET:
case Pid::CONTINUE_TEXT_OFFSET:
case Pid::END_TEXT_OFFSET:
return PropertyValue::fromValue(PointF(0, 0));
Expand Down
17 changes: 13 additions & 4 deletions src/engraving/libmscore/pedal.cpp
Expand Up @@ -33,6 +33,9 @@ using namespace mu;

namespace mu::engraving {
static const ElementStyle pedalStyle {
{ Sid::pedalText, Pid::BEGIN_TEXT },
{ Sid::pedalContinueText, Pid::CONTINUE_TEXT },
{ Sid::pedalEndText, Pid::END_TEXT },
{ Sid::pedalFontFace, Pid::BEGIN_FONT_FACE },
{ Sid::pedalFontFace, Pid::CONTINUE_FONT_FACE },
{ Sid::pedalFontFace, Pid::END_FONT_FACE },
Expand Down Expand Up @@ -92,9 +95,6 @@ Pedal::Pedal(EngravingItem* parent)
{
initElementStyle(&pedalStyle);
setLineVisible(true);
resetProperty(Pid::BEGIN_TEXT);
resetProperty(Pid::CONTINUE_TEXT);
resetProperty(Pid::END_TEXT);

resetProperty(Pid::LINE_WIDTH);
resetProperty(Pid::LINE_STYLE);
Expand Down Expand Up @@ -137,15 +137,24 @@ engraving::PropertyValue Pedal::propertyDefault(Pid propertyId) const
return style().styleV(Sid::pedalLineStyle);

case Pid::BEGIN_TEXT:
return style().styleV(Sid::pedalText);

case Pid::CONTINUE_TEXT:
return style().styleV(Sid::pedalContinueText);

case Pid::END_TEXT:
return "";
return style().styleV(Sid::pedalEndText);

case Pid::BEGIN_TEXT_PLACE:
case Pid::CONTINUE_TEXT_PLACE:
case Pid::END_TEXT_PLACE:
return TextPlace::LEFT;

case Pid::BEGIN_TEXT_OFFSET:
case Pid::CONTINUE_TEXT_OFFSET:
case Pid::END_TEXT_OFFSET:
return PropertyValue::fromValue(PointF(0, 0));

case Pid::BEGIN_HOOK_TYPE:
case Pid::END_HOOK_TYPE:
return HookType::NONE;
Expand Down
3 changes: 3 additions & 0 deletions src/engraving/rw/read114/read114.cpp
Expand Up @@ -1379,18 +1379,21 @@ static void readPedal114(XmlReader& e, ReadContext& ctx, Pedal* pedal)
text.at(0).isDigit()
? resolveSymCompatibility(SymId(text.toInt()), ctx.mscoreVersion())
: text));
pedal->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::UNSTYLED);
} else if (tag == "continueSymbol") {
String text(e.readText());
pedal->setContinueText(String(u"<sym>%1</sym>").arg(
text.at(0).isDigit()
? resolveSymCompatibility(SymId(text.toInt()), ctx.mscoreVersion())
: text));
pedal->setPropertyFlags(Pid::CONTINUE_TEXT, PropertyFlags::UNSTYLED);
} else if (tag == "endSymbol") {
String text(e.readText());
pedal->setEndText(String(u"<sym>%1</sym>").arg(
text.at(0).isDigit()
? resolveSymCompatibility(SymId(text.toInt()), ctx.mscoreVersion())
: text));
pedal->setPropertyFlags(Pid::END_TEXT, PropertyFlags::UNSTYLED);
} else if (tag == "beginSymbolOffset") { // obsolete
e.readPoint();
} else if (tag == "continueSymbolOffset") { // obsolete
Expand Down
3 changes: 3 additions & 0 deletions src/engraving/rw/read206/read206.cpp
Expand Up @@ -1987,16 +1987,19 @@ static bool readTextLineProperties(XmlReader& e, ReadContext& ctx, TextLineBase*
Text* text = Factory::createText(ctx.dummy(), TextStyleType::DEFAULT, false);
readText206(e, ctx, text, tl);
tl->setBeginText(text->xmlText());
tl->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::UNSTYLED);
delete text;
} else if (tag == "continueText") {
Text* text = Factory::createText(ctx.dummy(), TextStyleType::DEFAULT, false);
readText206(e, ctx, text, tl);
tl->setContinueText(text->xmlText());
tl->setPropertyFlags(Pid::CONTINUE_TEXT, PropertyFlags::UNSTYLED);
delete text;
} else if (tag == "endText") {
Text* text = Factory::createText(ctx.dummy(), TextStyleType::DEFAULT, false);
readText206(e, ctx, text, tl);
tl->setEndText(text->xmlText());
tl->setPropertyFlags(Pid::END_TEXT, PropertyFlags::UNSTYLED);
delete text;
} else if (tag == "beginHook") {
tl->setBeginHookType(e.readBool() ? HookType::HOOK_90 : HookType::NONE);
Expand Down
3 changes: 0 additions & 3 deletions src/engraving/rw/write/twrite.cpp
Expand Up @@ -2128,9 +2128,6 @@ void TWrite::write(const Pedal* item, XmlWriter& xml, WriteContext& ctx)

for (auto i : {
Pid::END_HOOK_TYPE,
Pid::BEGIN_TEXT,
Pid::CONTINUE_TEXT,
Pid::END_TEXT,
Pid::LINE_VISIBLE,
Pid::BEGIN_HOOK_TYPE
}) {
Expand Down
3 changes: 3 additions & 0 deletions src/engraving/style/styledef.cpp
Expand Up @@ -283,6 +283,9 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
{ Sid::pedalFrameRound, "pedalFrameRound", 0 },
{ Sid::pedalFrameFgColor, "pedalFrameFgColor", Color::BLACK },
{ Sid::pedalFrameBgColor, "pedalFrameBgColor", Color::transparent },
{ Sid::pedalText, "pedalText", String() },
{ Sid::pedalContinueText, "pedalContinueText", String() },
{ Sid::pedalEndText, "pedalEndText", String() },

{ Sid::trillPlacement, "trillPlacement", PlacementV::ABOVE },
{ Sid::trillPosAbove, "trillPosAbove", PointF(.0, -0.5) },
Expand Down
3 changes: 3 additions & 0 deletions src/engraving/style/styledef.h
Expand Up @@ -297,6 +297,9 @@ enum class Sid {
pedalFrameRound,
pedalFrameFgColor,
pedalFrameBgColor,
pedalText,
pedalContinueText,
pedalEndText,

trillPlacement,
trillPosAbove,
Expand Down
Expand Up @@ -90,7 +90,6 @@
</Dynamic>
<Spanner type="LetRing">
<LetRing>
<beginTextOffset x="0" y="0"/>
</LetRing>
<next>
<location>
Expand Down
1 change: 0 additions & 1 deletion src/importexport/guitarpro/tests/data/let-ring.gp-ref.mscx
Expand Up @@ -94,7 +94,6 @@
</Tempo>
<Spanner type="LetRing">
<LetRing>
<beginTextOffset x="0" y="0"/>
</LetRing>
<next>
<location>
Expand Down
Expand Up @@ -94,7 +94,6 @@
</Dynamic>
<Spanner type="LetRing">
<LetRing>
<beginTextOffset x="0" y="0"/>
</LetRing>
<next>
<location>
Expand Down
Expand Up @@ -90,7 +90,6 @@
</Dynamic>
<Spanner type="LetRing">
<LetRing>
<beginTextOffset x="0" y="0"/>
</LetRing>
<next>
<location>
Expand Down
Expand Up @@ -94,7 +94,6 @@
</Tempo>
<Spanner type="LetRing">
<LetRing>
<beginTextOffset x="0" y="0"/>
</LetRing>
<next>
<location>
Expand Down
Expand Up @@ -283,7 +283,6 @@
</Tempo>
<Spanner type="LetRing">
<LetRing>
<beginTextOffset x="0" y="0"/>
</LetRing>
<next>
<location>
Expand Down Expand Up @@ -342,7 +341,6 @@
</Rest>
<Spanner type="PalmMute">
<PalmMute>
<beginTextOffset x="0" y="0"/>
</PalmMute>
<next>
<location>
Expand Down Expand Up @@ -552,7 +550,6 @@
</Chord>
<Spanner type="LetRing">
<LetRing>
<beginTextOffset x="0" y="0"/>
</LetRing>
<next>
<location>
Expand Down
Expand Up @@ -329,7 +329,6 @@
</Tempo>
<Spanner type="LetRing">
<LetRing>
<beginTextOffset x="0" y="0"/>
</LetRing>
<next>
<location>
Expand Down Expand Up @@ -378,7 +377,6 @@
</Rest>
<Spanner type="PalmMute">
<PalmMute>
<beginTextOffset x="0" y="0"/>
</PalmMute>
<next>
<location>
Expand Down Expand Up @@ -517,7 +515,6 @@
</Chord>
<Spanner type="LetRing">
<LetRing>
<beginTextOffset x="0" y="0"/>
</LetRing>
<next>
<location>
Expand Down
Expand Up @@ -94,7 +94,6 @@
</Tempo>
<Spanner type="PalmMute">
<PalmMute>
<beginTextOffset x="0" y="0"/>
</PalmMute>
<next>
<location>
Expand Down
Expand Up @@ -94,7 +94,6 @@
</Dynamic>
<Spanner type="PalmMute">
<PalmMute>
<beginTextOffset x="0" y="0"/>
</PalmMute>
<next>
<location>
Expand Down
Expand Up @@ -90,7 +90,6 @@
</Dynamic>
<Spanner type="PalmMute">
<PalmMute>
<beginTextOffset x="0" y="0"/>
</PalmMute>
<next>
<location>
Expand Down
Expand Up @@ -94,7 +94,6 @@
</Tempo>
<Spanner type="PalmMute">
<PalmMute>
<beginTextOffset x="0" y="0"/>
</PalmMute>
<next>
<location>
Expand Down
5 changes: 0 additions & 5 deletions src/inspector/models/notation/lines/hairpinsettingsmodel.cpp
Expand Up @@ -111,11 +111,6 @@ void HairpinSettingsModel::onNotationChanged(const PropertyIdSet& changedPropert
loadProperties(changedPropertyIdSet);
}

bool HairpinSettingsModel::isTextVisible(TextType) const
{
return true;
}

void HairpinSettingsModel::loadProperties(const PropertyIdSet& propertyIdSet)
{
if (mu::contains(propertyIdSet, Pid::HAIRPIN_CIRCLEDTIP)) {
Expand Down
1 change: 0 additions & 1 deletion src/inspector/models/notation/lines/hairpinsettingsmodel.h
Expand Up @@ -49,7 +49,6 @@ class HairpinSettingsModel : public TextLineSettingsModel
void requestElements() override;
void onNotationChanged(const mu::engraving::PropertyIdSet& changedPropertyIdSet,
const mu::engraving::StyleIdSet& changedStyleIdSet) override;
bool isTextVisible(TextType type) const override;

void loadProperties(const mu::engraving::PropertyIdSet& propertyIdSet);

Expand Down
5 changes: 0 additions & 5 deletions src/inspector/models/notation/lines/ottavasettingsmodel.cpp
Expand Up @@ -111,8 +111,3 @@ void OttavaSettingsModel::resetProperties()
m_ottavaType->resetToDefault();
m_showNumbersOnly->resetToDefault();
}

bool OttavaSettingsModel::isTextVisible(TextType) const
{
return true;
}
2 changes: 0 additions & 2 deletions src/inspector/models/notation/lines/ottavasettingsmodel.h
Expand Up @@ -45,8 +45,6 @@ class OttavaSettingsModel : public TextLineSettingsModel
void loadProperties() override;
void resetProperties() override;

bool isTextVisible(TextType) const override;

PropertyItem* m_ottavaType = nullptr;
PropertyItem* m_showNumbersOnly = nullptr;
};
Expand Down
19 changes: 0 additions & 19 deletions src/inspector/models/notation/lines/pedalsettingsmodel.cpp
Expand Up @@ -57,11 +57,6 @@ PropertyItem* PedalSettingsModel::lineType() const
return m_lineType;
}

bool PedalSettingsModel::pedalSymbolVisible() const
{
return beginningText()->value().toString() == mu::engraving::Pedal::PEDAL_SYMBOL;
}

bool PedalSettingsModel::isChangingLineVisibilityAllowed() const
{
return isStarSymbolVisible();
Expand All @@ -72,19 +67,10 @@ bool PedalSettingsModel::isStarSymbolVisible() const
return endText()->value().toString() == mu::engraving::Pedal::STAR_SYMBOL;
}

void PedalSettingsModel::setPedalSymbolVisible(bool visible)
{
beginningText()->setValue(visible ? mu::engraving::Pedal::PEDAL_SYMBOL.toQString() : "");
}

void PedalSettingsModel::createProperties()
{
TextLineSettingsModel::createProperties();

connect(beginningText(), &PropertyItem::isModifiedChanged, this, [this]() {
emit pedalSymbolVisibleChanged();
});

connect(endText(), &PropertyItem::isModifiedChanged, this, [this]() {
emit isChangingLineVisibilityAllowedChanged();
});
Expand Down Expand Up @@ -129,8 +115,3 @@ void PedalSettingsModel::setLineType(int newType)

m_lineType->setValue(newType);
}

bool PedalSettingsModel::isTextVisible(TextType) const
{
return true;
}
7 changes: 0 additions & 7 deletions src/inspector/models/notation/lines/pedalsettingsmodel.h
Expand Up @@ -30,29 +30,22 @@ class PedalSettingsModel : public TextLineSettingsModel
Q_OBJECT

Q_PROPERTY(PropertyItem * lineType READ lineType CONSTANT)
Q_PROPERTY(bool pedalSymbolVisible READ pedalSymbolVisible WRITE setPedalSymbolVisible NOTIFY pedalSymbolVisibleChanged)
Q_PROPERTY(bool isChangingLineVisibilityAllowed READ isChangingLineVisibilityAllowed NOTIFY isChangingLineVisibilityAllowedChanged)

public:
explicit PedalSettingsModel(QObject* parent, IElementRepositoryService* repository);

PropertyItem* lineType() const;
bool pedalSymbolVisible() const;
bool isChangingLineVisibilityAllowed() const;

public slots:
void setPedalSymbolVisible(bool visible);

signals:
void pedalSymbolVisibleChanged();
void isChangingLineVisibilityAllowedChanged();

private:
bool isStarSymbolVisible() const;

void createProperties() override;
void loadProperties() override;
bool isTextVisible(TextType type) const override;

void setLineType(int newType);

Expand Down

0 comments on commit 548dd7b

Please sign in to comment.