From 026ea6e197d8dc4713c5535fd33d353c69a8efa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 22 Jan 2026 13:46:17 +0100 Subject: [PATCH] imgui debugger: Make the repeat button capable of returning values > 1 (for very fast repeats, but the caller must support it) Also just increase the repeat rates in the ge debugger --- UI/ImDebugger/ImGe.cpp | 10 ++++++---- ext/imgui/imgui_extras.cpp | 8 +++++--- ext/imgui/imgui_extras.h | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/UI/ImDebugger/ImGe.cpp b/UI/ImDebugger/ImGe.cpp index f8912dd80c..0ed1f2b77c 100644 --- a/UI/ImDebugger/ImGe.cpp +++ b/UI/ImDebugger/ImGe.cpp @@ -1028,19 +1028,21 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa bool disableStepButtons = gpuDebug->GetBreakNext() != GPUDebug::BreakNext::NONE && gpuDebug->GetBreakNext() != GPUDebug::BreakNext::DEBUG_RUN; + constexpr float fastRepeatRate = 0.025f; + if (disableStepButtons) { ImGui::BeginDisabled(); } ImGui::SameLine(); - if (ImGui::RepeatButtonShift("Tex")) { + if (ImGui::RepeatButtonShift("Tex", fastRepeatRate)) { gpuDebug->SetBreakNext(GPUDebug::BreakNext::TEX); } ImGui::SameLine(); - if (ImGui::RepeatButtonShift("Prim")) { + if (ImGui::RepeatButtonShift("Prim", fastRepeatRate)) { gpuDebug->SetBreakNext(GPUDebug::BreakNext::PRIM); } ImGui::SameLine(); - if (ImGui::RepeatButtonShift("Draw")) { + if (ImGui::RepeatButtonShift("Draw", fastRepeatRate)) { gpuDebug->SetBreakNext(GPUDebug::BreakNext::DRAW); } ImGui::SameLine(); @@ -1052,7 +1054,7 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa gpuDebug->SetBreakNext(GPUDebug::BreakNext::CURVE); } ImGui::SameLine(); - if (ImGui::RepeatButtonShift("Single step")) { + if (ImGui::RepeatButtonShift("Single step", fastRepeatRate)) { gpuDebug->SetBreakNext(GPUDebug::BreakNext::OP); } if (disableStepButtons) { diff --git a/ext/imgui/imgui_extras.cpp b/ext/imgui/imgui_extras.cpp index 6dbd80a86c..423ba19188 100644 --- a/ext/imgui/imgui_extras.cpp +++ b/ext/imgui/imgui_extras.cpp @@ -17,10 +17,11 @@ bool RepeatButton(const char *title) { return false; } -bool RepeatButtonShift(const char* label, float repeatRate) { +int RepeatButtonShift(const char* label, float repeatRate) { bool clicked = ImGui::Button(label); bool shiftHeld = ImGui::IsKeyDown(ImGuiKey_LeftShift) || ImGui::IsKeyDown(ImGuiKey_RightShift); + bool ctrlHeld = ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl); bool held = ImGui::IsItemActive() && shiftHeld; static float repeatDelay = 0.25f; // seconds before repeating starts @@ -39,8 +40,9 @@ bool RepeatButtonShift(const char* label, float repeatRate) { int steps = static_cast(t / repeatRate); static int lastStep = -1; if (steps != lastStep) { + int count = steps - lastStep; lastStep = steps; - return true; + return count; } } } @@ -52,7 +54,7 @@ bool RepeatButtonShift(const char* label, float repeatRate) { } } - return clicked; + return clicked ? 1 : 0; } bool CollapsingHeaderWithCount(const char *title, int count, ImGuiTreeNodeFlags flags) { diff --git a/ext/imgui/imgui_extras.h b/ext/imgui/imgui_extras.h index 2bc89fbd3e..8829aba841 100644 --- a/ext/imgui/imgui_extras.h +++ b/ext/imgui/imgui_extras.h @@ -10,7 +10,7 @@ inline void TextUnformatted(std::string_view str) { } bool RepeatButton(const char *title); -bool RepeatButtonShift(const char* label, float repeatRate = 0.05f); +int RepeatButtonShift(const char* label, float repeatRate = 0.05f); bool CollapsingHeaderWithCount(const char *title, int count, ImGuiTreeNodeFlags flags = 0);