From 4832e45fc2014495d493cec3709acd8b21e78e7f Mon Sep 17 00:00:00 2001 From: TaiseiHamaya <146906391+TaiseiHamaya@users.noreply.github.com> Date: Fri, 19 Dec 2025 01:27:14 +0900 Subject: [PATCH 1/7] Add a feature to draw a border around the selected window --- imgui.cpp | 13 +++++++++++++ imgui.h | 1 + imgui_draw.cpp | 3 +++ 3 files changed, 17 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 1d1c3649a..5c6e9aea5 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3761,6 +3761,7 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx) case ImGuiCol_ChildBg: return "ChildBg"; case ImGuiCol_PopupBg: return "PopupBg"; case ImGuiCol_Border: return "Border"; + case ImGuiCol_BorderSelected: return "BorderSelected"; case ImGuiCol_BorderShadow: return "BorderShadow"; case ImGuiCol_FrameBg: return "FrameBg"; case ImGuiCol_FrameBgHovered: return "FrameBgHovered"; @@ -7544,6 +7545,18 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar // Borders (for dock node host they will be rendered over after the tab bar) if (handle_borders_and_resize_grips && !window->DockNodeAsHost) RenderWindowOuterBorders(window); + + // Selected border + const float border_size = window->WindowBorderSize; + if (border_size > 0.0f && title_bar_is_highlight && !(flags & ImGuiWindowFlags_NoTitleBar)) { + if (!window->DockIsActive || window->DockNode->IsFocused) { + const ImU32 border_selected_col = GetColorU32(ImGuiCol_BorderSelected); + RenderWindowOuterSingleBorder(window, 0, border_selected_col, border_size); + RenderWindowOuterSingleBorder(window, 1, border_selected_col, border_size); + RenderWindowOuterSingleBorder(window, 2, border_selected_col, border_size); + RenderWindowOuterSingleBorder(window, 3, border_selected_col, border_size); + } + } } window->DC.NavLayerCurrent = ImGuiNavLayer_Main; } diff --git a/imgui.h b/imgui.h index 8bfe68307..f1fbe94e6 100644 --- a/imgui.h +++ b/imgui.h @@ -1812,6 +1812,7 @@ enum ImGuiCol_ ImGuiCol_ChildBg, // Background of child windows ImGuiCol_PopupBg, // Background of popups, menus, tooltips windows ImGuiCol_Border, + ImGuiCol_BorderSelected, ImGuiCol_BorderShadow, ImGuiCol_FrameBg, // Background of checkbox, radio button, plot, slider, text input ImGuiCol_FrameBgHovered, diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 87070e777..a8e057092 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -192,6 +192,7 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst) colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); + colors[ImGuiCol_BorderSelected] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f); colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); @@ -261,6 +262,7 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst) colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_PopupBg] = ImVec4(0.11f, 0.11f, 0.14f, 0.92f); colors[ImGuiCol_Border] = ImVec4(0.50f, 0.50f, 0.50f, 0.50f); + colors[ImGuiCol_BorderSelected] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_FrameBg] = ImVec4(0.43f, 0.43f, 0.43f, 0.39f); colors[ImGuiCol_FrameBgHovered] = ImVec4(0.47f, 0.47f, 0.69f, 0.40f); @@ -331,6 +333,7 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst) colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_PopupBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.98f); colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.30f); + colors[ImGuiCol_BorderSelected] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_FrameBg] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); From e3a70f3b9026ad979caaecb7ab1df7a3d70a8855 Mon Sep 17 00:00:00 2001 From: TaiseiHamaya <146906391+TaiseiHamaya@users.noreply.github.com> Date: Mon, 22 Dec 2025 12:41:47 +0900 Subject: [PATCH 2/7] Renamed ImGuiCol_BorderSelected to ImGuiCol_WindowBorderSelected. --- imgui.cpp | 4 ++-- imgui.h | 2 +- imgui_draw.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 5c6e9aea5..5a785cd61 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3761,7 +3761,7 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx) case ImGuiCol_ChildBg: return "ChildBg"; case ImGuiCol_PopupBg: return "PopupBg"; case ImGuiCol_Border: return "Border"; - case ImGuiCol_BorderSelected: return "BorderSelected"; + case ImGuiCol_WindowBorderSelected: return "WindowBorderSelected"; case ImGuiCol_BorderShadow: return "BorderShadow"; case ImGuiCol_FrameBg: return "FrameBg"; case ImGuiCol_FrameBgHovered: return "FrameBgHovered"; @@ -7550,7 +7550,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar const float border_size = window->WindowBorderSize; if (border_size > 0.0f && title_bar_is_highlight && !(flags & ImGuiWindowFlags_NoTitleBar)) { if (!window->DockIsActive || window->DockNode->IsFocused) { - const ImU32 border_selected_col = GetColorU32(ImGuiCol_BorderSelected); + const ImU32 border_selected_col = GetColorU32(ImGuiCol_WindowBorderSelected); RenderWindowOuterSingleBorder(window, 0, border_selected_col, border_size); RenderWindowOuterSingleBorder(window, 1, border_selected_col, border_size); RenderWindowOuterSingleBorder(window, 2, border_selected_col, border_size); diff --git a/imgui.h b/imgui.h index f1fbe94e6..916b8f37f 100644 --- a/imgui.h +++ b/imgui.h @@ -1809,10 +1809,10 @@ enum ImGuiCol_ ImGuiCol_Text, ImGuiCol_TextDisabled, ImGuiCol_WindowBg, // Background of normal windows + ImGuiCol_WindowBorderSelected, // border of selected normal windows ImGuiCol_ChildBg, // Background of child windows ImGuiCol_PopupBg, // Background of popups, menus, tooltips windows ImGuiCol_Border, - ImGuiCol_BorderSelected, ImGuiCol_BorderShadow, ImGuiCol_FrameBg, // Background of checkbox, radio button, plot, slider, text input ImGuiCol_FrameBgHovered, diff --git a/imgui_draw.cpp b/imgui_draw.cpp index a8e057092..2aab9a214 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -189,10 +189,10 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst) colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); + colors[ImGuiCol_WindowBorderSelected] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); - colors[ImGuiCol_BorderSelected] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f); colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); @@ -259,10 +259,10 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst) colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.85f); + colors[ImGuiCol_WindowBorderSelected] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_PopupBg] = ImVec4(0.11f, 0.11f, 0.14f, 0.92f); colors[ImGuiCol_Border] = ImVec4(0.50f, 0.50f, 0.50f, 0.50f); - colors[ImGuiCol_BorderSelected] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_FrameBg] = ImVec4(0.43f, 0.43f, 0.43f, 0.39f); colors[ImGuiCol_FrameBgHovered] = ImVec4(0.47f, 0.47f, 0.69f, 0.40f); @@ -330,10 +330,10 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst) colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); colors[ImGuiCol_WindowBg] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f); + colors[ImGuiCol_WindowBorderSelected] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_PopupBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.98f); colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.30f); - colors[ImGuiCol_BorderSelected] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_FrameBg] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); From d55014fd8d4a287888ced79da5a22b8858b50d0b Mon Sep 17 00:00:00 2001 From: TaiseiHamaya <146906391+TaiseiHamaya@users.noreply.github.com> Date: Tue, 23 Dec 2025 02:33:46 +0900 Subject: [PATCH 3/7] Fixed a bug where the condition for determining whether the window is selected was incorrect. --- imgui.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 5a785cd61..4e37cfacb 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7548,14 +7548,15 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar // Selected border const float border_size = window->WindowBorderSize; - if (border_size > 0.0f && title_bar_is_highlight && !(flags & ImGuiWindowFlags_NoTitleBar)) { - if (!window->DockIsActive || window->DockNode->IsFocused) { - const ImU32 border_selected_col = GetColorU32(ImGuiCol_WindowBorderSelected); - RenderWindowOuterSingleBorder(window, 0, border_selected_col, border_size); - RenderWindowOuterSingleBorder(window, 1, border_selected_col, border_size); - RenderWindowOuterSingleBorder(window, 2, border_selected_col, border_size); - RenderWindowOuterSingleBorder(window, 3, border_selected_col, border_size); - } + bool is_window_selected = border_size > 0.0f && title_bar_is_highlight && !(window->Flags & (ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_MenuBar)); + is_window_selected &= (!window->DockIsActive || window->DockNode->IsFocused); + if (is_window_selected) + { + const ImU32 border_selected_col = GetColorU32(ImGuiCol_WindowBorderSelected); + RenderWindowOuterSingleBorder(window, 0, border_selected_col, border_size); + RenderWindowOuterSingleBorder(window, 1, border_selected_col, border_size); + RenderWindowOuterSingleBorder(window, 2, border_selected_col, border_size); + RenderWindowOuterSingleBorder(window, 3, border_selected_col, border_size); } } window->DC.NavLayerCurrent = ImGuiNavLayer_Main; From 49dd13faedfe09c5ce322fba121a3df448410cdf Mon Sep 17 00:00:00 2001 From: TaiseiHamaya <146906391+TaiseiHamaya@users.noreply.github.com> Date: Thu, 29 Jan 2026 12:30:15 +0900 Subject: [PATCH 4/7] Fix: Corrected an issue where borders were rendered incorrectly when using BeginPopup/BeginMenu. --- imgui.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 4e37cfacb..199b82b20 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7548,7 +7548,18 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar // Selected border const float border_size = window->WindowBorderSize; - bool is_window_selected = border_size > 0.0f && title_bar_is_highlight && !(window->Flags & (ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_MenuBar)); + bool is_window_selected = border_size > 0.0f; + if (!(window->Flags & (ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Popup))) + { + // Regular window + is_window_selected &= g.WindowsFocusOrder.back() == window; + } + else + { + // BeginPopup/BeginMenu + is_window_selected &= g.OpenPopupStack.back().Window == window; + } + // When docked, only show selected border if the dock node is focused is_window_selected &= (!window->DockIsActive || window->DockNode->IsFocused); if (is_window_selected) { From 35a118f309b864be9adab0f5cf8e087d3ae156b1 Mon Sep 17 00:00:00 2001 From: TaiseiHamaya <146906391+TaiseiHamaya@users.noreply.github.com> Date: Fri, 6 Feb 2026 11:14:42 +0900 Subject: [PATCH 5/7] Fix an issue where the detection was incorrect when opening a new window from buttons in the menu bar or pop-up. --- imgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 199b82b20..b1196eeff 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7557,7 +7557,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar else { // BeginPopup/BeginMenu - is_window_selected &= g.OpenPopupStack.back().Window == window; + is_window_selected &= g.OpenPopupStack.back().Window == window && g.WindowsFocusOrder.back() == window->RootWindow; } // When docked, only show selected border if the dock node is focused is_window_selected &= (!window->DockIsActive || window->DockNode->IsFocused); From 8475471c1e22147267394c823cfaad24aa6dc68d Mon Sep 17 00:00:00 2001 From: TaiseiHamaya <146906391+TaiseiHamaya@users.noreply.github.com> Date: Wed, 13 May 2026 11:58:20 +0900 Subject: [PATCH 6/7] Refactoring: Replaced 'RenderWindowOuterSingleBorder' with 'AddRect'. --- imgui.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index b1196eeff..d01d2b0ad 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7564,10 +7564,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar if (is_window_selected) { const ImU32 border_selected_col = GetColorU32(ImGuiCol_WindowBorderSelected); - RenderWindowOuterSingleBorder(window, 0, border_selected_col, border_size); - RenderWindowOuterSingleBorder(window, 1, border_selected_col, border_size); - RenderWindowOuterSingleBorder(window, 2, border_selected_col, border_size); - RenderWindowOuterSingleBorder(window, 3, border_selected_col, border_size); + window->DrawList->AddRect(window->Pos, window->Pos + window->Size, border_selected_col, window_rounding, 0, border_size); } } window->DC.NavLayerCurrent = ImGuiNavLayer_Main; From 4c93eaa5549b5533b83e98a31e878d659fda841b Mon Sep 17 00:00:00 2001 From: TaiseiHamaya <146906391+TaiseiHamaya@users.noreply.github.com> Date: Wed, 13 May 2026 12:12:37 +0900 Subject: [PATCH 7/7] Fix: Check for border rendering when the window is set to 'NoInputs' or 'MenuBar'. --- imgui.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index d01d2b0ad..aa64061d0 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7552,7 +7552,10 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar if (!(window->Flags & (ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Popup))) { // Regular window - is_window_selected &= g.WindowsFocusOrder.back() == window; + if (!(window->Flags & (ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_MenuBar))) + is_window_selected &= g.WindowsFocusOrder.back() == window; + else + is_window_selected = false; } else {