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 : #include "draw/types/painterpath.h"
27 :
28 : namespace mu::engraving {
29 : class Factory;
30 :
31 : //---------------------------------------------------------
32 : // SpacerType
33 : //---------------------------------------------------------
34 :
35 : enum class SpacerType : char {
36 : UP, DOWN, FIXED
37 : };
38 :
39 : //-------------------------------------------------------------------
40 : // @@ Spacer
41 : /// Vertical spacer element to adjust the distance of staves.
42 : //-------------------------------------------------------------------
43 :
44 : class Spacer final : public EngravingItem
45 : {
46 2 : OBJECT_ALLOCATOR(engraving, Spacer)
47 1106 : DECLARE_CLASSOF(ElementType::SPACER)
48 :
49 : public:
50 :
51 0 : Spacer* clone() const override { return new Spacer(*this); }
52 0 : void setOwnershipParent(DummyParentOr<Measure> parent) { EngravingItem::setOwnershipParent(parent); }
53 0 : Measure* measure() const { return toMeasure(ownershipParent()); }
54 :
55 13 : SpacerType spacerType() const { return m_spacerType; }
56 1 : void setSpacerType(SpacerType t) { m_spacerType = t; }
57 :
58 0 : int subtype() const override { return int(m_spacerType); }
59 : TranslatableString subtypeUserName() const override;
60 :
61 0 : bool isEditable() const override { return true; }
62 : void startDragGrip(EditData&) override;
63 : void dragGrip(EditData&) override;
64 :
65 : void setGap(Spatium sp);
66 1 : Spatium gap() const { return m_gap; }
67 :
68 8 : double absoluteGap() const { return absoluteFromSpatium(m_gap); }
69 :
70 0 : bool needStartEditingAfterSelecting() const override { return true; }
71 0 : int gripsCount() const override { return 1; }
72 0 : Grip initialEditModeGrip() const override { return Grip::START; }
73 0 : Grip defaultGrip() const override { return Grip::START; }
74 : std::vector<PointF> gripsPositions(const EditData&) const override;
75 :
76 : PropertyValue getProperty(Pid propertyId) const override;
77 : bool setProperty(Pid propertyId, const PropertyValue&) override;
78 : PropertyValue propertyDefault(Pid id) const override;
79 : void triggerLayout() const override;
80 :
81 : struct LayoutData : public EngravingItem::LayoutData {
82 : PainterPath path;
83 : };
84 3 : DECLARE_LAYOUTDATA_METHODS(Spacer)
85 :
86 : private:
87 :
88 : friend class Factory;
89 : Spacer(DummyParentOr<Measure> parent);
90 : Spacer(const Spacer&);
91 :
92 : SpacerType m_spacerType = SpacerType::UP;
93 : Spatium m_gap;
94 : };
95 : }
|