@ -1971,21 +1971,21 @@ static bool NavScoreItem(ImRect cand)
if ( quadrant = = g . NavMoveDir )
{
// Does it beat the current best candidate?
if ( dist_box < g . NavMoveResult Best DistBox)
if ( dist_box < g . NavMoveResult DistBox)
{
g . NavMoveResult Best DistBox = dist_box ;
g . NavMoveResult Best DistCenter = dist_center ;
g . NavMoveResult DistBox = dist_box ;
g . NavMoveResult DistCenter = dist_center ;
return true ;
}
if ( dist_box = = g . NavMoveResult Best DistBox)
if ( dist_box = = g . NavMoveResult DistBox)
{
// Try using distance between center points to break ties
if ( dist_center < g . NavMoveResult Best DistCenter)
if ( dist_center < g . NavMoveResult DistCenter)
{
g . NavMoveResult Best DistCenter = dist_center ;
g . NavMoveResult DistCenter = dist_center ;
new_best = true ;
}
else if ( dist_center = = g . NavMoveResult Best DistCenter)
else if ( dist_center = = g . NavMoveResult DistCenter)
{
// Still tied! we need to be extra-careful to make sure everything gets linked properly. We consistently break ties by symbolically moving "later" buttons
// (with higher index) to the right/downwards by an infinitesimal amount since we the current "best" button already (so it must have a lower index),
@ -1999,10 +1999,10 @@ static bool NavScoreItem(ImRect cand)
// Axial check: if 'curr' has no link at all in some direction and 'cand' lies roughly in that direction, add a tentative link. This will only be kept if no "real" matches
// are found, so it only augments the graph produced by the above method using extra links. (important, since it doesn't guarantee strong connectedness)
// This is just to avoid buttons having no links in a particular direction when there's a suitable neighbor. you get good graphs without this too.
if ( g . NavMoveResult Best DistBox = = FLT_MAX )
if ( dist_axial < g . NavMoveResult Best DistAxial) // Check axial match
if ( g . NavMoveResult DistBox = = FLT_MAX )
if ( dist_axial < g . NavMoveResult DistAxial) // Check axial match
if ( ( g . NavMoveDir = = ImGuiNavDir_W & & dax < 0.0f ) | | ( g . NavMoveDir = = ImGuiNavDir_E & & dax > 0.0f ) | | ( g . NavMoveDir = = ImGuiNavDir_N & & day < 0.0f ) | | ( g . NavMoveDir = = ImGuiNavDir_S & & day > 0.0f ) )
g . NavMoveResult Best DistAxial = dist_axial , new_best = true ;
g . NavMoveResult DistAxial = dist_axial , new_best = true ;
return new_best ;
}
@ -2055,9 +2055,9 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id, const ImRect* nav_bb_ar
const ImRect & nav_bb = nav_bb_arg ? * nav_bb_arg : bb ;
if ( NavScoreItem ( nav_bb ) ) //if (!DEBUG || g.NavMoveRequest)
{
g . NavMoveResult Best Id = * id ;
g . NavMoveResult BestRef RectRel = ImRect ( nav_bb . Min - window - > Pos , nav_bb . Max - window - > Pos ) ;
//g.OverlayDrawList.AddRectFilled(g.Nav RefRectScreen.Min, g.NavRef RectScreen.Max+ImVec2(2,2), IM_COL32(255,255,0,255)); // [DEBUG]
g . NavMoveResult Id = * id ;
g . NavMoveResult RectRel = ImRect ( nav_bb . Min - window - > Pos , nav_bb . Max - window - > Pos ) ;
//g.OverlayDrawList.AddRectFilled(g.Nav ScoringRectScreen.Min, g.NavScoring RectScreen.Max+ImVec2(2,2), IM_COL32(255,255,0,255)); // [DEBUG]
//g.OverlayDrawList.AddRectFilled(nav_bb.Min, nav_bb.Max, IM_COL32(255,0,255,100)); // [DEBUG]
//g.OverlayDrawList.AddText(nav_bb.Min, ~0U, "new_best"); // [DEBUG]
}
@ -2326,38 +2326,38 @@ static void NavUpdate()
ImRect window_rect_rel ( g . NavWindow - > InnerRect . Min - g . NavWindow - > Pos , g . NavWindow - > InnerRect . Max - g . NavWindow - > Pos ) ;
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]
if ( g . NavWindow & & g . NavMoveResult Best Id ! = 0 & & ! window_rect_rel . Contains ( g . NavMoveResult BestRef RectRel) )
if ( g . NavWindow & & g . NavMoveResult Id ! = 0 & & ! window_rect_rel . Contains ( g . NavMoveResult RectRel) )
{
if ( g . NavWindow - > ScrollbarX & & g . NavMoveResult BestRef RectRel. Min . x < window_rect_rel . Min . x )
if ( g . NavWindow - > ScrollbarX & & g . NavMoveResult RectRel. Min . x < window_rect_rel . Min . x )
{
g . NavWindow - > ScrollTarget . x = g . NavMoveResult BestRef RectRel. Min . x + g . NavWindow - > Scroll . x - g . Style . ItemSpacing . x ;
g . NavWindow - > ScrollTarget . x = g . NavMoveResult RectRel. Min . x + g . NavWindow - > Scroll . x - g . Style . ItemSpacing . x ;
g . NavWindow - > ScrollTargetCenterRatio . x = 0.0f ;
}
else if ( g . NavWindow - > ScrollbarX & & g . NavMoveResult BestRef RectRel. Max . x > = window_rect_rel . Max . x )
else if ( g . NavWindow - > ScrollbarX & & g . NavMoveResult RectRel. Max . x > = window_rect_rel . Max . x )
{
g . NavWindow - > ScrollTarget . x = g . NavMoveResult BestRef RectRel. Max . x + g . NavWindow - > Scroll . x + g . Style . ItemSpacing . x ;
g . NavWindow - > ScrollTarget . x = g . NavMoveResult RectRel. Max . x + g . NavWindow - > Scroll . x + g . Style . ItemSpacing . x ;
g . NavWindow - > ScrollTargetCenterRatio . x = 1.0f ;
}
if ( g . NavMoveResult BestRef RectRel. Min . y < window_rect_rel . Min . y )
if ( g . NavMoveResult RectRel. Min . y < window_rect_rel . Min . y )
{
g . NavWindow - > ScrollTarget . y = g . NavMoveResult BestRef RectRel. Min . y + g . NavWindow - > Scroll . y - g . Style . ItemSpacing . y ;
g . NavWindow - > ScrollTarget . y = g . NavMoveResult RectRel. Min . y + g . NavWindow - > Scroll . y - g . Style . ItemSpacing . y ;
g . NavWindow - > ScrollTargetCenterRatio . y = 0.0f ;
}
else if ( g . NavMoveResult BestRef RectRel. Max . y > = window_rect_rel . Max . y )
else if ( g . NavMoveResult RectRel. Max . y > = window_rect_rel . Max . y )
{
g . NavWindow - > ScrollTarget . y = g . NavMoveResult BestRef RectRel. Max . y + g . NavWindow - > Scroll . y + g . Style . ItemSpacing . y ;
g . NavWindow - > ScrollTarget . y = g . NavMoveResult RectRel. Max . y + g . NavWindow - > Scroll . y + g . Style . ItemSpacing . y ;
g . NavWindow - > ScrollTargetCenterRatio . y = 1.0f ;
}
}
}
if ( g . NavMoveRequest & & g . NavMoveResult Best Id ! = 0 )
if ( g . NavMoveRequest & & g . NavMoveResult Id ! = 0 )
{
// Apply result from previous navigation directional move request
IM_ASSERT ( g . NavWindow ) ;
ImGui : : SetActiveID ( 0 ) ;
g . NavId = g . NavWindow - > NavLastId = g . NavMoveResult Best Id;
g . NavRefRectRel = g . NavMoveResult BestRef RectRel;
g . NavId = g . NavWindow - > NavLastId = g . NavMoveResult Id;
g . NavRefRectRel = g . NavMoveResult RectRel;
g . NavMousePosDirty = true ;
g . NavDisableHighlight = false ;
g . NavDisableMouseHover = true ;
@ -2476,8 +2476,8 @@ static void NavUpdate()
}
// Reset search
g . NavMoveResult Best Id = 0 ;
g . NavMoveResult Best DistAxial = g . NavMoveResult Best DistBox = g . NavMoveResul tBes tDistCenter = FLT_MAX ;
g . NavMoveResult Id = 0 ;
g . NavMoveResult DistAxial = g . NavMoveResult DistBox = g . NavMoveResul tDistCenter = FLT_MAX ;
// For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
g . NavScoringRectScreen = g . NavWindow ? ImRect ( g . NavWindow - > Pos + g . NavRefRectRel . Min , g . NavWindow - > Pos + g . NavRefRectRel . Max ) : ImRect ( ) ;