18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 06:12:41 +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
+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();