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) 2026 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 "notationsceneconfiguration.h"
24 :
25 : #include "global/translation.h"
26 :
27 : #include "muse_framework_config.h"
28 :
29 : #include "settings.h"
30 :
31 : using namespace mu::notation;
32 : using namespace muse;
33 : using namespace muse::async;
34 :
35 : static const std::string module_name("notation");
36 :
37 : static const Settings::Key PLAYBACK_SMOOTH_PANNING(module_name, "application/playback/smoothPan");
38 :
39 : static const Settings::Key IS_LIMIT_CANVAS_SCROLL_AREA_KEY(module_name, "ui/canvas/scroll/limitScrollArea");
40 :
41 : static const Settings::Key PIANO_KEYBOARD_NUMBER_OF_KEYS(module_name, "pianoKeyboard/numberOfKeys");
42 :
43 : static const Settings::Key PERCUSSION_PANEL_USE_NOTATION_PREVIEW_KEY(module_name, "ui/percussionPanelUseNotationPreview");
44 : static const Settings::Key PERCUSSION_PANEL_AUTO_SHOW_MODE_KEY(module_name, "ui/percussionPanelAutoShowMode");
45 : static const Settings::Key AUTO_CLOSE_PERCUSSION_PANEL_KEY(module_name, "ui/autoClosePercussionPanel");
46 : static const Settings::Key SHOW_PERCUSSION_PANEL_SWAP_DIALOG(module_name, "ui/showPercussionPanelPadSwapDialog");
47 : static const Settings::Key PERCUSSION_PANEL_MOVE_MIDI_NOTES_AND_SHORTCUTS(module_name, "ui/percussionPanelMoveMidiNotesAndShortcuts");
48 :
49 0 : NotationSceneConfiguration::NotationSceneConfiguration()
50 : {
51 0 : }
52 :
53 0 : void NotationSceneConfiguration::init()
54 : {
55 0 : settings()->setDefaultValue(PLAYBACK_SMOOTH_PANNING, Val(false));
56 0 : settings()->setDescription(PLAYBACK_SMOOTH_PANNING, muse::trc("notation", "Smooth panning"));
57 0 : settings()->setCanBeManuallyEdited(PLAYBACK_SMOOTH_PANNING, true);
58 0 : settings()->valueChanged(PLAYBACK_SMOOTH_PANNING).onReceive(this, [this](const Val&) {
59 0 : m_isSmoothPanningChanged.notify();
60 0 : });
61 :
62 0 : settings()->setDefaultValue(IS_LIMIT_CANVAS_SCROLL_AREA_KEY, Val(false));
63 0 : settings()->valueChanged(IS_LIMIT_CANVAS_SCROLL_AREA_KEY).onReceive(this, [this](const Val&) {
64 0 : m_isLimitCanvasScrollAreaChanged.notify();
65 0 : });
66 :
67 0 : settings()->setDefaultValue(PIANO_KEYBOARD_NUMBER_OF_KEYS, Val(88));
68 0 : m_pianoKeyboardNumberOfKeys.val = settings()->value(PIANO_KEYBOARD_NUMBER_OF_KEYS).toInt();
69 0 : settings()->valueChanged(PIANO_KEYBOARD_NUMBER_OF_KEYS).onReceive(this, [this](const Val& val) {
70 0 : m_pianoKeyboardNumberOfKeys.set(val.toInt());
71 0 : });
72 :
73 0 : settings()->setDefaultValue(PERCUSSION_PANEL_USE_NOTATION_PREVIEW_KEY, Val(false));
74 0 : settings()->valueChanged(PERCUSSION_PANEL_USE_NOTATION_PREVIEW_KEY).onReceive(this, [this](const Val&) {
75 0 : m_percussionPanelUseNotationPreviewChanged.notify();
76 0 : });
77 :
78 0 : settings()->setDefaultValue(PERCUSSION_PANEL_AUTO_SHOW_MODE_KEY, Val(PercussionPanelAutoShowMode::UNPITCHED_STAFF));
79 0 : settings()->valueChanged(PERCUSSION_PANEL_AUTO_SHOW_MODE_KEY).onReceive(this, [this](const Val&) {
80 0 : m_percussionPanelAutoShowModeChanged.notify();
81 0 : });
82 :
83 0 : settings()->setDefaultValue(AUTO_CLOSE_PERCUSSION_PANEL_KEY, Val(true));
84 0 : settings()->valueChanged(AUTO_CLOSE_PERCUSSION_PANEL_KEY).onReceive(this, [this](const Val&) {
85 0 : m_autoClosePercussionPanelChanged.notify();
86 0 : });
87 :
88 0 : settings()->setDefaultValue(SHOW_PERCUSSION_PANEL_SWAP_DIALOG, Val(true));
89 0 : settings()->valueChanged(SHOW_PERCUSSION_PANEL_SWAP_DIALOG).onReceive(this, [this](const Val&) {
90 0 : m_showPercussionPanelPadSwapDialogChanged.notify();
91 0 : });
92 :
93 0 : settings()->setDefaultValue(PERCUSSION_PANEL_MOVE_MIDI_NOTES_AND_SHORTCUTS, Val(true));
94 0 : settings()->valueChanged(PERCUSSION_PANEL_MOVE_MIDI_NOTES_AND_SHORTCUTS).onReceive(this, [this](const Val&) {
95 0 : m_percussionPanelMoveMidiNotesAndShortcutsChanged.notify();
96 0 : });
97 0 : }
98 :
99 0 : bool NotationSceneConfiguration::isSmoothPanning() const
100 : {
101 0 : return settings()->value(PLAYBACK_SMOOTH_PANNING).toBool();
102 : }
103 :
104 0 : void NotationSceneConfiguration::setIsSmoothPanning(bool value)
105 : {
106 0 : settings()->setSharedValue(PLAYBACK_SMOOTH_PANNING, Val(value));
107 0 : }
108 :
109 0 : Notification NotationSceneConfiguration::isSmoothPanningChanged() const
110 : {
111 0 : return m_isSmoothPanningChanged;
112 : }
113 :
114 0 : bool NotationSceneConfiguration::isLimitCanvasScrollArea() const
115 : {
116 0 : return settings()->value(IS_LIMIT_CANVAS_SCROLL_AREA_KEY).toBool();
117 : }
118 :
119 0 : void NotationSceneConfiguration::setIsLimitCanvasScrollArea(bool limited)
120 : {
121 0 : settings()->setSharedValue(IS_LIMIT_CANVAS_SCROLL_AREA_KEY, Val(limited));
122 0 : }
123 :
124 0 : Notification NotationSceneConfiguration::isLimitCanvasScrollAreaChanged() const
125 : {
126 0 : return m_isLimitCanvasScrollAreaChanged;
127 : }
128 :
129 0 : ValCh<int> NotationSceneConfiguration::pianoKeyboardNumberOfKeys() const
130 : {
131 0 : return m_pianoKeyboardNumberOfKeys;
132 : }
133 :
134 0 : void NotationSceneConfiguration::setPianoKeyboardNumberOfKeys(int number)
135 : {
136 0 : settings()->setSharedValue(PIANO_KEYBOARD_NUMBER_OF_KEYS, Val(number));
137 0 : }
138 :
139 0 : bool NotationSceneConfiguration::percussionPanelUseNotationPreview() const
140 : {
141 0 : return settings()->value(PERCUSSION_PANEL_USE_NOTATION_PREVIEW_KEY).toBool();
142 : }
143 :
144 0 : void NotationSceneConfiguration::setPercussionPanelUseNotationPreview(bool use)
145 : {
146 0 : settings()->setSharedValue(PERCUSSION_PANEL_USE_NOTATION_PREVIEW_KEY, Val(use));
147 0 : }
148 :
149 0 : Notification NotationSceneConfiguration::percussionPanelUseNotationPreviewChanged() const
150 : {
151 0 : return m_percussionPanelUseNotationPreviewChanged;
152 : }
153 :
154 0 : PercussionPanelAutoShowMode NotationSceneConfiguration::percussionPanelAutoShowMode() const
155 : {
156 0 : return settings()->value(PERCUSSION_PANEL_AUTO_SHOW_MODE_KEY).toEnum<PercussionPanelAutoShowMode>();
157 : }
158 :
159 0 : void NotationSceneConfiguration::setPercussionPanelAutoShowMode(PercussionPanelAutoShowMode autoShowMode)
160 : {
161 0 : settings()->setSharedValue(PERCUSSION_PANEL_AUTO_SHOW_MODE_KEY, Val(autoShowMode));
162 0 : }
163 :
164 0 : Notification NotationSceneConfiguration::percussionPanelAutoShowModeChanged() const
165 : {
166 0 : return m_percussionPanelAutoShowModeChanged;
167 : }
168 :
169 0 : bool NotationSceneConfiguration::autoClosePercussionPanel() const
170 : {
171 0 : return settings()->value(AUTO_CLOSE_PERCUSSION_PANEL_KEY).toBool();
172 : }
173 :
174 0 : void NotationSceneConfiguration::setAutoClosePercussionPanel(bool autoClose)
175 : {
176 0 : settings()->setSharedValue(AUTO_CLOSE_PERCUSSION_PANEL_KEY, Val(autoClose));
177 0 : }
178 :
179 0 : Notification NotationSceneConfiguration::autoClosePercussionPanelChanged() const
180 : {
181 0 : return m_autoClosePercussionPanelChanged;
182 : }
183 :
184 0 : bool NotationSceneConfiguration::showPercussionPanelPadSwapDialog() const
185 : {
186 0 : return settings()->value(SHOW_PERCUSSION_PANEL_SWAP_DIALOG).toBool();
187 : }
188 :
189 0 : void NotationSceneConfiguration::setShowPercussionPanelPadSwapDialog(bool show)
190 : {
191 0 : settings()->setSharedValue(SHOW_PERCUSSION_PANEL_SWAP_DIALOG, Val(show));
192 0 : }
193 :
194 0 : Notification NotationSceneConfiguration::showPercussionPanelPadSwapDialogChanged() const
195 : {
196 0 : return m_showPercussionPanelPadSwapDialogChanged;
197 : }
198 :
199 0 : bool NotationSceneConfiguration::percussionPanelMoveMidiNotesAndShortcuts() const
200 : {
201 0 : return settings()->value(PERCUSSION_PANEL_MOVE_MIDI_NOTES_AND_SHORTCUTS).toBool();
202 : }
203 :
204 0 : void NotationSceneConfiguration::setPercussionPanelMoveMidiNotesAndShortcuts(bool move)
205 : {
206 0 : settings()->setSharedValue(PERCUSSION_PANEL_MOVE_MIDI_NOTES_AND_SHORTCUTS, Val(move));
207 0 : }
208 :
209 0 : Notification NotationSceneConfiguration::percussionPanelMoveMidiNotesAndShortcutsChanged() const
210 : {
211 0 : return m_percussionPanelMoveMidiNotesAndShortcutsChanged;
212 : }
|