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 : #include "staffstate.h"
24 :
25 : #include "draw/types/pen.h"
26 :
27 : #include "part.h"
28 : #include "score.h"
29 :
30 : #include "log.h"
31 :
32 : using namespace mu;
33 : using namespace muse::draw;
34 :
35 : namespace mu::engraving {
36 : //---------------------------------------------------------
37 : // StaffState
38 : //---------------------------------------------------------
39 :
40 0 : StaffState::StaffState(DummyParentOr<EngravingItem> parent)
41 0 : : EngravingItem(ElementType::STAFF_STATE, parent)
42 : {
43 0 : m_staffStateType = StaffStateType::INSTRUMENT;
44 0 : m_instrument = new Instrument;
45 0 : }
46 :
47 0 : StaffState::StaffState(const StaffState& ss)
48 0 : : EngravingItem(ss)
49 : {
50 0 : m_instrument = new Instrument(*ss.m_instrument);
51 0 : }
52 :
53 0 : StaffState::~StaffState()
54 : {
55 0 : delete m_instrument;
56 0 : }
57 :
58 : //---------------------------------------------------------
59 : // setStaffStateType
60 : //---------------------------------------------------------
61 :
62 0 : void StaffState::setStaffStateType(const String& s)
63 : {
64 0 : if (s == "instrument") {
65 0 : setStaffStateType(StaffStateType::INSTRUMENT);
66 0 : } else if (s == "type") {
67 0 : setStaffStateType(StaffStateType::TYPE);
68 0 : } else if (s == "visible") {
69 0 : setStaffStateType(StaffStateType::VISIBLE);
70 0 : } else if (s == "invisible") {
71 0 : setStaffStateType(StaffStateType::INVISIBLE);
72 : }
73 0 : }
74 :
75 : //---------------------------------------------------------
76 : // staffStateTypeName
77 : //---------------------------------------------------------
78 :
79 0 : String StaffState::staffStateTypeName() const
80 : {
81 0 : switch (staffStateType()) {
82 0 : case StaffStateType::INSTRUMENT:
83 0 : return u"instrument";
84 0 : case StaffStateType::TYPE:
85 0 : return u"type";
86 0 : case StaffStateType::VISIBLE:
87 0 : return u"visible";
88 0 : case StaffStateType::INVISIBLE:
89 0 : return u"invisible";
90 0 : default:
91 0 : return u"??";
92 : }
93 : }
94 :
95 : //---------------------------------------------------------
96 : // acceptDrop
97 : //---------------------------------------------------------
98 :
99 0 : bool StaffState::acceptDrop(EditData&) const
100 : {
101 0 : return false;
102 : }
103 :
104 : //---------------------------------------------------------
105 : // drop
106 : //---------------------------------------------------------
107 :
108 0 : EngravingItem* StaffState::drop(Transaction&, EditData& data)
109 : {
110 0 : EngravingItem* e = data.dropElement;
111 0 : score()->undoChangeElement(this, e);
112 0 : return e;
113 : }
114 : }
|