From 6a667d949334566432892a59022dd2c67aba8e27 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 3 Jul 2023 21:24:36 +0200 Subject: [PATCH] impr: Allow image visualizer image to be scaled --- plugins/builtin/source/content/pl_visualizers.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/builtin/source/content/pl_visualizers.cpp b/plugins/builtin/source/content/pl_visualizers.cpp index 6f43d526a..877d8eaba 100644 --- a/plugins/builtin/source/content/pl_visualizers.cpp +++ b/plugins/builtin/source/content/pl_visualizers.cpp @@ -87,15 +87,25 @@ 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(); auto data = pattern->getBytes(); texture = ImGui::Texture(data.data(), data.size()); + scale = 200_scaled / texture.getSize().x; } 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 drawBitmapVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span arguments) {