From eb5def0070c198eca296e6af834b379086f9918c Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Tue, 4 Mar 2025 00:32:43 +0100 Subject: [PATCH] Added ImRaid helper library and first functions (ToggleButton and ToggleImageButton). --- public/raid/imraid.hpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 public/raid/imraid.hpp diff --git a/public/raid/imraid.hpp b/public/raid/imraid.hpp new file mode 100644 index 0000000..376c388 --- /dev/null +++ b/public/raid/imraid.hpp @@ -0,0 +1,31 @@ + +#pragma once + +#if !defined(RAID_PUBLIC_RAID_IMRAID_HPP_INCLUDED) +#define RAID_PUBLIC_RAID_IMRAID_HPP_INCLUDED 1 + +#include + +namespace ImRaid +{ +inline bool ToggleImageButton(const char* strId, ImTextureID textureId, const ImVec2& imageSize, bool& toggled) +{ + if (toggled) + { + ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive)); + } + const bool clicked = ImGui::ImageButton(strId, textureId, imageSize); + if (toggled) + { + ImGui::PopStyleColor(); + } + + if (clicked) + { + toggled = !toggled; + } + return clicked; +} +} // namespace ImRaid + +#endif // !defined(RAID_PUBLIC_RAID_IMRAID_HPP_INCLUDED)