From 519dd7f2dd66b26c9cd5fb074059d1ae6028e6cb Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 22 Mar 2022 18:05:32 -0500 Subject: [PATCH] GUI: aaand more sample editor work now it has a right click menu --- src/gui/gui.cpp | 2 -- src/gui/gui.h | 2 ++ src/gui/sampleEdit.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index fedf53d15..9f869e57d 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -1539,8 +1539,6 @@ void FurnaceGUI::processDrags(int dragX, int dragY) { fileName+=fallback; \ } -#define BIND_FOR(x) getKeyName(actionKeys[x],true).c_str() - void FurnaceGUI::editOptions(bool topMenu) { char id[4096]; if (ImGui::MenuItem("cut",BIND_FOR(GUI_ACTION_PAT_CUT))) doCopy(true); diff --git a/src/gui/gui.h b/src/gui/gui.h index f92efd959..a4feed9b5 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -43,6 +43,8 @@ #define TOGGLE_COLOR(x) ((x)?uiColors[GUI_COLOR_TOGGLE_ON]:uiColors[GUI_COLOR_TOGGLE_OFF]) +#define BIND_FOR(x) getKeyName(actionKeys[x],true).c_str() + enum FurnaceGUIColors { GUI_COLOR_BACKGROUND=0, GUI_COLOR_FRAME_BACKGROUND, diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index f8515db54..3bdfa6c9f 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -26,6 +26,7 @@ #include #include "guiConst.h" #include "sampleUtil.h" +#include "util.h" void FurnaceGUI::drawSampleEdit() { if (nextWindow==GUI_WINDOW_SAMPLE_EDIT) { @@ -580,10 +581,17 @@ void FurnaceGUI::drawSampleEdit() { logE("error while locking sample texture! %s\n",SDL_GetError()); } else { ImU32 bgColor=ImGui::GetColorU32(ImGuiCol_FrameBg); + ImU32 bgColorLoop=ImAlphaBlendColors(bgColor,ImGui::GetColorU32(ImGuiCol_FrameBgHovered,0.5)); ImU32 lineColor=ImGui::GetColorU32(ImGuiCol_PlotLines); ImU32 centerLineColor=ImAlphaBlendColors(bgColor,ImGui::GetColorU32(ImGuiCol_PlotLines,0.25)); - for (int i=0; iloopStart>=0 && sample->loopStart<(int)sample->samples && j-samplePos>sample->loopStart) { + data[i*availX+j]=bgColorLoop; + } else { + data[i*availX+j]=bgColor; + } + } } if (availY>0) { for (int i=availX*(availY>>1); i>1)); i++) { @@ -661,6 +669,33 @@ void FurnaceGUI::drawSampleEdit() { } } } + + if (!sampleDragMode && ImGui::IsItemClicked(ImGuiMouseButton_Right)) { + ImGui::OpenPopup("SRightClick"); + } + + if (ImGui::BeginPopup("SRightClick",ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize)) { + if (ImGui::MenuItem("cut",BIND_FOR(GUI_ACTION_SAMPLE_CUT))) { + doAction(GUI_ACTION_SAMPLE_CUT); + } + if (ImGui::MenuItem("copy",BIND_FOR(GUI_ACTION_SAMPLE_COPY))) { + doAction(GUI_ACTION_SAMPLE_COPY); + } + if (ImGui::MenuItem("paste",BIND_FOR(GUI_ACTION_SAMPLE_PASTE))) { + doAction(GUI_ACTION_SAMPLE_PASTE); + } + if (ImGui::MenuItem("paste (replace)",BIND_FOR(GUI_ACTION_SAMPLE_PASTE_REPLACE))) { + doAction(GUI_ACTION_SAMPLE_PASTE_REPLACE); + } + if (ImGui::MenuItem("paste (mix)",BIND_FOR(GUI_ACTION_SAMPLE_PASTE_MIX))) { + doAction(GUI_ACTION_SAMPLE_PASTE_MIX); + } + if (ImGui::MenuItem("select all",BIND_FOR(GUI_ACTION_SAMPLE_SELECT_ALL))) { + doAction(GUI_ACTION_SAMPLE_SELECT_ALL); + } + ImGui::EndPopup(); + } + String statusBar=sampleDragMode?"Draw":"Select"; bool drawSelection=false;