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