mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 15:50:25 +01:00
Navigation: Can nav-out but not nav-in a window with ImGuiWindowFlags_NoNav flag (#323)
This commit is contained in:
parent
67feb5ac6c
commit
175f42420c
10
imgui.cpp
10
imgui.cpp
@ -2368,6 +2368,7 @@ static void NavUpdate()
|
|||||||
g.NavWindowingTarget = g.NavWindow->RootNonPopupWindow;
|
g.NavWindowingTarget = g.NavWindow->RootNonPopupWindow;
|
||||||
if (g.NavWindowingTarget)
|
if (g.NavWindowingTarget)
|
||||||
{
|
{
|
||||||
|
// Select window to focus
|
||||||
// FIXME-NAVIGATION: Need to clarify input semantic, naming is misleading/incorrect here.
|
// FIXME-NAVIGATION: Need to clarify input semantic, naming is misleading/incorrect here.
|
||||||
int focus_change_dir = IsKeyPressedMap(ImGuiKey_NavTweakFaster, true) ? -1 : IsKeyPressedMap(ImGuiKey_NavTweakSlower, true) ? +1 : 0;
|
int focus_change_dir = IsKeyPressedMap(ImGuiKey_NavTweakFaster, true) ? -1 : IsKeyPressedMap(ImGuiKey_NavTweakSlower, true) ? +1 : 0;
|
||||||
if (focus_change_dir != 0 && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal))
|
if (focus_change_dir != 0 && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal))
|
||||||
@ -2379,16 +2380,13 @@ static void NavUpdate()
|
|||||||
i_current = i;
|
i_current = i;
|
||||||
int i_target = -1;
|
int i_target = -1;
|
||||||
for (int i = i_current+focus_change_dir; i >= 0 && i < g.Windows.Size && i_target == -1; i += focus_change_dir)
|
for (int i = i_current+focus_change_dir; i >= 0 && i < g.Windows.Size && i_target == -1; i += focus_change_dir)
|
||||||
if (g.Windows[i]->Active && g.Windows[i] == g.Windows[i]->RootNonPopupWindow)
|
if (g.Windows[i]->IsNavigableTo())
|
||||||
i_target = i;
|
i_target = i;
|
||||||
for (int i = (focus_change_dir < 0) ? (g.Windows.Size-1) : 0; i >= 0 && i < g.Windows.Size && i_target == -1 && i_target != i_current; i += focus_change_dir)
|
for (int i = (focus_change_dir < 0) ? (g.Windows.Size-1) : 0; i >= 0 && i < g.Windows.Size && i_target == -1 && i_target != i_current; i += focus_change_dir)
|
||||||
if (g.Windows[i]->Active && g.Windows[i] == g.Windows[i]->RootNonPopupWindow)
|
if (g.Windows[i]->IsNavigableTo())
|
||||||
i_target = i;
|
i_target = i;
|
||||||
if (i_target != -1)
|
if (i_target != -1 && i_target != i_current) // i_target might be == i_current in rare situation where we only have 1 navigable window
|
||||||
{
|
|
||||||
IM_ASSERT(i_target != i_current);
|
|
||||||
g.NavWindowingTarget = g.Windows[i_target];
|
g.NavWindowingTarget = g.Windows[i_target];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply actual focus only when leaving NavWindowing mode (until then the window was merely rendered front-most)
|
// Apply actual focus only when leaving NavWindowing mode (until then the window was merely rendered front-most)
|
||||||
|
@ -735,6 +735,7 @@ public:
|
|||||||
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
|
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
|
||||||
float MenuBarHeight() const { return (Flags & ImGuiWindowFlags_MenuBar) ? CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; }
|
float MenuBarHeight() const { return (Flags & ImGuiWindowFlags_MenuBar) ? CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; }
|
||||||
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
|
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
|
||||||
|
bool IsNavigableTo() const { return Active && this == this->RootNonPopupWindow && (!(Flags & ImGuiWindowFlags_NoNav) || this == GImGui->FocusedWindow); }
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user