From 636a01f3078bc8babf5d2727e818c3d8c8189408 Mon Sep 17 00:00:00 2001 From: Rene Stange Date: Mon, 11 Apr 2022 19:23:18 +0200 Subject: [PATCH] uimenu: Add shortcut for changing OP (#84) Allows to quickly change the current OP, when editing OP parameters. --- src/uimenu.cpp | 33 ++++++++++++++++++++++++++++++++- src/uimenu.h | 1 + 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/uimenu.cpp b/src/uimenu.cpp index 450023a..4cac376 100644 --- a/src/uimenu.cpp +++ b/src/uimenu.cpp @@ -94,6 +94,7 @@ const CUIMenu::TMenuItem CUIMenu::s_ReverbMenu[] = #endif +// inserting menu items before "OP1" affect OPShortcutHandler() const CUIMenu::TMenuItem CUIMenu::s_EditVoiceMenu[] = { {"OP1", MenuHandler, s_OperatorMenu, 0}, @@ -636,7 +637,7 @@ void CUIMenu::EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event) case MenuEventPressAndStepDown: case MenuEventPressAndStepUp: - pUIMenu->TGShortcutHandler (Event); + pUIMenu->OPShortcutHandler (Event); return; default: @@ -892,6 +893,36 @@ void CUIMenu::TGShortcutHandler (TMenuEvent Event) } } +void CUIMenu::OPShortcutHandler (TMenuEvent Event) +{ + assert (m_nCurrentMenuDepth >= 3); + assert (m_MenuStackMenu[m_nCurrentMenuDepth-2] = s_EditVoiceMenu); + unsigned nOP = m_nMenuStackSelection[m_nCurrentMenuDepth-2]; + assert (nOP < 6); + assert (m_nMenuStackItem[m_nCurrentMenuDepth-1] == nOP); + assert (m_nMenuStackParameter[m_nCurrentMenuDepth-1] == nOP); + + assert ( Event == MenuEventPressAndStepDown + || Event == MenuEventPressAndStepUp); + if (Event == MenuEventPressAndStepDown) + { + nOP--; + } + else + { + nOP++; + } + + if (nOP < 6) + { + m_nMenuStackSelection[m_nCurrentMenuDepth-2] = nOP; + m_nMenuStackItem[m_nCurrentMenuDepth-1] = nOP; + m_nMenuStackParameter[m_nCurrentMenuDepth-1] = nOP; + + EventHandler (MenuEventUpdate); + } +} + void CUIMenu::TimerHandler (TKernelTimerHandle hTimer, void *pParam, void *pContext) { CUIMenu *pThis = static_cast (pContext); diff --git a/src/uimenu.h b/src/uimenu.h index 0da612b..f48f659 100644 --- a/src/uimenu.h +++ b/src/uimenu.h @@ -103,6 +103,7 @@ private: static std::string ToOscillatorDetune (int nValue); void TGShortcutHandler (TMenuEvent Event); + void OPShortcutHandler (TMenuEvent Event); static void TimerHandler (TKernelTimerHandle hTimer, void *pParam, void *pContext);