-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimgui_layer.cpp
99 lines (88 loc) · 5.37 KB
/
imgui_layer.cpp
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
97
98
99
#include "imgui_layer.hpp"
#include <unified/application/application.hpp>
#include <GLFW/glfw3.h>
UNIFIED_BEGIN_NAMESPACE
UNIFIED_MODULES_BEGIN_NAMESPACE
void ImGuiLayer::Create(Application *application) {
ImGui::CreateContext();
ImGui_ImplGlfw_InitForOpenGL(static_cast<GLFWwindow*>(application->get_native_window()), true);
ImGui_ImplOpenGL3_Init("#version 330 core");
ApplyDefaultStyle(ImGui::GetStyle());
}
void ImGuiLayer::Destroy() {
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
void ImGuiLayer::OnPreUpdate() {
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}
void ImGuiLayer::OnPostUpdate() {
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}
void ImGuiLayer::ApplyDefaultStyle(ImGuiStyle &style) {
ImVec4 *colors = style.Colors;
colors[ImGuiCol_Text] = ImVec4(1.000f, 1.000f, 1.000f, 1.000f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.500f, 0.500f, 0.500f, 1.000f);
colors[ImGuiCol_WindowBg] = ImVec4(0.180f, 0.180f, 0.180f, 0.700f);
colors[ImGuiCol_ChildBg] = ImVec4(0.280f, 0.280f, 0.280f, 0.000f);
colors[ImGuiCol_PopupBg] = ImVec4(0.313f, 0.313f, 0.313f, 0.700f);
colors[ImGuiCol_Border] = ImVec4(0.266f, 0.266f, 0.266f, 0.700f);
colors[ImGuiCol_BorderShadow] = ImVec4(0.000f, 0.000f, 0.000f, 0.000f);
colors[ImGuiCol_FrameBg] = ImVec4(0.160f, 0.160f, 0.160f, 0.700f);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.200f, 0.200f, 0.200f, 0.700f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.280f, 0.280f, 0.280f, 0.700f);
colors[ImGuiCol_TitleBg] = ImVec4(0.148f, 0.148f, 0.148f, 0.700f);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.148f, 0.148f, 0.148f, 0.700f);
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.148f, 0.148f, 0.148f, 0.700f);
colors[ImGuiCol_MenuBarBg] = ImVec4(0.195f, 0.195f, 0.195f, 1.000f);
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.160f, 0.160f, 0.160f, 1.000f);
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.277f, 0.277f, 0.277f, 1.000f);
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.300f, 0.300f, 0.300f, 1.000f);
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(1.000f, 1.000f, 1.000f, 0.670f);
colors[ImGuiCol_CheckMark] = ImVec4(1.000f, 1.000f, 1.000f, 1.000f);
colors[ImGuiCol_SliderGrab] = ImVec4(0.391f, 0.391f, 0.391f, 1.000f);
colors[ImGuiCol_SliderGrabActive] = ImVec4(1.000f, 1.000f, 1.000f, 0.670f);
colors[ImGuiCol_Button] = ImVec4(1.000f, 1.000f, 1.000f, 0.000f);
colors[ImGuiCol_ButtonHovered] = ImVec4(1.000f, 1.000f, 1.000f, 0.156f);
colors[ImGuiCol_ButtonActive] = ImVec4(1.000f, 1.000f, 1.000f, 0.391f);
colors[ImGuiCol_Header] = ImVec4(0.313f, 0.313f, 0.313f, 1.000f);
colors[ImGuiCol_HeaderHovered] = ImVec4(0.469f, 0.469f, 0.469f, 1.000f);
colors[ImGuiCol_HeaderActive] = ImVec4(0.469f, 0.469f, 0.469f, 1.000f);
colors[ImGuiCol_Separator] = ImVec4(0.266f, 0.266f, 0.266f, 1.000f);
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.391f, 0.391f, 0.391f, 1.000f);
colors[ImGuiCol_SeparatorActive] = ImVec4(1.000f, 1.000f, 1.000f, 0.670f);
colors[ImGuiCol_ResizeGrip] = ImVec4(1.000f, 1.000f, 1.000f, 0.250f);
colors[ImGuiCol_ResizeGripHovered] = ImVec4(1.000f, 1.000f, 1.000f, 0.670f);
colors[ImGuiCol_ResizeGripActive] = ImVec4(1.000f, 1.000f, 1.000f, 0.670f);
colors[ImGuiCol_Tab] = ImVec4(0.098f, 0.098f, 0.098f, 1.000f);
colors[ImGuiCol_TabHovered] = ImVec4(0.352f, 0.352f, 0.352f, 1.000f);
colors[ImGuiCol_TabActive] = ImVec4(0.195f, 0.195f, 0.195f, 1.000f);
colors[ImGuiCol_TabUnfocused] = ImVec4(0.098f, 0.098f, 0.098f, 1.000f);
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.195f, 0.195f, 0.195f, 1.000f);
colors[ImGuiCol_PlotLines] = ImVec4(0.469f, 0.469f, 0.469f, 1.000f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.000f, 1.000f, 1.000f, 0.670f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.586f, 0.586f, 0.586f, 1.000f);
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.000f, 1.000f, 1.000f, 0.670f);
colors[ImGuiCol_TextSelectedBg] = ImVec4(1.000f, 1.000f, 1.000f, 0.156f);
colors[ImGuiCol_DragDropTarget] = ImVec4(1.000f, 1.000f, 1.000f, 0.670f);
colors[ImGuiCol_NavHighlight] = ImVec4(1.000f, 1.000f, 1.000f, 0.670f);
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.000f, 1.000f, 1.000f, 0.670f);
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.000f, 0.000f, 0.000f, 0.586f);
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.000f, 0.000f, 0.000f, 0.586f);
style.ChildRounding = 2.0f;
style.FrameBorderSize = 1.0f;
style.FrameRounding = 1.0f;
style.GrabMinSize = 7.0f;
style.PopupRounding = 2.0f;
style.ScrollbarRounding = 12.0f;
style.ScrollbarSize = 13.0f;
style.TabBorderSize = 1.0f;
style.TabRounding = 0.0f;
style.WindowRounding = 4.0f;
}
UNIFIED_END_NAMESPACE
UNIFIED_MODULES_END_NAMESPACE