diff options
Diffstat (limited to 'core/src/UI/UI_Utils.cpp')
-rw-r--r-- | core/src/UI/UI_Utils.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/core/src/UI/UI_Utils.cpp b/core/src/UI/UI_Utils.cpp index 06fd55e..15f88cf 100644 --- a/core/src/UI/UI_Utils.cpp +++ b/core/src/UI/UI_Utils.cpp @@ -4,31 +4,37 @@ #include <imgui.h> #include <imgui_internal.h> -void ImGui::SetNextWindowSizeRelScreen(float xPercent, float yPercent, ImGuiCond cond) { +void ImGui::SetNextWindowSizeRelScreen(float xPercent, float yPercent, ImGuiCond cond) +{ auto vs = ImGui::GetMainViewport()->Size; ImGui::SetNextWindowSize({ vs.x * xPercent, vs.y * yPercent }, cond); } -void ImGui::SetNextWindowCentered(ImGuiCond cond) { +void ImGui::SetNextWindowCentered(ImGuiCond cond) +{ auto vs = ImGui::GetMainViewport()->Size; ImGui::SetNextWindowPos({ vs.x / 2, vs.y / 2 }, cond, { 0.5f, 0.5f }); } -void ImGui::PushDisabled() { +void ImGui::PushDisabled() +{ ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f * ImGui::GetStyle().Alpha); } -void ImGui::PopDisabled() { +void ImGui::PopDisabled() +{ ImGui::PopItemFlag(); ImGui::PopStyleVar(); } -bool ImGui::Button(const char* label, bool disabled) { +bool ImGui::Button(const char* label, bool disabled) +{ return Button(label, ImVec2{}, disabled); } -bool ImGui::Button(const char* label, const ImVec2& sizeArg, bool disabled) { +bool ImGui::Button(const char* label, const ImVec2& sizeArg, bool disabled) +{ if (disabled) PushDisabled(); bool res = ImGui::Button(label, sizeArg); if (disabled) PopDisabled(); @@ -36,13 +42,15 @@ bool ImGui::Button(const char* label, const ImVec2& sizeArg, bool disabled) { return res; } -void ImGui::ErrorIcon() { +void ImGui::ErrorIcon() +{ ImGui::PushStyleColor(ImGuiCol_Text, ImVec4{ 237 / 255.0f, 67 / 255.0f, 55 / 255.0f, 1.0f }); // #ED4337 ImGui::Text(ICON_FA_EXCLAMATION_CIRCLE); ImGui::PopStyleColor(); } -void ImGui::ErrorMessage(const char* fmt, ...) { +void ImGui::ErrorMessage(const char* fmt, ...) +{ ErrorIcon(); SameLine(); @@ -52,13 +60,15 @@ void ImGui::ErrorMessage(const char* fmt, ...) { va_end(args); } -void ImGui::WarningIcon() { +void ImGui::WarningIcon() +{ ImGui::PushStyleColor(ImGuiCol_Text, ImVec4{ 255 / 255.0f, 184 / 255.0f, 24 / 255.0f, 1.0f }); // #FFB818 ImGui::Text(ICON_FA_EXCLAMATION_TRIANGLE); ImGui::PopStyleColor(); } -void ImGui::WarningMessage(const char* fmt, ...) { +void ImGui::WarningMessage(const char* fmt, ...) +{ WarningIcon(); SameLine(); |