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