Internals: Nav: Extracted code into IsWindowNavFocusable(). (#787)

This commit is contained in:
omar 2018-02-01 14:56:56 +01:00
parent bdd868704f
commit 8cc2dbc3bd
2 changed files with 10 additions and 5 deletions

View File

@ -2669,11 +2669,8 @@ static ImGuiWindow* FindWindowNavigable(int i_start, int i_stop, int dir) // FIX
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
for (int i = i_start; i >= 0 && i < g.Windows.Size && i != i_stop; i += dir) for (int i = i_start; i >= 0 && i < g.Windows.Size && i != i_stop; i += dir)
{ if (ImGui::IsWindowNavFocusable(g.Windows[i]))
ImGuiWindow* window = g.Windows[i]; return g.Windows[i];
if (window->Active && window == window->RootNonPopupWindow && (!(window->Flags & ImGuiWindowFlags_NoNavFocus) || window == g.NavWindow))
return window;
}
return NULL; return NULL;
} }
@ -6650,6 +6647,13 @@ bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
} }
} }
// Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext)
bool ImGui::IsWindowNavFocusable(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
return window->Active && window == window->RootNonPopupWindow && (!(window->Flags & ImGuiWindowFlags_NoNavFocus) || window == g.NavWindow);
}
float ImGui::GetWindowWidth() float ImGui::GetWindowWidth()
{ {
ImGuiWindow* window = GImGui->CurrentWindow; ImGuiWindow* window = GImGui->CurrentWindow;

View File

@ -1001,6 +1001,7 @@ namespace ImGui
IMGUI_API void BringWindowToFront(ImGuiWindow* window); IMGUI_API void BringWindowToFront(ImGuiWindow* window);
IMGUI_API void BringWindowToBack(ImGuiWindow* window); IMGUI_API void BringWindowToBack(ImGuiWindow* window);
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent); IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
IMGUI_API void Initialize(); IMGUI_API void Initialize();