LCOV - code coverage report
Current view: top level - src/engraving/dom - tremolotwochord.h Coverage Total Hit
Test: filtered_coverage.info Lines: 68.0 % 25 17
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 "beambase.h"
      26              : #include "engravingitem.h"
      27              : 
      28              : #include "durationtype.h"
      29              : #include "draw/types/painterpath.h"
      30              : #include "../types/types.h"
      31              : #include "beam.h"
      32              : #include "chord.h"
      33              : 
      34              : namespace mu::engraving {
      35              : class Chord;
      36              : 
      37              : class TremoloTwoChord final : public BeamBase
      38              : {
      39          157 :     OBJECT_ALLOCATOR(engraving, TremoloTwoChord)
      40              :     DECLARE_CLASSOF(ElementType::TREMOLO_TWOCHORD)
      41              : 
      42              : public:
      43              : 
      44              :     TremoloTwoChord& operator=(const TremoloTwoChord&) = delete;
      45            0 :     TremoloTwoChord* clone() const override { return new TremoloTwoChord(*this); }
      46              :     ~TremoloTwoChord() override;
      47              : 
      48          226 :     Chord* chord() const { return toChord(ownershipParent()); }
      49              : 
      50            0 :     int subtype() const override { return static_cast<int>(m_tremoloType); }
      51              :     TranslatableString subtypeUserName() const override;
      52              : 
      53              :     void scanElements(std::function<void(EngravingItem*)> func) override;
      54              : 
      55              :     void setTremoloType(TremoloType t);
      56          134 :     TremoloType tremoloType() const { return m_tremoloType; }
      57              : 
      58              :     double minHeight() const;
      59              :     void reset() override;
      60              : 
      61              :     PointF chordBeamAnchor(const ChordRest* chord, ChordBeamAnchorType anchorType) const;
      62              : 
      63              :     double chordMag() const;
      64              :     RectF drag(EditData&) override;
      65              : 
      66        10959 :     Chord* chord1() const { return m_chord1; }
      67          458 :     void setChord1(Chord* ch) { m_chord1 = ch; }
      68         5374 :     Chord* chord2() const { return m_chord2; }
      69           61 :     void setChord2(Chord* ch) { m_chord2 = ch; }
      70          109 :     void setChords(Chord* c1, Chord* c2)
      71              :     {
      72          109 :         m_chord1 = c1;
      73          109 :         m_chord2 = c2;
      74          109 :     }
      75              : 
      76              :     PairF beamPos() const;
      77              : 
      78              :     TDuration durationType() const;
      79              :     void setDurationType(TDuration d);
      80              : 
      81              :     Fraction tremoloLen() const;
      82         9421 :     int lines() const { return m_lines; }
      83              : 
      84              :     bool crossStaffBeamBetween() const;
      85              : 
      86              :     String accessibleInfo() const override;
      87              :     void triggerLayout() const override;
      88              : 
      89          554 :     TremoloStyle tremoloStyle() const { return m_style; }
      90           31 :     void setTremoloStyle(TremoloStyle v) { m_style = v; }
      91              :     void setDirection(DirectionV v) override;
      92            0 :     void setBeamFragment(const BeamFragment& bf) { m_beamFragment = bf; }
      93          102 :     const BeamFragment& beamFragment() const { return m_beamFragment; }
      94          790 :     BeamFragment& beamFragment() { return m_beamFragment; }
      95              : 
      96            1 :     bool playTremolo() const { return m_playTremolo; }
      97            0 :     void setPlayTremolo(bool v) { m_playTremolo = v; }
      98              : 
      99              :     bool customStyleApplicable() const;
     100              : 
     101              :     PropertyValue getProperty(Pid propertyId) const override;
     102              :     bool setProperty(Pid propertyId, const PropertyValue&) override;
     103              :     PropertyValue propertyDefault(Pid propertyId) const override;
     104              : 
     105              :     bool needStartEditingAfterSelecting() const override;
     106              :     int gripsCount() const override;
     107              :     Grip initialEditModeGrip() const override;
     108              :     Grip defaultGrip() const override;
     109              :     std::vector<PointF> gripsPositions(const EditData&) const override;
     110            0 :     bool isMovable() const override { return true; }
     111            0 :     bool isEditable() const override { return true; }
     112              :     void dragGrip(EditData&) override;
     113              : 
     114              :     void clearBeamSegments() override;
     115              : 
     116              :     int maxCRMove() const override;
     117              :     int minCRMove() const override;
     118              : 
     119              :     //! NOTE for palettes
     120              :     muse::draw::PainterPath basePath(double stretch = 0) const;
     121            0 :     const muse::draw::PainterPath& path() const { return m_path; }
     122            0 :     void setPath(const muse::draw::PainterPath& p) { m_path = p; }
     123              :     void computeShape();
     124              :     //! -----------------
     125              : 
     126              : private:
     127              :     friend class Factory;
     128              : 
     129              :     TremoloTwoChord(DummyParentOr<Chord> parent);
     130              :     TremoloTwoChord(const TremoloTwoChord&);
     131              : 
     132              :     void setBeamPos(const PairF& bp);
     133              : 
     134              :     TremoloType m_tremoloType = TremoloType::INVALID_TREMOLO;
     135              :     Chord* m_chord1 = nullptr;
     136              :     Chord* m_chord2 = nullptr;
     137              :     TDuration m_durationType;
     138              :     bool m_playTremolo = true;
     139              : 
     140              :     int m_lines = 0;         // derived from _subtype
     141              :     TremoloStyle m_style = TremoloStyle::DEFAULT;
     142              :     // for _startAnchor and _slope, once we decide to change trems so that they can
     143              :     // continue from one system to the other (or indeed, one measure to the other)
     144              :     // we will want a vector of fragments similar to Beam's _beamFragments structure.
     145              :     // for now, a single fragment is sufficient
     146              :     BeamFragment m_beamFragment;
     147              : 
     148              :     //! NOTE for palette
     149              :     PainterPath m_path;
     150              : };
     151              : }
        

Generated by: LCOV version 2.0-1