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 : #ifndef MU_ENGRAVING_GRADUALTEMPOCHANGE_H
24 : #define MU_ENGRAVING_GRADUALTEMPOCHANGE_H
25 :
26 : #include <optional>
27 :
28 : #include "textlinebase.h"
29 : #include "../types/types.h"
30 :
31 : namespace mu::engraving {
32 : class GradualTempoChangeSegment;
33 : class GradualTempoChange : public TextLineBase
34 : {
35 185 : OBJECT_ALLOCATOR(engraving, GradualTempoChange)
36 1756 : DECLARE_CLASSOF(ElementType::GRADUAL_TEMPO_CHANGE)
37 :
38 : public:
39 : GradualTempoChange(DummyParent* parent);
40 :
41 : GradualTempoChange* clone() const override;
42 : void setOwnershipParent(EngravingObject*) = delete;
43 :
44 377 : Anchor anchor() const override { return Anchor::SEGMENT; }
45 :
46 : LineSegment* createLineSegment() override;
47 :
48 : GradualTempoChangeType tempoChangeType() const;
49 : ChangeMethod easingMethod() const;
50 : void setTempoChangeType(const GradualTempoChangeType type);
51 :
52 : double tempoChangeFactor() const;
53 :
54 : PropertyValue getProperty(Pid id) const override;
55 : bool setProperty(Pid id, const PropertyValue& val) override;
56 : PropertyValue propertyDefault(Pid propertyId) const override;
57 : Sid getPropertyStyle(Pid id) const override;
58 :
59 : TranslatableString subtypeUserName() const override;
60 :
61 72 : bool snapToItemAfter() const { return m_snapToItemAfter; }
62 0 : void setSnapToItemAfter(bool v) { m_snapToItemAfter = v; }
63 :
64 : bool adjustForRehearsalMark(bool start) const;
65 : PointF linePos(Grip grip, System** system) const override;
66 :
67 : protected:
68 : Sid defaultPosSid() const override;
69 :
70 : private:
71 : GradualTempoChangeType m_tempoChangeType = GradualTempoChangeType::Undefined;
72 : ChangeMethod m_tempoEasingMethod = ChangeMethod::NORMAL;
73 : std::optional<float> m_tempoChangeFactor;
74 :
75 : bool m_snapToItemAfter = true;
76 :
77 : bool m_alignRightOfRehearsalMark = true;
78 :
79 : friend class GradualTempoChangeSegment;
80 : };
81 :
82 : class GradualTempoChangeSegment : public TextLineBaseSegment
83 : {
84 25 : OBJECT_ALLOCATOR(engraving, GradualTempoChangeSegment)
85 : DECLARE_CLASSOF(ElementType::GRADUAL_TEMPO_CHANGE_SEGMENT)
86 :
87 : public:
88 : GradualTempoChangeSegment(GradualTempoChange* annotation);
89 :
90 : GradualTempoChangeSegment* clone() const override;
91 :
92 : GradualTempoChange* tempoChange() const;
93 :
94 : void endEdit(EditData& editData) override;
95 :
96 : GradualTempoChangeSegment* findElementToSnapBefore() const;
97 : TempoText* findElementToSnapAfter() const;
98 :
99 : friend class GradualTempoChange;
100 : };
101 : }
102 :
103 : #endif // MU_ENGRAVING_GRADUALTEMPOCHANGE_H
|