Nav: Removed possibly redundant test prior to calling NavProcessItem() from ItemAdd()

This commit is contained in:
omar 2017-10-06 09:40:13 -07:00
parent a77dd02e8a
commit 40df7a5155

View File

@ -2174,6 +2174,8 @@ static bool NavScoreItem(ImRect cand)
static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id) static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
//if (!g.IO.NavUsable) // [2017/10/06] Removed this possibly redundant test but I am not sure of all the side-effects yet. Some of the feature here will need to work regardless of using a _NoNavInputs flag.
// return;
const ImGuiItemFlags item_flags = window->DC.ItemFlags; const ImGuiItemFlags item_flags = window->DC.ItemFlags;
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)
@ -2238,7 +2240,6 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id, const ImRect* nav_bb_ar
// 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.
if (id != NULL && g.NavWindow == window->RootNavWindow) if (id != NULL && g.NavWindow == window->RootNavWindow)
if (g.NavId == *id || g.NavMoveRequest || g.NavInitDefaultRequest || IMGUI_DEBUG_NAV) if (g.NavId == *id || g.NavMoveRequest || g.NavInitDefaultRequest || IMGUI_DEBUG_NAV)
if (g.IO.NavUsable)
NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, *id); NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, *id);
if (is_clipped) if (is_clipped)
@ -2482,7 +2483,11 @@ static void NavInitWindow(ImGuiWindow* window, bool force_reinit)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(window == g.NavWindow); IM_ASSERT(window == g.NavWindow);
bool init_for_nav = false;
if (!(window->Flags & ImGuiWindowFlags_NoNavInputs))
if (!(window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastIds[0] == 0) || force_reinit) if (!(window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastIds[0] == 0) || force_reinit)
init_for_nav = true;
if (init_for_nav)
{ {
SetNavId(0, g.NavLayer); SetNavId(0, g.NavLayer);
g.NavInitDefaultRequest = true; g.NavInitDefaultRequest = true;