| 348 | template <vkb::BindingType bindingType> |
| 349 | inline Gui<bindingType>::Gui( |
| 350 | vkb::rendering::RenderContext<bindingType> &render_context_, Window const &window, vkb::stats::Stats<bindingType> const *stats, float font_size, bool explicit_update) : |
| 351 | render_context{render_context_}, |
| 352 | content_scale_factor{window.get_content_scale_factor()}, |
| 353 | dpi_factor{window.get_dpi_factor() * content_scale_factor}, |
| 354 | explicit_update{explicit_update}, |
| 355 | stats_view(stats) |
| 356 | { |
| 357 | ImGui::CreateContext(); |
| 358 | |
| 359 | ImGuiStyle &style = ImGui::GetStyle(); |
| 360 | |
| 361 | // Color scheme |
| 362 | style.Colors[ImGuiCol_WindowBg] = ImVec4(0.005f, 0.005f, 0.005f, 0.94f); |
| 363 | style.Colors[ImGuiCol_TitleBg] = ImVec4(1.0f, 0.0f, 0.0f, 0.6f); |
| 364 | style.Colors[ImGuiCol_TitleBgActive] = ImVec4(1.0f, 0.0f, 0.0f, 0.8f); |
| 365 | style.Colors[ImGuiCol_MenuBarBg] = ImVec4(1.0f, 0.0f, 0.0f, 0.4f); |
| 366 | style.Colors[ImGuiCol_Header] = ImVec4(1.0f, 0.0f, 0.0f, 0.4f); |
| 367 | style.Colors[ImGuiCol_HeaderActive] = ImVec4(1.0f, 0.0f, 0.0f, 0.4f); |
| 368 | style.Colors[ImGuiCol_HeaderHovered] = ImVec4(1.0f, 0.0f, 0.0f, 0.4f); |
| 369 | style.Colors[ImGuiCol_FrameBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.8f); |
| 370 | style.Colors[ImGuiCol_CheckMark] = ImVec4(0.0f, 1.0f, 0.0f, 1.0f); |
| 371 | style.Colors[ImGuiCol_SliderGrab] = ImVec4(1.0f, 0.0f, 0.0f, 0.4f); |
| 372 | style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(1.0f, 0.0f, 0.0f, 0.8f); |
| 373 | style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(1.0f, 1.0f, 1.0f, 0.1f); |
| 374 | style.Colors[ImGuiCol_FrameBgActive] = ImVec4(1.0f, 1.0f, 1.0f, 0.2f); |
| 375 | style.Colors[ImGuiCol_Button] = ImVec4(1.0f, 0.0f, 0.0f, 0.4f); |
| 376 | style.Colors[ImGuiCol_ButtonHovered] = ImVec4(1.0f, 0.0f, 0.0f, 0.6f); |
| 377 | style.Colors[ImGuiCol_ButtonActive] = ImVec4(1.0f, 0.0f, 0.0f, 0.8f); |
| 378 | |
| 379 | // Borderless window |
| 380 | style.WindowBorderSize = 0.0f; |
| 381 | |
| 382 | // Global scale |
| 383 | style.ScaleAllSizes(dpi_factor); |
| 384 | |
| 385 | // Dimensions |
| 386 | ImGuiIO &io = ImGui::GetIO(); |
| 387 | auto extent = render_context.get_surface_extent(); |
| 388 | io.DisplaySize.x = static_cast<float>(extent.width); |
| 389 | io.DisplaySize.y = static_cast<float>(extent.height); |
| 390 | io.FontGlobalScale = 1.0f; |
| 391 | io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f); |
| 392 | |
| 393 | // Enable keyboard navigation |
| 394 | io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; |
| 395 | io.KeyMap[ImGuiKey_Space] = static_cast<int>(KeyCode::Space); |
| 396 | io.KeyMap[ImGuiKey_Enter] = static_cast<int>(KeyCode::Enter); |
| 397 | io.KeyMap[ImGuiKey_LeftArrow] = static_cast<int>(KeyCode::Left); |
| 398 | io.KeyMap[ImGuiKey_RightArrow] = static_cast<int>(KeyCode::Right); |
| 399 | io.KeyMap[ImGuiKey_UpArrow] = static_cast<int>(KeyCode::Up); |
| 400 | io.KeyMap[ImGuiKey_DownArrow] = static_cast<int>(KeyCode::Down); |
| 401 | io.KeyMap[ImGuiKey_Tab] = static_cast<int>(KeyCode::Tab); |
| 402 | io.KeyMap[ImGuiKey_Escape] = static_cast<int>(KeyCode::Backspace); |
| 403 | |
| 404 | // Default font |
| 405 | fonts.emplace_back(default_font, font_size * dpi_factor); |
| 406 | |
| 407 | // Debug window font |
nothing calls this directly
no test coverage detected