From 51148a729cb5d62332c3ac56717a7cb3b5b0210e Mon Sep 17 00:00:00 2001 From: YohananDiamond Date: Mon, 31 Jul 2023 15:58:38 -0300 Subject: [PATCH] command palette: instrument and sample menus won't be doing for wavetables because they don't have text and that would be impossible to search through with a keyboard --- src/gui/commandPalette.cpp | 46 ++++++++++++++++++++++++++++++++++---- src/gui/commandPalette.h | 3 +++ src/gui/doAction.cpp | 6 +++++ src/gui/gui.h | 2 ++ src/gui/guiConst.cpp | 2 ++ 5 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/gui/commandPalette.cpp b/src/gui/commandPalette.cpp index d3744741b..af38fa1ac 100644 --- a/src/gui/commandPalette.cpp +++ b/src/gui/commandPalette.cpp @@ -76,6 +76,26 @@ void FurnaceGUI::drawPalette() { } break; + case CMDPAL_TYPE_INSTRUMENTS: + if (matchFuzzy("- None -",paletteQuery.c_str())) { + paletteSearchResults.push_back(0); + } + for (int i=0; isong.insLen; i++) { + if (matchFuzzy(e->song.ins[i]->name.c_str(),paletteQuery.c_str())) { + paletteSearchResults.push_back(i+1); // because over here ins=0 is 'None' + } + } + break; + + case CMDPAL_TYPE_SAMPLES: + for (int i=0; isong.sampleLen; i++) { + logD("ins #%x: %s", i, e->song.sample[i]->name.c_str()); + if (matchFuzzy(e->song.sample[i]->name.c_str(),paletteQuery.c_str())) { + paletteSearchResults.push_back(i); + } + } + break; + default: logE("invalid command palette type"); ImGui::CloseCurrentPopup(); @@ -109,13 +129,21 @@ void FurnaceGUI::drawPalette() { case CMDPAL_TYPE_RECENT: s=recentFile.at(id).c_str(); break; + case CMDPAL_TYPE_INSTRUMENTS: + if (id==0) { + s="- None -"; + } else { + s=e->song.ins[id-1]->name.c_str(); + } + break; + case CMDPAL_TYPE_SAMPLES: + s=e->song.sample[id]->name.c_str(); + break; default: logE("invalid command palette type"); break; }; - logD("~ %d, %d", curPaletteType, s == nullptr); - if (ImGui::Selectable(s,current)) { curPaletteChoice=i; accepted=true; @@ -147,24 +175,34 @@ void FurnaceGUI::drawPalette() { int i=paletteSearchResults[curPaletteChoice]; switch (curPaletteType) { case CMDPAL_TYPE_MAIN: - resetPalette(this); doAction(i); if (i