From 33566137c28690de3a062a61fe845a07b5f5a653 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 4 Jul 2023 22:17:51 +0200 Subject: [PATCH] impr: Allow bitmap visualizers to be zoomed --- plugins/builtin/source/content/pl_visualizers.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/builtin/source/content/pl_visualizers.cpp b/plugins/builtin/source/content/pl_visualizers.cpp index 1f64ec5cf..ae12cfab0 100644 --- a/plugins/builtin/source/content/pl_visualizers.cpp +++ b/plugins/builtin/source/content/pl_visualizers.cpp @@ -89,6 +89,7 @@ namespace hex::plugin::builtin { void drawImageVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span arguments) { static ImGui::Texture texture; static float scale = 1.0F; + if (shouldReset) { auto pattern = arguments[0].toPattern(); @@ -111,6 +112,8 @@ namespace hex::plugin::builtin { void drawBitmapVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span arguments) { static ImGui::Texture texture; + static float scale = 1.0F; + if (shouldReset) { auto pattern = arguments[0].toPattern(); auto width = arguments[1].toUnsigned(); @@ -121,7 +124,15 @@ namespace hex::plugin::builtin { } if (texture.isValid()) - ImGui::Image(texture, texture.getSize()); + ImGui::Image(texture, texture.getSize() * scale); + + if (ImGui::IsWindowHovered()) { + auto scrollDelta = ImGui::GetIO().MouseWheel; + if (scrollDelta != 0.0F) { + scale += scrollDelta * 0.1F; + scale = std::clamp(scale, 0.1F, 10.0F); + } + } } void drawDisassemblyVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span arguments) {