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 : #pragma once
24 :
25 : #include "accessibility/iaccessibilitycontroller.h"
26 : #include "async/asyncable.h"
27 : #include "async/notification.h"
28 : #include "project/iprojectsession.h"
29 : #include "global/iglobalconfiguration.h"
30 : #include "ibrailleconfiguration.h"
31 : #include "inotationbraille.h"
32 : #include "modularity/ioc.h"
33 : #include "notation/types/noteinputtypes.h"
34 : #include "playback/iplaybackcontroller.h"
35 : #include "rcommand/icommanddispatcher.h"
36 :
37 : #include "braille.h"
38 : #include "brailleinput.h"
39 :
40 : namespace mu::engraving {
41 : class Score;
42 : class Selection;
43 : class TDuration;
44 :
45 : class NotationBraille : public mu::braille::INotationBraille, public muse::Contextable, public muse::async::Asyncable
46 : {
47 : muse::GlobalInject<braille::IBrailleConfiguration> brailleConfiguration;
48 : muse::GlobalInject<muse::IGlobalConfiguration> globalConfiguration;
49 : muse::ContextInject<muse::accessibility::IAccessibilityController> accessibilityController = { this };
50 : muse::ContextInject<project::IProjectSession> projectSession = { this };
51 : muse::ContextInject<playback::IPlaybackController> playbackController = { this };
52 : muse::ContextInject<muse::rcommand::ICommandDispatcher> commandDispatcher = { this };
53 :
54 : public:
55 0 : NotationBraille(const muse::modularity::ContextPtr& iocCtx)
56 0 : : muse::Contextable(iocCtx) {}
57 :
58 : void init();
59 : void doBraille(bool force = false);
60 :
61 : bool addNote();
62 : bool setVoice(bool new_voice = false);
63 : bool addSlurStart();
64 : bool addSlurEnd();
65 : bool addTie();
66 : bool addSlur();
67 : bool addLongSlur();
68 : bool addTuplet(const mu::notation::TupletOptions& options);
69 : bool incDuration();
70 : bool decDuration();
71 : bool setArticulation();
72 : void setInputNoteDuration(engraving::TDuration d);
73 : void setTupletDuration(int tuplet, engraving::TDuration d);
74 :
75 : muse::ValCh<std::string> brailleInfo() const override;
76 : muse::ValCh<int> cursorPosition() const override;
77 : muse::ValCh<int> currentItemPositionStart() const override;
78 : muse::ValCh<int> currentItemPositionEnd() const override;
79 : muse::ValCh<std::string> keys() const override;
80 : muse::ValCh<bool> enabled() const override;
81 : muse::ValCh<braille::BrailleIntervalDirection> intervalDirection() const override;
82 : muse::ValCh<int> mode() const override;
83 : muse::ValCh<std::string> cursorColor() const override;
84 :
85 : void setEnabled(const bool enabled) override;
86 : void setIntervalDirection(const braille::BrailleIntervalDirection direction) override;
87 :
88 : void setCursorPosition(const int pos) override;
89 : void setCurrentItemPosition(const int, const int) override;
90 : void setKeys(const QString&) override;
91 :
92 : void setMode(const braille::BrailleMode) override;
93 : void toggleMode() override;
94 : bool isNavigationMode() override;
95 : bool isBrailleInputMode() override;
96 :
97 : void setCursorColor(const QString color) override;
98 :
99 : EngravingItem* currentEngravingItem();
100 : Measure* currentMeasure();
101 :
102 : notation::INotationPtr notation();
103 : notation::INotationInteractionPtr interaction();
104 :
105 : BrailleEngravingItemList* brailleEngravingItemList();
106 : QString getBrailleStr();
107 :
108 : BrailleInputState* brailleInput();
109 :
110 : private:
111 : Score* score();
112 : Selection* selection();
113 :
114 : void setBrailleInfo(const QString& info);
115 : void setCurrentEngravingItem(EngravingItem* el, bool select);
116 :
117 : void updateTableForLyricsFromPreferences();
118 : muse::io::path_t tablesDefaultDirPath() const;
119 :
120 : IntervalDirection currentIntervalDirection();
121 :
122 : Measure* current_measure = nullptr;
123 : EngravingItem* current_engraving_item = nullptr;
124 : BrailleEngravingItem* current_bei = nullptr;
125 : BrailleEngravingItemList m_beil;
126 : BrailleInputState m_braille_input;
127 :
128 : muse::ValCh<std::string> m_brailleInfo;
129 : muse::ValCh<int> m_cursorPosition;
130 : muse::ValCh<int> m_currentItemPositionStart;
131 : muse::ValCh<int> m_currentItemPositionEnd;
132 : muse::ValCh<std::string> m_keys;
133 : muse::ValCh<bool> m_enabled;
134 : muse::ValCh<int> m_mode;
135 : muse::ValCh<braille::BrailleIntervalDirection> m_intervalDirection;
136 : muse::ValCh<std::string> m_cursorColor;
137 :
138 : muse::async::Notification m_selectionChanged;
139 : };
140 : }
|