mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
ImGui: Add "repeatshift" buttons that auto-repeat if you hold shift.
This commit is contained in:
@@ -662,6 +662,7 @@
|
||||
<ClCompile Include="..\ext\imgui\imgui.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_demo.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_draw.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_extras.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_impl_platform.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_impl_thin3d.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_tables.cpp" />
|
||||
|
||||
@@ -1303,6 +1303,9 @@
|
||||
<ClCompile Include="..\ext\lua\lzio.c">
|
||||
<Filter>ext\lua</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\imgui\imgui_extras.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Crypto">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "ext/imgui/imgui_internal.h"
|
||||
#include "ext/imgui/imgui_extras.h"
|
||||
#include "ext/imgui/imgui_impl_thin3d.h"
|
||||
|
||||
#include "Common/StringUtils.h"
|
||||
@@ -1239,8 +1240,7 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::SmallButton("Skim");
|
||||
if (ImGui::IsItemActive()) {
|
||||
if (ImGui::RepeatButton("Skim")) {
|
||||
u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC());
|
||||
Core_RequestCPUStep(CPUStepType::Into, stepSize);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ext/imgui/imgui.h"
|
||||
#include "ext/imgui/imgui_internal.h"
|
||||
#include "ext/imgui/imgui_extras.h"
|
||||
#include "ext/imgui/imgui_impl_thin3d.h"
|
||||
#include "Common/Data/Convert/ColorConv.h"
|
||||
#include "UI/ImDebugger/ImGe.h"
|
||||
@@ -847,19 +848,15 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa
|
||||
ImGui::BeginDisabled();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Tex")) {
|
||||
if (ImGui::RepeatButtonShift("Tex")) {
|
||||
gpuDebug->SetBreakNext(GPUDebug::BreakNext::TEX);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("NonTex")) {
|
||||
gpuDebug->SetBreakNext(GPUDebug::BreakNext::NONTEX);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Prim")) {
|
||||
if (ImGui::RepeatButtonShift("Prim")) {
|
||||
gpuDebug->SetBreakNext(GPUDebug::BreakNext::PRIM);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Draw")) {
|
||||
if (ImGui::RepeatButtonShift("Draw")) {
|
||||
gpuDebug->SetBreakNext(GPUDebug::BreakNext::DRAW);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
@@ -871,7 +868,7 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa
|
||||
gpuDebug->SetBreakNext(GPUDebug::BreakNext::CURVE);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Single step")) {
|
||||
if (ImGui::RepeatButtonShift("Single step")) {
|
||||
gpuDebug->SetBreakNext(GPUDebug::BreakNext::OP);
|
||||
}
|
||||
if (disableStepButtons) {
|
||||
|
||||
@@ -262,6 +262,7 @@
|
||||
<ClInclude Include="..\..\ext\basis_universal\basisu_transcoder_uastc.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imconfig.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imgui.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_extras.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_impl_platform.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_impl_thin3d.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_internal.h" />
|
||||
@@ -416,6 +417,7 @@
|
||||
<ClCompile Include="..\..\ext\imgui\imgui.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_demo.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_draw.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_extras.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_impl_platform.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_impl_thin3d.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_tables.cpp" />
|
||||
|
||||
@@ -517,6 +517,9 @@
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_impl_thin3d.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_extras.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="targetver.h" />
|
||||
@@ -993,6 +996,9 @@
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_impl_thin3d.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_extras.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\Common\Math\fast\fast_matrix_neon.S">
|
||||
|
||||
@@ -230,6 +230,7 @@ EXT_FILES := \
|
||||
$(SRC)/ext/imgui/imgui.cpp \
|
||||
$(SRC)/ext/imgui/imgui_demo.cpp \
|
||||
$(SRC)/ext/imgui/imgui_draw.cpp \
|
||||
$(SRC)/ext/imgui/imgui_extras.cpp \
|
||||
$(SRC)/ext/imgui/imgui_impl_thin3d.cpp \
|
||||
$(SRC)/ext/imgui/imgui_impl_platform.cpp \
|
||||
$(SRC)/ext/imgui/imgui_tables.cpp \
|
||||
|
||||
@@ -2,6 +2,7 @@ set(IMGUI_FILES
|
||||
imgui.cpp
|
||||
imgui_demo.cpp
|
||||
imgui_draw.cpp
|
||||
imgui_extras.cpp
|
||||
imgui_tables.cpp
|
||||
imgui_widgets.cpp
|
||||
imgui_impl_thin3d.cpp
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
// Just some string_view and related wrappers.
|
||||
|
||||
#include <string_view>
|
||||
#include "ext/imgui/imgui.h"
|
||||
|
||||
namespace ImGui {
|
||||
|
||||
bool RepeatButton(const char *title) {
|
||||
if (ImGui::SmallButton(title)) {
|
||||
return true;
|
||||
}
|
||||
if (ImGui::IsItemActive()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RepeatButtonShift(const char* label, float repeatRate) {
|
||||
bool clicked = ImGui::Button(label);
|
||||
|
||||
bool shiftHeld = ImGui::IsKeyDown(ImGuiKey_LeftShift) || ImGui::IsKeyDown(ImGuiKey_RightShift);
|
||||
bool held = ImGui::IsItemActive() && shiftHeld;
|
||||
|
||||
static float repeatDelay = 0.25f; // seconds before repeating starts
|
||||
static ImGuiID activeId = 0;
|
||||
static float holdTimer = 0.0f;
|
||||
|
||||
ImGuiID id = ImGui::GetItemID();
|
||||
if (held) {
|
||||
if (activeId != id) {
|
||||
activeId = id;
|
||||
holdTimer = 0.0f;
|
||||
} else {
|
||||
holdTimer += ImGui::GetIO().DeltaTime;
|
||||
if (holdTimer >= repeatDelay) {
|
||||
float t = holdTimer - repeatDelay;
|
||||
int steps = static_cast<int>(t / repeatRate);
|
||||
static int lastStep = -1;
|
||||
if (steps != lastStep) {
|
||||
lastStep = steps;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Reset if not holding
|
||||
if (activeId == id) {
|
||||
activeId = 0;
|
||||
holdTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
return clicked;
|
||||
}
|
||||
|
||||
} // namespace ImGui
|
||||
@@ -9,4 +9,7 @@ inline void TextUnformatted(std::string_view str) {
|
||||
TextUnformatted(str.data(), str.data() + str.size());
|
||||
}
|
||||
|
||||
bool RepeatButton(const char *title);
|
||||
bool RepeatButtonShift(const char* label, float repeatRate = 0.05f);
|
||||
|
||||
} // namespace ImGui
|
||||
|
||||
@@ -367,6 +367,7 @@ SOURCES_CXX += \
|
||||
$(EXTDIR)/imgui/imgui.cpp \
|
||||
$(EXTDIR)/imgui/imgui_demo.cpp \
|
||||
$(EXTDIR)/imgui/imgui_draw.cpp \
|
||||
$(EXTDIR)/imgui/imgui_extras.cpp \
|
||||
$(EXTDIR)/imgui/imgui_impl_thin3d.cpp \
|
||||
$(EXTDIR)/imgui/imgui_impl_platform.cpp \
|
||||
$(EXTDIR)/imgui/imgui_tables.cpp \
|
||||
|
||||
Reference in New Issue
Block a user