LCOV - code coverage report
Current view: top level - src/engraving/dom - letring.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 94.3 % 70 66
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 "letring.h"
      24              : 
      25              : #include "score.h"
      26              : #include "system.h"
      27              : #include "text.h"
      28              : 
      29              : #include "log.h"
      30              : 
      31              : using namespace mu;
      32              : using namespace mu::engraving;
      33              : 
      34              : namespace mu::engraving {
      35              : static const ElementStyle letRingStyle {
      36              :     { Sid::letRingFontFace,                      Pid::BEGIN_FONT_FACE },
      37              :     { Sid::letRingFontFace,                      Pid::CONTINUE_FONT_FACE },
      38              :     { Sid::letRingFontFace,                      Pid::END_FONT_FACE },
      39              :     { Sid::letRingFontSize,                      Pid::BEGIN_FONT_SIZE },
      40              :     { Sid::letRingFontSize,                      Pid::CONTINUE_FONT_SIZE },
      41              :     { Sid::letRingFontSize,                      Pid::END_FONT_SIZE },
      42              :     { Sid::letRingFontStyle,                     Pid::BEGIN_FONT_STYLE },
      43              :     { Sid::letRingFontStyle,                     Pid::CONTINUE_FONT_STYLE },
      44              :     { Sid::letRingFontStyle,                     Pid::END_FONT_STYLE },
      45              :     { Sid::letRingTextAlign,                     Pid::BEGIN_TEXT_ALIGN },
      46              :     { Sid::letRingTextAlign,                     Pid::CONTINUE_TEXT_ALIGN },
      47              :     { Sid::letRingTextAlign,                     Pid::END_TEXT_ALIGN },
      48              :     { Sid::letRingPosition,                      Pid::BEGIN_TEXT_POSITION },
      49              :     { Sid::letRingPosition,                      Pid::CONTINUE_TEXT_POSITION },
      50              :     { Sid::letRingPosition,                      Pid::END_TEXT_POSITION },
      51              :     { Sid::letRingHookHeight,                    Pid::BEGIN_HOOK_HEIGHT },
      52              :     { Sid::letRingHookHeight,                    Pid::END_HOOK_HEIGHT },
      53              :     { Sid::letRingLineStyle,                     Pid::LINE_STYLE },
      54              :     { Sid::letRingDashLineLen,                   Pid::DASH_LINE_LEN },
      55              :     { Sid::letRingDashGapLen,                    Pid::DASH_GAP_LEN },
      56              :     { Sid::letRingFontSpatiumDependent,          Pid::TEXT_SIZE_SPATIUM_DEPENDENT },
      57              :     { Sid::letRingEndHookType,                   Pid::END_HOOK_TYPE },
      58              :     { Sid::letRingLineWidth,                     Pid::LINE_WIDTH },
      59              :     { Sid::letRingPlacement,                     Pid::PLACEMENT },
      60              :     { Sid::letRingMusicalSymbolSize,             Pid::BEGIN_TEXT_MUSIC_SYMBOLS_SIZE },
      61              :     { Sid::letRingMusicalSymbolSize,             Pid::CONTINUE_TEXT_MUSIC_SYMBOLS_SIZE },
      62              :     { Sid::letRingMusicalSymbolSize,             Pid::END_TEXT_MUSIC_SYMBOLS_SIZE },
      63              :     { Sid::dummyMusicalSymbolsScale,             Pid::BEGIN_TEXT_MUSICAL_SYMBOLS_SCALE },
      64              :     { Sid::dummyMusicalSymbolsScale,             Pid::CONTINUE_TEXT_MUSICAL_SYMBOLS_SCALE },
      65              :     { Sid::dummyMusicalSymbolsScale,             Pid::END_TEXT_MUSICAL_SYMBOLS_SCALE },
      66              : };
      67              : 
      68           31 : LetRingSegment::LetRingSegment(LetRing* sp)
      69           31 :     : TextLineBaseSegment(ElementType::LET_RING_SEGMENT, sp, ElementFlag::MOVABLE | ElementFlag::ON_STAFF)
      70              : {
      71           31 :     m_text->setTextStyleType(propertyDefault(Pid::TEXT_STYLE).value<TextStyleType>());
      72           31 :     m_endText->setTextStyleType(propertyDefault(Pid::TEXT_STYLE).value<TextStyleType>());
      73           31 : }
      74              : 
      75              : //---------------------------------------------------------
      76              : //   LetRing
      77              : //---------------------------------------------------------
      78              : 
      79           88 : LetRing::LetRing(DummyParentOr<EngravingItem> parent)
      80           88 :     : ChordTextLineBase(ElementType::LET_RING, parent)
      81              : {
      82           88 :     initElementStyle(&letRingStyle);
      83           88 :     resetProperty(Pid::LINE_VISIBLE);
      84              : 
      85           88 :     resetProperty(Pid::BEGIN_TEXT_PLACE);
      86           88 :     resetProperty(Pid::BEGIN_TEXT);
      87           88 :     resetProperty(Pid::CONTINUE_TEXT_PLACE);
      88           88 :     resetProperty(Pid::CONTINUE_TEXT);
      89           88 :     resetProperty(Pid::END_TEXT_PLACE);
      90           88 :     resetProperty(Pid::END_TEXT);
      91           88 : }
      92              : 
      93              : static const ElementStyle letRingSegmentStyle {
      94              :     { Sid::letRingMinDistance,    Pid::MIN_DISTANCE },
      95              : };
      96              : 
      97              : //---------------------------------------------------------
      98              : //   createLineSegment
      99              : //---------------------------------------------------------
     100              : 
     101           31 : LineSegment* LetRing::createLineSegment()
     102              : {
     103           31 :     LetRingSegment* lr = new LetRingSegment(this);
     104           31 :     lr->setTrack(track());
     105           31 :     lr->initElementStyle(&letRingSegmentStyle);
     106           31 :     return lr;
     107              : }
     108              : 
     109              : //---------------------------------------------------------
     110              : //   propertyDefault
     111              : //---------------------------------------------------------
     112              : 
     113         2276 : PropertyValue LetRing::propertyDefault(Pid propertyId) const
     114              : {
     115         2276 :     switch (propertyId) {
     116            2 :     case Pid::LINE_WIDTH:
     117            2 :         return style().styleV(Sid::letRingLineWidth);
     118              : 
     119            0 :     case Pid::ALIGN:
     120            0 :         return Align(AlignH::LEFT, AlignV::BASELINE);
     121              : 
     122            2 :     case Pid::LINE_STYLE:
     123            2 :         return style().styleV(Sid::letRingLineStyle);
     124              : 
     125          140 :     case Pid::LINE_VISIBLE:
     126          140 :         return true;
     127              : 
     128          156 :     case Pid::BEGIN_TEXT_OFFSET:
     129              :     case Pid::CONTINUE_TEXT_OFFSET:
     130              :     case Pid::END_TEXT_OFFSET:
     131          156 :         return PropertyValue::fromValue(PointF(0, 0));
     132              : 
     133            2 :     case Pid::BEGIN_FONT_STYLE:
     134            2 :         return style().styleV(Sid::letRingFontStyle);
     135              : 
     136          280 :     case Pid::BEGIN_TEXT:
     137              :     case Pid::CONTINUE_TEXT:
     138          280 :         return style().styleV(Sid::letRingText);
     139          140 :     case Pid::END_TEXT:
     140          140 :         return "";
     141              : 
     142           52 :     case Pid::BEGIN_HOOK_TYPE:
     143           52 :         return HookType::NONE;
     144              : 
     145          420 :     case Pid::BEGIN_TEXT_PLACE:
     146              :     case Pid::CONTINUE_TEXT_PLACE:
     147              :     case Pid::END_TEXT_PLACE:
     148          420 :         return TextPlace::AUTO;
     149           62 :     case Pid::TEXT_STYLE:
     150           62 :         return TextStyleType::LET_RING;
     151              : 
     152          416 :     case Pid::BEGIN_FILLED_ARROW_HEIGHT:   // No arrow endings for let ring
     153              :     case Pid::BEGIN_FILLED_ARROW_WIDTH:
     154              :     case Pid::END_FILLED_ARROW_HEIGHT:
     155              :     case Pid::END_FILLED_ARROW_WIDTH:
     156              :     case Pid::BEGIN_LINE_ARROW_HEIGHT:
     157              :     case Pid::BEGIN_LINE_ARROW_WIDTH:
     158              :     case Pid::END_LINE_ARROW_HEIGHT:
     159              :     case Pid::END_LINE_ARROW_WIDTH:
     160          416 :         return 0.0;
     161              : 
     162          604 :     default:
     163          604 :         return TextLineBase::propertyDefault(propertyId);
     164              :     }
     165              : }
     166              : 
     167              : //---------------------------------------------------------
     168              : //   getPropertyStyle
     169              : //---------------------------------------------------------
     170              : 
     171         2874 : Sid LetRing::getPropertyStyle(Pid id) const
     172              : {
     173         2874 :     switch (id) {
     174           95 :     case Pid::PLACEMENT:
     175           95 :         return Sid::letRingPlacement;
     176           95 :     case Pid::BEGIN_FONT_FACE:
     177           95 :         return Sid::letRingFontFace;
     178          285 :     case Pid::BEGIN_FONT_SIZE:
     179              :     case Pid::CONTINUE_FONT_SIZE:
     180              :     case Pid::END_FONT_SIZE:
     181          285 :         return Sid::letRingFontSize;
     182          283 :     case Pid::BEGIN_FONT_STYLE:
     183              :     case Pid::CONTINUE_FONT_STYLE:
     184              :     case Pid::END_FONT_STYLE:
     185          283 :         return Sid::letRingFontStyle;
     186          285 :     case Pid::BEGIN_TEXT_ALIGN:
     187              :     case Pid::CONTINUE_TEXT_ALIGN:
     188              :     case Pid::END_TEXT_ALIGN:
     189          285 :         return Sid::letRingTextAlign;
     190          190 :     case Pid::BEGIN_HOOK_HEIGHT:
     191              :     case Pid::END_HOOK_HEIGHT:
     192          190 :         return Sid::letRingHookHeight;
     193            0 :     case Pid::BEGIN_TEXT:
     194            0 :         return Sid::letRingText;
     195         1641 :     default:
     196         1641 :         break;
     197              :     }
     198         1641 :     return TextLineBase::getPropertyStyle(id);
     199              : }
     200              : 
     201           31 : Sid LetRing::defaultPosSid() const
     202              : {
     203           31 :     return placeAbove() ? Sid::letRingPosAbove : Sid::letRingPosBelow;
     204              : }
     205              : }
        

Generated by: LCOV version 2.0-1