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_STAFFSTATE_H
24 : #define MU_ENGRAVING_STAFFSTATE_H
25 :
26 : #include "engravingitem.h"
27 : #include "instrument.h"
28 : #include "draw/types/painterpath.h"
29 :
30 : namespace mu::engraving {
31 : class Transaction;
32 :
33 : enum class StaffStateType : char {
34 : INSTRUMENT,
35 : TYPE,
36 : VISIBLE,
37 : INVISIBLE
38 : };
39 :
40 : //---------------------------------------------------------
41 : // @@ StaffState
42 : //---------------------------------------------------------
43 :
44 : class StaffState final : public EngravingItem
45 : {
46 0 : OBJECT_ALLOCATOR(engraving, StaffState)
47 1106 : DECLARE_CLASSOF(ElementType::STAFF_STATE)
48 :
49 : public:
50 :
51 : ~StaffState();
52 :
53 0 : StaffState* clone() const override { return new StaffState(*this); }
54 :
55 : void setStaffStateType(const String&);
56 0 : void setStaffStateType(StaffStateType st) { m_staffStateType = st; }
57 0 : StaffStateType staffStateType() const { return m_staffStateType; }
58 : String staffStateTypeName() const;
59 :
60 : bool acceptDrop(EditData&) const override;
61 : EngravingItem* drop(Transaction& tx, EditData&) override;
62 :
63 0 : Instrument* instrument() const { return m_instrument; }
64 : void setInstrument(const Instrument* i) { *m_instrument = *i; }
65 0 : void setInstrument(const Instrument&& i) { *m_instrument = i; }
66 : Segment* segment() { return (Segment*)ownershipParent(); }
67 :
68 : struct LayoutData : public EngravingItem::LayoutData {
69 : double lw = 0.0;
70 : muse::draw::PainterPath path;
71 : };
72 0 : DECLARE_LAYOUTDATA_METHODS(StaffState)
73 :
74 : private:
75 :
76 : friend class Factory;
77 : StaffState(DummyParentOr<EngravingItem> parent);
78 : StaffState(const StaffState&);
79 :
80 : StaffStateType m_staffStateType = StaffStateType::INVISIBLE;
81 :
82 : Instrument* m_instrument = nullptr;
83 : };
84 : } // namespace mu::engraving
85 : #endif
|