LCOV - code coverage report
Current view: top level - src/engraving/dom - hairpin.h Coverage Total Hit
Test: filtered_coverage.info Lines: 80.0 % 45 36
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              : #pragma once
      24              : 
      25              : #include "../types/types.h"
      26              : 
      27              : #include "textlinebase.h"
      28              : 
      29              : namespace mu::engraving {
      30              : class Hairpin;
      31              : class Transaction;
      32              : 
      33              : enum class HairpinType : signed char {
      34              :     INVALID = -1,
      35              :     CRESC_HAIRPIN,
      36              :     DIM_HAIRPIN,
      37              :     CRESC_LINE,
      38              :     DIM_LINE
      39              : };
      40              : 
      41              : //---------------------------------------------------------
      42              : //   @@ HairpinSegment
      43              : //---------------------------------------------------------
      44              : 
      45              : class HairpinSegment final : public TextLineBaseSegment
      46              : {
      47          559 :     OBJECT_ALLOCATOR(engraving, HairpinSegment)
      48              :     DECLARE_CLASSOF(ElementType::HAIRPIN_SEGMENT)
      49              : 
      50              : public:
      51              :     HairpinSegment(Hairpin* sp);
      52              : 
      53           17 :     HairpinSegment* clone() const override { return new HairpinSegment(*this); }
      54              : 
      55         8084 :     Hairpin* hairpin() const { return (Hairpin*)spanner(); }
      56              : 
      57          914 :     bool drawCircledTip() const { return m_drawCircledTip; }
      58          485 :     void setDrawCircledTip(bool arg) { m_drawCircledTip = arg; }
      59         1365 :     double circledTipRadius() const { return m_circledTipRadius; }
      60          483 :     void setCircledTipRadius(double r) { m_circledTipRadius = r; }
      61            3 :     PointF circledTip() const { return m_circledTip; }
      62          458 :     void setCircledTip(const PointF& p) { m_circledTip = p; }
      63              : 
      64              :     PropertyDelegate resolvePropertyDelegate(Pid) const override;
      65              : 
      66              :     int gripsCount() const override;
      67              :     std::vector<PointF> gripsPositions(const EditData& = EditData()) const override;
      68              : 
      69              :     std::unique_ptr<ElementGroup> getDragGroup(std::function<bool(const EngravingItem*)> isDragged) override;
      70              : 
      71          172 :     bool hasVoiceAssignmentProperties() const override { return spanner()->hasVoiceAssignmentProperties(); }
      72              : 
      73              :     EngravingItem* findElementToSnapBefore(bool ignoreInvisible = true) const;
      74              :     EngravingItem* findElementToSnapAfter(bool ignoreInvisible = true, bool requirePlayable = false) const;
      75              : 
      76              :     void endDragGrip(EditData& ed) override;
      77              : 
      78              : private:
      79              :     TextBase* findStartDynamicOrExpression(bool ignoreInvisible = true) const;
      80              :     TextBase* findEndDynamicOrExpression(bool ignoreInvisible = true, bool requirePlayable = false) const;
      81              : 
      82              :     void startDragGrip(EditData&) override;
      83              :     void dragGrip(EditData&) override;
      84              : 
      85              :     Sid getPropertyStyle(Pid) const override;
      86              : 
      87              :     bool acceptDrop(EditData&) const override;
      88              :     EngravingItem* drop(Transaction& tx, EditData&) override;
      89              : 
      90              :     void setPropertyFlags(Pid id, PropertyFlags f) override;
      91              : 
      92              :     bool m_drawCircledTip = false;
      93              :     PointF m_circledTip;
      94              :     double m_circledTipRadius = 0.0;
      95              : };
      96              : 
      97              : //---------------------------------------------------------
      98              : //   @@ Hairpin
      99              : //   @P hairpinType  enum (Hairpin.CRESCENDO, Hairpin.DIMINUENDO)
     100              : //   @P veloChange   int
     101              : //---------------------------------------------------------
     102              : 
     103              : class Hairpin final : public TextLineBase
     104              : {
     105          725 :     OBJECT_ALLOCATOR(engraving, Hairpin)
     106         1756 :     DECLARE_CLASSOF(ElementType::HAIRPIN)
     107              : 
     108              : public:
     109              :     Hairpin(DummyParent* parent);
     110              : 
     111           22 :     Hairpin* clone() const override { return new Hairpin(*this); }
     112              :     void setOwnershipParent(EngravingObject*) = delete;
     113              : 
     114         5535 :     Anchor anchor() const override { return Anchor::SEGMENT; }
     115              : 
     116              :     DynamicType dynamicTypeFrom() const;
     117              :     DynamicType dynamicTypeTo() const;
     118              : 
     119              :     const Dynamic* dynamicSnappedBefore() const;
     120              :     const Dynamic* dynamicSnappedAfter() const;
     121              : 
     122         2861 :     HairpinType hairpinType() const { return m_hairpinType; }
     123              :     void setHairpinType(HairpinType val);
     124              : 
     125              :     LineSegment* createLineSegment() override;
     126              : 
     127          593 :     bool hairpinCircledTip() const { return m_hairpinCircledTip; }
     128            3 :     void setHairpinCircledTip(bool val) { m_hairpinCircledTip = val; }
     129              : 
     130            8 :     int veloChange() const { return m_veloChange; }
     131           21 :     void setVeloChange(int v) { m_veloChange = v; }
     132              : 
     133          457 :     Spatium hairpinHeight() const { return m_hairpinHeight; }
     134            0 :     void setHairpinHeight(Spatium val) { m_hairpinHeight = val; }
     135              : 
     136          457 :     Spatium hairpinContHeight() const { return m_hairpinContHeight; }
     137            0 :     void setHairpinContHeight(Spatium val) { m_hairpinContHeight = val; }
     138              : 
     139              :     bool singleNoteDynamics() const { return m_singleNoteDynamics; }
     140            0 :     void setSingleNoteDynamics(bool val) { m_singleNoteDynamics = val; }
     141              : 
     142            8 :     ChangeMethod veloChangeMethod() const { return m_veloChangeMethod; }
     143            0 :     void setVeloChangeMethod(ChangeMethod val) { m_veloChangeMethod = val; }
     144              : 
     145           38 :     bool isCrescendo() const
     146              :     {
     147           38 :         return m_hairpinType == HairpinType::CRESC_HAIRPIN || m_hairpinType == HairpinType::CRESC_LINE;
     148              :     }
     149              : 
     150            0 :     bool isDecrescendo() const
     151              :     {
     152            0 :         return m_hairpinType == HairpinType::DIM_HAIRPIN || m_hairpinType == HairpinType::DIM_LINE;
     153              :     }
     154              : 
     155              :     PropertyValue getProperty(Pid id) const override;
     156              :     bool setProperty(Pid propertyId, const PropertyValue&) override;
     157              :     PropertyValue propertyDefault(Pid id) const override;
     158              : 
     159              :     String accessibleInfo() const override;
     160         5373 :     bool isLineType() const
     161              :     {
     162         5373 :         return m_hairpinType == HairpinType::CRESC_LINE || m_hairpinType == HairpinType::DIM_LINE;
     163              :     }
     164              : 
     165              :     PointF linePos(Grip grip, System** system) const override;
     166              : 
     167          852 :     bool hasVoiceAssignmentProperties() const override { return true; }
     168              : 
     169              :     void reset() override;
     170              : 
     171           13 :     void setVoiceAssignment(VoiceAssignment v) { m_voiceAssignment = v; }
     172         1031 :     VoiceAssignment voiceAssignment() const { return m_voiceAssignment; }
     173           55 :     void setDirection(DirectionV v) { m_direction = v; }
     174          636 :     DirectionV direction() const { return m_direction; }
     175            9 :     void setCenterBetweenStaves(AutoOnOff v) { m_centerBetweenStaves = v; }
     176          825 :     AutoOnOff centerBetweenStaves() const { return m_centerBetweenStaves; }
     177              : 
     178          283 :     bool snapToItemBefore() const { return m_snapToItemBefore; }
     179            0 :     void setSnapToItemBefore(bool v) { m_snapToItemBefore = v; }
     180          317 :     bool snapToItemAfter() const { return m_snapToItemAfter; }
     181            0 :     void setSnapToItemAfter(bool v) { m_snapToItemAfter = v; }
     182              : 
     183            0 :     int subtype() const override { return int(m_hairpinType); }
     184              :     TranslatableString subtypeUserName() const override;
     185              : 
     186              : protected:
     187              :     Sid defaultPosSid() const override;
     188              : 
     189              : private:
     190              : 
     191              :     Sid getPropertyStyle(Pid) const override;
     192              : 
     193              :     HairpinType m_hairpinType = HairpinType::INVALID;
     194              :     int m_veloChange = 0;
     195              :     bool m_hairpinCircledTip = false;
     196              :     bool m_singleNoteDynamics = false;
     197              :     ChangeMethod m_veloChangeMethod = ChangeMethod::NORMAL;
     198              : 
     199              :     Spatium m_hairpinHeight;
     200              :     Spatium m_hairpinContHeight;
     201              : 
     202              :     VoiceAssignment m_voiceAssignment = VoiceAssignment::ALL_VOICE_IN_INSTRUMENT;
     203              :     DirectionV m_direction = DirectionV::AUTO;
     204              :     AutoOnOff m_centerBetweenStaves = AutoOnOff::AUTO;
     205              : 
     206              :     bool m_snapToItemBefore = true;
     207              :     bool m_snapToItemAfter = true;
     208              : };
     209              : } // namespace mu::engraving
     210              : 
     211              : #ifndef NO_QT_SUPPORT
     212           18 : Q_DECLARE_METATYPE(mu::engraving::HairpinType)
     213              : #endif
        

Generated by: LCOV version 2.0-1