aboutsummaryrefslogtreecommitdiff
path: root/core/src/UI/UI_Utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/UI/UI_Utils.cpp')
-rw-r--r--core/src/UI/UI_Utils.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/core/src/UI/UI_Utils.cpp b/core/src/UI/UI_Utils.cpp
index 615caae..06fd55e 100644
--- a/core/src/UI/UI_Utils.cpp
+++ b/core/src/UI/UI_Utils.cpp
@@ -4,18 +4,18 @@
#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() {
- ImGui::PushItemFlag(ImGuiItemFlags_Disabled, false);
+ ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f * ImGui::GetStyle().Alpha);
}
@@ -24,14 +24,46 @@ void ImGui::PopDisabled() {
ImGui::PopStyleVar();
}
+bool ImGui::Button(const char* label, bool disabled) {
+ return Button(label, ImVec2{}, disabled);
+}
+
+bool ImGui::Button(const char* label, const ImVec2& sizeArg, bool disabled) {
+ if (disabled) PushDisabled();
+ bool res = ImGui::Button(label, sizeArg);
+ if (disabled) PopDisabled();
+
+ return res;
+}
+
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, ...) {
+ ErrorIcon();
+ SameLine();
+
+ va_list args;
+ va_start(args, fmt);
+ TextV(fmt, args);
+ va_end(args);
+}
+
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, ...) {
+ WarningIcon();
+ SameLine();
+
+ va_list args;
+ va_start(args, fmt);
+ TextV(fmt, args);
+ va_end(args);
+}