13#include <backends/imgui_impl_opengl3.h>
14#include <backends/imgui_impl_win32.h>
18#include "../application/application.h"
19#include "../render/render_context.h"
27 ImGui::CreateContext();
28 ImGui::StyleColorsClassic();
31 ImGuiIO &io = ImGui::GetIO(); (void)io;
32 io.ConfigWindowsMoveFromTitleBarOnly =
true;
33 io.ConfigFlags |= ImGuiConfigFlags_NavNoCaptureKeyboard;
34 io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
35 io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
36 io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable &&
43#ifdef SCL_PLATFORM_WINDOWS
44 const application &app = application::Get();
45 ImGui_ImplWin32_Init(app.GetWindow().GetHandle());
47# error Other platforms currently dont support GUI
55 default:
SCL_CORE_ASSERT(0,
"Other platforms currently dont support GUI");
return;
59 event_dispatcher::AddEventListner<keyboard_event>([&io](
keyboard_event &) {
return io.WantCaptureKeyboard; });
60 event_dispatcher::AddEventListner<mouse_button_event>([&io](
mouse_button_event &) {
return io.WantCaptureMouse; });
61 event_dispatcher::AddEventListner<mouse_move_event>([&io](
mouse_move_event &) {
return io.WantCaptureMouse; });
62 event_dispatcher::AddEventListner<mouse_wheel_event>([&io](
mouse_wheel_event &) {
return io.WantCaptureMouse; });
74 default:
SCL_CORE_ASSERT(0,
"Other render APIs currently dont support GUI");
return;
78#ifdef SCL_PLATFORM_WINDOWS
79 ImGui_ImplWin32_Shutdown();
81# error Other platforms currently dont support GUI
85 ImGui::DestroyContext();
91 ImGui_ImplOpenGL3_NewFrame();
92 ImGui_ImplWin32_NewFrame();
95 if (IsDockspace) DrawDockspace();
100 ImGuiIO &io = ImGui::GetIO();
101 const window::data &win_data = application::Get().GetWindow().GetWindowData();
102 io.DisplaySize = ImVec2((
float)win_data.
Width, (
float)win_data.
Height);
105 ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
107 if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
109#ifdef SCL_PLATFORM_WINDOWS
110 ImGui::UpdatePlatformWindows();
111 ImGui::RenderPlatformWindowsDefault();
113# error Other platforms currently dont support GUI
118void scl::gui::DrawDockspace()
120 ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
121 ImGuiWindowFlags window_flags =
122 ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus |
123 ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
125 const ImGuiViewport *viewport = ImGui::GetMainViewport();
126 ImGui::SetNextWindowPos(viewport->WorkPos);
127 ImGui::SetNextWindowSize(viewport->WorkSize);
128 ImGui::SetNextWindowViewport(viewport->ID);
129 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
130 ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
131 ImGui::Begin(
"DockSpace Demo", &IsDockspace, window_flags);
132 ImGui::PopStyleVar(2);
134 ImGuiIO &io = ImGui::GetIO();
135 if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
137 ImGuiID dockspace_id = ImGui::GetID(
"MyDockSpace");
138 ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
143void scl::gui::SetUpTheme()
145 auto& io = ImGui::GetIO();
146 float fontSize = 15.0f;
147 io.Fonts->AddFontFromFileTTF(
"assets/fonts/Quicksand-Regular.ttf", fontSize);
148 io.FontDefault = io.Fonts->AddFontFromFileTTF(
"assets/fonts/Quicksand-Regular.ttf", fontSize);
150 auto &style = ImGui::GetStyle();
151 style.FrameRounding = 4.0f;
152 style.WindowBorderSize = 0.0f;
153 style.WindowRounding = 4.0f;
154 style.PopupBorderSize = 0.0f;
155 style.GrabRounding = 4.0f;
156 style.ChildRounding = 4.0f;
158 ImVec4 *colors = style.Colors;
159 colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
160 colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
161 colors[ImGuiCol_WindowBg] = ImVec4(0.10f, 0.10f, 0.10f, 1.00f);
162 colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
163 colors[ImGuiCol_PopupBg] = ImVec4(0.19f, 0.19f, 0.19f, 0.92f);
164 colors[ImGuiCol_Border] = ImVec4(0.19f, 0.19f, 0.19f, 0.29f);
165 colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.24f);
166 colors[ImGuiCol_FrameBg] = ImVec4(0.05f, 0.05f, 0.05f, 0.54f);
167 colors[ImGuiCol_FrameBgHovered] = ImVec4(0.19f, 0.19f, 0.19f, 0.54f);
168 colors[ImGuiCol_FrameBgActive] = ImVec4(0.20f, 0.22f, 0.23f, 1.00f);
169 colors[ImGuiCol_TitleBg] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
170 colors[ImGuiCol_TitleBgActive] = ImVec4(0.06f, 0.06f, 0.06f, 1.00f);
171 colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
172 colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
173 colors[ImGuiCol_ScrollbarBg] = ImVec4(0.05f, 0.05f, 0.05f, 0.54f);
174 colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.34f, 0.34f, 0.34f, 0.54f);
175 colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.40f, 0.54f);
176 colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.56f, 0.56f, 0.56f, 0.54f);
177 colors[ImGuiCol_CheckMark] = ImVec4(0.33f, 0.67f, 0.86f, 1.00f);
178 colors[ImGuiCol_SliderGrab] = ImVec4(0.34f, 0.34f, 0.34f, 0.54f);
179 colors[ImGuiCol_SliderGrabActive] = ImVec4(0.56f, 0.56f, 0.56f, 0.54f);
180 colors[ImGuiCol_Button] = ImVec4(0.05f, 0.05f, 0.05f, 0.54f);
181 colors[ImGuiCol_ButtonHovered] = ImVec4(0.19f, 0.19f, 0.19f, 0.54f);
182 colors[ImGuiCol_ButtonActive] = ImVec4(0.20f, 0.22f, 0.23f, 1.00f);
183 colors[ImGuiCol_Header] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f);
184 colors[ImGuiCol_HeaderHovered] = ImVec4(0.00f, 0.00f, 0.00f, 0.36f);
185 colors[ImGuiCol_HeaderActive] = ImVec4(0.20f, 0.22f, 0.23f, 0.33f);
186 colors[ImGuiCol_Separator] = ImVec4(0.28f, 0.28f, 0.28f, 0.29f);
187 colors[ImGuiCol_SeparatorHovered] = ImVec4(0.44f, 0.44f, 0.44f, 0.29f);
188 colors[ImGuiCol_SeparatorActive] = ImVec4(0.40f, 0.44f, 0.47f, 1.00f);
189 colors[ImGuiCol_ResizeGrip] = ImVec4(0.28f, 0.28f, 0.28f, 0.29f);
190 colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.44f, 0.44f, 0.44f, 0.29f);
191 colors[ImGuiCol_ResizeGripActive] = ImVec4(0.40f, 0.44f, 0.47f, 1.00f);
192 colors[ImGuiCol_Tab] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f);
193 colors[ImGuiCol_TabHovered] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
194 colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.20f, 0.20f, 0.36f);
195 colors[ImGuiCol_TabUnfocused] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f);
196 colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
197 colors[ImGuiCol_DockingPreview] = ImVec4(0.33f, 0.67f, 0.86f, 1.00f);
198 colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.09f, 0.08f, 0.09f, 1.00f);
199 colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
200 colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
201 colors[ImGuiCol_PlotHistogram] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
202 colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
203 colors[ImGuiCol_TableHeaderBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f);
204 colors[ImGuiCol_TableBorderStrong] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f);
205 colors[ImGuiCol_TableBorderLight] = ImVec4(0.28f, 0.28f, 0.28f, 0.29f);
206 colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
207 colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f);
208 colors[ImGuiCol_TextSelectedBg] = ImVec4(0.20f, 0.22f, 0.23f, 1.00f);
209 colors[ImGuiCol_DragDropTarget] = ImVec4(0.33f, 0.67f, 0.86f, 1.00f);
210 colors[ImGuiCol_NavHighlight] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
211 colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 0.00f, 0.00f, 0.70f);
212 colors[ImGuiCol_NavWindowingDimBg] = ImVec4(1.00f, 0.00f, 0.00f, 0.20f);
213 colors[ImGuiCol_ModalWindowDimBg] = ImVec4(1.00f, 0.00f, 0.00f, 0.35f);
214 colors[ImGuiCol_PlotLines] = ImVec4(0.51f, 0.42f, 0.42f, 1.00f);
#define SCL_CORE_ASSERT(expr,...)
static void SubmitUpdate()
static void BeginUpdate()
static render_context_api GetApi()
#define SCL_CORE_SUCCES(...)
Sculpto library prehompiled header. Defines common definitions, includes commonly used modules.