From dc7aec2dc1a7707aead575c54c960c067be1217e Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 2 Dec 2022 04:13:26 -0500 Subject: [PATCH] GUI: long hold? --- extern/imgui_patched/imgui.cpp | 10 ++++++++++ extern/imgui_patched/imgui.h | 1 + src/gui/gui.cpp | 1 + src/gui/gui.h | 7 ++++++- src/gui/pattern.cpp | 24 ++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/extern/imgui_patched/imgui.cpp b/extern/imgui_patched/imgui.cpp index 742127d6b..37b0b5dfe 100644 --- a/extern/imgui_patched/imgui.cpp +++ b/extern/imgui_patched/imgui.cpp @@ -7552,6 +7552,16 @@ void ImGui::EndDisabled() g.Style.Alpha = g.DisabledAlphaBackup; //PopStyleVar(); } +// IsInertialScroll() + +bool ImGui::IsInertialScroll() +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window==NULL) return false; + return window->InertialScroll; +} + + // InhibitInertialScroll() void ImGui::InhibitInertialScroll() diff --git a/extern/imgui_patched/imgui.h b/extern/imgui_patched/imgui.h index 5359672e1..58dad2b61 100644 --- a/extern/imgui_patched/imgui.h +++ b/extern/imgui_patched/imgui.h @@ -839,6 +839,7 @@ namespace ImGui IMGUI_API void EndDisabled(); // Inertial scroll + IMGUI_API bool IsInertialScroll(); IMGUI_API void InhibitInertialScroll(); // Clipping diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index faba39198..eadac6d4b 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -5766,6 +5766,7 @@ FurnaceGUI::FurnaceGUI(): curWindowLast(GUI_WINDOW_NOTHING), curWindowThreadSafe(GUI_WINDOW_NOTHING), lastPatternWidth(0.0f), + longThreshold(0.4f), latchNote(-1), latchIns(-2), latchVol(-1), diff --git a/src/gui/gui.h b/src/gui/gui.h index 128bbe26a..8a9e1e441 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -53,6 +53,11 @@ _wi->std.waveMacro.vScroll=-1; \ } +#define CHECK_LONG_HOLD (mobileUI && ImGui::GetIO().MouseDown[ImGuiMouseButton_Left] && ImGui::GetIO().MouseDownDuration[ImGuiMouseButton_Left]>longThreshold && !ImGui::IsInertialScroll()) + +// for now +#define NOTIFY_LONG_HOLD logV("long hold"); + #define BIND_FOR(x) getKeyName(actionKeys[x],true).c_str() // TODO: @@ -1425,7 +1430,7 @@ class FurnaceGUI { float peak[2]; float patChanX[DIV_MAX_CHANS+1]; float patChanSlideY[DIV_MAX_CHANS+1]; - float lastPatternWidth; + float lastPatternWidth, longThreshold; String nextDesc; String nextDescName; diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index 483d66b53..89653daa1 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -128,6 +128,10 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int if (ImGui::IsItemClicked()) { startSelection(0,0,i,true); } + if (CHECK_LONG_HOLD) { + ImGui::InhibitInertialScroll(); + NOTIFY_LONG_HOLD; + } ImGui::PopStyleColor(); // for each column for (int j=0; jdata[i][index+1]==-1) { @@ -323,6 +343,10 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) { updateSelection(j,index,i); } + if (CHECK_LONG_HOLD) { + ImGui::InhibitInertialScroll(); + NOTIFY_LONG_HOLD; + } ImGui::PopStyleColor(); } }