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 : #include "durationtype.h"
28 : #include "draw/types/painterpath.h"
29 : #include "../types/types.h"
30 : #include "beam.h"
31 : #include "chord.h"
32 :
33 : namespace mu::engraving {
34 : class Chord;
35 : class TremoloSingleChord final : public EngravingItem
36 : {
37 305 : OBJECT_ALLOCATOR(engraving, TremoloSingleChord)
38 : DECLARE_CLASSOF(ElementType::TREMOLO_SINGLECHORD)
39 :
40 : public:
41 :
42 : TremoloSingleChord& operator=(const TremoloSingleChord&) = delete;
43 1 : TremoloSingleChord* clone() const override { return new TremoloSingleChord(*this); }
44 59 : void setOwnershipParent(DummyParentOr<Chord> parent) { EngravingItem::setOwnershipParent(parent); }
45 : ~TremoloSingleChord() override;
46 :
47 10107 : Chord* chord() const { return toChord(ownershipParent()); }
48 :
49 0 : int subtype() const override { return static_cast<int>(m_tremoloType); }
50 : TranslatableString subtypeUserName() const override;
51 :
52 : void scanElements(std::function<void(EngravingItem*)> func) override;
53 :
54 : void setTremoloType(TremoloType t);
55 386 : TremoloType tremoloType() const { return m_tremoloType; }
56 :
57 : double minHeight() const;
58 :
59 : double chordMag() const;
60 : RectF drag(EditData&) override;
61 :
62 : TDuration durationType() const;
63 : void setDurationType(TDuration d);
64 :
65 : Fraction tremoloLen() const;
66 3035 : bool isBuzzRoll() const { return m_tremoloType == TremoloType::BUZZ_ROLL; }
67 :
68 1183 : int lines() const { return m_lines; }
69 :
70 : void spatiumChanged(double oldValue, double newValue) override;
71 : void localSpatiumChanged(double oldValue, double newValue) override;
72 : void styleChanged() override;
73 : staff_idx_t vStaffIdx() const override;
74 : String accessibleInfo() const override;
75 :
76 109 : bool playTremolo() const { return m_playTremolo; }
77 1 : void setPlayTremolo(bool v) { m_playTremolo = v; }
78 :
79 : PropertyValue getProperty(Pid propertyId) const override;
80 : bool setProperty(Pid propertyId, const PropertyValue&) override;
81 : PropertyValue propertyDefault(Pid propertyId) const override;
82 :
83 0 : bool isMovable() const override { return true; }
84 :
85 : muse::draw::PainterPath basePath(double stretch = 0) const;
86 0 : const muse::draw::PainterPath& path() const { return m_path; }
87 412 : void setPath(const muse::draw::PainterPath& p) { m_path = p; }
88 :
89 : void computeShape();
90 :
91 : private:
92 : friend class Factory;
93 :
94 : TremoloSingleChord(DummyParentOr<Chord> parent);
95 : TremoloSingleChord(const TremoloSingleChord&);
96 :
97 : TremoloType m_tremoloType = TremoloType::INVALID_TREMOLO;
98 : TDuration m_durationType;
99 : muse::draw::PainterPath m_path;
100 : bool m_playTremolo = true;
101 :
102 : int m_lines = 0; // derived from _subtype
103 : };
104 : } // namespace mu::engraving
|