LCOV - code coverage report
Current view: top level - src/engraving/dom - arpeggio.h Coverage Total Hit
Test: filtered_coverage.info Lines: 60.0 % 25 15
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 "engravingitem.h"
      26              : 
      27              : namespace mu::engraving {
      28              : class Chord;
      29              : class Factory;
      30              : class Transaction;
      31              : 
      32              : //---------------------------------------------------------
      33              : //   @@ Arpeggio
      34              : //---------------------------------------------------------
      35              : 
      36              : enum class AnchorRebaseDirection : unsigned char {
      37              :     UP,
      38              :     DOWN
      39              : };
      40              : 
      41              : class Arpeggio : public EngravingItem
      42              : {
      43          319 :     OBJECT_ALLOCATOR(engraving, Arpeggio)
      44         2389 :     DECLARE_CLASSOF(ElementType::ARPEGGIO)
      45              : 
      46              : public:
      47              : 
      48              :     ~Arpeggio() override;
      49            0 :     Arpeggio* clone() const override { return new Arpeggio(*this); }
      50            0 :     void setOwnershipParent(DummyParentOr<Chord> parent) { EngravingItem::setOwnershipParent(parent); }
      51              : 
      52         1587 :     ArpeggioType arpeggioType() const { return m_arpeggioType; }
      53          145 :     void setArpeggioType(ArpeggioType v) { m_arpeggioType = v; }
      54              :     const TranslatableString& arpeggioTypeName() const;
      55              : 
      56            0 :     int subtype() const override { return int(m_arpeggioType); }
      57              :     TranslatableString subtypeUserName() const override;
      58              : 
      59         9504 :     Chord* chord() const { return (Chord*)ownershipParent(); }
      60              : 
      61              :     bool acceptDrop(EditData&) const override;
      62              :     EngravingItem* drop(Transaction& tx, EditData&) override;
      63              : 
      64            0 :     bool isEditable() const override { return true; }
      65              :     bool isEditAllowed(EditData&) const override;
      66              :     bool edit(EditData&) override;
      67              :     void dragGrip(EditData&) override;
      68              : 
      69              :     void reset() override;
      70              : 
      71         1561 :     int span() const { return m_span; }
      72           64 :     void setSpan(int val) { m_span = val; }
      73          671 :     track_idx_t endTrack() const { return track() + m_span - 1; }
      74              : 
      75              :     bool crossStaff() const;
      76              :     staff_idx_t vStaffIdx() const override;
      77              :     void findAndAttachToChords();
      78              :     void detachFromChords(track_idx_t strack, track_idx_t etrack);
      79              :     void rebaseStartAnchor(AnchorRebaseDirection direction);
      80              :     void rebaseEndAnchor(AnchorRebaseDirection direction);
      81              : 
      82         1046 :     double userLen1() const { return m_userLen1; }
      83          580 :     double userLen2() const { return m_userLen2; }
      84            3 :     void setUserLen1(double v) { m_userLen1 = v; }
      85            0 :     void setUserLen2(double v) { m_userLen2 = v; }
      86              : 
      87           18 :     bool playArpeggio() const { return m_playArpeggio; }
      88            0 :     void setPlayArpeggio(bool p) { m_playArpeggio = p; }
      89              : 
      90          151 :     double Stretch() const { return m_stretch; }
      91           15 :     void setStretch(double val) { m_stretch = val; }
      92              : 
      93              :     PropertyValue getProperty(Pid propertyId) const override;
      94              :     bool setProperty(Pid propertyId, const PropertyValue&) override;
      95              :     PropertyValue propertyDefault(Pid propertyId) const override;
      96              : 
      97            0 :     bool needStartEditingAfterSelecting() const override { return true; }
      98            0 :     int gripsCount() const override { return 3; }
      99            0 :     Grip initialEditModeGrip() const override { return Grip::END; }
     100            0 :     Grip defaultGrip() const override { return Grip::MIDDLE; }
     101              :     std::vector<PointF> gripsPositions(const EditData& = EditData()) const override;
     102              : 
     103              :     struct LayoutData : public EngravingItem::LayoutData {
     104              :         // cache
     105              :         double top = 0.0;
     106              :         double bottom = 0.0;
     107              :         double magS = 0.0;
     108              :         double maxChordPad = 0.0;
     109              :         double minChordX = 0.0;
     110              : 
     111              :         // out
     112              :         SymIdList symbols;
     113              :         RectF symsBBox;
     114              :         double arpeggioHeight = -1.0;
     115              :     };
     116         5780 :     DECLARE_LAYOUTDATA_METHODS(Arpeggio)
     117              : 
     118              : protected:
     119              :     friend class Factory;
     120              : 
     121              :     Arpeggio(DummyParentOr<Chord> parent, ElementType type = ElementType::ARPEGGIO);
     122              : 
     123              : private:
     124              :     void spatiumChanged(double /*oldValue*/, double /*newValue*/) override;
     125              :     std::vector<LineF> dragAnchorLines() const override;
     126              :     std::vector<LineF> gripAnchorLines(Grip) const override;
     127              :     void startEdit(EditData&) override;
     128              :     void startDragGrip(EditData&) override;
     129              : 
     130              :     ArpeggioType m_arpeggioType = ArpeggioType::NORMAL;
     131              :     double m_userLen1 = 0.0;
     132              :     double m_userLen2 = 0.0;
     133              : 
     134              :     int m_span = 1;                // how many voices the arpeggio spans
     135              :     bool m_playArpeggio = true;
     136              : 
     137              :     double m_stretch = 1.0;
     138              : };
     139              : }
        

Generated by: LCOV version 2.0-1