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

Generated by: LCOV version 2.0-1