implemented opening/closing of the drumset panel when the note input
mode is on/off
This commit is contained in:
parent
218a671af2
commit
5519b54220
21 changed files with 221 additions and 140 deletions
|
@ -41,7 +41,8 @@ enum class PanelType
|
||||||
Synthesizer,
|
Synthesizer,
|
||||||
SelectionFilter,
|
SelectionFilter,
|
||||||
Piano,
|
Piano,
|
||||||
ComparisonTool
|
ComparisonTool,
|
||||||
|
DrumsetPanel
|
||||||
};
|
};
|
||||||
using PanelTypeList = std::vector<PanelType>;
|
using PanelTypeList = std::vector<PanelType>;
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ bool NotationPageState::isPanelVisible(PanelType type) const
|
||||||
case PanelType::NotationStatusBar:
|
case PanelType::NotationStatusBar:
|
||||||
case PanelType::Mixer:
|
case PanelType::Mixer:
|
||||||
case PanelType::Timeline:
|
case PanelType::Timeline:
|
||||||
|
case PanelType::DrumsetPanel:
|
||||||
return m_panelVisibleMap[type];
|
return m_panelVisibleMap[type];
|
||||||
case PanelType::NotationNavigator:
|
case PanelType::NotationNavigator:
|
||||||
return configuration()->isNotationNavigatorVisible();
|
return configuration()->isNotationNavigatorVisible();
|
||||||
|
@ -86,6 +87,7 @@ void NotationPageState::setIsPanelVisible(PanelType type, bool visible)
|
||||||
case PanelType::NotationStatusBar:
|
case PanelType::NotationStatusBar:
|
||||||
case PanelType::Mixer:
|
case PanelType::Mixer:
|
||||||
case PanelType::Timeline:
|
case PanelType::Timeline:
|
||||||
|
case PanelType::DrumsetPanel:
|
||||||
m_panelVisibleMap[type] = visible;
|
m_panelVisibleMap[type] = visible;
|
||||||
break;
|
break;
|
||||||
case PanelType::NotationNavigator:
|
case PanelType::NotationNavigator:
|
||||||
|
|
|
@ -83,6 +83,7 @@ DockPage {
|
||||||
pageModel.setPianoRollDockName(pianoRollPanel.objectName)
|
pageModel.setPianoRollDockName(pianoRollPanel.objectName)
|
||||||
pageModel.setMixerDockName(mixerPanel.objectName)
|
pageModel.setMixerDockName(mixerPanel.objectName)
|
||||||
pageModel.setTimelineDockName(timelinePanel.objectName)
|
pageModel.setTimelineDockName(timelinePanel.objectName)
|
||||||
|
pageModel.setDrumsetPanelDockName(drumsetPanel.objectName)
|
||||||
pageModel.setStatusBarDockName(notationStatusBar.objectName)
|
pageModel.setStatusBarDockName(notationStatusBar.objectName)
|
||||||
|
|
||||||
Qt.callLater(pageModel.init, root.dockWindow)
|
Qt.callLater(pageModel.init, root.dockWindow)
|
||||||
|
@ -314,9 +315,8 @@ DockPage {
|
||||||
|
|
||||||
allowedAreas: Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea
|
allowedAreas: Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea
|
||||||
|
|
||||||
height: 100
|
minimumHeight: 30
|
||||||
minimumHeight: 100
|
maximumHeight: 30
|
||||||
maximumHeight: 100
|
|
||||||
|
|
||||||
DrumsetPanel {
|
DrumsetPanel {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -196,17 +196,28 @@ DockPanelHolder* DockPage::panelHolderByLocation(DockBase::DockLocation location
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DockPage::isDockShown(const QString& dockName) const
|
bool DockPage::isDockOpened(const QString& dockName) const
|
||||||
{
|
{
|
||||||
const DockBase* dock = dockByName(dockName);
|
const DockBase* dock = dockByName(dockName);
|
||||||
return dock ? dock->isShown() : false;
|
return dock ? dock->isOpen() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockPage::toggleDockVisibility(const QString& dockName)
|
void DockPage::toggleDock(const QString& dockName)
|
||||||
|
{
|
||||||
|
setDockOpened(dockName, !isDockOpened(dockName));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockPage::setDockOpened(const QString &dockName, bool opened)
|
||||||
{
|
{
|
||||||
DockBase* dock = dockByName(dockName);
|
DockBase* dock = dockByName(dockName);
|
||||||
if (dock) {
|
if (!dock) {
|
||||||
dock->toggle();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opened) {
|
||||||
|
dock->open();
|
||||||
|
} else {
|
||||||
|
dock->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +256,7 @@ void DockPage::close()
|
||||||
TRACEFUNC;
|
TRACEFUNC;
|
||||||
|
|
||||||
for (DockBase* dock : allDocks()) {
|
for (DockBase* dock : allDocks()) {
|
||||||
dock->hide();
|
dock->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,9 @@ public:
|
||||||
DockToolBarHolder* toolBarHolderByLocation(DockBase::DockLocation location) const;
|
DockToolBarHolder* toolBarHolderByLocation(DockBase::DockLocation location) const;
|
||||||
DockPanelHolder* panelHolderByLocation(DockBase::DockLocation location) const;
|
DockPanelHolder* panelHolderByLocation(DockBase::DockLocation location) const;
|
||||||
|
|
||||||
bool isDockShown(const QString& dockName) const;
|
bool isDockOpened(const QString& dockName) const;
|
||||||
void toggleDockVisibility(const QString& dockName);
|
void toggleDock(const QString& dockName);
|
||||||
|
void setDockOpened(const QString& dockName, bool opened);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setUri(const QString& uri);
|
void setUri(const QString& uri);
|
||||||
|
|
|
@ -98,7 +98,7 @@ void DockWindow::componentComplete()
|
||||||
hideCurrentToolBarDockingHolder();
|
hideCurrentToolBarDockingHolder();
|
||||||
|
|
||||||
if (holder) {
|
if (holder) {
|
||||||
holder->show();
|
holder->open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ void DockWindow::componentComplete()
|
||||||
|
|
||||||
if (holder) {
|
if (holder) {
|
||||||
qDebug() << holder->location();
|
qDebug() << holder->location();
|
||||||
holder->show();
|
holder->open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ void DockWindow::loadPage(const QString& uri)
|
||||||
|
|
||||||
for (DockBase* dock : newPage->allDocks()) {
|
for (DockBase* dock : newPage->allDocks()) {
|
||||||
if (!dock->isVisible()) {
|
if (!dock->isVisible()) {
|
||||||
dock->hide();
|
dock->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,17 +203,25 @@ void DockWindow::loadPage(const QString& uri)
|
||||||
emit currentPageUriChanged(uri);
|
emit currentPageUriChanged(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DockWindow::isDockShown(const QString& dockName) const
|
bool DockWindow::isDockOpened(const QString& dockName) const
|
||||||
{
|
{
|
||||||
const DockPage* currPage = currentPage();
|
const DockPage* currPage = currentPage();
|
||||||
return currPage ? currPage->isDockShown(dockName) : false;
|
return currPage ? currPage->isDockOpened(dockName) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockWindow::toggleDockVisibility(const QString& dockName)
|
void DockWindow::toggleDock(const QString& dockName)
|
||||||
{
|
{
|
||||||
DockPage* currPage = currentPage();
|
DockPage* currPage = currentPage();
|
||||||
if (currPage) {
|
if (currPage) {
|
||||||
currPage->toggleDockVisibility(dockName);
|
currPage->toggleDock(dockName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockWindow::setDockOpened(const QString& dockName, bool opened)
|
||||||
|
{
|
||||||
|
DockPage* currPage = currentPage();
|
||||||
|
if (currPage) {
|
||||||
|
currPage->setDockOpened(dockName, opened);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +266,7 @@ void DockWindow::loadPageContent(const DockPage* page)
|
||||||
}
|
}
|
||||||
|
|
||||||
addDock(m_mainToolBarDockingHolder, KDDockWidgets::Location_OnTop);
|
addDock(m_mainToolBarDockingHolder, KDDockWidgets::Location_OnTop);
|
||||||
m_mainToolBarDockingHolder->hide();
|
m_mainToolBarDockingHolder->close();
|
||||||
|
|
||||||
unitePanelsToTabs(page);
|
unitePanelsToTabs(page);
|
||||||
}
|
}
|
||||||
|
@ -562,7 +570,7 @@ void DockWindow::hideCurrentToolBarDockingHolder()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentToolBarDockingHolder->hide();
|
m_currentToolBarDockingHolder->close();
|
||||||
m_currentToolBarDockingHolder = nullptr;
|
m_currentToolBarDockingHolder = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,7 +580,7 @@ void DockWindow::hideCurrentPanelDockingHolder()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentPanelDockingHolder->hide();
|
m_currentPanelDockingHolder->close();
|
||||||
m_currentPanelDockingHolder = nullptr;
|
m_currentPanelDockingHolder = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,9 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void loadPage(const QString& uri);
|
Q_INVOKABLE void loadPage(const QString& uri);
|
||||||
|
|
||||||
bool isDockShown(const QString& dockName) const;
|
bool isDockOpened(const QString& dockName) const;
|
||||||
void toggleDockVisibility(const QString& dockName);
|
void toggleDock(const QString& dockName);
|
||||||
|
void setDockOpened(const QString& dockName, bool opened);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setMainToolBarDockingHolder(DockToolBarHolder* mainToolBarDockingHolder);
|
void setMainToolBarDockingHolder(DockToolBarHolder* mainToolBarDockingHolder);
|
||||||
|
|
|
@ -199,7 +199,7 @@ void DockBase::init()
|
||||||
applySizeConstraints();
|
applySizeConstraints();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DockBase::isShown() const
|
bool DockBase::isOpen() const
|
||||||
{
|
{
|
||||||
IF_ASSERT_FAILED(m_dockWidget) {
|
IF_ASSERT_FAILED(m_dockWidget) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -208,7 +208,7 @@ bool DockBase::isShown() const
|
||||||
return m_dockWidget->isOpen();
|
return m_dockWidget->isOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockBase::show()
|
void DockBase::open()
|
||||||
{
|
{
|
||||||
IF_ASSERT_FAILED(m_dockWidget) {
|
IF_ASSERT_FAILED(m_dockWidget) {
|
||||||
return;
|
return;
|
||||||
|
@ -217,7 +217,7 @@ void DockBase::show()
|
||||||
m_dockWidget->show();
|
m_dockWidget->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockBase::hide()
|
void DockBase::close()
|
||||||
{
|
{
|
||||||
IF_ASSERT_FAILED(m_dockWidget) {
|
IF_ASSERT_FAILED(m_dockWidget) {
|
||||||
return;
|
return;
|
||||||
|
@ -226,15 +226,6 @@ void DockBase::hide()
|
||||||
m_dockWidget->forceClose();
|
m_dockWidget->forceClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockBase::toggle()
|
|
||||||
{
|
|
||||||
if (isShown()) {
|
|
||||||
hide();
|
|
||||||
} else {
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DockBase::DockLocation DockBase::location() const
|
DockBase::DockLocation DockBase::location() const
|
||||||
{
|
{
|
||||||
return m_location;
|
return m_location;
|
||||||
|
|
|
@ -75,10 +75,9 @@ public:
|
||||||
|
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
|
||||||
bool isShown() const;
|
bool isOpen() const;
|
||||||
void show();
|
void open();
|
||||||
void hide();
|
void close();
|
||||||
void toggle();
|
|
||||||
|
|
||||||
DockLocation location() const;
|
DockLocation location() const;
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "dockwindow/dockwindow.h"
|
#include "dockwindow/dockwindow.h"
|
||||||
|
|
||||||
using namespace mu::appshell;
|
using namespace mu::appshell;
|
||||||
|
using namespace mu::notation;
|
||||||
|
|
||||||
NotationPageModel::NotationPageModel(QObject* parent)
|
NotationPageModel::NotationPageModel(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
@ -87,6 +88,11 @@ void NotationPageModel::setTimelineDockName(const QString& dockName)
|
||||||
setPanelDockName(PanelType::Timeline, dockName);
|
setPanelDockName(PanelType::Timeline, dockName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotationPageModel::setDrumsetPanelDockName(const QString& dockName)
|
||||||
|
{
|
||||||
|
setPanelDockName(PanelType::DrumsetPanel, dockName);
|
||||||
|
}
|
||||||
|
|
||||||
void NotationPageModel::setStatusBarDockName(const QString& dockName)
|
void NotationPageModel::setStatusBarDockName(const QString& dockName)
|
||||||
{
|
{
|
||||||
setPanelDockName(PanelType::NotationStatusBar, dockName);
|
setPanelDockName(PanelType::NotationStatusBar, dockName);
|
||||||
|
@ -110,7 +116,7 @@ void NotationPageModel::init(QQuickItem* dockWindow)
|
||||||
|
|
||||||
std::map<PanelType, bool> initialState;
|
std::map<PanelType, bool> initialState;
|
||||||
for (PanelType type : m_panelTypeToDockName.keys()) {
|
for (PanelType type : m_panelTypeToDockName.keys()) {
|
||||||
initialState[type] = m_window->isDockShown(m_panelTypeToDockName[type]);
|
initialState[type] = m_window->isDockOpened(m_panelTypeToDockName[type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pageState()->setIsPanelsVisible(initialState);
|
pageState()->setIsPanelsVisible(initialState);
|
||||||
|
@ -126,7 +132,7 @@ void NotationPageModel::init(QQuickItem* dockWindow)
|
||||||
{ "toggle-noteinput", PanelType::NoteInputBar },
|
{ "toggle-noteinput", PanelType::NoteInputBar },
|
||||||
{ "toggle-notationtoolbar", PanelType::NotationToolBar },
|
{ "toggle-notationtoolbar", PanelType::NotationToolBar },
|
||||||
{ "toggle-undoredo", PanelType::UndoRedoToolBar },
|
{ "toggle-undoredo", PanelType::UndoRedoToolBar },
|
||||||
{ "toggle-transport", PanelType::PlaybackToolBar }
|
{ "toggle-transport", PanelType::PlaybackToolBar },
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const std::string& actionCode : actionToPanelType.keys()) {
|
for (const std::string& actionCode : actionToPanelType.keys()) {
|
||||||
|
@ -140,6 +146,11 @@ void NotationPageModel::init(QQuickItem* dockWindow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updateDrumsetPanelVisibility();
|
||||||
|
globalContext()->currentNotationChanged().onNotify(this, [=]() {
|
||||||
|
updateDrumsetPanelVisibility();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotationPageModel::togglePanel(PanelType type)
|
void NotationPageModel::togglePanel(PanelType type)
|
||||||
|
@ -151,5 +162,26 @@ void NotationPageModel::togglePanel(PanelType type)
|
||||||
bool visible = pageState()->isPanelVisible(type);
|
bool visible = pageState()->isPanelVisible(type);
|
||||||
pageState()->setIsPanelsVisible({ { type, !visible } });
|
pageState()->setIsPanelsVisible({ { type, !visible } });
|
||||||
|
|
||||||
m_window->toggleDockVisibility(m_panelTypeToDockName[type]);
|
m_window->toggleDock(m_panelTypeToDockName[type]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotationPageModel::updateDrumsetPanelVisibility()
|
||||||
|
{
|
||||||
|
auto setDrumsetPanelVisible = [this](bool visible) {
|
||||||
|
m_window->setDockOpened(m_panelTypeToDockName[PanelType::DrumsetPanel], visible);
|
||||||
|
pageState()->setIsPanelsVisible({ { PanelType::DrumsetPanel, visible } });
|
||||||
|
};
|
||||||
|
|
||||||
|
setDrumsetPanelVisible(false);
|
||||||
|
|
||||||
|
INotationPtr notation = globalContext()->currentNotation();
|
||||||
|
if (!notation) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
INotationNoteInputPtr noteInput = notation->interaction()->noteInput();
|
||||||
|
noteInput->stateChanged().onNotify(this, [noteInput, setDrumsetPanelVisible]() {
|
||||||
|
bool visible = noteInput->isNoteInputMode() && noteInput->state().drumset != nullptr;
|
||||||
|
setDrumsetPanelVisible(visible);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "async/asyncable.h"
|
#include "async/asyncable.h"
|
||||||
#include "actions/actionable.h"
|
#include "actions/actionable.h"
|
||||||
#include "actions/iactionsdispatcher.h"
|
#include "actions/iactionsdispatcher.h"
|
||||||
|
#include "context/iglobalcontext.h"
|
||||||
#include "inotationpagestate.h"
|
#include "inotationpagestate.h"
|
||||||
|
|
||||||
namespace mu::dock {
|
namespace mu::dock {
|
||||||
|
@ -41,6 +42,7 @@ class NotationPageModel : public QObject, public async::Asyncable, public action
|
||||||
|
|
||||||
INJECT(appshell, INotationPageState, pageState)
|
INJECT(appshell, INotationPageState, pageState)
|
||||||
INJECT(appshell, actions::IActionsDispatcher, dispatcher)
|
INJECT(appshell, actions::IActionsDispatcher, dispatcher)
|
||||||
|
INJECT(appshell, context::IGlobalContext, globalContext)
|
||||||
|
|
||||||
Q_PROPERTY(bool isNavigatorVisible READ isNavigatorVisible NOTIFY isNavigatorVisibleChanged)
|
Q_PROPERTY(bool isNavigatorVisible READ isNavigatorVisible NOTIFY isNavigatorVisibleChanged)
|
||||||
|
|
||||||
|
@ -61,6 +63,7 @@ public:
|
||||||
Q_INVOKABLE void setPianoRollDockName(const QString& dockName);
|
Q_INVOKABLE void setPianoRollDockName(const QString& dockName);
|
||||||
Q_INVOKABLE void setMixerDockName(const QString& dockName);
|
Q_INVOKABLE void setMixerDockName(const QString& dockName);
|
||||||
Q_INVOKABLE void setTimelineDockName(const QString& dockName);
|
Q_INVOKABLE void setTimelineDockName(const QString& dockName);
|
||||||
|
Q_INVOKABLE void setDrumsetPanelDockName(const QString& dockName);
|
||||||
|
|
||||||
Q_INVOKABLE void setStatusBarDockName(const QString& dockName);
|
Q_INVOKABLE void setStatusBarDockName(const QString& dockName);
|
||||||
|
|
||||||
|
@ -73,6 +76,8 @@ private:
|
||||||
void setPanelDockName(PanelType type, const QString& dockName);
|
void setPanelDockName(PanelType type, const QString& dockName);
|
||||||
void togglePanel(PanelType type);
|
void togglePanel(PanelType type);
|
||||||
|
|
||||||
|
void updateDrumsetPanelVisibility();
|
||||||
|
|
||||||
QMap<PanelType, QString /* dockName */> m_panelTypeToDockName;
|
QMap<PanelType, QString /* dockName */> m_panelTypeToDockName;
|
||||||
dock::DockWindow* m_window = nullptr;
|
dock::DockWindow* m_window = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
virtual void putNote(const QPointF& pos, bool replace, bool insert) = 0;
|
virtual void putNote(const QPointF& pos, bool replace, bool insert) = 0;
|
||||||
virtual void setAccidental(AccidentalType accidentalType) = 0;
|
virtual void setAccidental(AccidentalType accidentalType) = 0;
|
||||||
virtual void setArticulation(SymbolId articulationSymbolId) = 0;
|
virtual void setArticulation(SymbolId articulationSymbolId) = 0;
|
||||||
|
virtual void setDrumNote(int note) = 0;
|
||||||
virtual void addTuplet(const TupletOptions& options) = 0;
|
virtual void addTuplet(const TupletOptions& options) = 0;
|
||||||
|
|
||||||
virtual void addSlur(Ms::Slur* slur) = 0;
|
virtual void addSlur(Ms::Slur* slur) = 0;
|
||||||
|
|
|
@ -60,7 +60,7 @@ bool NotationNoteInput::isNoteInputMode() const
|
||||||
|
|
||||||
NoteInputState NotationNoteInput::state() const
|
NoteInputState NotationNoteInput::state() const
|
||||||
{
|
{
|
||||||
Ms::InputState& inputState = score()->inputState();
|
const Ms::InputState& inputState = score()->inputState();
|
||||||
|
|
||||||
NoteInputState noteInputState;
|
NoteInputState noteInputState;
|
||||||
noteInputState.method = inputState.noteEntryMethod();
|
noteInputState.method = inputState.noteEntryMethod();
|
||||||
|
@ -69,6 +69,8 @@ NoteInputState NotationNoteInput::state() const
|
||||||
noteInputState.articulationIds = articulationIds();
|
noteInputState.articulationIds = articulationIds();
|
||||||
noteInputState.withSlur = inputState.slur() != nullptr;
|
noteInputState.withSlur = inputState.slur() != nullptr;
|
||||||
noteInputState.currentVoiceIndex = inputState.voice();
|
noteInputState.currentVoiceIndex = inputState.voice();
|
||||||
|
noteInputState.currentTrack = inputState.track();
|
||||||
|
noteInputState.drumset = inputState.drumset();
|
||||||
noteInputState.isRest = inputState.rest();
|
noteInputState.isRest = inputState.rest();
|
||||||
|
|
||||||
return noteInputState;
|
return noteInputState;
|
||||||
|
@ -209,6 +211,7 @@ void NotationNoteInput::putNote(const QPointF& pos, bool replace, bool insert)
|
||||||
apply();
|
apply();
|
||||||
|
|
||||||
notifyNoteAddedChanged();
|
notifyNoteAddedChanged();
|
||||||
|
notifyAboutStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotationNoteInput::setAccidental(AccidentalType accidentalType)
|
void NotationNoteInput::setAccidental(AccidentalType accidentalType)
|
||||||
|
@ -231,6 +234,12 @@ void NotationNoteInput::setArticulation(SymbolId articulationSymbolId)
|
||||||
notifyAboutStateChanged();
|
notifyAboutStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotationNoteInput::setDrumNote(int note)
|
||||||
|
{
|
||||||
|
score()->inputState().setDrumNote(note);
|
||||||
|
notifyAboutStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void NotationNoteInput::setCurrentVoiceIndex(int voiceIndex)
|
void NotationNoteInput::setCurrentVoiceIndex(int voiceIndex)
|
||||||
{
|
{
|
||||||
if (!isVoiceIndexValid(voiceIndex)) {
|
if (!isVoiceIndexValid(voiceIndex)) {
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
void putNote(const QPointF& pos, bool replace, bool insert) override;
|
void putNote(const QPointF& pos, bool replace, bool insert) override;
|
||||||
void setAccidental(AccidentalType accidentalType) override;
|
void setAccidental(AccidentalType accidentalType) override;
|
||||||
void setArticulation(SymbolId articulationSymbolId) override;
|
void setArticulation(SymbolId articulationSymbolId) override;
|
||||||
|
void setDrumNote(int note) override;
|
||||||
void addTuplet(const TupletOptions& options) override;
|
void addTuplet(const TupletOptions& options) override;
|
||||||
|
|
||||||
void addSlur(Ms::Slur* slur) override;
|
void addSlur(Ms::Slur* slur) override;
|
||||||
|
|
|
@ -223,6 +223,8 @@ struct NoteInputState
|
||||||
bool isRest = false;
|
bool isRest = false;
|
||||||
bool withSlur = false;
|
bool withSlur = false;
|
||||||
int currentVoiceIndex = 0;
|
int currentVoiceIndex = 0;
|
||||||
|
int currentTrack = 0;
|
||||||
|
const Drumset* drumset = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class NoteFilter
|
enum class NoteFilter
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "drumsetpanel.h"
|
#include "drumsetpalette.h"
|
||||||
|
|
||||||
#include "translation.h"
|
#include "translation.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
@ -35,72 +35,70 @@
|
||||||
#include "libmscore/mscore.h"
|
#include "libmscore/mscore.h"
|
||||||
#include "libmscore/undo.h"
|
#include "libmscore/undo.h"
|
||||||
|
|
||||||
|
using namespace mu::notation;
|
||||||
|
|
||||||
namespace Ms {
|
namespace Ms {
|
||||||
DrumsetPanel::DrumsetPanel(QWidget* parent)
|
DrumsetPalette::DrumsetPalette(QWidget* parent)
|
||||||
: PaletteScrollArea(nullptr, parent)
|
: PaletteScrollArea(nullptr, parent)
|
||||||
{
|
{
|
||||||
setObjectName("DrumsetPanel");
|
setObjectName("DrumsetPalette");
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
|
|
||||||
drumPalette = new Palette(this);
|
m_drumPalette = new Palette(this);
|
||||||
drumPalette->setMag(0.8);
|
m_drumPalette->setMag(0.8);
|
||||||
drumPalette->setSelectable(true);
|
m_drumPalette->setSelectable(true);
|
||||||
drumPalette->setUseDoubleClickToActivate(true);
|
m_drumPalette->setUseDoubleClickToActivate(true);
|
||||||
drumPalette->setGrid(28, 60);
|
m_drumPalette->setGrid(28, 60);
|
||||||
drumPalette->setContextMenuPolicy(Qt::PreventContextMenu);
|
m_drumPalette->setContextMenuPolicy(Qt::PreventContextMenu);
|
||||||
|
|
||||||
setWidget(drumPalette);
|
setWidget(m_drumPalette);
|
||||||
retranslate();
|
retranslate();
|
||||||
|
|
||||||
connect(drumPalette, SIGNAL(boxClicked(int)), SLOT(drumNoteSelected(int)));
|
connect(m_drumPalette, SIGNAL(boxClicked(int)), SLOT(drumNoteSelected(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrumsetPanel::setNotation(mu::notation::INotationPtr notation)
|
void DrumsetPalette::setNotation(INotationPtr notation)
|
||||||
{
|
{
|
||||||
m_notation = notation;
|
m_notation = notation;
|
||||||
updateDrumset();
|
updateDrumset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Score* DrumsetPanel::score() const
|
void DrumsetPalette::retranslate()
|
||||||
{
|
{
|
||||||
return m_notation ? m_notation->elements()->msScore() : nullptr;
|
m_drumPalette->setName(mu::qtrc("palette", "Drumset"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrumsetPanel::retranslate()
|
void DrumsetPalette::updateDrumset()
|
||||||
{
|
{
|
||||||
drumPalette->setName(mu::qtrc("palette", "Drumset"));
|
INotationNoteInputPtr noteInput = this->noteInput();
|
||||||
}
|
if (!noteInput) {
|
||||||
|
|
||||||
void DrumsetPanel::updateDrumset()
|
|
||||||
{
|
|
||||||
Score* score = this->score();
|
|
||||||
|
|
||||||
if (!score) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
drumPalette->clear();
|
m_drumPalette->clear();
|
||||||
|
|
||||||
const InputState& inputState = score->inputState();
|
NoteInputState state = noteInput->state();
|
||||||
drumset = inputState.drumset();
|
m_drumset = state.drumset;
|
||||||
staff = score->staff(inputState.track() / VOICES);
|
|
||||||
|
|
||||||
if (!drumset) {
|
if (!m_drumset) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACEFUNC;
|
||||||
|
|
||||||
double _spatium = gscore->spatium();
|
double _spatium = gscore->spatium();
|
||||||
|
|
||||||
for (int pitch = 0; pitch < 128; ++pitch) {
|
for (int pitch = 0; pitch < 128; ++pitch) {
|
||||||
if (!drumset->isValid(pitch)) {
|
if (!m_drumset->isValid(pitch)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool up;
|
bool up = false;
|
||||||
int line = drumset->line(pitch);
|
int line = m_drumset->line(pitch);
|
||||||
NoteHead::Group noteHead = drumset->noteHead(pitch);
|
NoteHead::Group noteHead = m_drumset->noteHead(pitch);
|
||||||
int voice = drumset->voice(pitch);
|
int voice = m_drumset->voice(pitch);
|
||||||
Direction dir = drumset->stemDirection(pitch);
|
Direction dir = m_drumset->stemDirection(pitch);
|
||||||
|
|
||||||
if (dir == Direction::UP) {
|
if (dir == Direction::UP) {
|
||||||
up = true;
|
up = true;
|
||||||
} else if (dir == Direction::DOWN) {
|
} else if (dir == Direction::DOWN) {
|
||||||
|
@ -128,63 +126,63 @@ void DrumsetPanel::updateDrumset()
|
||||||
note->setHeadGroup(noteHead);
|
note->setHeadGroup(noteHead);
|
||||||
SymId noteheadSym = SymId::noteheadBlack;
|
SymId noteheadSym = SymId::noteheadBlack;
|
||||||
if (noteHead == NoteHead::Group::HEAD_CUSTOM) {
|
if (noteHead == NoteHead::Group::HEAD_CUSTOM) {
|
||||||
noteheadSym = drumset->noteHeads(pitch, NoteHead::Type::HEAD_QUARTER);
|
noteheadSym = m_drumset->noteHeads(pitch, NoteHead::Type::HEAD_QUARTER);
|
||||||
} else {
|
} else {
|
||||||
noteheadSym = note->noteHead(true, noteHead, NoteHead::Type::HEAD_QUARTER);
|
noteheadSym = note->noteHead(true, noteHead, NoteHead::Type::HEAD_QUARTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
note->setCachedNoteheadSym(noteheadSym); // we use the cached notehead so we don't recompute it at each layout
|
note->setCachedNoteheadSym(noteheadSym); // we use the cached notehead so we don't recompute it at each layout
|
||||||
chord->add(note);
|
chord->add(note);
|
||||||
int sc = drumset->shortcut(pitch);
|
int sc = m_drumset->shortcut(pitch);
|
||||||
QString shortcut;
|
QString shortcut;
|
||||||
if (sc) {
|
if (sc) {
|
||||||
shortcut = QChar(sc);
|
shortcut = QChar(sc);
|
||||||
}
|
}
|
||||||
drumPalette->append(chord, mu::qtrc("drumset", drumset->name(pitch).toUtf8().data()), shortcut);
|
m_drumPalette->append(chord, mu::qtrc("drumset", m_drumset->name(pitch).toUtf8().data()), shortcut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrumsetPanel::drumNoteSelected(int val)
|
void DrumsetPalette::drumNoteSelected(int val)
|
||||||
{
|
{
|
||||||
Score* score = this->score();
|
INotationNoteInputPtr noteInput = this->noteInput();
|
||||||
|
if (!noteInput) {
|
||||||
if (!score) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementPtr element = drumPalette->element(val);
|
ElementPtr element = m_drumPalette->element(val);
|
||||||
if (!element || element->type() != ElementType::CHORD) {
|
if (!element || element->type() != ElementType::CHORD) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACEFUNC;
|
||||||
|
|
||||||
const Chord* ch = dynamic_cast<Chord*>(element.get());
|
const Chord* ch = dynamic_cast<Chord*>(element.get());
|
||||||
const Note* note = ch->downNote();
|
const Note* note = ch->downNote();
|
||||||
int pitch = note->pitch();
|
int pitch = note->pitch();
|
||||||
|
int voice = element->voice();
|
||||||
|
|
||||||
int track = (score->inputState().track() / VOICES) * VOICES + element->track();
|
noteInput->setCurrentVoiceIndex(voice);
|
||||||
score->inputState().setTrack(track);
|
noteInput->setDrumNote(pitch);
|
||||||
score->inputState().setDrumNote(pitch);
|
|
||||||
m_notation->interaction()->noteInput()->stateChanged().notify();
|
|
||||||
|
|
||||||
QString voiceActionCode = QString("voice-%1").arg(element->voice() + 1);
|
QString voiceActionCode = QString("voice-%1").arg(voice + 1);
|
||||||
dispatcher()->dispatch(voiceActionCode.toStdString());
|
dispatcher()->dispatch(voiceActionCode.toStdString());
|
||||||
|
|
||||||
auto pitchCell = drumPalette->cellAt(val);
|
auto pitchCell = m_drumPalette->cellAt(val);
|
||||||
m_pitchNameChanged.send(pitchCell->name);
|
m_pitchNameChanged.send(pitchCell->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrumsetPanel::selectedDrumNote()
|
int DrumsetPalette::selectedDrumNote()
|
||||||
{
|
{
|
||||||
int idx = drumPalette->getSelectedIdx();
|
int idx = m_drumPalette->getSelectedIdx();
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementPtr element = drumPalette->element(idx);
|
ElementPtr element = m_drumPalette->element(idx);
|
||||||
if (element && element->type() == ElementType::CHORD) {
|
if (element && element->type() == ElementType::CHORD) {
|
||||||
const Chord* ch = dynamic_cast<Chord*>(element.get());
|
const Chord* ch = dynamic_cast<Chord*>(element.get());
|
||||||
const Note* note = ch->downNote();
|
const Note* note = ch->downNote();
|
||||||
auto pitchCell = drumPalette->cellAt(idx);
|
auto pitchCell = m_drumPalette->cellAt(idx);
|
||||||
m_pitchNameChanged.send(pitchCell->name);
|
m_pitchNameChanged.send(pitchCell->name);
|
||||||
return note->pitch();
|
return note->pitch();
|
||||||
}
|
}
|
||||||
|
@ -192,7 +190,7 @@ int DrumsetPanel::selectedDrumNote()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrumsetPanel::changeEvent(QEvent* event)
|
void DrumsetPalette::changeEvent(QEvent* event)
|
||||||
{
|
{
|
||||||
QWidget::changeEvent(event);
|
QWidget::changeEvent(event);
|
||||||
if (event->type() == QEvent::LanguageChange) {
|
if (event->type() == QEvent::LanguageChange) {
|
||||||
|
@ -200,23 +198,28 @@ void DrumsetPanel::changeEvent(QEvent* event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrumsetPanel::mousePressEvent(QMouseEvent* event)
|
void DrumsetPalette::mousePressEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
drumPalette->handleEvent(event);
|
m_drumPalette->handleEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrumsetPanel::mouseMoveEvent(QMouseEvent* event)
|
void DrumsetPalette::mouseMoveEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
drumPalette->handleEvent(event);
|
m_drumPalette->handleEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrumsetPanel::handleEvent(QEvent* e)
|
bool DrumsetPalette::handleEvent(QEvent* e)
|
||||||
{
|
{
|
||||||
return QWidget::event(e);
|
return QWidget::event(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
mu::async::Channel<QString> DrumsetPanel::pitchNameChanged() const
|
mu::async::Channel<QString> DrumsetPalette::pitchNameChanged() const
|
||||||
{
|
{
|
||||||
return m_pitchNameChanged;
|
return m_pitchNameChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INotationNoteInputPtr DrumsetPalette::noteInput() const
|
||||||
|
{
|
||||||
|
return m_notation ? m_notation->interaction()->noteInput() : nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -20,8 +20,8 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MU_PALETTE_DRUMSETPANEL_H
|
#ifndef MU_PALETTE_DRUMSETPALETTE_H
|
||||||
#define MU_PALETTE_DRUMSETPANEL_H
|
#define MU_PALETTE_DRUMSETPALETTE_H
|
||||||
|
|
||||||
#include "palette/palette.h"
|
#include "palette/palette.h"
|
||||||
#include "notation/inotation.h"
|
#include "notation/inotation.h"
|
||||||
|
@ -34,14 +34,14 @@ class Score;
|
||||||
class Drumset;
|
class Drumset;
|
||||||
class Staff;
|
class Staff;
|
||||||
|
|
||||||
class DrumsetPanel : public PaletteScrollArea
|
class DrumsetPalette : public PaletteScrollArea
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
INJECT(Ms, mu::actions::IActionsDispatcher, dispatcher)
|
INJECT(Ms, mu::actions::IActionsDispatcher, dispatcher)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DrumsetPanel(QWidget* parent = nullptr);
|
explicit DrumsetPalette(QWidget* parent = nullptr);
|
||||||
|
|
||||||
void setNotation(mu::notation::INotationPtr notation);
|
void setNotation(mu::notation::INotationPtr notation);
|
||||||
void updateDrumset();
|
void updateDrumset();
|
||||||
|
@ -60,15 +60,14 @@ private:
|
||||||
int selectedDrumNote();
|
int selectedDrumNote();
|
||||||
void retranslate();
|
void retranslate();
|
||||||
|
|
||||||
Score* score() const;
|
mu::notation::INotationNoteInputPtr noteInput() const;
|
||||||
|
|
||||||
Staff* staff = nullptr;
|
Palette* m_drumPalette = nullptr;
|
||||||
Palette* drumPalette = nullptr;
|
const Drumset* m_drumset = nullptr;
|
||||||
const Drumset* drumset = nullptr;
|
|
||||||
|
|
||||||
mu::notation::INotationPtr m_notation;
|
mu::notation::INotationPtr m_notation;
|
||||||
mu::async::Channel<QString> m_pitchNameChanged;
|
mu::async::Channel<QString> m_pitchNameChanged;
|
||||||
};
|
};
|
||||||
} // namespace Ms
|
} // namespace Ms
|
||||||
|
|
||||||
#endif // MU_PALETTE_DRUMSETPANEL_H
|
#endif // MU_PALETTE_DRUMSETPALETTE_H
|
|
@ -31,22 +31,28 @@ Rectangle {
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: 26
|
||||||
|
anchors.rightMargin: 26
|
||||||
|
|
||||||
spacing: 6
|
spacing: 26
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
Layout.preferredWidth: 175
|
|
||||||
|
|
||||||
Layout.leftMargin: 26
|
|
||||||
|
|
||||||
spacing: 6
|
spacing: 6
|
||||||
|
|
||||||
StyledTextLabel {
|
StyledTextLabel {
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
|
height: 20
|
||||||
|
width: editDrumsetButton.width
|
||||||
|
|
||||||
text: drumsetView.pitchName
|
text: drumsetView.pitchName
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatButton {
|
FlatButton {
|
||||||
|
id: editDrumsetButton
|
||||||
|
|
||||||
text: qsTrc("palette", "Edit drumset")
|
text: qsTrc("palette", "Edit drumset")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
#include "drumsetpanelview.h"
|
#include "drumsetpanelview.h"
|
||||||
|
|
||||||
#include "internal/widgets/drumsetpanel.h"
|
#include "internal/widgets/drumsetpalette.h"
|
||||||
|
|
||||||
using namespace mu::notation;
|
using namespace mu::notation;
|
||||||
|
|
||||||
namespace mu::palette {
|
namespace mu::palette {
|
||||||
class DrumsetPanelAdapter : public ui::IDisplayableWidget
|
class DrumsetPaletteAdapter : public ui::IDisplayableWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrumsetPanelAdapter()
|
DrumsetPaletteAdapter()
|
||||||
: m_msDrumsetPanel(new Ms::DrumsetPanel())
|
: m_msDrumsetPalette(new Ms::DrumsetPalette())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~DrumsetPanelAdapter() override
|
~DrumsetPaletteAdapter() override
|
||||||
{
|
{
|
||||||
delete m_msDrumsetPanel;
|
delete m_msDrumsetPalette;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNotation(INotationPtr notation)
|
void setNotation(INotationPtr notation)
|
||||||
{
|
{
|
||||||
m_msDrumsetPanel->setNotation(notation);
|
m_msDrumsetPalette->setNotation(notation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateDrumset()
|
void updateDrumset()
|
||||||
{
|
{
|
||||||
m_msDrumsetPanel->updateDrumset();
|
m_msDrumsetPalette->updateDrumset();
|
||||||
}
|
}
|
||||||
|
|
||||||
async::Channel<QString> pitchNameChanged() const
|
async::Channel<QString> pitchNameChanged() const
|
||||||
{
|
{
|
||||||
return m_msDrumsetPanel->pitchNameChanged();
|
return m_msDrumsetPalette->pitchNameChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget* qWidget() override
|
QWidget* qWidget() override
|
||||||
{
|
{
|
||||||
return m_msDrumsetPanel;
|
return m_msDrumsetPalette;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handleEvent(QEvent* event) override
|
bool handleEvent(QEvent* event) override
|
||||||
{
|
{
|
||||||
return m_msDrumsetPanel->handleEvent(event);
|
return m_msDrumsetPalette->handleEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ms::DrumsetPanel* m_msDrumsetPanel = nullptr;
|
Ms::DrumsetPalette* m_msDrumsetPalette = nullptr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,16 +69,16 @@ void DrumsetPanelView::componentComplete()
|
||||||
{
|
{
|
||||||
WidgetView::componentComplete();
|
WidgetView::componentComplete();
|
||||||
|
|
||||||
auto drumsetPanel = std::make_shared<DrumsetPanelAdapter>();
|
auto drumsetPalette = std::make_shared<DrumsetPaletteAdapter>();
|
||||||
|
|
||||||
auto updateView = [this, drumsetPanel]() {
|
auto updateView = [this, drumsetPalette]() {
|
||||||
drumsetPanel->updateDrumset();
|
drumsetPalette->updateDrumset();
|
||||||
update();
|
update();
|
||||||
};
|
};
|
||||||
|
|
||||||
globalContext()->currentNotationChanged().onNotify(this, [this, drumsetPanel, updateView]() {
|
globalContext()->currentNotationChanged().onNotify(this, [this, drumsetPalette, updateView]() {
|
||||||
INotationPtr notation = globalContext()->currentNotation();
|
INotationPtr notation = globalContext()->currentNotation();
|
||||||
drumsetPanel->setNotation(notation);
|
drumsetPalette->setNotation(notation);
|
||||||
updateView();
|
updateView();
|
||||||
|
|
||||||
if (!notation) {
|
if (!notation) {
|
||||||
|
@ -90,10 +90,10 @@ void DrumsetPanelView::componentComplete()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
drumsetPanel->pitchNameChanged().onReceive(this, [this](const QString& pitchName) {
|
drumsetPalette->pitchNameChanged().onReceive(this, [this](const QString& pitchName) {
|
||||||
m_pitchName = pitchName;
|
m_pitchName = pitchName;
|
||||||
emit pitchNameChanged();
|
emit pitchNameChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
setWidget(drumsetPanel);
|
setWidget(drumsetPalette);
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,9 +129,12 @@ EditDrumsetDialog::EditDrumsetDialog(QWidget* parent)
|
||||||
setObjectName(EDIT_DRUMSET_DIALOG_NAME);
|
setObjectName(EDIT_DRUMSET_DIALOG_NAME);
|
||||||
|
|
||||||
m_notation = globalContext()->currentNotation();
|
m_notation = globalContext()->currentNotation();
|
||||||
const INotationInteractionPtr interaction = m_notation ? m_notation->interaction() : nullptr;
|
if (!m_notation) {
|
||||||
INotationInteraction::HitElementContext context
|
return;
|
||||||
= interaction ? interaction->hitElementContext() : INotationInteraction::HitElementContext();
|
}
|
||||||
|
|
||||||
|
const INotationInteractionPtr interaction = m_notation->interaction();
|
||||||
|
INotationInteraction::HitElementContext context = interaction->hitElementContext();
|
||||||
const Measure* measure = toMeasure(context.element);
|
const Measure* measure = toMeasure(context.element);
|
||||||
|
|
||||||
if (measure && context.staff) {
|
if (measure && context.staff) {
|
||||||
|
@ -139,6 +142,12 @@ EditDrumsetDialog::EditDrumsetDialog(QWidget* parent)
|
||||||
m_instrumentId = instrument->getId();
|
m_instrumentId = instrument->getId();
|
||||||
m_partId = context.staff->part()->id();
|
m_partId = context.staff->part()->id();
|
||||||
m_editedDrumset = *instrument->drumset();
|
m_editedDrumset = *instrument->drumset();
|
||||||
|
} else {
|
||||||
|
NoteInputState state = m_notation->interaction()->noteInput()->state();
|
||||||
|
const Staff* staff = m_notation->elements()->msScore()->staff(track2staff(state.currentTrack));
|
||||||
|
m_instrumentId = staff ? staff->part()->instrumentId() : QString();
|
||||||
|
m_partId = staff ? staff->part()->id() : QString();
|
||||||
|
m_editedDrumset = state.drumset ? *state.drumset : Drumset();
|
||||||
}
|
}
|
||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
|
@ -19,8 +19,8 @@ set(WIDGETS_SRC
|
||||||
${CMAKE_CURRENT_LIST_DIR}/specialcharactersdialog.h
|
${CMAKE_CURRENT_LIST_DIR}/specialcharactersdialog.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/editdrumsetdialog.h
|
${CMAKE_CURRENT_LIST_DIR}/editdrumsetdialog.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/editdrumsetdialog.cpp
|
${CMAKE_CURRENT_LIST_DIR}/editdrumsetdialog.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/drumsetpanel.cpp
|
${CMAKE_CURRENT_LIST_DIR}/drumsetpalette.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/drumsetpanel.h
|
${CMAKE_CURRENT_LIST_DIR}/drumsetpalette.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (WIDGETS_UI
|
set (WIDGETS_UI
|
||||||
|
|
Loading…
Reference in a new issue