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 : #pragma once
23 :
24 : #include "async/asyncable.h"
25 :
26 : #include "modularity/ioc.h"
27 : #include "global/iglobalconfiguration.h"
28 : #include "io/ifilesystem.h"
29 : #include "ui/iuiconfiguration.h"
30 : #include "engraving/iengravingconfiguration.h"
31 :
32 : #include "../inotationconfiguration.h"
33 :
34 : namespace mu::notation {
35 : class NotationConfiguration : public INotationConfiguration, public muse::async::Asyncable
36 : {
37 : muse::GlobalInject<muse::IGlobalConfiguration> globalConfiguration;
38 : muse::GlobalInject<muse::io::IFileSystem> fileSystem;
39 : muse::GlobalInject<muse::ui::IUiConfiguration> uiConfiguration;
40 : muse::GlobalInject<engraving::IEngravingConfiguration> engravingConfiguration;
41 :
42 : public:
43 0 : NotationConfiguration() = default;
44 :
45 : void init();
46 :
47 : QColor notationColor() const override;
48 : void setNotationColor(const QColor& color) override;
49 : muse::async::Notification notationColorChanged() const override;
50 : void resetNotationColor() override;
51 :
52 : QColor backgroundColor() const override;
53 : void setBackgroundColor(const QColor& color) override;
54 :
55 : muse::io::path_t backgroundWallpaperPath() const override;
56 : const QPixmap& backgroundWallpaper() const override;
57 : void setBackgroundWallpaperPath(const muse::io::path_t& path) override;
58 :
59 : bool backgroundUseColor() const override;
60 : void setBackgroundUseColor(bool value) override;
61 :
62 : void resetBackground() override;
63 :
64 : muse::async::Notification backgroundChanged() const override;
65 :
66 : QColor foregroundColor() const override;
67 : void setForegroundColor(const QColor& color) override;
68 :
69 : muse::io::path_t foregroundWallpaperPath() const override;
70 : const QPixmap& foregroundWallpaper() const override;
71 : void setForegroundWallpaperPath(const muse::io::path_t& path) override;
72 :
73 : bool foregroundUseColor() const override;
74 : void setForegroundUseColor(bool value) override;
75 :
76 : void resetForeground() override;
77 :
78 : muse::async::Notification foregroundChanged() const override;
79 :
80 : muse::io::path_t wallpapersDefaultDirPath() const override;
81 :
82 : bool shouldInvertScore() const override; // Whether score should be inverted now, based on theme.
83 :
84 : bool scoreInversionEnabled() const override;
85 : void setScoreInversionEnabled(bool value) override;
86 : muse::async::Notification scoreInversionChanged() const override;
87 :
88 : bool isOnlyInvertInDarkTheme() const override;
89 : void setOnlyInvertInDarkTheme(bool value) override;
90 : muse::async::Notification isOnlyInvertInDarkThemeChanged() const override;
91 :
92 : QColor borderColor() const override;
93 : int borderWidth() const override;
94 :
95 : QColor playbackCursorColor() const override;
96 : QColor loopMarkerColor() const override;
97 : int cursorOpacity() const override;
98 :
99 : bool thinNoteInputCursor() const override;
100 :
101 : QColor selectionColor(engraving::voice_idx_t voiceIndex = 0) const override;
102 : QColor highlightSelectionColor(engraving::voice_idx_t voiceIndex = 0) const override;
103 :
104 : QColor dropRectColor() const override;
105 :
106 : muse::draw::Color noteInputPreviewColor() const override;
107 :
108 : bool useNoteInputCursorInInputByDuration() const override;
109 : void setUseNoteInputCursorInInputByDuration(bool use) override;
110 : muse::async::Notification useNoteInputCursorInInputByDurationChanged() const override;
111 :
112 : int selectionProximity() const override;
113 : void setSelectionProximity(int proximity) override;
114 : muse::async::Channel<int> selectionProximityChanged() const override;
115 :
116 : ZoomType defaultZoomType() const override;
117 : void setDefaultZoomType(ZoomType zoomType) override;
118 :
119 : int defaultZoom() const override;
120 : void setDefaultZoom(int zoomPercentage) override;
121 : muse::async::Notification defaultZoomChanged() const override;
122 :
123 : QList<int> possibleZoomPercentageList() const override;
124 :
125 : mu::engraving::AutomationType currentAutomationType() const override;
126 : void setCurrentAutomationType(mu::engraving::AutomationType type) override;
127 : muse::async::Notification currentAutomationTypeChanged() const override;
128 :
129 : int mouseZoomPrecision() const override;
130 : void setMouseZoomPrecision(int precision) override;
131 : muse::async::Notification mouseZoomPrecisionChanged() const override;
132 :
133 : std::string fontFamily() const override;
134 : int fontSize() const override;
135 :
136 : muse::io::path_t userStylesPath() const override;
137 : void setUserStylesPath(const muse::io::path_t& path) override;
138 : muse::async::Channel<muse::io::path_t> userStylesPathChanged() const override;
139 :
140 : muse::io::path_t defaultStyleFilePath() const override;
141 : void setDefaultStyleFilePath(const muse::io::path_t& path) override;
142 : muse::async::Channel<muse::io::path_t> defaultStyleFilePathChanged() const override;
143 :
144 : muse::io::path_t partStyleFilePath() const override;
145 : void setPartStyleFilePath(const muse::io::path_t& path) override;
146 : muse::async::Channel<muse::io::path_t> partStyleFilePathChanged() const override;
147 :
148 : NoteInputMethod defaultNoteInputMethod() const override;
149 : void setDefaultNoteInputMethod(NoteInputMethod method) override;
150 : muse::async::Notification defaultNoteInputMethodChanged() const override;
151 :
152 : bool addAccidentalDotsArticulationsToNextNoteEntered() const override;
153 : void setAddAccidentalDotsArticulationsToNextNoteEntered(bool value) override;
154 : muse::async::Notification addAccidentalDotsArticulationsToNextNoteEnteredChanged() const override;
155 :
156 : muse::io::path_t userMusicFontsPath() const override;
157 : void setUserMusicFontsPath(const muse::io::path_t& path) override;
158 : muse::async::Channel<muse::io::path_t> userMusicFontsPathChanged() const override;
159 :
160 : bool isMidiInputEnabled() const override;
161 : void setIsMidiInputEnabled(bool enabled) override;
162 : muse::async::Notification isMidiInputEnabledChanged() const override;
163 :
164 : bool startNoteInputAtSelectedNoteRestWhenPressingMidiKey() const override;
165 : void setStartNoteInputAtSelectedNoteRestWhenPressingMidiKey(bool value) override;
166 : muse::async::Notification startNoteInputAtSelectedNoteRestWhenPressingMidiKeyChanged() const override;
167 :
168 : bool isAutomaticallyPanEnabled() const override;
169 : void setIsAutomaticallyPanEnabled(bool enabled) override;
170 : muse::async::Notification isAutomaticallyPanEnabledChanged() const override;
171 :
172 : bool isPlayRepeatsEnabled() const override;
173 : void setIsPlayRepeatsEnabled(bool enabled) override;
174 : muse::async::Notification isPlayRepeatsChanged() const override;
175 :
176 : bool isPlayChordSymbolsEnabled() const override;
177 : void setIsPlayChordSymbolsEnabled(bool enabled) override;
178 : muse::async::Notification isPlayChordSymbolsChanged() const override;
179 :
180 : bool isPlayPreviewNotesInInputByDuration() const override;
181 : void setIsPlayPreviewNotesInInputByDuration(bool play) override;
182 : muse::async::Notification isPlayPreviewNotesInInputByDurationChanged() const override;
183 :
184 : bool playPreviewNotesWithScoreDynamics() const override;
185 : void setPlayPreviewNotesWithScoreDynamics(bool use) override;
186 : muse::async::Notification playPreviewNotesWithScoreDynamicsChanged() const override;
187 :
188 : bool isMetronomeEnabled() const override;
189 : void setIsMetronomeEnabled(bool enabled) override;
190 : muse::async::Notification isMetronomeEnabledChanged() const override;
191 :
192 : bool isCountInEnabled() const override;
193 : void setIsCountInEnabled(bool enabled) override;
194 : muse::async::Notification isCountInEnabledChanged() const override;
195 :
196 : muse::ValCh<muse::Orientation> canvasOrientation() const override;
197 : void setCanvasOrientation(muse::Orientation orientation) override;
198 :
199 : bool colorNotesOutsideOfUsablePitchRange() const override;
200 : void setColorNotesOutsideOfUsablePitchRange(bool value) override;
201 : muse::async::Channel<bool> colorNotesOutsideOfUsablePitchRangeChanged() const override;
202 :
203 : bool warnGuitarBends() const override;
204 : void setWarnGuitarBends(bool value) override;
205 : muse::async::Channel<bool> warnGuitarBendsChanged() const override;
206 :
207 : int delayBetweenNotesInRealTimeModeMilliseconds() const override;
208 : void setDelayBetweenNotesInRealTimeModeMilliseconds(int delayMs) override;
209 : muse::async::Channel<int> delayBetweenNotesInRealTimeModeMillisecondsChanged() const override;
210 :
211 : bool useMidiVelocityAndDurationDuringNoteInput() const override;
212 : void setUseMidiVelocityAndDurationDuringNoteInput(bool use) override;
213 : muse::async::Channel<bool> useMidiVelocityAndDurationDuringNoteInputChanged() const override;
214 :
215 : int notePlayDurationMilliseconds() const override;
216 : void setNotePlayDurationMilliseconds(int durationMs) override;
217 : muse::async::Channel<int> notePlayDurationMillisecondsChanged() const override;
218 :
219 : void setTemplateModeEnabled(std::optional<bool> enabled) override;
220 : void setTestModeEnabled(std::optional<bool> enabled) override;
221 :
222 : muse::io::path_t instrumentsXmlPath() const override;
223 : muse::io::path_t scoreOrdersXmlPath() const override;
224 :
225 : muse::io::path_t userInstrumentsFolder() const override;
226 : muse::io::paths_t userInstrumentsAndScoreOrdersPaths() const override;
227 : void setUserInstrumentsFolder(const muse::io::path_t& path) override;
228 : muse::async::Channel<muse::io::path_t> userInstrumentsFolderChanged() const override;
229 :
230 : muse::io::path_t stringTuningsPresetsPath() const override;
231 :
232 : bool isSnappedToGrid(muse::Orientation gridOrientation) const override;
233 : void setIsSnappedToGrid(muse::Orientation gridOrientation, bool isSnapped) override;
234 :
235 : int gridSizeSpatium(muse::Orientation gridOrientation) const override;
236 : void setGridSize(muse::Orientation gridOrientation, int sizeSpatium) override;
237 :
238 : bool needToShowMScoreError(const std::string& errorKey) const override;
239 : void setNeedToShowMScoreError(const std::string& errorKey, bool show) override;
240 :
241 : muse::ValCh<bool> midiUseWrittenPitch() const override;
242 : void setMidiUseWrittenPitch(bool useWrittenPitch) override;
243 :
244 : muse::io::path_t styleFileImportPath() const override;
245 : void setStyleFileImportPath(const muse::io::path_t& path) override;
246 : muse::async::Channel<std::string> styleFileImportPathChanged() const override;
247 :
248 : private:
249 : muse::async::Notification m_notationColorChanged;
250 : muse::async::Notification m_backgroundChanged;
251 : muse::async::Notification m_foregroundChanged;
252 : muse::async::Notification m_scoreInversionChanged;
253 : muse::async::Notification m_isOnlyInvertInDarkThemeChanged;
254 :
255 : muse::async::Notification m_defaultNoteInputMethodChanged;
256 : muse::async::Notification m_addAccidentalDotsArticulationsToNextNoteEnteredChanged;
257 : muse::async::Notification m_useNoteInputCursorInInputByDurationChanged;
258 : muse::async::Notification m_isMidiInputEnabledChanged;
259 : muse::async::Notification m_startNoteInputAtSelectedNoteRestWhenPressingMidiKeyChanged;
260 :
261 : muse::async::Notification m_defaultZoomChanged;
262 : muse::async::Notification m_mouseZoomPrecisionChanged;
263 : muse::async::Notification m_currentAutomationTypeChanged;
264 : muse::async::Channel<muse::Orientation> m_canvasOrientationChanged;
265 : muse::async::Channel<muse::io::path_t> m_userStylesPathChanged;
266 : muse::async::Channel<muse::io::path_t> m_userMusicFontsPathChanged;
267 : muse::async::Channel<muse::io::path_t> m_userInstrumentsFolderChanged;
268 : muse::async::Channel<int> m_selectionProximityChanged;
269 : muse::async::Channel<bool> m_colorNotesOutsideOfUsablePitchRangeChanged;
270 : muse::async::Channel<bool> m_warnGuitarBendsChanged;
271 : muse::async::Channel<int> m_delayBetweenNotesInRealTimeModeMillisecondsChanged;
272 : muse::async::Channel<int> m_notePlayDurationMillisecondsChanged;
273 : muse::async::Channel<bool> m_useMidiVelocityAndDurationDuringNoteInputChanged;
274 : muse::async::Channel<std::string> m_styleFileImportPathChanged;
275 : muse::async::Notification m_isPlayRepeatsChanged;
276 : muse::async::Notification m_isPlayChordSymbolsChanged;
277 : muse::async::Notification m_isPlayNotesPreviewInInputByDurationChanged;
278 : muse::async::Notification m_playPreviewNotesWithScoreDynamicsChanged;
279 : muse::async::Notification m_isMetronomeEnabledChanged;
280 : muse::ValCh<bool> m_midiInputUseWrittenPitch;
281 : muse::async::Channel<QColor> m_anchorColorChanged;
282 :
283 : muse::async::Notification m_isAutomaticallyPanEnabledChanged;
284 : muse::async::Notification m_isCountInEnabledChanged;
285 : };
286 : }
|