Skip to content

Commit

Permalink
Introducing text settings for tempo change
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-spa committed Jan 22, 2023
1 parent 0bd5c09 commit d151c83
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 37 deletions.
62 changes: 31 additions & 31 deletions src/engraving/libmscore/gradualtempochange.cpp
Expand Up @@ -33,41 +33,41 @@ using namespace mu;
using namespace mu::engraving;

static const ElementStyle tempoStyle {
{ Sid::tempoSystemFlag, Pid::SYSTEM_FLAG },
{ Sid::tempoPlacement, Pid::PLACEMENT },
{ Sid::tempoMinDistance, Pid::MIN_DISTANCE },
{ Sid::tempoLineSpacing, Pid::TEXT_LINE_SPACING },
{ Sid::tempoChangeSystemFlag, Pid::SYSTEM_FLAG },
{ Sid::tempoChangePlacement, Pid::PLACEMENT },
{ Sid::tempoChangeMinDistance, Pid::MIN_DISTANCE },
{ Sid::tempoChangeLineSpacing, Pid::TEXT_LINE_SPACING },

{ Sid::tempoColor, Pid::COLOR },
{ Sid::tempoPosAbove, Pid::OFFSET },
{ Sid::tempoChangeColor, Pid::COLOR },
{ Sid::tempoChangePosAbove, Pid::OFFSET },

{ Sid::tempoFontFace, Pid::BEGIN_FONT_FACE },
{ Sid::tempoFontFace, Pid::CONTINUE_FONT_FACE },
{ Sid::tempoFontFace, Pid::END_FONT_FACE },
{ Sid::tempoChangeFontFace, Pid::BEGIN_FONT_FACE },
{ Sid::tempoChangeFontFace, Pid::CONTINUE_FONT_FACE },
{ Sid::tempoChangeFontFace, Pid::END_FONT_FACE },

{ Sid::tempoFontSize, Pid::BEGIN_FONT_SIZE },
{ Sid::tempoFontSize, Pid::CONTINUE_FONT_SIZE },
{ Sid::tempoFontSize, Pid::END_FONT_SIZE },
{ Sid::tempoChangeFontSize, Pid::BEGIN_FONT_SIZE },
{ Sid::tempoChangeFontSize, Pid::CONTINUE_FONT_SIZE },
{ Sid::tempoChangeFontSize, Pid::END_FONT_SIZE },

{ Sid::tempoFontStyle, Pid::BEGIN_FONT_STYLE },
{ Sid::tempoFontStyle, Pid::CONTINUE_FONT_STYLE },
{ Sid::tempoFontStyle, Pid::END_FONT_STYLE },
{ Sid::tempoChangeFontStyle, Pid::BEGIN_FONT_STYLE },
{ Sid::tempoChangeFontStyle, Pid::CONTINUE_FONT_STYLE },
{ Sid::tempoChangeFontStyle, Pid::END_FONT_STYLE },

{ Sid::tempoAlign, Pid::BEGIN_TEXT_ALIGN },
{ Sid::tempoAlign, Pid::CONTINUE_TEXT_ALIGN },
{ Sid::tempoAlign, Pid::END_TEXT_ALIGN },
{ Sid::tempoChangeAlign, Pid::BEGIN_TEXT_ALIGN },
{ Sid::tempoChangeAlign, Pid::CONTINUE_TEXT_ALIGN },
{ Sid::tempoChangeAlign, Pid::END_TEXT_ALIGN },

{ Sid::tempoFontSpatiumDependent, Pid::SIZE_SPATIUM_DEPENDENT },
{ Sid::tempoChangeFontSpatiumDependent, Pid::SIZE_SPATIUM_DEPENDENT },
{ Sid::tempoChangeLineWidth, Pid::LINE_WIDTH },
{ Sid::tempoChangeLineStyle, Pid::LINE_STYLE },
{ Sid::tempoChangeDashLineLen, Pid::DASH_LINE_LEN },
{ Sid::tempoChangeDashGapLen, Pid::DASH_GAP_LEN },
{ Sid::tempoFontSpatiumDependent, Pid::TEXT_SIZE_SPATIUM_DEPENDENT },
{ Sid::tempoChangeFontSpatiumDependent, Pid::TEXT_SIZE_SPATIUM_DEPENDENT },
};

static const ElementStyle tempoSegmentStyle {
{ Sid::tempoPosAbove, Pid::OFFSET },
{ Sid::tempoMinDistance, Pid::MIN_DISTANCE }
{ Sid::tempoChangePosAbove, Pid::OFFSET },
{ Sid::tempoChangeMinDistance, Pid::MIN_DISTANCE }
};

static const std::unordered_map<GradualTempoChangeType, double> DEFAULT_FACTORS_MAP {
Expand Down Expand Up @@ -215,7 +215,7 @@ PropertyValue GradualTempoChange::propertyDefault(Pid propertyId) const
{
switch (propertyId) {
case Pid::ALIGN:
return score()->styleV(Sid::tempoAlign);
return score()->styleV(Sid::tempoChangeAlign);

case Pid::LINE_WIDTH:
return score()->styleV(Sid::tempoChangeLineWidth);
Expand All @@ -229,7 +229,7 @@ PropertyValue GradualTempoChange::propertyDefault(Pid propertyId) const
return PropertyValue::fromValue(PointF(0, 0));

case Pid::BEGIN_FONT_STYLE:
return score()->styleV(Sid::tempoFontStyle);
return score()->styleV(Sid::tempoChangeFontStyle);

case Pid::BEGIN_TEXT:
case Pid::CONTINUE_TEXT:
Expand Down Expand Up @@ -260,30 +260,30 @@ Sid GradualTempoChange::getPropertyStyle(Pid id) const
{
switch (id) {
case Pid::PLACEMENT:
return Sid::tempoPlacement;
return Sid::tempoChangePlacement;
case Pid::BEGIN_FONT_FACE:
case Pid::CONTINUE_FONT_FACE:
case Pid::END_FONT_FACE:
return Sid::tempoFontFace;
return Sid::tempoChangeFontFace;
case Pid::BEGIN_FONT_SIZE:
case Pid::CONTINUE_FONT_SIZE:
case Pid::END_FONT_SIZE:
return Sid::tempoFontSize;
return Sid::tempoChangeFontSize;
case Pid::BEGIN_FONT_STYLE:
case Pid::CONTINUE_FONT_STYLE:
case Pid::END_FONT_STYLE:
return Sid::tempoFontStyle;
return Sid::tempoChangeFontStyle;
case Pid::BEGIN_TEXT_ALIGN:
case Pid::CONTINUE_TEXT_ALIGN:
case Pid::END_TEXT_ALIGN:
return Sid::tempoAlign;
return Sid::tempoChangeAlign;
case Pid::BEGIN_TEXT:
return Sid::letRingText;
case Pid::OFFSET:
if (placeAbove()) {
return Sid::tempoPosAbove;
return Sid::tempoChangePosAbove;
} else {
return Sid::tempoPosBelow;
return Sid::tempoChangePosBelow;
}
default:
break;
Expand Down
31 changes: 25 additions & 6 deletions src/engraving/style/styledef.cpp
Expand Up @@ -890,12 +890,31 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
{ Sid::tempoFramePadding, "tempoFramePadding", 0.2 },
{ Sid::tempoFrameWidth, "tempoFrameWidth", 0.1 },
{ Sid::tempoFrameRound, "tempoFrameRound", 0 },
{ Sid::tempoFrameFgColor, "tempoFrameFgColor", PropertyValue::fromValue(Color::BLACK) },
{ Sid::tempoFrameBgColor, "tempoFrameBgColor", PropertyValue::fromValue(Color::transparent) },
{ Sid::tempoChangeLineWidth, "tempoChangeLineWidth", Spatium(0.15) },
{ Sid::tempoChangeLineStyle, "tempoChangeLineStyle", PropertyValue(LineType::DASHED) },
{ Sid::tempoChangeDashLineLen, "tempoChangeDashLineLen", 6.0 },
{ Sid::tempoChangeDashGapLen, "tempoChangeDashGapLen", 9.0 },
{ Sid::tempoFrameFgColor, "tempoFrameFgColor", PropertyValue::fromValue(draw::Color::BLACK) },
{ Sid::tempoFrameBgColor, "tempoFrameBgColor", PropertyValue::fromValue(draw::Color::transparent) },

{ Sid::tempoChangeFontFace, "tempoChangeFontFace", "Edwin" },
{ Sid::tempoChangeFontSize, "tempoChangeFontSize", 12.0 },
{ Sid::tempoChangeLineSpacing, "tempoChangeLineSpacing", 1.0 },
{ Sid::tempoChangeFontSpatiumDependent, "tempoChangeFontSpatiumDependent", true },
{ Sid::tempoChangeFontStyle, "tempoChangeFontStyle", int(FontStyle::Bold) },
{ Sid::tempoChangeColor, "tempoChangeColor", PropertyValue::fromValue(draw::Color::BLACK) },
{ Sid::tempoChangeAlign, "tempoChangeAlign", Align(AlignH::LEFT, AlignV::BASELINE) },
{ Sid::tempoChangeSystemFlag, "tempoChangeSystemFlag", true },
{ Sid::tempoChangePlacement, "tempoChangePlacement", PlacementV::ABOVE },
{ Sid::tempoChangePosAbove, "tempoChangePosAbove", PointF(.0, -2.0) },
{ Sid::tempoChangePosBelow, "tempoChangePosBelow", PointF(.0, 3.0) },
{ Sid::tempoChangeMinDistance, "tempoChangeMinDistance", Spatium(.5) },
{ Sid::tempoChangeFrameType, "tempoChangeFrameType", int(FrameType::NO_FRAME) },
{ Sid::tempoChangeFramePadding, "tempoChangeFramePadding", 0.2 },
{ Sid::tempoChangeFrameWidth, "tempoChangeFrameWidth", 0.1 },
{ Sid::tempoChangeFrameRound, "tempoChangeFrameRound", 0 },
{ Sid::tempoChangeFrameFgColor, "tempoChangeFrameFgColor", PropertyValue::fromValue(draw::Color::BLACK) },
{ Sid::tempoChangeFrameBgColor, "tempoChangeFrameBgColor", PropertyValue::fromValue(draw::Color::transparent) },
{ Sid::tempoChangeLineWidth, "tempoChangeLineWidth", Spatium(0.15) },
{ Sid::tempoChangeLineStyle, "tempoChangeLineStyle", PropertyValue(LineType::DASHED) },
{ Sid::tempoChangeDashLineLen, "tempoChangeDashLineLen", 6.0 },
{ Sid::tempoChangeDashGapLen, "tempoChangeDashGapLen", 9.0 },

{ Sid::metronomeFontFace, "metronomeFontFace", "Edwin" },
{ Sid::metronomeFontSize, "metronomeFontSize", 12.0 },
Expand Down
19 changes: 19 additions & 0 deletions src/engraving/style/styledef.h
Expand Up @@ -906,6 +906,25 @@ enum class Sid {
tempoFrameRound,
tempoFrameFgColor,
tempoFrameBgColor,

tempoChangeFontFace,
tempoChangeFontSize,
tempoChangeLineSpacing,
tempoChangeFontSpatiumDependent,
tempoChangeFontStyle,
tempoChangeColor,
tempoChangeAlign,
tempoChangeSystemFlag,
tempoChangePlacement,
tempoChangePosAbove,
tempoChangePosBelow,
tempoChangeMinDistance,
tempoChangeFrameType,
tempoChangeFramePadding,
tempoChangeFrameWidth,
tempoChangeFrameRound,
tempoChangeFrameFgColor,
tempoChangeFrameBgColor,
tempoChangeLineWidth,
tempoChangeLineStyle,
tempoChangeDashLineLen,
Expand Down
18 changes: 18 additions & 0 deletions src/engraving/style/textstyle.cpp
Expand Up @@ -316,6 +316,23 @@ const TextStyle tempoTextStyle { {
{ TextStylePropertyType::FrameFillColor, Sid::tempoFrameBgColor, Pid::FRAME_BG_COLOR },
} };

const TextStyle tempoChangeTextStyle { {
{ TextStylePropertyType::FontFace, Sid::tempoChangeFontFace, Pid::FONT_FACE },
{ TextStylePropertyType::FontSize, Sid::tempoChangeFontSize, Pid::FONT_SIZE },
{ TextStylePropertyType::LineSpacing, Sid::tempoChangeLineSpacing, Pid::TEXT_LINE_SPACING },
{ TextStylePropertyType::SizeSpatiumDependent, Sid::tempoChangeFontSpatiumDependent, Pid::SIZE_SPATIUM_DEPENDENT },
{ TextStylePropertyType::FontStyle, Sid::tempoChangeFontStyle, Pid::FONT_STYLE },
{ TextStylePropertyType::Color, Sid::tempoChangeColor, Pid::COLOR },
{ TextStylePropertyType::TextAlign, Sid::tempoChangeAlign, Pid::ALIGN },
{ TextStylePropertyType::Offset, Sid::tempoChangePosAbove, Pid::OFFSET },
{ TextStylePropertyType::FrameType, Sid::tempoChangeFrameType, Pid::FRAME_TYPE },
{ TextStylePropertyType::FramePadding, Sid::tempoChangeFramePadding, Pid::FRAME_PADDING },
{ TextStylePropertyType::FrameWidth, Sid::tempoChangeFrameWidth, Pid::FRAME_WIDTH },
{ TextStylePropertyType::FrameRound, Sid::tempoChangeFrameRound, Pid::FRAME_ROUND },
{ TextStylePropertyType::FrameBorderColor, Sid::tempoChangeFrameFgColor, Pid::FRAME_FG_COLOR },
{ TextStylePropertyType::FrameFillColor, Sid::tempoChangeFrameBgColor, Pid::FRAME_BG_COLOR },
} };

const TextStyle metronomeTextStyle { {
{ TextStylePropertyType::FontFace, Sid::metronomeFontFace, Pid::FONT_FACE },
{ TextStylePropertyType::FontSize, Sid::metronomeFontSize, Pid::FONT_SIZE },
Expand Down Expand Up @@ -1017,6 +1034,7 @@ const TextStyle* textStyle(TextStyleType idx)
case TextStyleType::MMREST_RANGE: return &mmRestRangeTextStyle;

case TextStyleType::TEMPO: return &tempoTextStyle;
case TextStyleType::TEMPO_CHANGE: return &tempoChangeTextStyle;
case TextStyleType::METRONOME: return &metronomeTextStyle;
case TextStyleType::REPEAT_LEFT: return &repeatLeftTextStyle;
case TextStyleType::REPEAT_RIGHT: return &repeatRightTextStyle;
Expand Down
1 change: 1 addition & 0 deletions src/engraving/types/types.h
Expand Up @@ -627,6 +627,7 @@ enum class TextStyleType {

// System-level styles
TEMPO,
TEMPO_CHANGE,
METRONOME,
REPEAT_LEFT, // align to start of measure
REPEAT_RIGHT, // align to end of measure
Expand Down
1 change: 1 addition & 0 deletions src/engraving/types/typesconv.cpp
Expand Up @@ -940,6 +940,7 @@ static const std::vector<Item<TextStyleType> > TEXTSTYLE_TYPES = {
{ TextStyleType::MMREST_RANGE, "mmrest_range", TranslatableString("engraving", "Multimeasure rest range") },

{ TextStyleType::TEMPO, "tempo", TranslatableString("engraving", "Tempo") },
{ TextStyleType::TEMPO_CHANGE, "tempo change", TranslatableString("engraving", "Gradual tempo change") },
{ TextStyleType::METRONOME, "metronome", TranslatableString("engraving", "Metronome") },
{ TextStyleType::REPEAT_LEFT, "repeat_left", TranslatableString("engraving", "Repeat text left") },
{ TextStyleType::REPEAT_RIGHT, "repeat_right", TranslatableString("engraving", "Repeat text right") },
Expand Down

0 comments on commit d151c83

Please sign in to comment.