18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 02:42:46 +01:00

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.
This commit is contained in:
maj00r
2026-11-24 00:21:49 +01:00
parent 58521e565f
commit 9f33045c2e
3 changed files with 19 additions and 6 deletions
+3
View File
@@ -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
+12 -5
View File
@@ -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();
+4 -1
View File
@@ -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