LCOV - code coverage report
Current view: top level - src/engraving/dom - slur.h Coverage Total Hit
Test: filtered_coverage.info Lines: 95.5 % 22 21
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              : #pragma once
      24              : 
      25              : #include "slurtie.h"
      26              : 
      27              : #include "global/allocator.h"
      28              : 
      29              : namespace mu::engraving {
      30              : //---------------------------------------------------------
      31              : //   @@ SlurSegment
      32              : ///    a single segment of slur; also used for Tie
      33              : //---------------------------------------------------------
      34              : 
      35              : class SlurSegment : public SlurTieSegment
      36              : {
      37          872 :     OBJECT_ALLOCATOR(engraving, SlurSegment)
      38              :     DECLARE_CLASSOF(ElementType::SLUR_SEGMENT)
      39              : 
      40          929 :     M_PROPERTY2(double, extraHeight, setExtraHeight, 0.0)
      41          957 :     M_PROPERTY2(PointF, endPointOff1, setEndPointOff1, PointF(0.0, 0.0))
      42          957 :     M_PROPERTY2(PointF, endPointOff2, setEndPointOff2, PointF(0.0, 0.0))
      43              : 
      44              : public:
      45              :     SlurSegment(Slur* sp, ElementType type = ElementType::SLUR_SEGMENT);
      46              :     SlurSegment(const SlurSegment& ss);
      47              : 
      48           34 :     SlurSegment* clone() const override { return new SlurSegment(*this); }
      49              : 
      50              :     bool isEdited() const;
      51              :     bool isEndPointsEdited() const;
      52              :     bool isEditAllowed(EditData&) const override;
      53              :     bool edit(EditData&) override;
      54              : 
      55              :     void dragGrip(EditData& ed) override;
      56              : 
      57        18041 :     Slur* slur() const { return toSlur(spanner()); }
      58              : 
      59              :     double endWidth() const override;
      60              :     double midWidth() const override;
      61              :     double dottedWidth() const override;
      62              : 
      63              :     Color curColor(const rendering::PaintOptions& opt) const override;
      64              : 
      65              : protected:
      66              :     void changeAnchor(EditData&, EngravingItem*) override;
      67              : };
      68              : 
      69              : //---------------------------------------------------------
      70              : //   @@ Slur
      71              : //---------------------------------------------------------
      72              : 
      73              : class Slur : public SlurTie
      74              : {
      75          876 :     OBJECT_ALLOCATOR(engraving, Slur)
      76         3527 :     DECLARE_CLASSOF(ElementType::SLUR)
      77              : 
      78              : public:
      79              :     Slur(DummyParentOr<EngravingItem> parent, ElementType type = ElementType::SLUR);
      80              :     Slur(const Slur&);
      81              : 
      82       195050 :     Anchor anchor() const override { return Anchor::CHORDREST; }
      83              : 
      84              :     struct StemFloated
      85              :     {
      86              :         bool left = false;
      87              :         bool right = false;
      88          929 :         void reset()
      89              :         {
      90          929 :             left = false;
      91          929 :             right = false;
      92          929 :         }
      93              :     };
      94              : 
      95              :     /// temporary HACK for correct guitar pro import
      96              :     enum ConnectedElement : unsigned char {
      97              :         NONE,
      98              :         GLISSANDO
      99              :     };
     100              : 
     101          808 :     ~Slur() {}
     102              : 
     103           34 :     Slur* clone() const override { return new Slur(*this); }
     104              : 
     105              :     void setTrack(track_idx_t val) override;
     106              : 
     107              :     PropertyValue getProperty(Pid propertyId) const override;
     108              :     PropertyValue propertyDefault(Pid propertyId) const override;
     109              :     bool setProperty(Pid propertyId, const PropertyValue& v) override;
     110              : 
     111          958 :     SlurSegment* frontSegment() { return toSlurSegment(Spanner::frontSegment()); }
     112              :     const SlurSegment* frontSegment() const { return toSlurSegment(Spanner::frontSegment()); }
     113          863 :     SlurSegment* backSegment() { return toSlurSegment(Spanner::backSegment()); }
     114              :     const SlurSegment* backSegment() const { return toSlurSegment(Spanner::backSegment()); }
     115            0 :     SlurSegment* segmentAt(int n) { return toSlurSegment(Spanner::segmentAt(n)); }
     116              :     const SlurSegment* segmentAt(int n) const { return toSlurSegment(Spanner::segmentAt(n)); }
     117              : 
     118              :     bool isCrossStaff();
     119              :     bool hasCrossBeams();
     120              :     const StemFloated& stemFloated() const { return m_stemFloated; }
     121         2774 :     StemFloated& stemFloated() { return m_stemFloated; }
     122              : 
     123          468 :     SlurTieSegment* newSlurTieSegment() override { return new SlurSegment(this); }
     124              : 
     125              :     double scalingFactor() const override;
     126              : 
     127              :     void undoSetIncoming(bool incoming);
     128              :     void undoSetOutgoing(bool outgoing);
     129              :     void setIncoming(bool incoming);
     130              :     void setOutgoing(bool outgoing);
     131              :     bool isIncoming() const;
     132              :     bool isOutgoing() const;
     133              : 
     134              :     void undoChangeStartEndElements(ChordRest* scr, ChordRest* ecr);
     135              : 
     136              : private:
     137           10 :     M_PROPERTY2(ConnectedElement, connectedElement, setConnectedElement, ConnectedElement::NONE)
     138          314 :     M_PROPERTY2(PartialSpannerDirection, partialSpannerDirection, setPartialSpannerDirection, PartialSpannerDirection::NONE)
     139              : 
     140              :     PartialSpannerDirection calcIncomingDirection(bool incoming);
     141              :     PartialSpannerDirection calcOutgoingDirection(bool outgoing);
     142              : 
     143              :     friend class Factory;
     144              : 
     145              :     StemFloated m_stemFloated; // end point position is attached to stem but floated towards the note
     146              : };
     147              : } // namespace mu::engraving
        

Generated by: LCOV version 2.0-1