From 75c54e63844d262b1005865eba370ad487808b1f Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 11 Oct 2021 14:40:42 +0200 Subject: [PATCH] Nav: Fixed vertical scoring offset when wrapping on Y in a decorated window. --- docs/CHANGELOG.txt | 1 + imgui.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 19d4c1fb2..cd9a40cff 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -74,6 +74,7 @@ Other Changes: the PressedOnClick/PressedOnDoubleClick/PressedOnRelease button policy. - Nav: Fixed an issue with losing focus on docked windows when pressing Alt while keyboard navigation is disabled. (#4547, #4439) [@PathogenDavid] +- Nav: Fixed vertical scoring offset when wrapping on Y in a decorated window. - Nav: Improve scrolling behavior when navigating to an item larger than view. - TreePush(): removed unnecessary/inconsistent legacy behavior where passing a NULL value to the TreePush(const char*) and TreePush(const void*) functions would use an hardcoded replacement. diff --git a/imgui.cpp b/imgui.cpp index 38fcb9304..de0fb7468 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -9814,10 +9814,11 @@ static void ImGui::NavEndFrame() } do_forward = true; } + const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); if (g.NavMoveDir == ImGuiDir_Up && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY))) { bb_rel.Min.y = bb_rel.Max.y = - ImMax(window->SizeFull.y, window->ContentSize.y + window->WindowPadding.y * 2.0f) - window->Scroll.y; + ImMax(window->SizeFull.y, window->ContentSize.y + window->WindowPadding.y * 2.0f) - window->Scroll.y + decoration_up_height; if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(-bb_rel.GetWidth()); @@ -9827,7 +9828,7 @@ static void ImGui::NavEndFrame() } if (g.NavMoveDir == ImGuiDir_Down && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY))) { - bb_rel.Min.y = bb_rel.Max.y = -window->Scroll.y; + bb_rel.Min.y = bb_rel.Max.y = -window->Scroll.y + decoration_up_height; if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(+bb_rel.GetWidth());