Nav: Fixed nav highlight clipping (affected non non-menu items within menubar) (#323)

This commit is contained in:
ocornut 2016-08-21 15:25:29 +02:00
parent 78b7e2dfb3
commit fddf9ca10e

View File

@ -2084,12 +2084,14 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id)
return; return;
ImGuiWindow* window = ImGui::GetCurrentWindow(); ImGuiWindow* window = ImGui::GetCurrentWindow();
ImRect clip_rect(window->InnerRect.Min - ImVec2(4,4), window->InnerRect.Max + ImVec2(4,4)); const float THICKNESS = 2.0f;
if (!window->ClipRect.Contains(clip_rect)) const float DISTANCE = 3.0f + THICKNESS * 0.5f;
window->DrawList->PushClipRect(clip_rect.Min, clip_rect.Max); ImRect display_rect(bb.Min - ImVec2(DISTANCE,DISTANCE), bb.Max + ImVec2(DISTANCE,DISTANCE));
window->DrawList->AddRect(bb.Min - ImVec2(3,3), bb.Max + ImVec2(3,3), GetColorU32(ImGuiCol_NavHighlight), g.Style.FrameRounding, 0x0F, 2.0f); 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)); //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(); window->DrawList->PopClipRect();
} }