0 | 0 |
#include "font.hpp"
|
1 | 1 |
#include "ui.hpp"
|
2 | 2 |
#include "imgui.h"
|
|
3 |
#include <cstdlib>
|
3 | 4 |
|
4 | 5 |
namespace ana {
|
5 | 6 |
namespace ui {
|
6 | 7 |
|
7 | |
void init_imgui() {
|
8 | |
ImGuiIO &io = ImGui::GetIO();
|
9 | |
io.Fonts->AddFontFromMemoryTTF(font_data, font_data_len, 16);
|
10 | |
}
|
|
8 |
static ImVec4 base = ImVec4(0.502f, 0.075f, 0.256f, 1.0f);
|
|
9 |
static ImVec4 bg = ImVec4(0.200f, 0.220f, 0.270f, 1.0f);
|
|
10 |
static ImVec4 text = ImVec4(0.860f, 0.930f, 0.890f, 1.0f);
|
|
11 |
static float high_val = 0.8f;
|
|
12 |
static float mid_val = 0.5f;
|
|
13 |
static float low_val = 0.3f;
|
|
14 |
static float window_offset = -0.2f;
|
|
15 |
|
|
16 |
inline ImVec4 make_high(float alpha) {
|
|
17 |
ImVec4 res(0, 0, 0, alpha);
|
|
18 |
ImGui::ColorConvertRGBtoHSV(base.x, base.y, base.z, res.x, res.y, res.z);
|
|
19 |
res.z = high_val;
|
|
20 |
ImGui::ColorConvertHSVtoRGB(res.x, res.y, res.z, res.x, res.y, res.z);
|
|
21 |
return res;
|
|
22 |
}
|
|
23 |
|
|
24 |
inline ImVec4 make_mid(float alpha) {
|
|
25 |
ImVec4 res(0, 0, 0, alpha);
|
|
26 |
ImGui::ColorConvertRGBtoHSV(base.x, base.y, base.z, res.x, res.y, res.z);
|
|
27 |
res.z = mid_val;
|
|
28 |
ImGui::ColorConvertHSVtoRGB(res.x, res.y, res.z, res.x, res.y, res.z);
|
|
29 |
return res;
|
|
30 |
}
|
|
31 |
|
|
32 |
inline ImVec4 make_low(float alpha) {
|
|
33 |
ImVec4 res(0, 0, 0, alpha);
|
|
34 |
ImGui::ColorConvertRGBtoHSV(base.x, base.y, base.z, res.x, res.y, res.z);
|
|
35 |
res.z = low_val;
|
|
36 |
ImGui::ColorConvertHSVtoRGB(res.x, res.y, res.z, res.x, res.y, res.z);
|
|
37 |
return res;
|
|
38 |
}
|
|
39 |
|
|
40 |
inline ImVec4 make_bg(float alpha, float offset = 0.f) {
|
|
41 |
ImVec4 res(0, 0, 0, alpha);
|
|
42 |
ImGui::ColorConvertRGBtoHSV(bg.x, bg.y, bg.z, res.x, res.y, res.z);
|
|
43 |
res.z += offset;
|
|
44 |
ImGui::ColorConvertHSVtoRGB(res.x, res.y, res.z, res.x, res.y, res.z);
|
|
45 |
return res;
|
|
46 |
}
|
|
47 |
|
|
48 |
inline ImVec4 make_text(float alpha) {
|
|
49 |
return ImVec4(text.x, text.y, text.z, alpha);
|
|
50 |
}
|
|
51 |
|
|
52 |
void init_imgui() {
|
|
53 |
ImGuiIO &io = ImGui::GetIO();
|
|
54 |
void *data = malloc(font_data_len);
|
|
55 |
memcpy(data, &font_data, font_data_len);
|
|
56 |
io.Fonts->AddFontFromMemoryTTF(data, font_data_len, 24);
|
|
57 |
|
|
58 |
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
|
59 |
|
|
60 |
ImGuiStyle &style = ImGui::GetStyle();
|
|
61 |
style.FrameRounding = 3.0f;
|
|
62 |
style.GrabRounding = 2.0f;
|
|
63 |
|
|
64 |
auto &colors = style.Colors;
|
|
65 |
colors[ImGuiCol_Text] = ImVec4(1.00f, 0.90f, 0.92f, 0.78f);
|
|
66 |
colors[ImGuiCol_TextDisabled] = ImVec4(1.00f, 0.90f, 0.92f, 0.28f);
|
|
67 |
colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.04f, 0.04f, 1.00f);
|
|
68 |
colors[ImGuiCol_ChildBg] = ImVec4(0.14f, 0.08f, 0.09f, 0.58f);
|
|
69 |
colors[ImGuiCol_PopupBg] = ImVec4(0.14f, 0.08f, 0.09f, 0.90f);
|
|
70 |
colors[ImGuiCol_Border] = ImVec4(0.09f, 0.05f, 0.06f, 0.60f);
|
|
71 |
colors[ImGuiCol_BorderShadow] = ImVec4(0.14f, 0.08f, 0.09f, 0.00f);
|
|
72 |
colors[ImGuiCol_FrameBg] = ImVec4(0.14f, 0.08f, 0.09f, 1.00f);
|
|
73 |
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.60f, 0.10f, 0.20f, 0.78f);
|
|
74 |
colors[ImGuiCol_FrameBgActive] = ImVec4(0.60f, 0.10f, 0.20f, 1.00f);
|
|
75 |
colors[ImGuiCol_TitleBg] = ImVec4(0.23f, 0.04f, 0.08f, 1.00f);
|
|
76 |
colors[ImGuiCol_TitleBgActive] = ImVec4(0.76f, 0.13f, 0.26f, 1.00f);
|
|
77 |
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.14f, 0.08f, 0.09f, 0.75f);
|
|
78 |
colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.08f, 0.09f, 0.47f);
|
|
79 |
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.14f, 0.08f, 0.09f, 1.00f);
|
|
80 |
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.23f, 0.04f, 0.08f, 1.00f);
|
|
81 |
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.60f, 0.10f, 0.20f, 0.78f);
|
|
82 |
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.60f, 0.10f, 0.20f, 1.00f);
|
|
83 |
colors[ImGuiCol_CheckMark] = ImVec4(0.76f, 0.13f, 0.26f, 1.00f);
|
|
84 |
colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.14f, 0.16f, 1.00f);
|
|
85 |
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.76f, 0.13f, 0.26f, 1.00f);
|
|
86 |
colors[ImGuiCol_Button] = ImVec4(0.34f, 0.20f, 0.23f, 1.00f);
|
|
87 |
colors[ImGuiCol_ButtonHovered] = ImVec4(0.60f, 0.10f, 0.20f, 1.00f);
|
|
88 |
colors[ImGuiCol_ButtonActive] = ImVec4(0.76f, 0.13f, 0.26f, 1.00f);
|
|
89 |
colors[ImGuiCol_Header] = ImVec4(0.60f, 0.10f, 0.20f, 0.76f);
|
|
90 |
colors[ImGuiCol_HeaderHovered] = ImVec4(0.60f, 0.10f, 0.20f, 0.86f);
|
|
91 |
colors[ImGuiCol_HeaderActive] = ImVec4(0.76f, 0.13f, 0.26f, 1.00f);
|
|
92 |
colors[ImGuiCol_Separator] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
|
|
93 |
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f);
|
|
94 |
colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f);
|
|
95 |
colors[ImGuiCol_ResizeGrip] = ImVec4(0.47f, 0.77f, 0.83f, 0.04f);
|
|
96 |
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.60f, 0.10f, 0.20f, 0.78f);
|
|
97 |
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.60f, 0.10f, 0.20f, 1.00f);
|
|
98 |
colors[ImGuiCol_Tab] = ImVec4(0.14f, 0.08f, 0.09f, 0.40f);
|
|
99 |
colors[ImGuiCol_TabHovered] = ImVec4(0.76f, 0.13f, 0.26f, 1.00f);
|
|
100 |
colors[ImGuiCol_TabActive] = ImVec4(0.60f, 0.10f, 0.20f, 1.00f);
|
|
101 |
colors[ImGuiCol_TabUnfocused] = ImVec4(0.14f, 0.08f, 0.09f, 0.40f);
|
|
102 |
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.14f, 0.08f, 0.09f, 0.70f);
|
|
103 |
colors[ImGuiCol_DockingPreview] = ImVec4(0.76f, 0.13f, 0.26f, 0.30f);
|
|
104 |
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
|
105 |
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 0.90f, 0.92f, 0.63f);
|
|
106 |
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.60f, 0.10f, 0.20f, 1.00f);
|
|
107 |
colors[ImGuiCol_PlotHistogram] = ImVec4(1.00f, 0.90f, 0.92f, 0.63f);
|
|
108 |
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(0.60f, 0.10f, 0.20f, 1.00f);
|
|
109 |
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.60f, 0.10f, 0.20f, 0.43f);
|
|
110 |
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
|
111 |
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
|
112 |
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
|
113 |
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
|
|
114 |
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.14f, 0.08f, 0.09f, 0.73f);
|
|
115 |
}
|
11 | 116 |
|
12 | 117 |
}
|
13 | 118 |
}
|