From 6ea90af6b76f2b9f7b86c12813bafd6f0408bdc0 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 3 Oct 2017 13:53:17 -0700 Subject: [PATCH] Nav: Highlight clipped within host window then extruded out. (#787) --- imgui.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 954f6424..805844f2 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2155,14 +2155,16 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id) return; ImGuiWindow* window = ImGui::GetCurrentWindow(); + ImRect display_rect = bb; + display_rect.ClipWith(window->ClipRect); 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)) + display_rect.Expand(ImVec2(DISTANCE,DISTANCE)); + bool fully_visible = window->ClipRect.Contains(display_rect); + if (!fully_visible) 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(display_rect)) + if (!fully_visible) window->DrawList->PopClipRect(); }