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 "stafftextbase.h"
24 :
25 : #include "score.h"
26 : #include "segment.h"
27 : #include "staff.h"
28 :
29 : #include "log.h"
30 :
31 : using namespace mu::engraving;
32 :
33 778 : StaffTextBase::StaffTextBase(const ElementType& type, DummyParentOr<Segment> parent, TextStyleType tid, ElementFlags flags)
34 3890 : : TextBase(type, parent, tid, flags)
35 : {
36 778 : setSwingParameters(Constants::DIVISION / 2, 60);
37 778 : }
38 :
39 212 : void StaffTextBase::clear()
40 : {
41 1060 : for (voice_idx_t voice = 0; voice < VOICES; ++voice) {
42 848 : m_channelNames[voice].clear();
43 : }
44 212 : clearAeolusStops();
45 212 : }
46 :
47 212 : void StaffTextBase::clearAeolusStops()
48 : {
49 1060 : for (int i = 0; i < 4; ++i) {
50 848 : m_aeolusStops[i] = 0;
51 : }
52 212 : }
53 :
54 0 : void StaffTextBase::setAeolusStop(int group, int idx, bool val)
55 : {
56 0 : if (val) {
57 0 : m_aeolusStops[group] |= (1 << idx);
58 : } else {
59 0 : m_aeolusStops[group] &= ~(1 << idx);
60 : }
61 0 : }
62 :
63 0 : void StaffTextBase::setAeolusStop(int group, int val)
64 : {
65 0 : m_aeolusStops[group] = val;
66 0 : }
67 :
68 0 : bool StaffTextBase::getAeolusStop(int group, int idx) const
69 : {
70 0 : return m_aeolusStops[group] & (1 << idx);
71 : }
72 :
73 0 : int StaffTextBase::aeolusStop(int group) const
74 : {
75 0 : return m_aeolusStops[group];
76 : }
77 :
78 146 : Segment* StaffTextBase::segment() const
79 : {
80 146 : if (!ownershipParent()->isSegment()) {
81 0 : LOGD("parent %s", ownershipParent()->typeName());
82 0 : return 0;
83 : }
84 146 : Segment* s = toSegment(ownershipParent());
85 146 : return s;
86 : }
87 :
88 768 : void StaffTextBase::added()
89 : {
90 768 : TextBase::added();
91 :
92 768 : Score* s = score();
93 768 : if (s && swing()) {
94 8 : s->updateSwing();
95 : }
96 768 : }
97 :
98 23 : void StaffTextBase::removed()
99 : {
100 23 : TextBase::removed();
101 :
102 23 : Score* s = score();
103 23 : if (s && swing()) {
104 0 : s->updateSwing();
105 : }
106 23 : }
|