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 "global/allocator.h"
26 : #include "draw/types/geometry.h"
27 :
28 : namespace mu::engraving {
29 : class EngravingItem;
30 : class EditData;
31 :
32 : //-------------------------------------------------------------------
33 : // ElementGroup
34 : /// Base class for implementing logic to handle groups of elements
35 : /// together in certain operations.
36 : //-------------------------------------------------------------------
37 :
38 : class ElementGroup
39 : {
40 0 : OBJECT_ALLOCATOR(engraving, ElementGroup)
41 : public:
42 0 : virtual ~ElementGroup() {}
43 :
44 : virtual void startDrag(EditData&) = 0;
45 : virtual muse::RectF drag(EditData&) = 0;
46 : virtual void endDrag(EditData&) = 0;
47 :
48 0 : virtual bool enabled() const { return true; }
49 : };
50 :
51 : //-------------------------------------------------------------------
52 : // DisabledElementGroup
53 : //-------------------------------------------------------------------
54 :
55 : class DisabledElementGroup final : public ElementGroup
56 : {
57 0 : OBJECT_ALLOCATOR(engraving, DisabledElementGroup)
58 : public:
59 0 : bool enabled() const override { return false; }
60 :
61 0 : void startDrag(EditData&) override {}
62 0 : muse::RectF drag(EditData&) override { return muse::RectF(); }
63 0 : void endDrag(EditData&) override {}
64 : };
65 :
66 : //-------------------------------------------------------------------
67 : // SingleElementGroup
68 : /// EngravingItem group for single element.
69 : //-------------------------------------------------------------------
70 :
71 : class SingleElementGroup final : public ElementGroup
72 : {
73 0 : OBJECT_ALLOCATOR(engraving, SingleElementGroup)
74 :
75 : public:
76 0 : SingleElementGroup(EngravingItem* el)
77 0 : : m_e(el) {}
78 :
79 : void startDrag(EditData& ed) override;
80 : muse::RectF drag(EditData& ed) override;
81 : void endDrag(EditData& ed) override;
82 :
83 : private:
84 : EngravingItem* m_e = nullptr;
85 : };
86 : }
|