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 "systemtext.h"
24 :
25 : using namespace mu;
26 :
27 : namespace mu::engraving {
28 : //---------------------------------------------------------
29 : // systemStyle
30 : //---------------------------------------------------------
31 :
32 : static const ElementStyle systemStyle {
33 : { Sid::systemTextPlacement, Pid::PLACEMENT },
34 : { Sid::systemTextMinDistance, Pid::MIN_DISTANCE },
35 : };
36 :
37 : //---------------------------------------------------------
38 : // SystemText
39 : //---------------------------------------------------------
40 :
41 64 : SystemText::SystemText(DummyParentOr<Segment> parent, TextStyleType tid, ElementType type)
42 64 : : StaffTextBase(type, parent, tid, ElementFlag::SYSTEM | ElementFlag::MOVABLE | ElementFlag::ON_STAFF)
43 : {
44 64 : initElementStyle(&systemStyle);
45 64 : resetProperty(Pid::MUSIC_SYMBOL_SIZE);
46 64 : }
47 :
48 : //---------------------------------------------------------
49 : // isEditAllowed
50 : //---------------------------------------------------------
51 :
52 0 : bool SystemText::isEditAllowed(EditData& ed) const
53 : {
54 0 : bool ctrlPressed = ed.modifiers & ControlModifier;
55 0 : bool shiftPressed = ed.modifiers & ShiftModifier;
56 0 : bool altPressed = ed.modifiers & AltModifier;
57 0 : if (altPressed && !ctrlPressed && !shiftPressed && (ed.key == Key_Left || ed.key == Key_Right)) {
58 0 : return false;
59 : }
60 :
61 0 : return TextBase::isEditAllowed(ed);
62 : }
63 :
64 : //---------------------------------------------------------
65 : // propertyDefault
66 : //---------------------------------------------------------
67 :
68 338 : engraving::PropertyValue SystemText::propertyDefault(Pid id) const
69 : {
70 338 : switch (id) {
71 21 : case Pid::TEXT_STYLE:
72 21 : return TextStyleType::SYSTEM;
73 317 : default:
74 317 : return TextBase::propertyDefault(id);
75 : }
76 : }
77 : } // namespace mu::engraving
|