3#include "LkEngine/Renderer/UI/Font.h"
6namespace LkEngine::UI {
13 enum class EStyle : uint32_t
18 LK_ENUM_CLASS(EStyle);
25 FORCEINLINE
FScopedStyle(
const ImGuiStyleVar StyleVar,
const T Value) { ImGui::PushStyleVar(StyleVar, Value); }
35 FORCEINLINE
FScopedColor(
const ImGuiCol ColorID,
const T Color) { ImGui::PushStyleColor(ColorID, ImColor(Color).Value); }
45 FORCEINLINE
FScopedID(
const T ID) { ImGui::PushID(ID); }
54 template <
typename ColorType,
typename... OtherColors>
56 const ColorType FirstColor,
57 OtherColors&&... OtherColorPairs)
58 : Count((
sizeof... (OtherColorPairs) / 2) + 1)
60 static_assert((
sizeof... (OtherColorPairs) & 1u) == 0,
"FScopedColorStack expects a list of pairs of color IDs and colors");
61 PushColor(FirstColorID, FirstColor, std::forward<OtherColors>(OtherColorPairs)...);
71 template <
typename ColorType,
typename... OtherColors>
72 FORCEINLINE
void PushColor(
const ImGuiCol ColorID,
73 const ColorType Color,
74 OtherColors&& ... OtherColorPairs)
76 if constexpr (
sizeof... (OtherColorPairs) == 0)
78 ImGui::PushStyleColor(ColorID, ImColor(Color).Value);
82 ImGui::PushStyleColor(ColorID, ImColor(Color).Value);
83 PushColor(std::forward<OtherColors>(OtherColorPairs)...);
91 template<
typename ValueType,
typename... OtherStylePairs>
93 const ValueType FirstValue,
94 OtherStylePairs&& ... OtherPairs)
95 : StackCount((
sizeof...(OtherPairs) / 2) + 1)
97 static_assert((
sizeof...(OtherPairs) & 1u) == 0);
98 PushStyle(FirstStyleVar, FirstValue, std::forward<OtherStylePairs>(OtherPairs)...);
108 template<
typename ValueType,
typename... OtherStylePairs>
109 FORCEINLINE
void PushStyle(
const ImGuiStyleVar StyleVar,
110 const ValueType Value,
111 OtherStylePairs&& ... OtherPairs)
113 if constexpr (
sizeof...(OtherPairs) == 0)
115 ImGui::PushStyleVar(StyleVar, Value);
119 ImGui::PushStyleVar(StyleVar, Value);
120 PushStyle(std::forward<OtherStylePairs>(OtherPairs)...);
128 FORCEINLINE
FScopedFont(ImFont* Font) { ImGui::PushFont(Font); }
137 using T = std::underlying_type_t<EStyle>;
146 FStyleMod(
const EStyle Style,
const int Value)
152 FStyleMod(
const EStyle Style,
const float Value)
161 ArrFloat[0] = Value.X;
162 ArrFloat[1] = Value.Y;
171 float AlignHorizontal = -1.0f;
174 FORCEINLINE ImColor ColorWithMultipliedValue(
const ImColor& Color,
const float Multiplier)
176 const ImVec4& ColorRaw = Color.Value;
177 float Hue, Saturation, Value;
178 ImGui::ColorConvertRGBtoHSV(ColorRaw.x, ColorRaw.y, ColorRaw.z, Hue, Saturation, Value);
179 return ImColor::HSV(Hue, Saturation, std::min(Value * Multiplier, 1.0f));
182 FORCEINLINE ImColor ColorWithMultipliedSaturation(
const ImColor& Color,
const float Multiplier)
184 const ImVec4& ColorRaw = Color.Value;
185 float Hue, Saturation, Value;
186 ImGui::ColorConvertRGBtoHSV(ColorRaw.x, ColorRaw.y, ColorRaw.z, Hue, Saturation, Value);
187 return ImColor::HSV(Hue, std::min(Saturation * Multiplier, 1.0f), Value);
190 FORCEINLINE ImColor ColorWithMultipliedHue(
const ImColor& Color,
const float Multiplier)
192 const ImVec4& ColorRaw = Color.Value;
193 float Hue, Saturation, Value;
194 ImGui::ColorConvertRGBtoHSV(ColorRaw.x, ColorRaw.y, ColorRaw.z, Hue, Saturation, Value);
195 return ImColor::HSV(std::min(Hue * Multiplier, 1.0f), Saturation, Value);