Skip to content

Commit 3d76cda

Browse files
authored
Merge pull request #153 from igorkorsukov/w/rcmd/rcmd_step13
returned navigation ui actions (compat)
2 parents 54a9947 + f66a527 commit 3d76cda

4 files changed

Lines changed: 187 additions & 0 deletions

File tree

framework/ui/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ target_sources(muse_ui PRIVATE
7272
internal/navigationcommandsstate.h
7373
internal/navigationcontroller.cpp
7474
internal/navigationcontroller.h
75+
internal/navigationuiactions.cpp
76+
internal/navigationuiactions.h
7577
internal/uiarrangement.cpp
7678
internal/uiarrangement.h
7779
internal/dragcontroller.cpp
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-only
3+
* MuseScore-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+
#include "navigationuiactions.h"
23+
24+
#include "../uiaction.h"
25+
#include "shortcuts/shortcutcontext.h"
26+
27+
#include "muse_framework_config.h"
28+
29+
using namespace muse::ui;
30+
using namespace muse::actions;
31+
32+
#ifdef MUSE_MODULE_UI_NAVIGATION_EXCLUDEPROJECT
33+
static const std::string NAVIGATION_SHORTCUTS_CTX = muse::shortcuts::CTX_NOT_PROJECT_FOCUSED;
34+
#else
35+
static const std::string NAVIGATION_SHORTCUTS_CTX = muse::shortcuts::CTX_ANY;
36+
#endif
37+
38+
const UiActionList NavigationUiActions::m_actions = {
39+
UiAction("nav-dev-show-controls",
40+
ui::UiCtxAny,
41+
muse::shortcuts::CTX_ANY
42+
),
43+
UiAction("nav-next-section",
44+
ui::UiCtxAny,
45+
muse::shortcuts::CTX_ANY
46+
),
47+
UiAction("nav-prev-section",
48+
ui::UiCtxAny,
49+
muse::shortcuts::CTX_ANY
50+
),
51+
UiAction("nav-next-panel",
52+
ui::UiCtxAny,
53+
muse::shortcuts::CTX_ANY
54+
),
55+
UiAction("nav-prev-panel",
56+
ui::UiCtxAny,
57+
muse::shortcuts::CTX_ANY
58+
),
59+
UiAction("nav-next-tab",
60+
ui::UiCtxAny,
61+
muse::shortcuts::CTX_ANY
62+
),
63+
UiAction("nav-prev-tab",
64+
ui::UiCtxAny,
65+
muse::shortcuts::CTX_ANY
66+
),
67+
UiAction("nav-right",
68+
ui::UiCtxAny,
69+
NAVIGATION_SHORTCUTS_CTX
70+
),
71+
UiAction("nav-left",
72+
ui::UiCtxAny,
73+
NAVIGATION_SHORTCUTS_CTX
74+
),
75+
UiAction("nav-up",
76+
ui::UiCtxAny,
77+
NAVIGATION_SHORTCUTS_CTX
78+
),
79+
UiAction("nav-down",
80+
ui::UiCtxAny,
81+
NAVIGATION_SHORTCUTS_CTX
82+
),
83+
UiAction("nav-escape",
84+
ui::UiCtxAny,
85+
muse::shortcuts::CTX_DISABLED
86+
),
87+
UiAction("nav-trigger-control",
88+
ui::UiCtxAny,
89+
NAVIGATION_SHORTCUTS_CTX
90+
),
91+
UiAction("nav-first-control",
92+
ui::UiCtxAny,
93+
NAVIGATION_SHORTCUTS_CTX
94+
),
95+
UiAction("nav-last-control",
96+
ui::UiCtxAny,
97+
NAVIGATION_SHORTCUTS_CTX
98+
),
99+
UiAction("nav-nextrow-control",
100+
ui::UiCtxAny,
101+
NAVIGATION_SHORTCUTS_CTX
102+
),
103+
UiAction("nav-prevrow-control",
104+
ui::UiCtxAny,
105+
NAVIGATION_SHORTCUTS_CTX
106+
)
107+
};
108+
109+
const UiActionList& NavigationUiActions::actionsList() const
110+
{
111+
return m_actions;
112+
}
113+
114+
bool NavigationUiActions::actionEnabled(const UiAction&) const
115+
{
116+
return true;
117+
}
118+
119+
muse::async::Channel<ActionCodeList> NavigationUiActions::actionEnabledChanged() const
120+
{
121+
static async::Channel<ActionCodeList> ch;
122+
return ch;
123+
}
124+
125+
bool NavigationUiActions::actionChecked(const UiAction&) const
126+
{
127+
return false;
128+
}
129+
130+
muse::async::Channel<ActionCodeList> NavigationUiActions::actionCheckedChanged() const
131+
{
132+
static async::Channel<ActionCodeList> ch;
133+
return ch;
134+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-only
3+
* MuseScore-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+
#ifndef MUSE_UI_NAVIGATIONUIACTIONS_H
23+
#define MUSE_UI_NAVIGATIONUIACTIONS_H
24+
25+
#include "../iuiactionsmodule.h"
26+
27+
namespace muse::ui {
28+
class NavigationUiActions : public IUiActionsModule
29+
{
30+
public:
31+
NavigationUiActions() = default;
32+
33+
const UiActionList& actionsList() const override;
34+
bool actionEnabled(const UiAction& act) const override;
35+
async::Channel<actions::ActionCodeList> actionEnabledChanged() const override;
36+
37+
bool actionChecked(const UiAction& act) const override;
38+
async::Channel<actions::ActionCodeList> actionCheckedChanged() const override;
39+
40+
private:
41+
static const UiActionList m_actions;
42+
};
43+
}
44+
45+
#endif // MUSE_UI_NAVIGATIONUIACTIONS_H

framework/ui/uimodule.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "internal/uistate.h"
3838
#include "internal/uiactionsregister.h"
3939
#include "internal/navigationcontroller.h"
40+
#include "internal/navigationuiactions.h"
4041
#include "internal/dragcontroller.h"
4142
#include "view/iconcodes.h"
4243
#include "view/widgetstyle.h"
@@ -190,6 +191,11 @@ void UiModuleContext::resolveImports()
190191
if (cs) {
191192
cs->reg(std::make_shared<NavigationCommandsState>(iocContext()));
192193
}
194+
195+
auto ar = ioc()->resolve<IUiActionsRegister>(module_name);
196+
if (ar) {
197+
ar->reg(std::make_shared<NavigationUiActions>());
198+
}
193199
}
194200

195201
void UiModuleContext::onInit(const IApplication::RunMode& mode)

0 commit comments

Comments
 (0)