Added ImRaid helper library and first functions (ToggleButton and ToggleImageButton).

This commit is contained in:
Patrick 2025-03-04 00:32:43 +01:00
parent 08ea619a8e
commit eb5def0070

31
public/raid/imraid.hpp Normal file
View File

@ -0,0 +1,31 @@
#pragma once
#if !defined(RAID_PUBLIC_RAID_IMRAID_HPP_INCLUDED)
#define RAID_PUBLIC_RAID_IMRAID_HPP_INCLUDED 1
#include <imgui.h>
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)