From fca3ce02a7febbf433069c406470e7c4ef7388da Mon Sep 17 00:00:00 2001 From: alederer Date: Sat, 17 Aug 2024 13:50:52 -0700 Subject: [PATCH] Add action to set curIns based on current channel instrument at cursor (#2090) * push test * remove test file * add GUI_ACTION_PAT_ABSORB_INSTRUMENT action (set current instrument to channel's current instrument column) --------- Co-authored-by: Adam Lederer --- src/gui/doAction.cpp | 11 +++++++++++ src/gui/gui.h | 1 + src/gui/guiConst.cpp | 1 + src/gui/settings.cpp | 1 + 4 files changed, 14 insertions(+) diff --git a/src/gui/doAction.cpp b/src/gui/doAction.cpp index fff5a85d9..bf5b89519 100644 --- a/src/gui/doAction.cpp +++ b/src/gui/doAction.cpp @@ -676,6 +676,17 @@ void FurnaceGUI::doAction(int what) { latchTarget=0; latchNibble=false; break; + case GUI_ACTION_PAT_ABSORB_INSTRUMENT: { + DivPattern* pat=e->curPat[cursor.xCoarse].getPattern(e->curOrders->ord[cursor.xCoarse][curOrder],false); + if (!pat) break; + for (int i=cursor.y; i>=0; i--) { + if (pat->data[i][2] >= 0) { + curIns=pat->data[i][2]; + break; + } + } + break; + } case GUI_ACTION_INS_LIST_ADD: if (settings.insTypeMenu) { diff --git a/src/gui/gui.h b/src/gui/gui.h index 0a4f434f5..ae6dde1ef 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -816,6 +816,7 @@ enum FurnaceGUIActions { GUI_ACTION_PAT_LATCH, GUI_ACTION_PAT_SCROLL_MODE, GUI_ACTION_PAT_CLEAR_LATCH, + GUI_ACTION_PAT_ABSORB_INSTRUMENT, GUI_ACTION_PAT_MAX, GUI_ACTION_INS_LIST_MIN, diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 09d0fefbb..13e8a9478 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -687,6 +687,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={ D("PAT_LATCH", _N("Set note input latch"), 0), D("PAT_SCROLL_MODE", _N("Change mobile scroll mode"), 0), D("PAT_CLEAR_LATCH", _N("Clear note input latch"), 0), + D("PAT_ABSORB_INSTRUMENT", _N("Set current instrument to channel's current instrument column"), 0), D("PAT_MAX", "", NOT_AN_ACTION), D("INS_LIST_MIN", _N("---Instrument list"), NOT_AN_ACTION), diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index b6c244430..8241e9ab1 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -2415,6 +2415,7 @@ void FurnaceGUI::drawSettings() { UI_KEYBIND_CONFIG(GUI_ACTION_PAT_EXPAND_SONG); UI_KEYBIND_CONFIG(GUI_ACTION_PAT_LATCH); UI_KEYBIND_CONFIG(GUI_ACTION_PAT_CLEAR_LATCH); + UI_KEYBIND_CONFIG(GUI_ACTION_PAT_ABSORB_INSTRUMENT); KEYBIND_CONFIG_END; ImGui::TreePop();