| 863 | } |
| 864 | |
| 865 | void EditorUI::initialize(WindowUIInitInfo init_info) |
| 866 | { |
| 867 | std::shared_ptr<ConfigManager> config_manager = g_runtime_global_context.m_config_manager; |
| 868 | ASSERT(config_manager); |
| 869 | |
| 870 | // create imgui context |
| 871 | IMGUI_CHECKVERSION(); |
| 872 | ImGui::CreateContext(); |
| 873 | |
| 874 | // set ui content scale |
| 875 | float x_scale, y_scale; |
| 876 | glfwGetWindowContentScale(init_info.window_system->getWindow(), &x_scale, &y_scale); |
| 877 | float content_scale = fmaxf(1.0f, fmaxf(x_scale, y_scale)); |
| 878 | windowContentScaleUpdate(content_scale); |
| 879 | glfwSetWindowContentScaleCallback(init_info.window_system->getWindow(), windowContentScaleCallback); |
| 880 | |
| 881 | // load font for imgui |
| 882 | ImGuiIO& io = ImGui::GetIO(); |
| 883 | io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; |
| 884 | io.ConfigDockingAlwaysTabBar = true; |
| 885 | io.ConfigWindowsMoveFromTitleBarOnly = true; |
| 886 | io.Fonts->AddFontFromFileTTF( |
| 887 | config_manager->getEditorFontPath().generic_string().data(), content_scale * 16, nullptr, nullptr); |
| 888 | io.Fonts->Build(); |
| 889 | |
| 890 | ImGuiStyle& style = ImGui::GetStyle(); |
| 891 | style.WindowPadding = ImVec2(1.0, 0); |
| 892 | style.FramePadding = ImVec2(14.0, 2.0f); |
| 893 | style.ChildBorderSize = 0.0f; |
| 894 | style.FrameRounding = 5.0f; |
| 895 | style.FrameBorderSize = 1.5f; |
| 896 | |
| 897 | // set imgui color style |
| 898 | setUIColorStyle(); |
| 899 | |
| 900 | // setup window icon |
| 901 | GLFWimage window_icon[2]; |
| 902 | std::string big_icon_path_string = config_manager->getEditorBigIconPath().generic_string(); |
| 903 | std::string small_icon_path_string = config_manager->getEditorSmallIconPath().generic_string(); |
| 904 | window_icon[0].pixels = |
| 905 | stbi_load(big_icon_path_string.data(), &window_icon[0].width, &window_icon[0].height, 0, 4); |
| 906 | window_icon[1].pixels = |
| 907 | stbi_load(small_icon_path_string.data(), &window_icon[1].width, &window_icon[1].height, 0, 4); |
| 908 | glfwSetWindowIcon(init_info.window_system->getWindow(), 2, window_icon); |
| 909 | stbi_image_free(window_icon[0].pixels); |
| 910 | stbi_image_free(window_icon[1].pixels); |
| 911 | |
| 912 | // initialize imgui vulkan render backend |
| 913 | init_info.render_system->initializeUIRenderBackend(this); |
| 914 | } |
| 915 | |
| 916 | void EditorUI::setUIColorStyle() |
| 917 | { |
nothing calls this directly
no test coverage detected