mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Navigation: comments + moving init block of code above in NavUpdate(), should have no side-effect (committed to simplify next commit) (#323)
This commit is contained in:
parent
a424d6f805
commit
67feb5ac6c
24
imgui.cpp
24
imgui.cpp
@ -2298,6 +2298,15 @@ static void NavUpdate()
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
g.IO.WantMoveMouse = false;
|
g.IO.WantMoveMouse = false;
|
||||||
|
|
||||||
|
// Process navigation init request (select first/default focus)
|
||||||
|
if (g.NavInitDefaultResultId != 0 && (!g.NavDisableHighlight || g.NavInitDefaultResultExplicit))
|
||||||
|
{
|
||||||
|
// Apply result from previous navigation init request (typically select the first item, unless SetItemDefaultFocus() has been called)
|
||||||
|
IM_ASSERT(g.NavWindow);
|
||||||
|
g.NavId = g.NavWindow->NavLastId = g.NavInitDefaultResultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply application mouse position movement
|
||||||
if (g.NavMousePosDirty && g.NavIdIsAlive)
|
if (g.NavMousePosDirty && g.NavIdIsAlive)
|
||||||
{
|
{
|
||||||
// Set mouse position given our knowledge of the nav widget position from last frame
|
// Set mouse position given our knowledge of the nav widget position from last frame
|
||||||
@ -2311,22 +2320,16 @@ static void NavUpdate()
|
|||||||
g.NavIdIsAlive = false;
|
g.NavIdIsAlive = false;
|
||||||
g.NavTabbedId = 0;
|
g.NavTabbedId = 0;
|
||||||
|
|
||||||
if (g.NavInitDefaultResultId != 0 && (!g.NavDisableHighlight || g.NavInitDefaultResultExplicit))
|
// Process navigation move request
|
||||||
|
if (g.NavMoveRequest && g.NavMoveResultId != 0)
|
||||||
{
|
{
|
||||||
// Apply result from previous navigation init request (typically select the first item, unless SetItemDefaultFocus() has been called)
|
|
||||||
IM_ASSERT(g.NavWindow);
|
IM_ASSERT(g.NavWindow);
|
||||||
g.NavId = g.NavWindow->NavLastId = g.NavInitDefaultResultId;
|
|
||||||
//if (g.NavInitDefaultResultExplicit)
|
|
||||||
// g.NavDisableHighlight = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g.NavMoveRequest)
|
|
||||||
{
|
|
||||||
// Scroll to keep newly navigated item fully into view
|
// Scroll to keep newly navigated item fully into view
|
||||||
ImRect window_rect_rel(g.NavWindow->InnerRect.Min - g.NavWindow->Pos, g.NavWindow->InnerRect.Max - g.NavWindow->Pos);
|
ImRect window_rect_rel(g.NavWindow->InnerRect.Min - g.NavWindow->Pos, g.NavWindow->InnerRect.Max - g.NavWindow->Pos);
|
||||||
window_rect_rel.Expand(1.0f);
|
window_rect_rel.Expand(1.0f);
|
||||||
//g.OverlayDrawList.AddRect(g.NavWindow->Pos + window_rect_rel.Min, g.NavWindow->Pos + window_rect_rel.Max, IM_COL32_WHITE); // [DEBUG]
|
//g.OverlayDrawList.AddRect(g.NavWindow->Pos + window_rect_rel.Min, g.NavWindow->Pos + window_rect_rel.Max, IM_COL32_WHITE); // [DEBUG]
|
||||||
if (g.NavWindow && g.NavMoveResultId != 0 && !window_rect_rel.Contains(g.NavMoveResultRectRel))
|
if (!window_rect_rel.Contains(g.NavMoveResultRectRel))
|
||||||
{
|
{
|
||||||
if (g.NavWindow->ScrollbarX && g.NavMoveResultRectRel.Min.x < window_rect_rel.Min.x)
|
if (g.NavWindow->ScrollbarX && g.NavMoveResultRectRel.Min.x < window_rect_rel.Min.x)
|
||||||
{
|
{
|
||||||
@ -2349,10 +2352,7 @@ static void NavUpdate()
|
|||||||
g.NavWindow->ScrollTargetCenterRatio.y = 1.0f;
|
g.NavWindow->ScrollTargetCenterRatio.y = 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (g.NavMoveRequest && g.NavMoveResultId != 0)
|
|
||||||
{
|
|
||||||
// Apply result from previous navigation directional move request
|
// Apply result from previous navigation directional move request
|
||||||
IM_ASSERT(g.NavWindow);
|
IM_ASSERT(g.NavWindow);
|
||||||
ImGui::SetActiveID(0);
|
ImGui::SetActiveID(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user