From 003c9c323505f46a12fee9d31a2aa8a4596f167f Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 16 Apr 2022 23:58:29 -0500 Subject: [PATCH] GUI: prepare for GB envelope view --- src/gui/gui.h | 1 + src/gui/insEdit.cpp | 23 +++++++++++++++++++++++ src/gui/settings.cpp | 10 +++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/gui/gui.h b/src/gui/gui.h index b6613e9d..36b6a889 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1078,6 +1078,7 @@ class FurnaceGUI { void drawWaveform(unsigned char type, bool opz, const ImVec2& size); void drawAlgorithm(unsigned char alg, FurnaceGUIFMAlgs algType, const ImVec2& size); void drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, unsigned char d2r, unsigned char rr, unsigned char sl, unsigned char sus, unsigned char egt, unsigned char algOrGlobalSus, float maxTl, float maxArDr, const ImVec2& size, unsigned short instType); + void drawGBEnv(unsigned char vol, unsigned char len, unsigned char sLen, bool dir, const ImVec2& size); void drawSysConf(int i); // these ones offer ctrl-wheel fine value changes. diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 730d1695..a58feea8 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -1002,6 +1002,27 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, } } +void FurnaceGUI::drawGBEnv(unsigned char vol, unsigned char len, unsigned char sLen, bool dir, const ImVec2& size) { + //ImDrawList* dl=ImGui::GetWindowDrawList(); + ImGuiWindow* window=ImGui::GetCurrentWindow(); + + ImVec2 minArea=window->DC.CursorPos; + ImVec2 maxArea=ImVec2( + minArea.x+size.x, + minArea.y+size.y + ); + ImRect rect=ImRect(minArea,maxArea); + ImGuiStyle& style=ImGui::GetStyle(); + //ImU32 color=ImGui::GetColorU32(uiColors[GUI_COLOR_FM_ENVELOPE]); + //ImU32 colorS=ImGui::GetColorU32(uiColors[GUI_COLOR_FM_ENVELOPE_SUS_GUIDE]); // Sustain horiz/vert line color + ImGui::ItemSize(size,style.FramePadding.y); + if (ImGui::ItemAdd(rect,ImGui::GetID("alg"))) { + ImGui::RenderFrame(rect.Min,rect.Max,ImGui::GetColorU32(ImGuiCol_FrameBg),true,style.FrameRounding); + + // TODO: this whole thing + } +} + #define P(x) if (x) { \ MARK_MODIFIED; \ e->notifyInsChange(curIns); \ @@ -2242,6 +2263,8 @@ void FurnaceGUI::drawInsEdit() { goesUp=false; ins->gb.envDir=goesUp; } + + drawGBEnv(ins->gb.envVol,ins->gb.envLen,ins->gb.soundLen,ins->gb.envDir,ImVec2(ImGui::GetContentRegionAvail().x,100.0f*dpiScale)); ImGui::EndTabItem(); } if (ins->type==DIV_INS_C64) if (ImGui::BeginTabItem("C64")) { diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 2e23f2f7..5e0bdbad 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -1082,15 +1082,19 @@ void FurnaceGUI::drawSettings() { UI_COLOR_CONFIG(GUI_COLOR_ORDER_INACTIVE,"Inactive patterns"); ImGui::TreePop(); } + if (ImGui::TreeNode("Envelope View")) { + UI_COLOR_CONFIG(GUI_COLOR_FM_ENVELOPE,"Envelope"); + UI_COLOR_CONFIG(GUI_COLOR_FM_ENVELOPE_SUS_GUIDE,"Sustain guide"); + UI_COLOR_CONFIG(GUI_COLOR_FM_ENVELOPE_RELEASE,"Release"); + + ImGui::TreePop(); + } if (ImGui::TreeNode("FM Editor")) { UI_COLOR_CONFIG(GUI_COLOR_FM_ALG_BG,"Algorithm background"); UI_COLOR_CONFIG(GUI_COLOR_FM_ALG_LINE,"Algorithm lines"); UI_COLOR_CONFIG(GUI_COLOR_FM_MOD,"Modulator"); UI_COLOR_CONFIG(GUI_COLOR_FM_CAR,"Carrier"); - UI_COLOR_CONFIG(GUI_COLOR_FM_ENVELOPE,"Envelope"); - UI_COLOR_CONFIG(GUI_COLOR_FM_ENVELOPE_SUS_GUIDE,"Sustain guide"); - UI_COLOR_CONFIG(GUI_COLOR_FM_ENVELOPE_RELEASE,"Release"); UI_COLOR_CONFIG(GUI_COLOR_FM_SSG,"SSG-EG"); UI_COLOR_CONFIG(GUI_COLOR_FM_WAVE,"Waveform");