Skip to content

Commit

Permalink
line style options for text lines
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoMigros committed Jul 18, 2024
1 parent 8e3b4f2 commit 134a47c
Show file tree
Hide file tree
Showing 6 changed files with 478 additions and 20 deletions.
55 changes: 36 additions & 19 deletions src/engraving/dom/textline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ static const ElementStyle textLineStyle {
{ Sid::textLineTextAlign, Pid::BEGIN_TEXT_ALIGN },
{ Sid::textLineTextAlign, Pid::CONTINUE_TEXT_ALIGN },
{ Sid::textLineTextAlign, Pid::END_TEXT_ALIGN },
{ Sid::textLineHookHeight, Pid::BEGIN_HOOK_HEIGHT },
{ Sid::textLineHookHeight, Pid::END_HOOK_HEIGHT },
{ Sid::textLineLineWidth, Pid::LINE_WIDTH },
{ Sid::textLineDashLineLen, Pid::DASH_LINE_LEN },
{ Sid::textLineDashGapLen, Pid::DASH_GAP_LEN },
{ Sid::textLinePlacement, Pid::PLACEMENT },
{ Sid::textLineLineStyle, Pid::LINE_STYLE },
{ Sid::textLinePosAbove, Pid::OFFSET },
{ Sid::textLineFontSpatiumDependent, Pid::TEXT_SIZE_SPATIUM_DEPENDENT },
};
Expand All @@ -89,7 +95,13 @@ static const ElementStyle systemTextLineStyle {
{ Sid::systemTextLineTextAlign, Pid::BEGIN_TEXT_ALIGN },
{ Sid::systemTextLineTextAlign, Pid::CONTINUE_TEXT_ALIGN },
{ Sid::systemTextLineTextAlign, Pid::END_TEXT_ALIGN },
{ Sid::systemTextLineHookHeight, Pid::BEGIN_HOOK_HEIGHT },
{ Sid::systemTextLineHookHeight, Pid::END_HOOK_HEIGHT },
{ Sid::systemTextLineLineWidth, Pid::LINE_WIDTH },
{ Sid::systemTextLineDashLineLen, Pid::DASH_LINE_LEN },
{ Sid::systemTextLineDashGapLen, Pid::DASH_GAP_LEN },
{ Sid::systemTextLinePlacement, Pid::PLACEMENT },
{ Sid::systemTextLineLineStyle, Pid::LINE_STYLE },
{ Sid::systemTextLinePosAbove, Pid::OFFSET },
};

Expand All @@ -101,11 +113,7 @@ TextLineSegment::TextLineSegment(Spanner* sp, System* parent, bool system)
: TextLineBaseSegment(ElementType::TEXTLINE_SEGMENT, sp, parent, ElementFlag::MOVABLE | ElementFlag::ON_STAFF)
{
setSystemFlag(system);
if (systemFlag()) {
initElementStyle(&systemTextLineSegmentStyle);
} else {
initElementStyle(&textLineSegmentStyle);
}
initStyle();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -168,6 +176,15 @@ void TextLine::initStyle()
}
}

void TextLineSegment::initStyle()
{
if (systemFlag()) {
initElementStyle(&systemTextLineSegmentStyle);
} else {
initElementStyle(&textLineSegmentStyle);
}
}

//---------------------------------------------------------
// createLineSegment
//---------------------------------------------------------
Expand All @@ -180,12 +197,7 @@ LineSegment* TextLine::createLineSegment(System* parent)
if (anchor() == Spanner::Anchor::NOTE) {
seg->setFlag(ElementFlag::ON_STAFF, false);
}

if (systemFlag()) {
seg->initElementStyle(&systemTextLineSegmentStyle);
} else {
seg->initElementStyle(&textLineSegmentStyle);
}
seg->initStyle();

return seg;
}
Expand All @@ -196,11 +208,7 @@ LineSegment* TextLine::createLineSegment(System* parent)

Sid TextLineSegment::getTextLinePos(bool above) const
{
if (systemFlag()) {
return above ? Sid::systemTextLinePosAbove : Sid::systemTextLinePosBelow;
} else {
return above ? Sid::textLinePosAbove : Sid::textLinePosBelow;
}
return textLine()->getTextLinePos(above);
}

Sid TextLine::getTextLinePos(bool above) const
Expand Down Expand Up @@ -270,9 +278,18 @@ engraving::PropertyValue TextLine::propertyDefault(Pid propertyId) const
case Pid::CONTINUE_TEXT_PLACE:
case Pid::END_TEXT_PLACE:
return TextPlace::LEFT;
case Pid::BEGIN_HOOK_HEIGHT:
case Pid::END_HOOK_HEIGHT:
return Spatium(1.5);
case Pid::LINE_WIDTH:
if (systemFlag()) {
return style().styleMM(Sid::systemTextLineLineWidth);
} else {
return style().styleMM(Sid::textLineLineWidth);
}
case Pid::LINE_STYLE:
if (systemFlag()) {
return style().styleV(Sid::systemTextLineLineStyle);
} else {
return style().styleV(Sid::textLineLineStyle);
}
default:
return TextLineBase::propertyDefault(propertyId);
}
Expand Down
2 changes: 2 additions & 0 deletions src/engraving/dom/textline.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class TextLineSegment final : public TextLineBaseSegment

TextLineSegment* clone() const override { return new TextLineSegment(*this); }

void initStyle();

virtual EngravingItem* propertyDelegate(Pid) override;

TextLine* textLine() const { return toTextLine(spanner()); }
Expand Down
10 changes: 10 additions & 0 deletions src/engraving/style/styledef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,11 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
styleDef(textLinePlacement, PlacementV::ABOVE),
styleDef(textLinePosAbove, PointF(.0, -1.0)),
styleDef(textLinePosBelow, PointF(.0, 1.0)),
styleDef(textLineLineWidth, Spatium(0.15),
styleDef(textLineLineStyle, PropertyValue(LineType::SOLID),
styleDef(textLineDashLineLen, 4.0,
styleDef(textLineDashGapLen, 4.0,
styleDef(textLineHookHeight, Spatium(1.5),
styleDef(textLineFrameType, int(FrameType::NO_FRAME)),
styleDef(textLineFramePadding, 0.2),
styleDef(textLineFrameWidth, 0.1),
Expand All @@ -703,6 +708,11 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
styleDef(systemTextLinePlacement, PlacementV::ABOVE),
styleDef(systemTextLinePosAbove, PointF(.0, -1.0)),
styleDef(systemTextLinePosBelow, PointF(.0, 1.0)),
styleDef(systemTextLineLineWidth, Spatium(0.15),
styleDef(systemTextLineLineStyle, PropertyValue(LineType::SOLID),
styleDef(systemTextLineDashLineLen, 4.0,
styleDef(systemTextLineDashGapLen, 4.0,
styleDef(systemTextLineHookHeight, Spatium(1.5),
styleDef(systemTextLineFrameType, int(FrameType::NO_FRAME)),
styleDef(systemTextLineFramePadding, 0.2),
styleDef(systemTextLineFrameWidth, 0.1),
Expand Down
10 changes: 10 additions & 0 deletions src/engraving/style/styledef.h
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,11 @@ enum class Sid {
textLinePlacement,
textLinePosAbove,
textLinePosBelow,
textLineLineWidth,
textLineLineStyle,
textLineDashLineLen,
textLineDashGapLen,
textLineHookHeight,
textLineFrameType,
textLineFramePadding,
textLineFrameWidth,
Expand All @@ -716,6 +721,11 @@ enum class Sid {
systemTextLinePlacement,
systemTextLinePosAbove,
systemTextLinePosBelow,
systemTextLineLineWidth,
systemTextLineLineStyle,
systemTextLineDashLineLen,
systemTextLineDashGapLen,
systemTextLineHookHeight,
systemTextLineFrameType,
systemTextLineFramePadding,
systemTextLineFrameWidth,
Expand Down
27 changes: 27 additions & 0 deletions src/notation/view/widgets/editstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ EditStyle::EditStyle(QWidget* parent)
{ StyleId::pedalLineStyle, false, pedalLineStyle, resetPedalLineStyle },
{ StyleId::pedalDashLineLen, false, pedalLineStyleDashSize, resetPedalLineStyleDashSize },
{ StyleId::pedalDashGapLen, false, pedalLineStyleGapSize, resetPedalLineStyleGapSize },
{ StyleId::textLineLineStyle, false, textLineLineStyle, resetTextLineLineStyle },
{ StyleId::textLineDashLineLen, false, textLineLineStyleDashSize, resetTextLineLineStyleDashSize },
{ StyleId::textLineDashGapLen, false, textLineLineStyleGapSize, resetTextLineLineStyleGapSize },
{ StyleId::systemTextLineLineStyle, false, systemTextLineLineStyle, resetSystemTextLineLineStyle },
{ StyleId::systemTextLineDashLineLen, false, systemTextLineLineStyleDashSize, resetSystemTextLineLineStyleDashSize },
{ StyleId::systemTextLineDashGapLen, false, systemTextLineLineStyleGapSize, resetSystemTextLineLineStyleGapSize },

{ StyleId::staffUpperBorder, false, staffUpperBorder, resetStaffUpperBorder },
{ StyleId::staffLowerBorder, false, staffLowerBorder, resetStaffLowerBorder },
Expand Down Expand Up @@ -631,13 +637,16 @@ EditStyle::EditStyle(QWidget* parent)

{ StyleId::autoplaceVerticalAlignRange, false, autoplaceVerticalAlignRange, resetAutoplaceVerticalAlignRange },
{ StyleId::minVerticalDistance, false, minVerticalDistance, resetMinVerticalDistance },

{ StyleId::textLinePlacement, false, textLinePlacement, resetTextLinePlacement },
{ StyleId::textLinePosAbove, false, textLinePosAbove, resetTextLinePosAbove },
{ StyleId::textLinePosBelow, false, textLinePosBelow, resetTextLinePosBelow },
{ StyleId::textLineLineWidth, false, textLineLineWidth, resetTextLineLineWidth },

{ StyleId::systemTextLinePlacement, false, systemTextLinePlacement, resetSystemTextLinePlacement },
{ StyleId::systemTextLinePosAbove, false, systemTextLinePosAbove, resetSystemTextLinePosAbove },
{ StyleId::systemTextLinePosBelow, false, systemTextLinePosBelow, resetSystemTextLinePosBelow },
{ StyleId::systemTextLineLineWidth, false, systemTextLineLineWidth, resetSystemTextLineLineWidth },

{ StyleId::fermataPosAbove, false, fermataPosAbove, resetFermataPosAbove },
{ StyleId::fermataPosBelow, false, fermataPosBelow, resetFermataPosBelow },
Expand Down Expand Up @@ -720,6 +729,24 @@ EditStyle::EditStyle(QWidget* parent)
label_pedalLine_lineStyle_gapSize,
pedalLineStyleGapSize,
resetPedalLineStyleGapSize
}),

new LineStyleSelect(this, textLineLineStyle, {
label_textLineLine_lineStyle_dashSize,
textLineLineStyleDashSize,
resetTextLineLineStyleDashSize,
label_textLineLine_lineStyle_gapSize,
textLineLineStyleGapSize,
resetTextLineLineStyleGapSize
}),

new LineStyleSelect(this, systemTextLineLineStyle, {
label_systemTextLineLine_lineStyle_dashSize,
systemTextLineLineStyleDashSize,
resetSystemTextLineLineStyleDashSize,
label_systemTextLineLine_lineStyle_gapSize,
systemTextLineLineStyleGapSize,
resetSystemTextLineLineStyleGapSize
})
};

Expand Down
Loading

0 comments on commit 134a47c

Please sign in to comment.