From d863ec18c34576c27a7905de75881a984bd7d718 Mon Sep 17 00:00:00 2001 From: combolek <4743344+combolek@users.noreply.github.com> Date: Sat, 11 Jul 2026 15:41:25 -0700 Subject: [PATCH] uilayer: Implement ui.bg.opacity setting (#139) uilayer: Implement up ui.bg.opacity setting --- application/uilayer.cpp | 2 +- utilities/Globals.h | 2 +- widgets/map.cpp | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/application/uilayer.cpp b/application/uilayer.cpp index 8dd993ed..60c8a778 100644 --- a/application/uilayer.cpp +++ b/application/uilayer.cpp @@ -141,7 +141,7 @@ void ui_layer::imgui_style() colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_TextDisabled] = ImVec4(0.35f, 0.35f, 0.35f, 1.00f); - colors[ImGuiCol_WindowBg] = ImVec4(0.04f, 0.04f, 0.04f, 0.94f); + colors[ImGuiCol_WindowBg] = ImVec4(0.04f, 0.04f, 0.04f, Global.UIBgOpacity); // ui.bg.opacity from config file colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_PopupBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); colors[ImGuiCol_Border] = ImVec4(0.31f, 0.34f, 0.31f, 0.50f); diff --git a/utilities/Globals.h b/utilities/Globals.h index a21a191e..729b7cbc 100644 --- a/utilities/Globals.h +++ b/utilities/Globals.h @@ -123,7 +123,7 @@ struct global_settings { int PythonScreenUpdateRate{ 200 }; // delay between python-based screen updates, in milliseconds int iTextMode{ 0 }; // tryb pracy wyświetlacza tekstowego glm::vec4 UITextColor{ glm::vec4( 225.f / 255.f, 225.f / 255.f, 225.f / 255.f, 1.f ) }; // base color of UI text - float UIBgOpacity{ 0.65f }; // opacity of ui windows + float UIBgOpacity{ 0.94f }; // opacity of ui windows std::string asLang{ "pl" }; // domyślny język - http://tools.ietf.org/html/bcp47 // gfx glm::ivec2 window_size; // main window size in platform-specific virtual pixels diff --git a/widgets/map.cpp b/widgets/map.cpp index 379b0311..25beb794 100644 --- a/widgets/map.cpp +++ b/widgets/map.cpp @@ -299,7 +299,23 @@ void ui::map_panel::render_contents() ImVec2 window_origin = ImGui::GetCursorPos(); ImVec2 screen_origin = ImGui::GetCursorScreenPos(); - ImGui::ImageButton((ImTextureID)(intptr_t)(m_tex->id), surface_size_im, ImVec2(0, surface_size.y / fb_size), ImVec2(surface_size.x / fb_size, 0), 0); + + // Specify alpha for the map image tint so the map window + // honors the ui.bg.opacity setting like other windows. + // Make the button frame fully transparent so ImageButton's + // ImGuiCol_Button background (green and opaque on hover) doesn't + // show behind the tinted image. + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); + ImGui::ImageButton((ImTextureID)(intptr_t)(m_tex->id), + surface_size_im, + ImVec2(0, surface_size.y / fb_size), + ImVec2(surface_size.x / fb_size, 0), + 0, + ImVec4(0.0f, 0.0f, 0.0f, 0.0f), + ImVec4(1.0f, 1.0f, 1.0f, Global.UIBgOpacity)); + ImGui::PopStyleColor(3); if (ImGui::IsItemHovered()) {