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_DYNAMICHAIRPINGROUP_H
24 : #define MU_ENGRAVING_DYNAMICHAIRPINGROUP_H
25 :
26 : #include <memory>
27 : #include <functional>
28 :
29 : #include "elementgroup.h"
30 : #include "draw/types/geometry.h"
31 :
32 : namespace mu::engraving {
33 : class Dynamic;
34 : class Hairpin;
35 : class HairpinSegment;
36 : class Expression;
37 :
38 : //-------------------------------------------------------------------
39 : // HairpinWithDynamicsDragGroup
40 : /// Sequence of Dynamics and Hairpins
41 : //-------------------------------------------------------------------
42 :
43 : class HairpinWithDynamicsDragGroup : public ElementGroup
44 : {
45 0 : OBJECT_ALLOCATOR(engraving, HairpinWithDynamicsDragGroup)
46 :
47 : public:
48 0 : HairpinWithDynamicsDragGroup(Dynamic* start, HairpinSegment* hs, Dynamic* end)
49 0 : : m_startDynamic(start), m_hairpinSegment(hs), m_endDynamic(end) {}
50 :
51 : void startDrag(EditData&) override;
52 : muse::RectF drag(EditData&) override;
53 : void endDrag(EditData&) override;
54 :
55 : static std::unique_ptr<ElementGroup> detectFor(HairpinSegment* hs, std::function<bool(const EngravingItem*)> isDragged);
56 : static std::unique_ptr<ElementGroup> detectFor(Dynamic* d, std::function<bool(const EngravingItem*)> isDragged);
57 :
58 : private:
59 :
60 : Dynamic* m_startDynamic = nullptr;
61 : HairpinSegment* m_hairpinSegment = nullptr;
62 : Dynamic* m_endDynamic = nullptr;
63 : };
64 :
65 : //-------------------------------------------------------------------
66 : // DynamicNearHairpinsDragGroup
67 : //-------------------------------------------------------------------
68 :
69 : class DynamicNearHairpinsDragGroup : public ElementGroup
70 : {
71 0 : OBJECT_ALLOCATOR(engraving, DynamicNearHairpinsDragGroup)
72 :
73 : public:
74 0 : DynamicNearHairpinsDragGroup(Hairpin* left, Dynamic* d, Hairpin* right)
75 0 : : m_leftHairpin(left), m_dynamic(d), m_rightHairpin(right) {}
76 :
77 : void startDrag(EditData&) override;
78 : muse::RectF drag(EditData&) override;
79 : void endDrag(EditData&) override;
80 :
81 : static std::unique_ptr<ElementGroup> detectFor(Dynamic* d, std::function<bool(const EngravingItem*)> isDragged);
82 :
83 : private:
84 : Hairpin* m_leftHairpin = nullptr;
85 : Dynamic* m_dynamic = nullptr;
86 : Hairpin* m_rightHairpin = nullptr;
87 : };
88 :
89 : //-------------------------------------------------------------------
90 : // DynamicExpressionDragGroup
91 : //-------------------------------------------------------------------
92 :
93 : class DynamicExpressionDragGroup : public ElementGroup
94 : {
95 0 : OBJECT_ALLOCATOR(engraving, DynamicNearHairpinsDragGroup)
96 :
97 : public:
98 0 : DynamicExpressionDragGroup(Dynamic* d, Expression* e)
99 0 : : m_dynamic(d), m_expression(e) {}
100 :
101 : void startDrag(EditData& ed) override;
102 : muse::RectF drag(EditData& ed) override;
103 : void endDrag(EditData& ed) override;
104 :
105 : static std::unique_ptr<ElementGroup> detectFor(Dynamic* d, std::function<bool(const EngravingItem*)> isDragged);
106 : static std::unique_ptr<ElementGroup> detectFor(Expression* e, std::function<bool(const EngravingItem*)> isDragged);
107 :
108 : private:
109 : Dynamic* m_dynamic = nullptr;
110 : Expression* m_expression = nullptr;
111 : };
112 : } // namespace mu::engraving
113 :
114 : #endif
|