From 16e6437dc481492a4bae7a516d36bcbd81ff10f8 Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Sat, 1 Nov 2025 23:36:22 +0100 Subject: [PATCH] Refactor _drawIcon function to make accessible outside --- src/ImGuiToolkit.cpp | 5 ++++- src/ImGuiToolkit.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ImGuiToolkit.cpp b/src/ImGuiToolkit.cpp index f188bbb..ff934af 100644 --- a/src/ImGuiToolkit.cpp +++ b/src/ImGuiToolkit.cpp @@ -173,12 +173,15 @@ bool ImGuiToolkit::ButtonSwitch(const char* label, bool* toggle, const char* too -void _drawIcon(ImVec2 screenpos, int i, int j, bool enabled = true, ImGuiWindow* window = ImGui::GetCurrentWindow() ) +void _drawIcon(ImVec2 screenpos, int i, int j, bool enabled, ImGuiWindow* window ) { // icons.dds is a 20 x 20 grid of icons if (textureicons == 0) textureicons = Resource::getTextureDDS("images/icons.dds"); + if (window == nullptr) + window = ImGui::GetCurrentWindow(); + ImVec2 uv0( static_cast(i) * 0.05, static_cast(j) * 0.05 ); ImVec2 uv1( uv0.x + 0.05, uv0.y + 0.05 ); diff --git a/src/ImGuiToolkit.h b/src/ImGuiToolkit.h index ad62ce9..dc06b3e 100644 --- a/src/ImGuiToolkit.h +++ b/src/ImGuiToolkit.h @@ -12,6 +12,8 @@ #include "IconsFontAwesome5.h" +void _drawIcon(ImVec2 screenpos, int i, int j, bool enabled = true, struct ImGuiWindow* window = nullptr ); + namespace ImGuiToolkit { // Icons from resource icon.dds