From 40a63433c55b09416272171ffbf2e92910506b27 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 17 May 2022 15:48:37 -0500 Subject: [PATCH] GUI: prepare for the input pad --- src/gui/gui.cpp | 6 ++-- src/gui/gui.h | 2 +- src/gui/piano.cpp | 72 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 76 insertions(+), 4 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 7933a14b5..903ae888b 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2323,8 +2323,8 @@ void FurnaceGUI::processPoint(SDL_Event& ev) { } TouchPoint newPoint(ev.button.x,ev.button.y); #ifdef __APPLE__ - newPoint->x*=dpiScale; - newPoint->y*=dpiScale; + newPoint.x*=dpiScale; + newPoint.y*=dpiScale; #endif activePoints.push_back(newPoint); pressedPoints.push_back(newPoint); @@ -4276,6 +4276,7 @@ FurnaceGUI::FurnaceGUI(): pianoOffset(6), pianoOffsetEdit(9), pianoView(2), + pianoInputPadMode(2), #else pianoOctaves(7), pianoOctavesEdit(4), @@ -4284,6 +4285,7 @@ FurnaceGUI::FurnaceGUI(): pianoOffset(6), pianoOffsetEdit(6), pianoView(0), + pianoInputPadMode(0), #endif hasACED(false) { // value keys diff --git a/src/gui/gui.h b/src/gui/gui.h index ee80a3d6f..777a9690a 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1226,7 +1226,7 @@ class FurnaceGUI { float pianoKeyHit[180]; bool pianoKeyPressed[180]; int pianoOffset, pianoOffsetEdit; - int pianoView; + int pianoView, pianoInputPadMode; // TX81Z bool hasACED; diff --git a/src/gui/piano.cpp b/src/gui/piano.cpp index c4c1a474e..130c746c2 100644 --- a/src/gui/piano.cpp +++ b/src/gui/piano.cpp @@ -40,7 +40,11 @@ const bool isTopKey[12]={ false, true, false, true, false, false, true, false, true, false, true, false }; -// TODO: actually implement a piano! +#define VALUE_DIGIT(x,label) \ + if (ImGui::Selectable(label,false,0,ImVec2(50.0*dpiScale,50.0*dpiScale))) { \ + valueInput(x,false); \ + } + void FurnaceGUI::drawPiano() { if (nextWindow==GUI_WINDOW_PIANO) { pianoOpen=true; @@ -86,6 +90,19 @@ void FurnaceGUI::drawPiano() { if (ImGui::RadioButton("Continuous",pianoView==1)) { pianoView=1; } + ImGui::Text("Value input pad:"); + if (ImGui::RadioButton("Disabled",pianoInputPadMode==0)) { + pianoInputPadMode=0; + } + if (ImGui::RadioButton("On keyboard",pianoInputPadMode==1)) { + pianoInputPadMode=1; + } + if (ImGui::RadioButton("Split (automatic)",pianoInputPadMode==2)) { + pianoInputPadMode=2; + } + if (ImGui::RadioButton("Split (always visible)",pianoInputPadMode==3)) { + pianoInputPadMode=3; + } ImGui::Checkbox("Share play/edit offset/range",&pianoSharePosition); ImGui::EndPopup(); } @@ -295,4 +312,57 @@ void FurnaceGUI::drawPiano() { } if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PIANO; ImGui::End(); + + // draw input pad if necessary + if ((pianoInputPadMode==2 && cursor.xFine>0) || pianoInputPadMode==3) { + if (ImGui::Begin("Input Pad",NULL,ImGuiWindowFlags_NoTitleBar)) { + if (ImGui::BeginTable("InputPad",3,ImGuiTableFlags_Borders)) { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + VALUE_DIGIT(10,"A"); + ImGui::TableNextColumn(); + VALUE_DIGIT(11,"B"); + ImGui::TableNextColumn(); + VALUE_DIGIT(12,"C"); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + VALUE_DIGIT(13,"D"); + ImGui::TableNextColumn(); + VALUE_DIGIT(14,"E"); + ImGui::TableNextColumn(); + VALUE_DIGIT(15,"F"); + + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + VALUE_DIGIT(1,"1"); + ImGui::TableNextColumn(); + VALUE_DIGIT(2,"2"); + ImGui::TableNextColumn(); + VALUE_DIGIT(3,"3"); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + VALUE_DIGIT(4,"4"); + ImGui::TableNextColumn(); + VALUE_DIGIT(5,"5"); + ImGui::TableNextColumn(); + VALUE_DIGIT(6,"6"); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + VALUE_DIGIT(7,"7"); + ImGui::TableNextColumn(); + VALUE_DIGIT(8,"8"); + ImGui::TableNextColumn(); + VALUE_DIGIT(9,"9"); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TableNextColumn(); + VALUE_DIGIT(0,"0"); + ImGui::TableNextColumn(); + + ImGui::EndTable(); + } + } + if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PIANO; + ImGui::End(); + } }