diff --git a/imgui.cpp b/imgui.cpp index c8ff306..207993c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2233,7 +2233,7 @@ // (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests unfortunately, but it is still limited to one window. // it may not scale very well for windows with ten of thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame. // We could early out with `if (is_clipped && !g.NavInitDefaultRequest) return false;` but when we wouldn't be able to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick) - window->DC.NavLayerActiveMaskNext |= (1 << window->DC.NavLayerCurrent); + window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask; if (g.NavWindow == window->RootNavWindow) if (g.NavId == id || g.NavMoveRequest || g.NavInitDefaultRequest || IMGUI_DEBUG_NAV) NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, id); @@ -5377,9 +5377,10 @@ if (!(flags & ImGuiWindowFlags_NoTitleBar)) { // Close & collapse button are on layer 1 (same as menus) and don't default focus - const ImGuiItemFlags backup_item_options = window->DC.ItemFlags; + const ImGuiItemFlags item_flags_backup = window->DC.ItemFlags; window->DC.ItemFlags |= ImGuiItemFlags_NoNavDefaultFocus; window->DC.NavLayerCurrent++; + window->DC.NavLayerCurrentMask <<= 1; // Collapse button if (!(flags & ImGuiWindowFlags_NoCollapse)) @@ -5403,7 +5404,8 @@ } window->DC.NavLayerCurrent--; - window->DC.ItemFlags = backup_item_options; + window->DC.NavLayerCurrentMask >>= 1; + window->DC.ItemFlags = item_flags_backup; // Title text (FIXME: refactor text alignment facilities along with RenderText helpers) const ImVec2 text_size = CalcTextSize(name, NULL, true); @@ -10093,6 +10095,7 @@ window->DC.CursorPos = ImVec2(rect.Min.x + window->DC.MenuBarOffsetX, rect.Min.y);// + g.Style.FramePadding.y); window->DC.LayoutType = ImGuiLayoutType_Horizontal; window->DC.NavLayerCurrent++; + window->DC.NavLayerCurrentMask <<= 1; window->DC.MenuBarAppending = true; AlignFirstTextHeightToWidgets(); return true; @@ -10134,6 +10137,7 @@ EndGroup(); window->DC.LayoutType = ImGuiLayoutType_Vertical; window->DC.NavLayerCurrent--; + window->DC.NavLayerCurrentMask >>= 1; window->DC.MenuBarAppending = false; } diff --git a/imgui.cpp b/imgui.cpp index c8ff306..207993c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2233,7 +2233,7 @@ // (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests unfortunately, but it is still limited to one window. // it may not scale very well for windows with ten of thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame. // We could early out with `if (is_clipped && !g.NavInitDefaultRequest) return false;` but when we wouldn't be able to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick) - window->DC.NavLayerActiveMaskNext |= (1 << window->DC.NavLayerCurrent); + window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask; if (g.NavWindow == window->RootNavWindow) if (g.NavId == id || g.NavMoveRequest || g.NavInitDefaultRequest || IMGUI_DEBUG_NAV) NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, id); @@ -5377,9 +5377,10 @@ if (!(flags & ImGuiWindowFlags_NoTitleBar)) { // Close & collapse button are on layer 1 (same as menus) and don't default focus - const ImGuiItemFlags backup_item_options = window->DC.ItemFlags; + const ImGuiItemFlags item_flags_backup = window->DC.ItemFlags; window->DC.ItemFlags |= ImGuiItemFlags_NoNavDefaultFocus; window->DC.NavLayerCurrent++; + window->DC.NavLayerCurrentMask <<= 1; // Collapse button if (!(flags & ImGuiWindowFlags_NoCollapse)) @@ -5403,7 +5404,8 @@ } window->DC.NavLayerCurrent--; - window->DC.ItemFlags = backup_item_options; + window->DC.NavLayerCurrentMask >>= 1; + window->DC.ItemFlags = item_flags_backup; // Title text (FIXME: refactor text alignment facilities along with RenderText helpers) const ImVec2 text_size = CalcTextSize(name, NULL, true); @@ -10093,6 +10095,7 @@ window->DC.CursorPos = ImVec2(rect.Min.x + window->DC.MenuBarOffsetX, rect.Min.y);// + g.Style.FramePadding.y); window->DC.LayoutType = ImGuiLayoutType_Horizontal; window->DC.NavLayerCurrent++; + window->DC.NavLayerCurrentMask <<= 1; window->DC.MenuBarAppending = true; AlignFirstTextHeightToWidgets(); return true; @@ -10134,6 +10137,7 @@ EndGroup(); window->DC.LayoutType = ImGuiLayoutType_Vertical; window->DC.NavLayerCurrent--; + window->DC.NavLayerCurrentMask >>= 1; window->DC.MenuBarAppending = false; } diff --git a/imgui_internal.h b/imgui_internal.h index c31fc4e..f8519e9 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -683,6 +683,7 @@ bool LastItemRectHoveredRect; bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f) int NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1) + int NavLayerCurrentMask; // = (1 << NavLayerCurrent) used by ItemAdd prior to clipping. int NavLayerActiveMask; // Which layer have been written to (result from previous frame) int NavLayerActiveMaskNext; // Which layer have been written to (buffer for current frame) bool MenuBarAppending; // FIXME: Remove this @@ -730,6 +731,7 @@ NavHasScroll = false; NavLayerActiveMask = NavLayerActiveMaskNext = 0x00; NavLayerCurrent = 0; + NavLayerCurrentMask = 1 << 0; MenuBarAppending = false; MenuBarOffsetX = 0.0f; StateStorage = NULL;