LCOV - code coverage report
Current view: top level - src/engraving/dom - rasgueado.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 97.1 % 68 66
Test Date: 2026-11-19 04:14:36

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

Generated by: LCOV version 2.0-1