From 77184c65cf71c4f2289a12c9364135de5560563f Mon Sep 17 00:00:00 2001 From: njantony1 Date: Thu, 20 Apr 2023 18:44:15 -0400 Subject: [PATCH] added ability to adjust gap between text and line --- src/engraving/libmscore/property.cpp | 1 + src/engraving/libmscore/property.h | 1 + src/engraving/libmscore/textline.cpp | 1 + src/engraving/libmscore/textlinebase.cpp | 25 ++++++++++++++++--- src/engraving/libmscore/textlinebase.h | 4 ++- .../notation/lines/textlinesettingsmodel.cpp | 15 +++++++++++ .../notation/lines/textlinesettingsmodel.h | 3 +++ .../lines/internal/LineTextSettingsTab.qml | 23 ++++++++++++++++- 8 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/engraving/libmscore/property.cpp b/src/engraving/libmscore/property.cpp index eee22154f3..dd9ed8ca9f 100644 --- a/src/engraving/libmscore/property.cpp +++ b/src/engraving/libmscore/property.cpp @@ -322,6 +322,7 @@ static constexpr PropertyMetaData propertyList[] = { { Pid::BEGIN_FONT_SIZE, false, "beginFontSize", P_TYPE::REAL, DUMMY_QT_TR_NOOP("propertyName", "begin font size") }, { Pid::BEGIN_FONT_STYLE, false, "beginFontStyle", P_TYPE::INT, DUMMY_QT_TR_NOOP("propertyName", "begin font style") }, { Pid::BEGIN_TEXT_OFFSET, false, "beginTextOffset", P_TYPE::POINT, DUMMY_QT_TR_NOOP("propertyName", "begin text offset") }, + { Pid::GAP_BETWEEN_TEXT_AND_LINE, false, "gapBetweenTextAndLine", P_TYPE::SPATIUM, DUMMY_QT_TR_NOOP("propertyName", "gap between text and line") }, { Pid::CONTINUE_TEXT, true, "continueText", P_TYPE::STRING, DUMMY_QT_TR_NOOP("propertyName", "continue text") }, { Pid::CONTINUE_TEXT_ALIGN, false, "continueTextAlign", P_TYPE::ALIGN, DUMMY_QT_TR_NOOP("propertyName", "continue text align") }, diff --git a/src/engraving/libmscore/property.h b/src/engraving/libmscore/property.h index b61e3ac5d0..154546d37d 100644 --- a/src/engraving/libmscore/property.h +++ b/src/engraving/libmscore/property.h @@ -332,6 +332,7 @@ enum class Pid { BEGIN_FONT_SIZE, BEGIN_FONT_STYLE, BEGIN_TEXT_OFFSET, + GAP_BETWEEN_TEXT_AND_LINE, CONTINUE_TEXT, CONTINUE_TEXT_ALIGN, diff --git a/src/engraving/libmscore/textline.cpp b/src/engraving/libmscore/textline.cpp index fd8e0ba193..63b41dfe62 100644 --- a/src/engraving/libmscore/textline.cpp +++ b/src/engraving/libmscore/textline.cpp @@ -156,6 +156,7 @@ TextLine::TextLine(EngravingItem* parent, bool system) setEndHookType(HookType::NONE); setBeginHookHeight(Spatium(1.5)); setEndHookHeight(Spatium(1.5)); + setGapBetweenTextAndLine(Spatium(0.5)); initElementStyle(&textLineStyle); diff --git a/src/engraving/libmscore/textlinebase.cpp b/src/engraving/libmscore/textlinebase.cpp index 445d43ce5d..dbf5323f95 100644 --- a/src/engraving/libmscore/textlinebase.cpp +++ b/src/engraving/libmscore/textlinebase.cpp @@ -395,10 +395,10 @@ void TextLineBaseSegment::layout() double l = 0.0; if (!_text->empty()) { - double textlineTextDistance = _spatium * .5; + double gapBetweenTextAndLine = _spatium * tl->gapBetweenTextAndLine().val(); if ((isSingleBeginType() && (tl->beginTextPlace() == TextPlace::LEFT || tl->beginTextPlace() == TextPlace::AUTO)) || (!isSingleBeginType() && (tl->continueTextPlace() == TextPlace::LEFT || tl->continueTextPlace() == TextPlace::AUTO))) { - l = _text->pos().x() + _text->bbox().width() + textlineTextDistance; + l = _text->pos().x() + _text->bbox().width() + gapBetweenTextAndLine; } double h = _text->height(); @@ -545,12 +545,13 @@ void TextLineBaseSegment::spatiumChanged(double ov, double nv) _endText->spatiumChanged(ov, nv); } -static constexpr std::array TextLineBasePropertyId = { { +static constexpr std::array TextLineBasePropertyId = { { Pid::LINE_VISIBLE, Pid::BEGIN_HOOK_TYPE, Pid::BEGIN_HOOK_HEIGHT, Pid::END_HOOK_TYPE, Pid::END_HOOK_HEIGHT, + Pid::GAP_BETWEEN_TEXT_AND_LINE, Pid::BEGIN_TEXT, Pid::BEGIN_TEXT_ALIGN, Pid::BEGIN_TEXT_PLACE, @@ -574,7 +575,7 @@ static constexpr std::array TextLineBasePropertyId = { { Pid::END_TEXT_OFFSET, } }; -const std::array& TextLineBase::textLineBasePropertyIds() +const std::array& TextLineBase::textLineBasePropertyIds() { return TextLineBasePropertyId; } @@ -602,6 +603,7 @@ TextLineBase::TextLineBase(const ElementType& type, EngravingItem* parent, Eleme { setBeginHookHeight(Spatium(1.9)); setEndHookHeight(Spatium(1.9)); + setGapBetweenTextAndLine(Spatium(0.5)); } //--------------------------------------------------------- @@ -661,6 +663,8 @@ PropertyValue TextLineBase::getProperty(Pid id) const return _endHookType; case Pid::END_HOOK_HEIGHT: return _endHookHeight; + case Pid::GAP_BETWEEN_TEXT_AND_LINE: + return _gapBetweenTextAndLine; case Pid::END_FONT_FACE: return _endFontFamily; case Pid::END_FONT_SIZE: @@ -721,6 +725,9 @@ bool TextLineBase::setProperty(Pid id, const PropertyValue& v) case Pid::BEGIN_TEXT_OFFSET: setBeginTextOffset(v.value()); break; + case Pid::GAP_BETWEEN_TEXT_AND_LINE: + _gapBetweenTextAndLine = v.value(); + break; case Pid::CONTINUE_TEXT_OFFSET: setContinueTextOffset(v.value()); break; @@ -775,4 +782,14 @@ bool TextLineBase::setProperty(Pid id, const PropertyValue& v) triggerLayout(); return true; } + +mu::engraving::PropertyValue TextLineBase::propertyDefault(Pid propertyId) const +{ + switch (propertyId) { + case Pid::GAP_BETWEEN_TEXT_AND_LINE: + return Spatium(0.5); + default: + return SLine::propertyDefault(propertyId); + } +} } diff --git a/src/engraving/libmscore/textlinebase.h b/src/engraving/libmscore/textlinebase.h index 6e2c4d9c28..51f87ed6fe 100644 --- a/src/engraving/libmscore/textlinebase.h +++ b/src/engraving/libmscore/textlinebase.h @@ -85,6 +85,7 @@ class TextLineBase : public SLine M_PROPERTY2(HookType, endHookType, setEndHookType, HookType::NONE) M_PROPERTY(Spatium, beginHookHeight, setBeginHookHeight) M_PROPERTY(Spatium, endHookHeight, setEndHookHeight) + M_PROPERTY(Spatium, gapBetweenTextAndLine, setGapBetweenTextAndLine) M_PROPERTY2(TextPlace, beginTextPlace, setBeginTextPlace, TextPlace::AUTO) M_PROPERTY(String, beginText, setBeginText) @@ -118,8 +119,9 @@ public: PropertyValue getProperty(Pid id) const override; bool setProperty(Pid propertyId, const PropertyValue&) override; + PropertyValue propertyDefault(Pid) const override; - static const std::array& textLineBasePropertyIds(); + static const std::array& textLineBasePropertyIds(); protected: friend class TextLineBaseSegment; diff --git a/src/inspector/models/notation/lines/textlinesettingsmodel.cpp b/src/inspector/models/notation/lines/textlinesettingsmodel.cpp index 1dcf192298..ce55e01dd2 100644 --- a/src/inspector/models/notation/lines/textlinesettingsmodel.cpp +++ b/src/inspector/models/notation/lines/textlinesettingsmodel.cpp @@ -82,6 +82,8 @@ void TextLineSettingsModel::createProperties() m_startHookHeight = buildPropertyItem(Pid::BEGIN_HOOK_HEIGHT); m_endHookHeight = buildPropertyItem(Pid::END_HOOK_HEIGHT); + m_gapBetweenTextAndLine = buildPropertyItem(Pid::GAP_BETWEEN_TEXT_AND_LINE, applyPropertyValueAndUpdateAvailability); + m_thickness = buildPropertyItem(Pid::LINE_WIDTH); m_dashLineLength = buildPropertyItem(Pid::DASH_LINE_LEN); m_dashGapLength = buildPropertyItem(Pid::DASH_GAP_LEN); @@ -118,6 +120,7 @@ void TextLineSettingsModel::loadProperties() Pid::DASH_GAP_LEN, Pid::END_HOOK_HEIGHT, Pid::BEGIN_HOOK_HEIGHT, + Pid::GAP_BETWEEN_TEXT_AND_LINE, Pid::PLACEMENT, Pid::BEGIN_TEXT, Pid::BEGIN_TEXT_OFFSET, @@ -143,6 +146,7 @@ void TextLineSettingsModel::resetProperties() m_endHookType, m_startHookHeight, m_endHookHeight, + m_gapBetweenTextAndLine, m_placement, m_beginningText, m_beginningTextOffset, @@ -209,6 +213,11 @@ PropertyItem* TextLineSettingsModel::endHookHeight() const return m_endHookHeight; } +PropertyItem* TextLineSettingsModel::gapBetweenTextAndLine() const +{ + return m_gapBetweenTextAndLine; +} + PropertyItem* TextLineSettingsModel::placement() const { return m_placement; @@ -287,6 +296,8 @@ void TextLineSettingsModel::onUpdateLinePropertiesAvailability() m_lineStyle->setIsEnabled(isLineAvailable); m_thickness->setIsEnabled(isLineAvailable); + m_gapBetweenTextAndLine->setIsEnabled(isLineAvailable); + auto currentStyle = static_cast(m_lineStyle->value().toInt()); bool areDashPropertiesAvailable = currentStyle == LineTypes::LineStyle::LINE_STYLE_DASHED; @@ -357,6 +368,10 @@ void TextLineSettingsModel::loadProperties(const PropertyIdSet& propertyIdSet) loadPropertyItem(m_endHookHeight); } + if (mu::contains(propertyIdSet, Pid::GAP_BETWEEN_TEXT_AND_LINE)) { + loadPropertyItem(m_gapBetweenTextAndLine); + } + if (mu::contains(propertyIdSet, Pid::PLACEMENT)) { loadPropertyItem(m_placement); } diff --git a/src/inspector/models/notation/lines/textlinesettingsmodel.h b/src/inspector/models/notation/lines/textlinesettingsmodel.h index bd444ad820..5fdb9ed27f 100644 --- a/src/inspector/models/notation/lines/textlinesettingsmodel.h +++ b/src/inspector/models/notation/lines/textlinesettingsmodel.h @@ -44,6 +44,7 @@ class TextLineSettingsModel : public AbstractInspectorModel Q_PROPERTY(PropertyItem * endHookType READ endHookType CONSTANT) Q_PROPERTY(PropertyItem * startHookHeight READ startHookHeight CONSTANT) Q_PROPERTY(PropertyItem * endHookHeight READ endHookHeight CONSTANT) + Q_PROPERTY(PropertyItem * gapBetweenTextAndLine READ gapBetweenTextAndLine CONSTANT) Q_PROPERTY(PropertyItem * placement READ placement CONSTANT) @@ -73,6 +74,7 @@ public: PropertyItem* endHookType() const; PropertyItem* startHookHeight() const; PropertyItem* endHookHeight() const; + PropertyItem* gapBetweenTextAndLine() const; PropertyItem* placement() const; @@ -142,6 +144,7 @@ private: PropertyItem* m_endHookType = nullptr; PropertyItem* m_startHookHeight = nullptr; PropertyItem* m_endHookHeight = nullptr; + PropertyItem* m_gapBetweenTextAndLine = nullptr; PropertyItem* m_beginningText = nullptr; PointFPropertyItem* m_beginningTextOffset = nullptr; diff --git a/src/inspector/view/qml/MuseScore/Inspector/notation/lines/internal/LineTextSettingsTab.qml b/src/inspector/view/qml/MuseScore/Inspector/notation/lines/internal/LineTextSettingsTab.qml index 54205971a4..3f29604ba4 100644 --- a/src/inspector/view/qml/MuseScore/Inspector/notation/lines/internal/LineTextSettingsTab.qml +++ b/src/inspector/view/qml/MuseScore/Inspector/notation/lines/internal/LineTextSettingsTab.qml @@ -67,13 +67,34 @@ FocusableItem { SeparatorLine { anchors.margins: -12 } + SpinBoxPropertyView { + id: gapBetweenTextAndLineControl + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: 2 + + titleText: qsTrc("inspector", "Gap between text and line") + propertyItem: root.model ? root.model.gapBetweenTextAndLine : null + + step: 0.1 + maxValue: 100.0 + minValue: 0.0 + decimals: 2 + + navigationName: "GapBetweenTextAndLine" + navigationPanel: root.navigationPanel + navigationRowStart: beginningTextOffsetSection.navigationRowEnd + 1 + } + + SeparatorLine { anchors.margins: -12 } + TextSection { id: continuousTextSection titleText: qsTrc("inspector", "Text when continuing to a new system") propertyItem: root.model ? root.model.continuousText : null navigationPanel: root.navigationPanel - navigationRowStart: beginningTextOffsetSection.navigationRowEnd + 1 + navigationRowStart: gapBetweenTextAndLineControl.navigationRowEnd + 1 } OffsetSection {