LCOV - code coverage report
Current view: top level - src/engraving/dom - textlinebase.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 70.4 % 436 307
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #include "textlinebase.h"
      24              : 
      25              : #include "rendering/iscorerenderer.h"
      26              : 
      27              : #include "factory.h"
      28              : #include "score.h"
      29              : #include "system.h"
      30              : #include "text.h"
      31              : 
      32              : #include "log.h"
      33              : 
      34              : using namespace mu;
      35              : using namespace mu::engraving;
      36              : 
      37              : namespace mu::engraving {
      38              : //---------------------------------------------------------
      39              : //   TextLineBaseSegment
      40              : //---------------------------------------------------------
      41              : 
      42          774 : TextLineBaseSegment::TextLineBaseSegment(const ElementType& type, TextLineBase* sp, ElementFlags f)
      43          774 :     : LineSegment(type, sp, f)
      44              : {
      45          774 :     m_text    = Factory::createText(this, TextStyleType::DEFAULT, false);
      46          774 :     m_endText = Factory::createText(this, TextStyleType::DEFAULT, false);
      47          774 :     m_text->setFlag(ElementFlag::MOVABLE, false);
      48          774 :     m_endText->setFlag(ElementFlag::MOVABLE, false);
      49          774 : }
      50              : 
      51           98 : TextLineBaseSegment::TextLineBaseSegment(const TextLineBaseSegment& seg)
      52           98 :     : LineSegment(seg)
      53              : {
      54           98 :     m_text    = seg.m_text->clone();
      55           98 :     m_endText = seg.m_endText->clone();
      56           98 :     m_text->setOwnershipParent(this);
      57           98 :     m_endText->setOwnershipParent(this);
      58              :     // set the right _text
      59           98 :     renderer()->layoutTextLineBaseSegment(this);
      60           98 : }
      61              : 
      62          776 : TextLineBaseSegment::~TextLineBaseSegment()
      63              : {
      64          776 :     delete m_text;
      65          776 :     delete m_endText;
      66          776 : }
      67              : 
      68              : //---------------------------------------------------------
      69              : //   setSelected
      70              : //---------------------------------------------------------
      71              : 
      72         1046 : void TextLineBaseSegment::setSelected(bool f)
      73              : {
      74         1046 :     SpannerSegment::setSelected(f);
      75         1046 :     m_text->setSelected(f);
      76         1046 :     m_endText->setSelected(f);
      77         1046 : }
      78              : 
      79         2128 : RectF TextLineBaseSegment::boundingBoxOfLine(const PointF& p1, const PointF& p2, double lw2, bool isDottedLine)
      80              : {
      81         2128 :     if (isDottedLine) {
      82            9 :         return RectF(p1, p2).normalized().adjusted(-lw2, -lw2, lw2, lw2);
      83              :     }
      84              : 
      85         2119 :     PointF a = lw2 * (p2 - p1).normalized();
      86         2119 :     PointF b(-a.y(), a.x());
      87         2119 :     return RectF(p1 - b, p1 + b).normalized().united(RectF(p2 - b, p2 + b).normalized());
      88              : }
      89              : 
      90          871 : bool TextLineBaseSegment::setProperty(Pid id, const PropertyValue& v)
      91              : {
      92          871 :     if (id == Pid::COLOR) {
      93            0 :         Color color = v.value<Color>();
      94              : 
      95            0 :         if (m_text) {
      96            0 :             m_text->setColor(color);
      97              :         }
      98              : 
      99            0 :         if (m_endText) {
     100            0 :             m_endText->setColor(color);
     101              :         }
     102              :     }
     103              : 
     104          871 :     return LineSegment::setProperty(id, v);
     105              : }
     106              : 
     107              : //---------------------------------------------------------
     108              : //   spatiumChanged
     109              : //---------------------------------------------------------
     110              : 
     111            6 : void TextLineBaseSegment::spatiumChanged(double ov, double nv)
     112              : {
     113            6 :     LineSegment::spatiumChanged(ov, nv);
     114              : 
     115            6 :     textLineBase()->spatiumChanged(ov, nv);
     116            6 :     m_text->spatiumChanged(ov, nv);
     117            6 :     m_endText->spatiumChanged(ov, nv);
     118            6 : }
     119              : 
     120              : static constexpr std::array<Pid, 45> TextLineBasePropertyId = { {
     121              :     Pid::LINE_VISIBLE,
     122              :     Pid::BEGIN_HOOK_TYPE,
     123              :     Pid::BEGIN_HOOK_HEIGHT,
     124              :     Pid::BEGIN_LINE_ARROW_HEIGHT,
     125              :     Pid::BEGIN_LINE_ARROW_WIDTH,
     126              :     Pid::BEGIN_FILLED_ARROW_HEIGHT,
     127              :     Pid::BEGIN_FILLED_ARROW_WIDTH,
     128              :     Pid::END_HOOK_TYPE,
     129              :     Pid::END_HOOK_HEIGHT,
     130              :     Pid::END_LINE_ARROW_HEIGHT,
     131              :     Pid::END_LINE_ARROW_WIDTH,
     132              :     Pid::END_FILLED_ARROW_HEIGHT,
     133              :     Pid::END_FILLED_ARROW_WIDTH,
     134              :     Pid::GAP_BETWEEN_TEXT_AND_LINE,
     135              :     Pid::BEGIN_TEXT,
     136              :     Pid::BEGIN_TEXT_ALIGN,
     137              :     Pid::BEGIN_TEXT_POSITION,
     138              :     Pid::BEGIN_TEXT_PLACE,
     139              :     Pid::BEGIN_FONT_FACE,
     140              :     Pid::BEGIN_FONT_SIZE,
     141              :     Pid::BEGIN_FONT_STYLE,
     142              :     Pid::BEGIN_TEXT_MUSICAL_SYMBOLS_SCALE,
     143              :     Pid::BEGIN_TEXT_MUSIC_SYMBOLS_SIZE,
     144              :     Pid::CONTINUE_TEXT_MUSICAL_SYMBOLS_SCALE,
     145              :     Pid::CONTINUE_TEXT_MUSIC_SYMBOLS_SIZE,
     146              :     Pid::END_TEXT_MUSICAL_SYMBOLS_SCALE,
     147              :     Pid::END_TEXT_MUSIC_SYMBOLS_SIZE,
     148              :     Pid::BEGIN_TEXT_OFFSET,
     149              :     Pid::CONTINUE_TEXT,
     150              :     Pid::CONTINUE_TEXT_ALIGN,
     151              :     Pid::CONTINUE_TEXT_POSITION,
     152              :     Pid::CONTINUE_TEXT_PLACE,
     153              :     Pid::CONTINUE_FONT_FACE,
     154              :     Pid::CONTINUE_FONT_SIZE,
     155              :     Pid::CONTINUE_FONT_STYLE,
     156              :     Pid::CONTINUE_TEXT_OFFSET,
     157              :     Pid::END_TEXT,
     158              :     Pid::END_TEXT_ALIGN,
     159              :     Pid::END_TEXT_POSITION,
     160              :     Pid::END_TEXT_PLACE,
     161              :     Pid::END_FONT_FACE,
     162              :     Pid::END_FONT_SIZE,
     163              :     Pid::END_FONT_STYLE,
     164              :     Pid::END_TEXT_OFFSET,
     165              :     Pid::TEXT_SIZE_SPATIUM_DEPENDENT
     166              : } };
     167              : 
     168         3492 : const std::array<Pid, 45>& TextLineBase::textLineBasePropertyIds()
     169              : {
     170         3492 :     return TextLineBasePropertyId;
     171              : }
     172              : 
     173            0 : void TextLineBase::reset()
     174              : {
     175            0 :     String beginText = _beginText;
     176            0 :     String contText = _continueText;
     177            0 :     String endText = _endText;
     178            0 :     bool beginStyled = isStyled(Pid::BEGIN_TEXT);
     179            0 :     bool contStyled = isStyled(Pid::CONTINUE_TEXT);
     180            0 :     bool endStyled = isStyled(Pid::END_TEXT);
     181              : 
     182            0 :     SLine::reset();
     183            0 :     if (!beginStyled) {
     184            0 :         undoChangeProperty(Pid::BEGIN_TEXT, beginText, PropertyFlags::UNSTYLED);
     185              :     }
     186            0 :     if (!contStyled) {
     187            0 :         undoChangeProperty(Pid::CONTINUE_TEXT, contText, PropertyFlags::UNSTYLED);
     188              :     }
     189            0 :     if (!endStyled) {
     190            0 :         undoChangeProperty(Pid::END_TEXT, endText, PropertyFlags::UNSTYLED);
     191              :     }
     192            0 : }
     193              : 
     194              : //---------------------------------------------------------
     195              : //   propertyDelegate
     196              : //---------------------------------------------------------
     197              : 
     198         5904 : EngravingObject* TextLineBaseSegment::propertyDelegate(Pid pid) const
     199              : {
     200         5904 :     if (pid == Pid::TEXT_STYLE) {
     201         1548 :         return spanner();
     202              :     }
     203              : 
     204       200024 :     for (Pid id : TextLineBasePropertyId) {
     205       195679 :         if (pid == id) {
     206           11 :             return spanner();
     207              :         }
     208              :     }
     209         4345 :     return LineSegment::propertyDelegate(pid);
     210              : }
     211              : 
     212              : //---------------------------------------------------------
     213              : //   TextLineBase
     214              : //---------------------------------------------------------
     215              : 
     216         1488 : TextLineBase::TextLineBase(const ElementType& type, EngravingObject* parent, ElementFlags f)
     217         1488 :     : SLine(type, parent, f)
     218              : {
     219         1488 :     setBeginHookHeight(1.9_sp);
     220         1488 :     setEndHookHeight(1.9_sp);
     221         1488 :     setGapBetweenTextAndLine(0.5_sp);
     222         1488 : }
     223              : 
     224              : //---------------------------------------------------------
     225              : //   spatiumChanged
     226              : //---------------------------------------------------------
     227              : 
     228            6 : void TextLineBase::spatiumChanged(double /*ov*/, double /*nv*/)
     229              : {
     230            6 : }
     231              : 
     232              : //---------------------------------------------------------
     233              : //   getProperty
     234              : //---------------------------------------------------------
     235              : 
     236        20527 : PropertyValue TextLineBase::getProperty(Pid id) const
     237              : {
     238        20527 :     switch (id) {
     239          395 :     case Pid::BEGIN_TEXT:
     240          395 :         return beginText();
     241           60 :     case Pid::ALIGN: // Redirect to begin text...
     242              :     case Pid::BEGIN_TEXT_ALIGN:
     243           60 :         return PropertyValue::fromValue(beginTextAlign());
     244           60 :     case Pid::CONTINUE_TEXT_ALIGN:
     245           60 :         return PropertyValue::fromValue(continueTextAlign());
     246           60 :     case Pid::END_TEXT_ALIGN:
     247           60 :         return PropertyValue::fromValue(endTextAlign());
     248           60 :     case Pid::POSITION: // Redirect to begin text...
     249              :     case Pid::BEGIN_TEXT_POSITION:
     250           60 :         return PropertyValue::fromValue(beginTextPosition());
     251           60 :     case Pid::CONTINUE_TEXT_POSITION:
     252           60 :         return PropertyValue::fromValue(continueTextPosition());
     253           60 :     case Pid::END_TEXT_POSITION:
     254           60 :         return PropertyValue::fromValue(endTextPosition());
     255          697 :     case Pid::BEGIN_TEXT_PLACE:
     256          697 :         return _beginTextPlace;
     257          697 :     case Pid::BEGIN_HOOK_TYPE:
     258          697 :         return _beginHookType;
     259          524 :     case Pid::BEGIN_HOOK_HEIGHT:
     260          524 :         return _beginHookHeight;
     261          272 :     case Pid::BEGIN_LINE_ARROW_HEIGHT:
     262          272 :         return _beginLineArrowHeight;
     263          272 :     case Pid::BEGIN_LINE_ARROW_WIDTH:
     264          272 :         return _beginLineArrowWidth;
     265          272 :     case Pid::BEGIN_FILLED_ARROW_HEIGHT:
     266          272 :         return _beginFilledArrowHeight;
     267          272 :     case Pid::BEGIN_FILLED_ARROW_WIDTH:
     268          272 :         return _beginFilledArrowWidth;
     269           66 :     case Pid::FONT_FACE: // Redirect to begin text...
     270              :     case Pid::BEGIN_FONT_FACE:
     271           66 :         return _beginFontFamily;
     272           66 :     case Pid::FONT_SIZE: // Redirect to begin text...
     273              :     case Pid::BEGIN_FONT_SIZE:
     274           66 :         return _beginFontSize;
     275           66 :     case Pid::FONT_STYLE: // Redirect to begin text...
     276              :     case Pid::BEGIN_FONT_STYLE:
     277           66 :         return int(_beginFontStyle);
     278           60 :     case Pid::MUSIC_SYMBOL_SIZE: // Redirect to begin text...
     279              :     case Pid::BEGIN_TEXT_MUSIC_SYMBOLS_SIZE:
     280           60 :         return _beginTextMusicSymbolsSize;
     281           60 :     case Pid::MUSICAL_SYMBOLS_SCALE: // Redirect to begin text...
     282              :     case Pid::BEGIN_TEXT_MUSICAL_SYMBOLS_SCALE:
     283           60 :         return _beginTextMusicalSymbolsScale;
     284           60 :     case Pid::CONTINUE_TEXT_MUSICAL_SYMBOLS_SCALE:
     285           60 :         return _continueTextMusicalSymbolsScale;
     286           60 :     case Pid::CONTINUE_TEXT_MUSIC_SYMBOLS_SIZE:
     287           60 :         return _continueTextMusicSymbolsSize;
     288           60 :     case Pid::END_TEXT_MUSICAL_SYMBOLS_SCALE:
     289           60 :         return _endTextMusicalSymbolsScale;
     290           60 :     case Pid::END_TEXT_MUSIC_SYMBOLS_SIZE:
     291           60 :         return _endTextMusicSymbolsSize;
     292          642 :     case Pid::BEGIN_TEXT_OFFSET:
     293          642 :         return _beginTextOffset;
     294          415 :     case Pid::CONTINUE_TEXT:
     295          415 :         return continueText();
     296          697 :     case Pid::CONTINUE_TEXT_PLACE:
     297          697 :         return _continueTextPlace;
     298           60 :     case Pid::CONTINUE_FONT_FACE:
     299           60 :         return _continueFontFamily;
     300           60 :     case Pid::CONTINUE_FONT_SIZE:
     301           60 :         return _continueFontSize;
     302           60 :     case Pid::CONTINUE_FONT_STYLE:
     303           60 :         return int(_continueFontStyle);
     304          642 :     case Pid::CONTINUE_TEXT_OFFSET:
     305          642 :         return _continueTextOffset;
     306          647 :     case Pid::END_TEXT:
     307          647 :         return endText();
     308          589 :     case Pid::END_TEXT_PLACE:
     309          589 :         return _endTextPlace;
     310          611 :     case Pid::END_HOOK_TYPE:
     311          611 :         return _endHookType;
     312          424 :     case Pid::END_HOOK_HEIGHT:
     313          424 :         return _endHookHeight;
     314          272 :     case Pid::END_LINE_ARROW_HEIGHT:
     315          272 :         return _endLineArrowHeight;
     316          272 :     case Pid::END_LINE_ARROW_WIDTH:
     317          272 :         return _endLineArrowWidth;
     318          272 :     case Pid::END_FILLED_ARROW_HEIGHT:
     319          272 :         return _endFilledArrowHeight;
     320          272 :     case Pid::END_FILLED_ARROW_WIDTH:
     321          272 :         return _endFilledArrowWidth;
     322          708 :     case Pid::GAP_BETWEEN_TEXT_AND_LINE:
     323          708 :         return _gapBetweenTextAndLine;
     324           62 :     case Pid::END_FONT_FACE:
     325           62 :         return _endFontFamily;
     326           62 :     case Pid::END_FONT_SIZE:
     327           62 :         return _endFontSize;
     328           62 :     case Pid::END_FONT_STYLE:
     329           62 :         return int(_endFontStyle);
     330          642 :     case Pid::END_TEXT_OFFSET:
     331          642 :         return _endTextOffset;
     332          697 :     case Pid::LINE_VISIBLE:
     333          697 :         return lineVisible();
     334           60 :     case Pid::TEXT_SIZE_SPATIUM_DEPENDENT:
     335           60 :         return textSizeSpatiumDependent();
     336         7980 :     default:
     337         7980 :         return SLine::getProperty(id);
     338              :     }
     339              : }
     340              : 
     341              : //---------------------------------------------------------
     342              : //   setProperty
     343              : //---------------------------------------------------------
     344              : 
     345        93158 : bool TextLineBase::setProperty(Pid id, const PropertyValue& v)
     346              : {
     347        93158 :     switch (id) {
     348         1305 :     case Pid::BEGIN_TEXT_PLACE:
     349         1305 :         _beginTextPlace = v.value<TextPlace>();
     350         1305 :         break;
     351         2360 :     case Pid::BEGIN_TEXT_ALIGN:
     352         2360 :         _beginTextAlign = v.value<Align>();
     353         2360 :         break;
     354         2360 :     case Pid::BEGIN_TEXT_POSITION:
     355         2360 :         _beginTextPosition = v.value<AlignH>();
     356         2360 :         break;
     357         2361 :     case Pid::BEGIN_FONT_FACE:
     358         2361 :         setBeginFontFamily(v.value<String>());
     359         2361 :         break;
     360         2361 :     case Pid::BEGIN_FONT_SIZE:
     361         2361 :         if (v.toReal() <= 0) {
     362            0 :             ASSERT_X(String(u"font size is %1").arg(v.toReal()));
     363              :         }
     364         2361 :         setBeginFontSize(v.toReal());
     365         2361 :         break;
     366         2361 :     case Pid::BEGIN_FONT_STYLE:
     367         2361 :         setBeginFontStyle(FontStyle(v.toInt()));
     368         2361 :         break;
     369         2361 :     case Pid::BEGIN_TEXT_MUSICAL_SYMBOLS_SCALE:
     370         2361 :         setBeginTextMusicalSymbolsScale(v.toReal());
     371         2361 :         break;
     372         2361 :     case Pid::BEGIN_TEXT_MUSIC_SYMBOLS_SIZE:
     373         2361 :         setBeginTextMusicSymbolsSize(v.toReal());
     374         2361 :         break;
     375         2361 :     case Pid::CONTINUE_TEXT_MUSICAL_SYMBOLS_SCALE:
     376         2361 :         setContinueTextMusicalSymbolsScale(v.toReal());
     377         2361 :         break;
     378         2361 :     case Pid::CONTINUE_TEXT_MUSIC_SYMBOLS_SIZE:
     379         2361 :         setContinueTextMusicSymbolsSize(v.toReal());
     380         2361 :         break;
     381         2361 :     case Pid::END_TEXT_MUSICAL_SYMBOLS_SCALE:
     382         2361 :         setEndTextMusicalSymbolsScale(v.toReal());
     383         2361 :         break;
     384         2361 :     case Pid::END_TEXT_MUSIC_SYMBOLS_SIZE:
     385         2361 :         setEndTextMusicSymbolsSize(v.toReal());
     386         2361 :         break;
     387              : 
     388         2361 :     case Pid::CONTINUE_TEXT_ALIGN:
     389         2361 :         _continueTextAlign = v.value<Align>();
     390         2361 :         break;
     391         2372 :     case Pid::END_TEXT_ALIGN:
     392         2372 :         _endTextAlign = v.value<Align>();
     393         2372 :         break;
     394         2360 :     case Pid::CONTINUE_TEXT_POSITION:
     395         2360 :         _continueTextPosition = v.value<AlignH>();
     396         2360 :         break;
     397         2359 :     case Pid::END_TEXT_POSITION:
     398         2359 :         _endTextPosition = v.value<AlignH>();
     399         2359 :         break;
     400         1189 :     case Pid::CONTINUE_TEXT_PLACE:
     401         1189 :         _continueTextPlace = v.value<TextPlace>();
     402         1189 :         break;
     403         1187 :     case Pid::END_TEXT_PLACE:
     404         1187 :         _endTextPlace = v.value<TextPlace>();
     405         1187 :         break;
     406         2361 :     case Pid::CONTINUE_FONT_FACE:
     407         2361 :         setContinueFontFamily(v.value<String>());
     408         2361 :         break;
     409         2361 :     case Pid::CONTINUE_FONT_SIZE:
     410         2361 :         setContinueFontSize(v.toReal());
     411         2361 :         break;
     412         2361 :     case Pid::CONTINUE_FONT_STYLE:
     413         2361 :         setContinueFontStyle(FontStyle(v.toInt()));
     414         2361 :         break;
     415         2361 :     case Pid::END_FONT_FACE:
     416         2361 :         setEndFontFamily(v.value<String>());
     417         2361 :         break;
     418         2361 :     case Pid::END_FONT_SIZE:
     419         2361 :         setEndFontSize(v.toReal());
     420         2361 :         break;
     421         2361 :     case Pid::END_FONT_STYLE:
     422         2361 :         setEndFontStyle(FontStyle(v.toInt()));
     423         2361 :         break;
     424              : 
     425         1518 :     case Pid::BEGIN_HOOK_HEIGHT:
     426         1518 :         _beginHookHeight = v.value<Spatium>();
     427         1518 :         break;
     428         1757 :     case Pid::END_HOOK_HEIGHT:
     429         1757 :         _endHookHeight = v.value<Spatium>();
     430         1757 :         break;
     431          177 :     case Pid::BEGIN_HOOK_TYPE:
     432          177 :         _beginHookType = v.value<HookType>();
     433          177 :         break;
     434          925 :     case Pid::END_HOOK_TYPE:
     435          925 :         _endHookType = v.value<HookType>();
     436          925 :         break;
     437              : 
     438         1855 :     case Pid::BEGIN_FILLED_ARROW_HEIGHT:
     439         1855 :         _beginFilledArrowHeight = v.value<Spatium>();
     440         1855 :         break;
     441         1855 :     case Pid::BEGIN_FILLED_ARROW_WIDTH:
     442         1855 :         _beginFilledArrowWidth = v.value<Spatium>();
     443         1855 :         break;
     444         1855 :     case Pid::END_FILLED_ARROW_HEIGHT:
     445         1855 :         _endFilledArrowHeight = v.value<Spatium>();
     446         1855 :         break;
     447         1855 :     case Pid::END_FILLED_ARROW_WIDTH:
     448         1855 :         _endFilledArrowWidth = v.value<Spatium>();
     449         1855 :         break;
     450         1855 :     case Pid::BEGIN_LINE_ARROW_HEIGHT:
     451         1855 :         _beginLineArrowHeight = v.value<Spatium>();
     452         1855 :         break;
     453         1855 :     case Pid::BEGIN_LINE_ARROW_WIDTH:
     454         1855 :         _beginLineArrowWidth = v.value<Spatium>();
     455         1855 :         break;
     456         1855 :     case Pid::END_LINE_ARROW_HEIGHT:
     457         1855 :         _endLineArrowHeight = v.value<Spatium>();
     458         1855 :         break;
     459         1855 :     case Pid::END_LINE_ARROW_WIDTH:
     460         1855 :         _endLineArrowWidth = v.value<Spatium>();
     461         1855 :         break;
     462         2373 :     case Pid::BEGIN_TEXT:
     463         2373 :         setBeginText(v.value<String>());
     464         2373 :         break;
     465          314 :     case Pid::BEGIN_TEXT_OFFSET:
     466          314 :         setBeginTextOffset(v.value<PointF>());
     467          314 :         break;
     468            1 :     case Pid::GAP_BETWEEN_TEXT_AND_LINE:
     469            1 :         _gapBetweenTextAndLine = v.value<Spatium>();
     470            1 :         break;
     471          178 :     case Pid::CONTINUE_TEXT_OFFSET:
     472          178 :         setContinueTextOffset(v.value<PointF>());
     473          178 :         break;
     474          178 :     case Pid::END_TEXT_OFFSET:
     475          178 :         setEndTextOffset(v.value<PointF>());
     476          178 :         break;
     477         2162 :     case Pid::CONTINUE_TEXT:
     478         2162 :         setContinueText(v.value<String>());
     479         2162 :         break;
     480         1005 :     case Pid::END_TEXT:
     481         1005 :         setEndText(v.value<String>());
     482         1005 :         break;
     483          879 :     case Pid::LINE_VISIBLE:
     484          879 :         setLineVisible(v.toBool());
     485          879 :         break;
     486         2361 :     case Pid::TEXT_SIZE_SPATIUM_DEPENDENT:
     487         2361 :         setTextSizeSpatiumDependent(v.toBool());
     488         2361 :         break;
     489              : 
     490              :     /// In >=4.6 text line begin, continue, and end text should all have the same style. This preserves backwards
     491              :     /// compatibility and will allow us to style these text items separately in the future if desired
     492              : 
     493              :     // These are TextBase properties - updating these should update begin, continue, and end text...
     494            0 :     case Pid::ALIGN: {
     495            0 :         const Align align(v.value<Align>());
     496            0 :         _beginTextAlign = align;
     497            0 :         _continueTextAlign = align;
     498            0 :         _endTextAlign = align;
     499            0 :         break;
     500              :     }
     501            0 :     case Pid::POSITION: {
     502            0 :         const AlignH alignH(v.value<AlignH>());
     503            0 :         _beginTextPosition = alignH;
     504            0 :         _continueTextPosition = alignH;
     505            0 :         _endTextPosition = alignH;
     506            0 :         break;
     507              :     }
     508            0 :     case Pid::FONT_FACE: {
     509            0 :         const String face(v.value<String>());
     510            0 :         setBeginFontFamily(face);
     511            0 :         setContinueFontFamily(face);
     512            0 :         setEndFontFamily(face);
     513            0 :         break;
     514            0 :     }
     515            0 :     case Pid::FONT_SIZE: {
     516            0 :         const double size(v.toReal());
     517            0 :         if (size <= 0) {
     518            0 :             ASSERT_X(String(u"font size is %1").arg(size));
     519              :         }
     520            0 :         setBeginFontSize(size);
     521            0 :         setContinueFontSize(size);
     522            0 :         setEndFontSize(size);
     523            0 :         break;
     524              :     }
     525            0 :     case Pid::FONT_STYLE: {
     526            0 :         const FontStyle style = FontStyle(v.toInt());
     527            0 :         setBeginFontStyle(style);
     528            0 :         setContinueFontStyle(style);
     529            0 :         setEndFontStyle(style);
     530            0 :         break;
     531              :     }
     532            0 :     case Pid::MUSIC_SYMBOL_SIZE: {
     533            0 :         const double size = v.toReal();
     534            0 :         setBeginTextMusicSymbolsSize(size);
     535            0 :         setContinueTextMusicSymbolsSize(size);
     536            0 :         setEndTextMusicSymbolsSize(size);
     537            0 :         break;
     538              :     }
     539            0 :     case Pid::MUSICAL_SYMBOLS_SCALE: {
     540            0 :         const double scale = v.toReal();
     541            0 :         setBeginTextMusicalSymbolsScale(scale);
     542            0 :         setContinueTextMusicalSymbolsScale(scale);
     543            0 :         setEndTextMusicalSymbolsScale(scale);
     544            0 :         break;
     545              :     }
     546              : 
     547        11222 :     default:
     548        11222 :         return SLine::setProperty(id, v);
     549              :     }
     550        81936 :     triggerLayout();
     551        81936 :     return true;
     552              : }
     553              : 
     554         9320 : PropertyValue TextLineBase::propertyDefault(Pid propertyId) const
     555              : {
     556         9320 :     switch (propertyId) {
     557          695 :     case Pid::GAP_BETWEEN_TEXT_AND_LINE:
     558          695 :         return 0.5_sp;
     559              : 
     560              :     // Redirect to begin text for these...
     561            0 :     case Pid::ALIGN:
     562            0 :         return propertyDefault(Pid::BEGIN_TEXT_ALIGN);
     563            0 :     case Pid::POSITION:
     564            0 :         return propertyDefault(Pid::BEGIN_TEXT_POSITION);
     565            0 :     case Pid::FONT_FACE:
     566            0 :         return propertyDefault(Pid::BEGIN_FONT_FACE);
     567            0 :     case Pid::FONT_SIZE:
     568            0 :         return propertyDefault(Pid::BEGIN_FONT_SIZE);
     569            0 :     case Pid::FONT_STYLE:
     570            0 :         return propertyDefault(Pid::BEGIN_FONT_STYLE);
     571            0 :     case Pid::MUSICAL_SYMBOLS_SCALE:
     572            0 :         return propertyDefault(Pid::BEGIN_TEXT_MUSICAL_SYMBOLS_SCALE);
     573            0 :     case Pid::MUSIC_SYMBOL_SIZE:
     574            0 :         return propertyDefault(Pid::BEGIN_TEXT_MUSIC_SYMBOLS_SIZE);
     575              : 
     576         8625 :     default:
     577         8625 :         return SLine::propertyDefault(propertyId);
     578              :     }
     579              : }
     580              : 
     581       123397 : PropertyFlags TextLineBase::propertyFlags(Pid id) const
     582              : {
     583       123397 :     switch (id) {
     584            0 :     case Pid::ALIGN:
     585            0 :         return propertyFlags(Pid::BEGIN_TEXT_ALIGN);
     586            0 :     case Pid::POSITION:
     587            0 :         return propertyFlags(Pid::BEGIN_TEXT_POSITION);
     588            0 :     case Pid::FONT_FACE:
     589            0 :         return propertyFlags(Pid::BEGIN_FONT_FACE);
     590            0 :     case Pid::FONT_SIZE:
     591            0 :         return propertyFlags(Pid::BEGIN_FONT_SIZE);
     592            0 :     case Pid::FONT_STYLE:
     593            0 :         return propertyFlags(Pid::BEGIN_FONT_STYLE);
     594            0 :     case Pid::MUSICAL_SYMBOLS_SCALE:
     595            0 :         return propertyFlags(Pid::BEGIN_TEXT_MUSICAL_SYMBOLS_SCALE);
     596            0 :     case Pid::MUSIC_SYMBOL_SIZE:
     597            0 :         return propertyFlags(Pid::BEGIN_TEXT_MUSIC_SYMBOLS_SIZE);
     598              : 
     599       123397 :     default:
     600       123397 :         return SLine::propertyFlags(id);
     601              :     }
     602              : }
     603              : 
     604         2428 : void TextLineBase::setPropertyFlags(Pid id, PropertyFlags f)
     605              : {
     606         2428 :     switch (id) {
     607            0 :     case Pid::ALIGN: {
     608            0 :         setPropertyFlags(Pid::BEGIN_TEXT_ALIGN, f);
     609            0 :         setPropertyFlags(Pid::CONTINUE_TEXT_ALIGN, f);
     610            0 :         setPropertyFlags(Pid::END_TEXT_ALIGN, f);
     611            0 :         break;
     612              :     }
     613            0 :     case Pid::POSITION: {
     614            0 :         setPropertyFlags(Pid::BEGIN_TEXT_POSITION, f);
     615            0 :         setPropertyFlags(Pid::CONTINUE_TEXT_POSITION, f);
     616            0 :         setPropertyFlags(Pid::END_TEXT_POSITION, f);
     617            0 :         break;
     618              :     }
     619            0 :     case Pid::FONT_FACE: {
     620            0 :         setPropertyFlags(Pid::BEGIN_FONT_FACE, f);
     621            0 :         setPropertyFlags(Pid::CONTINUE_FONT_FACE, f);
     622            0 :         setPropertyFlags(Pid::END_FONT_FACE, f);
     623            0 :         break;
     624              :     }
     625            0 :     case Pid::FONT_SIZE: {
     626            0 :         setPropertyFlags(Pid::BEGIN_FONT_SIZE, f);
     627            0 :         setPropertyFlags(Pid::CONTINUE_FONT_SIZE, f);
     628            0 :         setPropertyFlags(Pid::END_FONT_SIZE, f);
     629            0 :         break;
     630              :     }
     631            0 :     case Pid::FONT_STYLE: {
     632            0 :         setPropertyFlags(Pid::BEGIN_FONT_STYLE, f);
     633            0 :         setPropertyFlags(Pid::CONTINUE_FONT_STYLE, f);
     634            0 :         setPropertyFlags(Pid::END_FONT_STYLE, f);
     635            0 :         break;
     636              :     }
     637            0 :     case Pid::MUSICAL_SYMBOLS_SCALE: {
     638            0 :         setPropertyFlags(Pid::BEGIN_TEXT_MUSICAL_SYMBOLS_SCALE, f);
     639            0 :         setPropertyFlags(Pid::CONTINUE_TEXT_MUSICAL_SYMBOLS_SCALE, f);
     640            0 :         setPropertyFlags(Pid::END_TEXT_MUSICAL_SYMBOLS_SCALE, f);
     641            0 :         break;
     642              :     }
     643            0 :     case Pid::MUSIC_SYMBOL_SIZE: {
     644            0 :         setPropertyFlags(Pid::BEGIN_TEXT_MUSIC_SYMBOLS_SIZE, f);
     645            0 :         setPropertyFlags(Pid::CONTINUE_TEXT_MUSIC_SYMBOLS_SIZE, f);
     646            0 :         setPropertyFlags(Pid::END_TEXT_MUSIC_SYMBOLS_SIZE, f);
     647            0 :         break;
     648              :     }
     649              : 
     650         2428 :     default:
     651         2428 :         SLine::setPropertyFlags(id, f);
     652              :     }
     653         2428 : }
     654              : }
        

Generated by: LCOV version 2.0-1