From fddf9ca10ed63f8d837a3104ac178d1910bdcf93 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 21 Aug 2016 15:25:29 +0200 Subject: [PATCH] Nav: Fixed nav highlight clipping (affected non non-menu items within menubar) (#323) --- imgui.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 5fcb20971..f2d08b293 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2084,12 +2084,14 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id) return; ImGuiWindow* window = ImGui::GetCurrentWindow(); - ImRect clip_rect(window->InnerRect.Min - ImVec2(4,4), window->InnerRect.Max + ImVec2(4,4)); - if (!window->ClipRect.Contains(clip_rect)) - window->DrawList->PushClipRect(clip_rect.Min, clip_rect.Max); - window->DrawList->AddRect(bb.Min - ImVec2(3,3), bb.Max + ImVec2(3,3), GetColorU32(ImGuiCol_NavHighlight), g.Style.FrameRounding, 0x0F, 2.0f); + const float THICKNESS = 2.0f; + const float DISTANCE = 3.0f + THICKNESS * 0.5f; + ImRect display_rect(bb.Min - ImVec2(DISTANCE,DISTANCE), bb.Max + ImVec2(DISTANCE,DISTANCE)); + if (!window->ClipRect.Contains(display_rect)) + window->DrawList->PushClipRect(display_rect.Min, display_rect.Max); + window->DrawList->AddRect(display_rect.Min + ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), display_rect.Max - ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), GetColorU32(ImGuiCol_NavHighlight), g.Style.FrameRounding, 0x0F, THICKNESS); //window->DrawList->AddRect(g.NavRefRectScreen.Min, g.NavRefRectScreen.Max, IM_COL32(255,0,0,255)); - if (!window->ClipRect.Contains(clip_rect)) + if (!window->ClipRect.Contains(display_rect)) window->DrawList->PopClipRect(); }