-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Percussions - provide mechanism for adding actions to DockFrame
- Loading branch information
1 parent
2f5cf79
commit 0569fb2
Showing
17 changed files
with
462 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
src/framework/dockwindow/internal/dockframetoolbarmodel.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
* MuseScore-Studio-CLA-applies | ||
* | ||
* MuseScore Studio | ||
* Music Composition & Notation | ||
* | ||
* Copyright (C) 2024 MuseScore Limited | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "dockframetoolbarmodel.h" | ||
|
||
#include "uicomponents/view/toolbaritem.h" | ||
#include "context/shortcutcontext.h" | ||
#include "context/iuicontextresolver.h" | ||
|
||
using namespace muse; | ||
using namespace actions; | ||
using namespace dock; | ||
using namespace ui; | ||
using namespace uicomponents; | ||
|
||
Location DockFrameToolBarModel::location() const | ||
{ | ||
return m_location; | ||
} | ||
|
||
QString DockFrameToolBarModel::currentDockUniqueName() const | ||
{ | ||
return m_currentDockUniqueName; | ||
} | ||
|
||
void DockFrameToolBarModel::setLocation(const Location& location) | ||
{ | ||
m_location = location; | ||
} | ||
|
||
void DockFrameToolBarModel::setCurrentDock(const QString& currentDockUniqueName) | ||
{ | ||
m_currentDockUniqueName = currentDockUniqueName; | ||
|
||
UiActionList actions; | ||
|
||
switch (m_location) { | ||
case Location::Center: | ||
actions = centralActionsForDockName(m_currentDockUniqueName); | ||
break; | ||
case Location::Right: | ||
actions = rightSideActionsForDockName(m_currentDockUniqueName); | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
setItems(toolBarItemsForActionList(actions)); | ||
} | ||
|
||
// TODO: This shouldn't live here... | ||
const UiActionList DockFrameToolBarModel::m_percussionCentralActions = { | ||
UiAction("percussion-write", | ||
mu::context::UiCtxNotationFocused, | ||
mu::context::CTX_ANY, | ||
TranslatableString("action", "Write"), | ||
TranslatableString("action", "Write"), | ||
IconCode::Code::EDIT | ||
), | ||
UiAction("percussion-preview", | ||
mu::context::UiCtxNotationFocused, | ||
mu::context::CTX_ANY, | ||
TranslatableString("action", "Preview"), | ||
TranslatableString("action", "Preview"), | ||
IconCode::Code::PLAY | ||
), | ||
}; | ||
|
||
// TODO: This shouldn't live here... | ||
const UiActionList DockFrameToolBarModel::m_percussionRightSideActions = { | ||
UiAction("percussion-layout", | ||
mu::context::UiCtxNotationFocused, | ||
mu::context::CTX_ANY, | ||
TranslatableString("action", "Layout"), | ||
TranslatableString("action", "Layout"), | ||
IconCode::Code::SPLIT_VIEW_HORIZONTAL, | ||
Checkable::No, | ||
m_percussionLayoutSubActions | ||
), | ||
UiAction("percussion-customize-kit", | ||
mu::context::UiCtxNotationFocused, | ||
mu::context::CTX_ANY, | ||
TranslatableString("action", "Customize kit"), | ||
TranslatableString("action", "Customize kit") | ||
), | ||
}; | ||
|
||
// TODO: This shouldn't live here... | ||
const std::vector<UiAction> DockFrameToolBarModel::m_percussionLayoutSubActions = { | ||
UiAction("percussion-instrument-names", | ||
mu::context::UiCtxNotationFocused, | ||
mu::context::CTX_ANY, | ||
TranslatableString("action", "Instrument names"), | ||
TranslatableString("action", "Instrument names") | ||
), | ||
UiAction("percussion-notation-preview", | ||
mu::context::UiCtxNotationFocused, | ||
mu::context::CTX_ANY, | ||
TranslatableString("action", "Notation preview"), | ||
TranslatableString("action", "Notation preview") | ||
), | ||
UiAction("percussion-edit-layout", | ||
mu::context::UiCtxNotationFocused, | ||
mu::context::CTX_ANY, | ||
TranslatableString("action", "Edit layout"), | ||
TranslatableString("action", "Edit layout"), | ||
IconCode::Code::CONFIGURE | ||
), | ||
UiAction("percussion-reset-layout", | ||
mu::context::UiCtxNotationFocused, | ||
mu::context::CTX_ANY, | ||
TranslatableString("action", "Reset layout"), | ||
TranslatableString("action", "Reset layout"), | ||
IconCode::Code::UNDO | ||
), | ||
}; | ||
|
||
// TODO: Placeholder method - info will be pulled from elsewhere... | ||
UiActionList DockFrameToolBarModel::centralActionsForDockName(const QString& dockUniqueName) const | ||
{ | ||
if (dockUniqueName == "percussionPanel") { | ||
return m_percussionCentralActions; | ||
} | ||
return {}; | ||
} | ||
|
||
// TODO: Placeholder method - info will be pulled from elsewhere... | ||
UiActionList DockFrameToolBarModel::rightSideActionsForDockName(const QString& dockUniqueName) const | ||
{ | ||
if (dockUniqueName == "percussionPanel") { | ||
return m_percussionRightSideActions; | ||
} | ||
return {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
* MuseScore-CLA-applies | ||
* | ||
* MuseScore | ||
* Music Composition & Notation | ||
* | ||
* Copyright (C) 2024 MuseScore BVBA and others | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef MUSE_DOCK_DOCKFRAMETOOLBARMODEL_H | ||
#define MUSE_DOCK_DOCKFRAMETOOLBARMODEL_H | ||
|
||
#include "docktypes.h" | ||
#include "uicomponents/view/abstracttoolbarmodel.h" | ||
|
||
namespace muse::dock { | ||
class DockFrameToolBarModel : public muse::uicomponents::AbstractToolBarModel | ||
{ | ||
Q_OBJECT | ||
|
||
Q_PROPERTY(QString currentDockUniqueName READ currentDockUniqueName | ||
WRITE setCurrentDock NOTIFY currentDockUniqueNameChanged REQUIRED) | ||
Q_PROPERTY(Location location READ location | ||
WRITE setLocation NOTIFY locationChanged REQUIRED) | ||
|
||
public: | ||
Location location() const; | ||
QString currentDockUniqueName() const; | ||
|
||
public slots: | ||
void setLocation(const Location& location); | ||
void setCurrentDock(const QString& currentDockUniqueName); | ||
|
||
signals: | ||
void locationChanged(Location location); | ||
void currentDockUniqueNameChanged(QString currentDockUniqueName); | ||
|
||
private: | ||
// TODO: Placeholder methods - info will be pulled from elsewhere... | ||
muse::ui::UiActionList centralActionsForDockName(const QString& dockUniqueName) const; | ||
muse::ui::UiActionList rightSideActionsForDockName(const QString& dockUniqueName) const; | ||
|
||
// TODO: These shouldn't live here... | ||
static const muse::ui::UiActionList m_percussionCentralActions; | ||
static const muse::ui::UiActionList m_percussionRightSideActions; | ||
static const std::vector<ui::UiAction> m_percussionLayoutSubActions; | ||
|
||
Location m_location = Location::Undefined; | ||
QString m_currentDockUniqueName; | ||
}; | ||
} | ||
|
||
#endif // MUSE_DOCK_DOCKFRAMETOOLBARMODEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.