From 9f33045c2e315d3feb864ffe914bf51cc1bfcdb3 Mon Sep 17 00:00:00 2001 From: maj00r <73280030+maj00r@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:21:49 +0100 Subject: [PATCH] fix(editor): the panels of the editor opaque, the 3d scene doesn't show through the docks around the view The 3d scene is drawn under the whole window and the windows took the opacity of the simulator's interface (ui.bg.opacity, 0.65 in the ini of the game): the tracks and the models beside the view showed through the docks around it. The editor's windows are opaque now; the ones over the view meant to be seen through set their own alpha as before. The simulator keeps ui.bg.opacity for its own interface. --- application/editoruilayer.h | 3 +++ application/uilayer.cpp | 17 ++++++++++++----- application/uilayer.h | 5 ++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/application/editoruilayer.h b/application/editoruilayer.h index 0f90060d1..eaa1b881a 100644 --- a/application/editoruilayer.h +++ b/application/editoruilayer.h @@ -214,6 +214,9 @@ class editor_ui : public ui_layer void render_windows_menu() override; void render_tools_menu() override; int palette() const override; + // the panels of the editor are opaque: the 3d scene, drawn under the whole window, doesn't show through the docks around the view; + // a window over the view which wants to be seen through says so itself (SetNextWindowBgAlpha) + float window_alpha() const override { return 1.0f; } void render_dockspace() override; void render_() override; // docks the windows of the editor in their default places diff --git a/application/uilayer.cpp b/application/uilayer.cpp index 080623689..e1ab267c6 100644 --- a/application/uilayer.cpp +++ b/application/uilayer.cpp @@ -30,6 +30,7 @@ ImGuiIO *ui_layer::m_imguiio{nullptr}; GLint ui_layer::m_textureunit{GL_TEXTURE0}; bool ui_layer::m_cursorvisible; int ui_layer::m_palette{0}; +float ui_layer::m_window_alpha{-1.0f}; ImFont *ui_layer::font_default{nullptr}; ImFont *ui_layer::font_mono{nullptr}; ImFont *ui_layer::font_loading{nullptr}; @@ -182,9 +183,10 @@ void create_viewport_window(ImGuiViewport *Viewport) } } // namespace -void ui_layer::imgui_colors(int const Palette) +void ui_layer::imgui_colors(int const Palette, float const WindowAlpha) { m_palette = Palette; + m_window_alpha = WindowAlpha; auto const rgb = [](int const Color, float const Alpha = 1.0f) { return ImVec4(((Color >> 16) & 0xff) / 255.0f, ((Color >> 8) & 0xff) / 255.0f, (Color & 0xff) / 255.0f, Alpha); }; @@ -204,7 +206,7 @@ void ui_layer::imgui_colors(int const Palette) colors[ImGuiCol_Text] = rgb(editor ? 0xe6e8eb : 0xffffff); colors[ImGuiCol_TextDisabled] = rgb(editor ? 0x8a929c : 0xa0a0a2); - colors[ImGuiCol_WindowBg] = rgb(panel, Global.UIBgOpacity); // ui.bg.opacity from config file + colors[ImGuiCol_WindowBg] = rgb(panel, WindowAlpha); // ui.bg.opacity from config file, unless the ui has its own colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_PopupBg] = rgb(base, 0.98f); colors[ImGuiCol_Border] = rgb(border); @@ -261,7 +263,7 @@ void ui_layer::imgui_colors(int const Palette) void ui_layer::imgui_style() { - imgui_colors(0); + imgui_colors(0, Global.UIBgOpacity); // flat, square elements with thin borders auto &style = ImGui::GetStyle(); @@ -539,11 +541,16 @@ void ui_layer::render_internal() } } +float ui_layer::window_alpha() const +{ + return Global.UIBgOpacity; +} + void ui_layer::begin_ui_frame() { // the colours follow the ui of the mode drawn - if (palette() != m_palette) - imgui_colors(palette()); + if (palette() != m_palette || window_alpha() != m_window_alpha) + imgui_colors(palette(), window_alpha()); begin_ui_frame_internal(); render_dockspace(); m_dockspaceframe = ImGui::GetFrameCount(); diff --git a/application/uilayer.h b/application/uilayer.h index 69c4e08d3..03eb2667a 100644 --- a/application/uilayer.h +++ b/application/uilayer.h @@ -79,7 +79,7 @@ public: static bool init( GLFWwindow *Window ); static void imgui_style(); // colours of the user interface: 0 the green ones shared with the starter, 1 the amber ones of the editor - static void imgui_colors(int const Palette); + static void imgui_colors(int const Palette, float const WindowAlpha); // assign texturing hardware unit static void set_unit( GLint const Textureunit ) { m_textureunit = GL_TEXTURE0 + Textureunit; } @@ -154,7 +154,10 @@ protected: { return 0; } + // how opaque the windows of this ui are: the setting of the simulator, ui.bg.opacity, unless the ui says otherwise + virtual float window_alpha() const; static int m_palette; // colours set at the moment + static float m_window_alpha; ui_log_panel m_logpanel { "Log", true }; bool m_suppress_menu = false; // if `true`, the menu at the top of the window will not be present bool m_menu_always = false; // if `true`, the menu is shown all the time, not only when the mouse is at the top of the window