1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#include "UI.hpp"
#include <IconsFontAwesome.h>
#include <imgui.h>
#include <imgui_internal.h>
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) {
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, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f * ImGui::GetStyle().Alpha);
}
void ImGui::PopDisabled() {
ImGui::PopItemFlag();
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);
}
|