Skip to content

Commit

Permalink
Nav: Fixed explicit directional input not re-highlighting current nav…
Browse files Browse the repository at this point in the history
… item if there is a single item in the window and highlight has been previously disabled by the mouse. (#787)
  • Loading branch information
ocornut committed Nov 21, 2018
1 parent b9ae9bb commit cc4b1f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Other Changes:
- Nav, Focus: Fixed ImGuiWindowFlags_NoBringToFrontOnFocus windows not being restoring focus
properly after the main menu bar or last focused window is deactivated.
- Nav: Fixed an assert in certain circumstance (mostly when using popups) when mouse positions stop being valid. (#2168)
- Nav: Fixed explicit directional input not re-highlighting current nav item if there is a single item in the window
and highlight has been previously disabled by the mouse. (#787)
- DragFloat: Fixed a situation where dragging with value rounding enabled or with a power curve
erroneously wrapped the value to one of the min/max edge. (#2024, #708, #320, #2075).
- DragFloat: Disabled using power curve when one edge is FLT_MAX (broken in 1.61). (#2024)
Expand Down
17 changes: 14 additions & 3 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7242,7 +7242,7 @@ static void ImGui::NavUpdate()
g.NavJustMovedToId = 0;

// Process navigation move request
if (g.NavMoveRequest && (g.NavMoveResultLocal.ID != 0 || g.NavMoveResultOther.ID != 0))
if (g.NavMoveRequest)
NavUpdateMoveResult();

// When a forwarded move request failed, we restore the highlight that we disabled during the forward frame
Expand Down Expand Up @@ -7457,10 +7457,22 @@ static void ImGui::NavUpdate()
#endif
}

// Apply result from previous frame navigation directional move request
static void ImGui::NavUpdateMoveResult()
{
// Select which result to use
ImGuiContext& g = *GImGui;
if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
{
// In a situation when there is no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
if (g.NavId != 0)
{
g.NavDisableHighlight = false;
g.NavDisableMouseHover = true;
}
return;
}

// Select which result to use
ImGuiNavMoveResult* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;

// PageUp/PageDown behavior first jumps to the bottom/top mostly visible item, _otherwise_ use the result from the previous/next page.
Expand Down Expand Up @@ -7490,7 +7502,6 @@ static void ImGui::NavUpdateMoveResult()
NavScrollToBringItemIntoView(result->Window->ParentWindow, ImRect(rect_abs.Min + delta_scroll, rect_abs.Max + delta_scroll));
}

// Apply result from previous frame navigation directional move request
ClearActiveID();
g.NavWindow = result->Window;
SetNavIDWithRectRel(result->ID, g.NavLayer, result->RectRel);
Expand Down

0 comments on commit cc4b1f9

Please sign in to comment.