aboutsummaryrefslogtreecommitdiff
path: root/core/src/UI/UI_Utils.cpp
blob: 615caae4064ffc4285287577d3c97e1d45567ed1 (plain)
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
#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, false);
	ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f * ImGui::GetStyle().Alpha);
}

void ImGui::PopDisabled() {
	ImGui::PopItemFlag();
	ImGui::PopStyleVar();
}

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::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();
}