mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-25 00:56:35 +00:00
Nav: Added ImGuiItemFlags_NoNav item flag
This commit is contained in:
parent
878fa96896
commit
2d859dee4e
@ -2182,16 +2182,16 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id, const ImRect* nav_bb_ar
|
|||||||
// 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)
|
// 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)
|
||||||
// A more pragmatic solution for handling long lists is relying on the fact that they are likely evenly spread items (so that clipper can be used) and we could Nav at higher-level (apply index, etc.)
|
// A more pragmatic solution for handling long lists is relying on the fact that they are likely evenly spread items (so that clipper can be used) and we could Nav at higher-level (apply index, etc.)
|
||||||
// So eventually we would like to provide the user will the primitives to be able to implement that customized/efficient navigation handling whenever necessary.
|
// So eventually we would like to provide the user will the primitives to be able to implement that customized/efficient navigation handling whenever necessary.
|
||||||
|
const ImGuiItemFlags item_flags = window->DC.ItemFlags;
|
||||||
if (id != NULL && g.NavWindow == window->RootNavWindow)
|
if (id != NULL && g.NavWindow == window->RootNavWindow)
|
||||||
if (g.NavId == *id || g.NavMoveRequest || g.NavInitDefaultRequest)
|
if (g.NavId == *id || g.NavMoveRequest || g.NavInitDefaultRequest)
|
||||||
if (g.IO.NavUsable)
|
if (g.IO.NavUsable && !(item_flags & ImGuiItemFlags_NoNav))
|
||||||
{
|
{
|
||||||
const ImRect& nav_bb = nav_bb_arg ? *nav_bb_arg : bb;
|
const ImRect& nav_bb = nav_bb_arg ? *nav_bb_arg : bb;
|
||||||
const ImRect nav_bb_rel(nav_bb.Min - g.NavWindow->Pos, nav_bb.Max - g.NavWindow->Pos);
|
const ImRect nav_bb_rel(nav_bb.Min - g.NavWindow->Pos, nav_bb.Max - g.NavWindow->Pos);
|
||||||
if (g.NavInitDefaultRequest && g.NavLayer == window->DC.NavLayerCurrent)
|
if (g.NavInitDefaultRequest && g.NavLayer == window->DC.NavLayerCurrent)
|
||||||
{
|
{
|
||||||
// Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
|
// Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
|
||||||
const ImGuiItemFlags item_flags = window->DC.ItemFlags;
|
|
||||||
if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
|
if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
|
||||||
g.NavInitDefaultRequest = g.NavInitDefaultResultExplicit = false; // Found a match, clear request
|
g.NavInitDefaultRequest = g.NavInitDefaultResultExplicit = false; // Found a match, clear request
|
||||||
if (g.NavInitDefaultResultId == 0 || !(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
|
if (g.NavInitDefaultResultId == 0 || !(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
|
||||||
|
@ -638,8 +638,9 @@ enum ImGuiItemFlags_
|
|||||||
ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // true
|
ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // true
|
||||||
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
||||||
//ImGuiItemFlags_Disabled = 1 << 2, // false // All widgets appears are disabled
|
//ImGuiItemFlags_Disabled = 1 << 2, // false // All widgets appears are disabled
|
||||||
ImGuiItemFlags_NoNavDefaultFocus = 1 << 3, // true
|
ImGuiItemFlags_NoNav = 1 << 3, // false
|
||||||
ImGuiItemFlags_SelectableDontClosePopup = 1 << 4, // false // MenuItem/Selectable() automatically closes current Popup window
|
ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false
|
||||||
|
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window
|
||||||
ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus
|
ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user