Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create defaults for pedal begin, continue and end text #19666

Merged
merged 6 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/engraving/dom/pedal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace mu::engraving {
static const ElementStyle pedalStyle {
{ Sid::pedalText, Pid::BEGIN_TEXT },
{ Sid::pedalContinueText, Pid::CONTINUE_TEXT },
{ Sid::pedalEndText, Pid::END_TEXT },
{ Sid::pedalRosetteEndText, 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 @@ -87,10 +87,18 @@ Shape PedalSegment::doCreateShape() const

Sid Pedal::getPropertyStyle(Pid pid) const
{
if (pid == Pid::OFFSET) {
switch (pid) {
case Pid::OFFSET:
return placeAbove() ? Sid::pedalPosAbove : Sid::pedalPosBelow;
case Pid::END_TEXT:
return lineVisible() ? Sid::pedalEndText : Sid::pedalRosetteEndText;
case Pid::BEGIN_TEXT:
return beginHookType() == HookType::NONE ? Sid::pedalText : Sid::pedalHookText;
case Pid::CONTINUE_TEXT:
return beginHookType() == HookType::NONE ? Sid::pedalContinueText : Sid:: pedalContinueHookText;
default:
return TextLineBase::getPropertyStyle(pid);
}
return TextLineBase::getPropertyStyle(pid);
}

//---------------------------------------------------------
Expand All @@ -111,6 +119,7 @@ Pedal::Pedal(EngravingItem* parent)

resetProperty(Pid::BEGIN_TEXT_PLACE);
resetProperty(Pid::LINE_VISIBLE);
resetProperty(Pid::END_TEXT);
}

//---------------------------------------------------------
Expand Down Expand Up @@ -144,13 +153,9 @@ 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 style().styleV(Sid::pedalEndText);
return style().styleV(getPropertyStyle(propertyId));

case Pid::BEGIN_TEXT_PLACE:
case Pid::CONTINUE_TEXT_PLACE:
Expand Down
21 changes: 21 additions & 0 deletions src/engraving/dom/textlinebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,27 @@ const std::array<Pid, 27>& TextLineBase::textLineBasePropertyIds()
return TextLineBasePropertyId;
}

void TextLineBase::reset()
{
String beginText = _beginText;
String contText = _continueText;
String endText = _endText;
bool beginStyled = isStyled(Pid::BEGIN_TEXT);
bool contStyled = isStyled(Pid::CONTINUE_TEXT);
bool endStyled = isStyled(Pid::END_TEXT);

SLine::reset();
if (!beginStyled) {
undoChangeProperty(Pid::BEGIN_TEXT, beginText, PropertyFlags::UNSTYLED);
}
if (!contStyled) {
undoChangeProperty(Pid::CONTINUE_TEXT, contText, PropertyFlags::UNSTYLED);
}
if (!endStyled) {
undoChangeProperty(Pid::END_TEXT, endText, PropertyFlags::UNSTYLED);
}
}

//---------------------------------------------------------
// propertyDelegate
//---------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/engraving/dom/textlinebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class TextLineBase : public SLine

static const std::array<Pid, 27>& textLineBasePropertyIds();

void reset() override;

protected:
friend class TextLineBaseSegment;
};
Expand Down
73 changes: 57 additions & 16 deletions src/engraving/rw/read114/read114.cpp
cbjeukendrup marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,10 @@ static void readTextLine114(XmlReader& e, ReadContext& ctx, TextLine* textLine)

static void readPedal114(XmlReader& e, ReadContext& ctx, Pedal* pedal)
{
bool beginTextTag = false;
bool continueTextTag = false;
bool endTextTag = false;

while (e.readNextStartElement()) {
const AsciiStringView tag(e.name());
if (tag == "subtype") {
Expand All @@ -1373,36 +1377,73 @@ static void readPedal114(XmlReader& e, ReadContext& ctx, Pedal* pedal)
read400::TRead::readProperty(pedal, e, ctx, Pid::LINE_STYLE);
pedal->setPropertyFlags(Pid::LINE_STYLE, PropertyFlags::UNSTYLED);
} else if (tag == "beginSymbol" || tag == "symbol") { // "symbol" is obsolete
beginTextTag = true;
String text(e.readText());
pedal->setBeginText(String(u"<sym>%1</sym>").arg(
text.at(0).isDigit()
? resolveSymCompatibility(SymId(text.toInt()), ctx.mscoreVersion())
: text));
pedal->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::UNSTYLED);
String symbol = String(u"<sym>%1</sym>").arg(
text.at(0).isDigit()
? resolveSymCompatibility(SymId(text.toInt()), ctx.mscoreVersion())
: text);
if (symbol != pedal->propertyDefault(Pid::BEGIN_TEXT).value<String>()) {
pedal->setBeginText(symbol);
pedal->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::UNSTYLED);
}
} else if (tag == "continueSymbol") {
continueTextTag = true;
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);
String symbol = String(u"<sym>%1</sym>").arg(
text.at(0).isDigit()
? resolveSymCompatibility(SymId(text.toInt()), ctx.mscoreVersion())
: text);
if (symbol != pedal->propertyDefault(Pid::CONTINUE_TEXT).value<String>()) {
pedal->setContinueText(symbol);
pedal->setPropertyFlags(Pid::CONTINUE_TEXT, PropertyFlags::UNSTYLED);
}
} else if (tag == "endSymbol") {
endTextTag = true;
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);
String symbol = String(u"<sym>%1</sym>").arg(
text.at(0).isDigit()
? resolveSymCompatibility(SymId(text.toInt()), ctx.mscoreVersion())
: text);
if (symbol != pedal->propertyDefault(Pid::END_TEXT).value<String>()) {
pedal->setEndText(symbol);
pedal->setPropertyFlags(Pid::END_TEXT, PropertyFlags::UNSTYLED);
}
} else if (tag == "beginSymbolOffset") { // obsolete
e.readPoint();
} else if (tag == "continueSymbolOffset") { // obsolete
e.readPoint();
} else if (tag == "endSymbolOffset") { // obsolete
e.readPoint();
} else if (!readTextLineProperties114(e, ctx, pedal)) {
} else if (readTextLineProperties114(e, ctx, pedal)) {
beginTextTag = beginTextTag || tag == "beginText";
continueTextTag = continueTextTag || tag == "continueText";
endTextTag = endTextTag || tag == "endText";
} else {
e.unknown();
}
}

// Set to the 114 defaults if no value was specified;
// or follow the new style setting if the specified value matches it
if (!beginTextTag) {
pedal->setBeginText(String());
pedal->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::UNSTYLED);
} else if (pedal->beginText() == pedal->propertyDefault(Pid::BEGIN_TEXT).value<String>()) {
pedal->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::STYLED);
}
if (!continueTextTag) {
pedal->setContinueText(String());
pedal->setPropertyFlags(Pid::CONTINUE_TEXT, PropertyFlags::UNSTYLED);
} else if (pedal->continueText() == pedal->propertyDefault(Pid::CONTINUE_TEXT).value<String>()) {
pedal->setPropertyFlags(Pid::CONTINUE_TEXT, PropertyFlags::STYLED);
}
if (!endTextTag) {
pedal->setEndText(String());
pedal->setPropertyFlags(Pid::END_TEXT, PropertyFlags::UNSTYLED);
} else if (pedal->endText() == pedal->propertyDefault(Pid::END_TEXT).value<String>()) {
pedal->setPropertyFlags(Pid::END_TEXT, PropertyFlags::STYLED);
}
}

//---------------------------------------------------------
Expand Down
33 changes: 32 additions & 1 deletion src/engraving/rw/read206/read206.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2051,11 +2051,42 @@ static void readVolta206(XmlReader& e, ReadContext& ctx, Volta* volta)

static void readPedal(XmlReader& e, ReadContext& ctx, Pedal* pedal)
{
bool beginTextTag = false;
bool continueTextTag = false;
bool endTextTag = false;

while (e.readNextStartElement()) {
if (!readTextLineProperties(e, ctx, pedal)) {
const AsciiStringView tag(e.name());
if (readTextLineProperties(e, ctx, pedal)) {
beginTextTag = beginTextTag || tag == "beginText";
continueTextTag = continueTextTag || tag == "continueText";
endTextTag = endTextTag || tag == "endText";
} else {
e.unknown();
}
}

// Set to the 206 defaults if no value was specified;
// or follow the new style setting if the specified value matches it
if (!beginTextTag) {
pedal->setBeginText(String());
pedal->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::UNSTYLED);
} else if (pedal->beginText() == pedal->propertyDefault(Pid::BEGIN_TEXT).value<String>()) {
pedal->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::STYLED);
}
if (!continueTextTag) {
pedal->setContinueText(String());
pedal->setPropertyFlags(Pid::CONTINUE_TEXT, PropertyFlags::UNSTYLED);
} else if (pedal->continueText() == pedal->propertyDefault(Pid::CONTINUE_TEXT).value<String>()) {
pedal->setPropertyFlags(Pid::CONTINUE_TEXT, PropertyFlags::STYLED);
}
if (!endTextTag) {
pedal->setEndText(String());
pedal->setPropertyFlags(Pid::END_TEXT, PropertyFlags::UNSTYLED);
} else if (pedal->endText() == pedal->propertyDefault(Pid::END_TEXT).value<String>()) {
pedal->setPropertyFlags(Pid::END_TEXT, PropertyFlags::STYLED);
}

adjustPlacement(pedal);
}

Expand Down
29 changes: 29 additions & 0 deletions src/engraving/rw/read400/tread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3354,13 +3354,42 @@ void TRead::read(Pedal* p, XmlReader& e, ReadContext& ctx)
if (p->score()->mscVersion() < 301) {
ctx.addSpanner(e.intAttribute("id", -1), p);
}

bool beginTextTag = false;
bool continueTextTag = false;
bool endTextTag = false;

while (e.readNextStartElement()) {
const AsciiStringView tag(e.name());
beginTextTag = beginTextTag || tag == "beginText";
continueTextTag = continueTextTag || tag == "continueText";
endTextTag = endTextTag || tag == "endText";
if (readStyledProperty(p, tag, e, ctx)) {
} else if (!readProperties(static_cast<TextLineBase*>(p), e, ctx)) {
e.unknown();
}
}

// Set to the 400 defaults if no value was specified;
// or follow the new style setting if the specified value matches it
if (!beginTextTag) {
p->setBeginText(String());
p->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::UNSTYLED);
} else if (p->beginText() == p->propertyDefault(Pid::BEGIN_TEXT).value<String>()) {
p->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::STYLED);
}
if (!continueTextTag) {
p->setContinueText(String());
p->setPropertyFlags(Pid::CONTINUE_TEXT, PropertyFlags::UNSTYLED);
} else if (p->continueText() == p->propertyDefault(Pid::CONTINUE_TEXT).value<String>()) {
p->setPropertyFlags(Pid::CONTINUE_TEXT, PropertyFlags::STYLED);
}
if (!endTextTag) {
p->setEndText(String());
p->setPropertyFlags(Pid::END_TEXT, PropertyFlags::UNSTYLED);
} else if (p->endText() == p->propertyDefault(Pid::END_TEXT).value<String>()) {
p->setPropertyFlags(Pid::END_TEXT, PropertyFlags::STYLED);
}
}

void TRead::read(Rasgueado* r, XmlReader& xml, ReadContext& ctx)
Expand Down
39 changes: 39 additions & 0 deletions src/engraving/rw/read410/tread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3431,13 +3431,52 @@ void TRead::read(Pedal* p, XmlReader& e, ReadContext& ctx)
if (p->score()->mscVersion() < 301) {
ctx.addSpanner(e.intAttribute("id", -1), p);
}

bool beginTextTag = false;
bool continueTextTag = false;
bool endTextTag = false;

while (e.readNextStartElement()) {
const AsciiStringView tag(e.name());
beginTextTag = beginTextTag || tag == "beginText";
continueTextTag = continueTextTag || tag == "continueText";
endTextTag = endTextTag || tag == "endText";

if (readStyledProperty(p, tag, e, ctx)) {
} else if (TRead::readProperty(p, tag, e, ctx, Pid::LINE_VISIBLE)) {
p->resetProperty(Pid::END_TEXT);
} else if (TRead::readProperty(p, tag, e, ctx, Pid::BEGIN_HOOK_TYPE)) {
if (p->beginHookType() != HookType::NONE) {
p->setBeginText(String());
p->setContinueText(String());
}
} else if (!readProperties(static_cast<TextLineBase*>(p), e, ctx)) {
e.unknown();
}
}

if (p->score()->mscVersion() < 420) {
// Set to the pre-420 defaults if no value was specified;
// or follow the new style setting if the specified value matches it
if (!beginTextTag) {
p->setBeginText(String());
p->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::UNSTYLED);
} else if (p->beginText() == p->propertyDefault(Pid::BEGIN_TEXT).value<String>()) {
p->setPropertyFlags(Pid::BEGIN_TEXT, PropertyFlags::STYLED);
}
if (!continueTextTag) {
p->setContinueText(String());
p->setPropertyFlags(Pid::CONTINUE_TEXT, PropertyFlags::UNSTYLED);
} else if (p->continueText() == p->propertyDefault(Pid::CONTINUE_TEXT).value<String>()) {
p->setPropertyFlags(Pid::CONTINUE_TEXT, PropertyFlags::STYLED);
}
if (!endTextTag) {
p->setEndText(String());
p->setPropertyFlags(Pid::END_TEXT, PropertyFlags::UNSTYLED);
} else if (p->endText() == p->propertyDefault(Pid::END_TEXT).value<String>()) {
p->setPropertyFlags(Pid::END_TEXT, PropertyFlags::STYLED);
}
}
}

void TRead::read(Rasgueado* r, XmlReader& xml, ReadContext& ctx)
Expand Down
7 changes: 5 additions & 2 deletions src/engraving/style/styledef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,12 @@ 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::pedalText, "pedalText", String(u"<sym>keyboardPedalPed</sym>") },
{ Sid::pedalHookText, "pedalHookText", String() },
{ Sid::pedalContinueText, "pedalContinueText", String(u"(<sym>keyboardPedalPed</sym>)") },
{ Sid::pedalContinueHookText, "pedalContinueHookText", String() },
{ Sid::pedalEndText, "pedalEndText", String() },
{ Sid::pedalRosetteEndText, "pedalRosetteEndText", String(u"<sym>keyboardPedalUp</sym>") },

{ 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
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,11 @@ enum class Sid {
pedalFrameFgColor,
pedalFrameBgColor,
pedalText,
pedalHookText,
pedalContinueText,
pedalContinueHookText,
pedalEndText,
pedalRosetteEndText,

trillPlacement,
trillPosAbove,
Expand Down
1 change: 0 additions & 1 deletion src/engraving/tests/compat114_data/pedal-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
</TimeSig>
<Spanner type="Pedal">
<Pedal>
<beginText>&lt;sym&gt;keyboardPedalPed&lt;/sym&gt;</beginText>
<continueText>&lt;font size=&quot;11&quot;/&gt;</continueText>
<endHookHeight>-1.5</endHookHeight>
<lineWidth>0.006</lineWidth>
Expand Down
2 changes: 0 additions & 2 deletions src/engraving/tests/compat206_data/textstyles-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,6 @@
<Spanner type="Pedal">
<Pedal>
<endHookType>1</endHookType>
<beginText>&lt;sym&gt;keyboardPedalPed&lt;/sym&gt;</beginText>
<continueText>(&lt;sym&gt;keyboardPedalPed&lt;/sym&gt;)</continueText>
</Pedal>
<next>
<location>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Spanner type="Pedal">
<Pedal>
<beginText>&lt;sym&gt;keyboardPedalPed&lt;sym&gt;</beginText>
<continueText></continueText>
<ticks_f>3/4</ticks_f>
</Pedal>
<next>
Expand Down
2 changes: 2 additions & 0 deletions src/importexport/mei/internal/meiconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,8 @@ void Convert::pedalFromMEI(engraving::Pedal* pedal, const libmei::Pedal& meiPeda
pedal->setEndHookType(engraving::HookType::HOOK_90);
} else {
pedal->setBeginHookType(engraving::HookType::HOOK_90);
pedal->setBeginText(String());
pedal->setContinueText(String());
pedal->setEndHookType(engraving::HookType::HOOK_90);
}

Expand Down
1 change: 0 additions & 1 deletion src/importexport/mei/tests/data/color-01.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@
<Spanner type="Pedal">
<Pedal>
<endHookType>1</endHookType>
<beginText>&lt;sym&gt;keyboardPedalPed&lt;/sym&gt;</beginText>
<color r="148" g="33" b="146" a="255"/>
<color r="148" g="33" b="146" a="255"/>
</Pedal>
Expand Down
Loading
Loading