LCOV - code coverage report
Current view: top level - src/engraving/dom - systemdivider.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 37.0 % 54 20
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 "systemdivider.h"
      24              : 
      25              : #include "types/symnames.h"
      26              : 
      27              : #include "score.h"
      28              : #include "system.h"
      29              : 
      30              : using namespace mu;
      31              : using namespace mu::engraving;
      32              : 
      33              : namespace mu::engraving {
      34              : //---------------------------------------------------------
      35              : //   SystemDivider
      36              : //---------------------------------------------------------
      37              : 
      38              : static const ElementStyle dividerStyle {
      39              :     { Sid::dividerLeftSize, Pid::SYMBOLS_SIZE }, // left or right is decided later
      40              :     { Sid::musicalSymbolFont, Pid::SCORE_FONT }
      41              : };
      42              : 
      43           14 : SystemDivider::SystemDivider(DummyParentOr<System> parent)
      44           14 :     : Symbol(ElementType::SYSTEM_DIVIDER, parent, ElementFlag::SYSTEM | ElementFlag::MOVABLE)
      45              : {
      46              :     // default value, but not valid until setDividerType()
      47           14 :     m_dividerType = SystemDividerType::LEFT;
      48           14 :     m_sym = SymId::systemDivider;
      49           14 : }
      50              : 
      51              : //---------------------------------------------------------
      52              : //   SystemDivider
      53              : //---------------------------------------------------------
      54              : 
      55            0 : SystemDivider::SystemDivider(const SystemDivider& sd)
      56            0 :     : Symbol(sd)
      57              : {
      58            0 :     m_dividerType = sd.m_dividerType;
      59            0 : }
      60              : 
      61              : //---------------------------------------------------------
      62              : //   setDividerType
      63              : //---------------------------------------------------------
      64              : 
      65           14 : void SystemDivider::setDividerType(SystemDividerType v)
      66              : {
      67           14 :     m_dividerType = v;
      68              : 
      69           14 :     if (v == SystemDividerType::LEFT) {
      70            7 :         setSym(SymNames::symIdByName(style().styleSt(Sid::dividerLeftSym)));
      71              :     } else {
      72            7 :         setSym(SymNames::symIdByName(style().styleSt(Sid::dividerRightSym)));
      73              :     }
      74              : 
      75           14 :     initElementStyle(&dividerStyle);
      76           14 : }
      77              : 
      78            0 : void SystemDivider::styleChanged()
      79              : {
      80            0 :     if (m_dividerType == SystemDividerType::LEFT) {
      81            0 :         setSym(SymNames::symIdByName(style().styleSt(Sid::dividerLeftSym)));
      82              :     } else {
      83            0 :         setSym(SymNames::symIdByName(style().styleSt(Sid::dividerRightSym)));
      84              :     }
      85              : 
      86            0 :     if (isStyled(Pid::SYMBOLS_SIZE)) {
      87            0 :         m_symbolsSize = style().styleD(getPropertyStyle(Pid::SYMBOLS_SIZE));
      88              :     }
      89              : 
      90            0 :     Symbol::styleChanged();
      91            0 : }
      92              : 
      93           30 : Sid SystemDivider::getPropertyStyle(Pid id) const
      94              : {
      95           30 :     if (id == Pid::SYMBOLS_SIZE) {
      96           14 :         return m_dividerType == SystemDividerType::LEFT ? Sid::dividerLeftSize : Sid::dividerRightSize;
      97              :     }
      98              : 
      99           16 :     return Symbol::getPropertyStyle(id);
     100              : }
     101              : 
     102            0 : std::vector<LineF> SystemDivider::dragAnchorLines() const
     103              : {
     104            0 :     std::vector<LineF> result;
     105              : 
     106            0 :     const System* system = this->system();
     107            0 :     IF_ASSERT_FAILED(system) {
     108            0 :         return result;
     109              :     }
     110              : 
     111            0 :     RectF systemBBox = system->canvasBoundingRect();
     112            0 :     PointF p1 =  PointF(m_dividerType == SystemDividerType::LEFT
     113            0 :                         ? systemBBox.left() + system->leftMargin() : systemBBox.right(), systemBBox.bottom());
     114              : 
     115            0 :     RectF thisBBox = canvasBoundingRect();
     116            0 :     PointF p2 = 0.5 * (thisBBox.topLeft() + thisBBox.bottomRight());
     117              : 
     118            0 :     result.push_back(LineF(p1, p2));
     119              : 
     120            0 :     return result;
     121            0 : }
     122              : 
     123            0 : void SystemDivider::reset()
     124              : {
     125            0 :     Symbol::reset();
     126            0 :     setGenerated(true);
     127            0 : }
     128              : 
     129              : //---------------------------------------------------------
     130              : //   drag
     131              : //---------------------------------------------------------
     132              : 
     133            0 : RectF SystemDivider::drag(EditData& ed)
     134              : {
     135            0 :     setGenerated(false);
     136            0 :     return Symbol::drag(ed);
     137              : }
     138              : 
     139           21 : PropertyValue SystemDivider::propertyDefault(Pid id) const
     140              : {
     141           21 :     switch (id) {
     142            0 :     case Pid::SYMBOLS_SIZE:
     143            0 :         return style().styleD(m_dividerType == SystemDividerType::LEFT ? Sid::dividerLeftSize : Sid::dividerRightSize);
     144           21 :     default:
     145           21 :         return Symbol::propertyDefault(id);
     146              :     }
     147              : }
     148              : } // namespace mu::engraving
        

Generated by: LCOV version 2.0-1