-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimguipp_v2.h
More file actions
96 lines (78 loc) · 2.1 KB
/
imguipp_v2.h
File metadata and controls
96 lines (78 loc) · 2.1 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#pragma once
#include "imgui.h"
#include "imgui_internal.h"
#include <string>
#include <vector>
#include <functional>
#define MAX_RGB 255.0
#define HELPMARKER(str) ImGui::SameLine(); ImGui::TextColored(ImColor(220, 190, 0, 255), "(?)"); if (ImGui::IsItemHovered()) ImGui::SetTooltip(str)
#pragma warning(disable: 26812 26815)
namespace ImGuiPP
{
void Line(int newId)
{
std::string id = ("imguipp_line_" + std::to_string(newId));
ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(0, 0, 0, 0));
{
ImGui::BeginChild(id.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 1), false);
ImGui::Separator();
ImGui::EndChild();
}
ImGui::PopStyleColor();
}
void Linevertical()
{
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
}
void CenterText(const char* text, int lineId, bool separator)
{
if (text == nullptr)
return;
ImGui::Spacing();
ImGui::SameLine((ImGui::GetContentRegionAvail().x / 2) - (ImGui::CalcTextSize(text).x / 2));
ImGui::Text(text);
ImGui::Spacing();
if (true == separator)
Line(lineId);
}
void CenterTextEx(const char* text, float width, int lineId, bool separator)
{
if (text == nullptr)
return;
ImGui::Spacing();
ImGui::SameLine((width / 2) - (ImGui::CalcTextSize(text).x / 2));
ImGui::Text(text);
ImGui::Spacing();
if (true == separator)
Line(lineId);
}
void DrawTextImGui(ImVec2 position, ImColor color, const char* format, ...)
{
if (format == nullptr)
return;
char buffer[512];
va_list args;
va_start(args, format);
vsnprintf_s(buffer, sizeof(buffer), format, args);
va_end(args);
ImGui::GetBackgroundDrawList()->AddText(position, color, format, buffer);
}
void DrawCircle(ImVec2 windowSize, ImColor color, float radius, float thickness = 1)
{
ImGui::GetBackgroundDrawList()->AddCircle(windowSize, radius, color, 100, thickness);
}
float GetX()
{
return ImGui::GetContentRegionAvail().x;
}
float GetY()
{
return ImGui::GetContentRegionAvail().y;
}
ImVec4 ToVec4(float r, float g, float b, float a)
{
return ImVec4(r / MAX_RGB, g / MAX_RGB, b / MAX_RGB, a / MAX_RGB);
}
}