@ -2174,7 +2174,7 @@ static bool NavScoreItem(ImRect cand)
static inline void NavUpdateAnyRequestFlag ( )
{
ImGuiContext & g = * GImGui ;
g . NavAnyRequest = g . NavMoveRequest | | g . NavInit Default Request | | IMGUI_DEBUG_NAV ;
g . NavAnyRequest = g . NavMoveRequest | | g . NavInit Request | | IMGUI_DEBUG_NAV ;
}
static void NavMoveRequestCancel ( )
@ -2191,18 +2191,18 @@ static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGu
// return;
const ImGuiItemFlags item_flags = window - > DC . ItemFlags ;
const ImRect nav_bb_rel ( nav_bb . Min - g . NavWindow - > Pos , nav_bb . Max - g . NavWindow - > Pos ) ;
if ( g . NavInit Default Request & & g . NavLayer = = window - > DC . NavLayerCurrent )
if ( g . NavInit Request & & g . NavLayer = = window - > DC . NavLayerCurrent )
{
// Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
if ( ! ( item_flags & ImGuiItemFlags_NoNavDefaultFocus ) )
{
g . NavInit Default Request = g . NavIni tDefaul tResultExplicit = false ; // Found a match, clear request
g . NavInit Request = g . NavIni tResultExplicit = false ; // Found a match, clear request
NavUpdateAnyRequestFlag ( ) ;
}
if ( g . NavInit Default ResultId = = 0 | | ! ( item_flags & ImGuiItemFlags_NoNavDefaultFocus ) )
if ( g . NavInit ResultId = = 0 | | ! ( item_flags & ImGuiItemFlags_NoNavDefaultFocus ) )
{
g . NavInit Default ResultId = id ;
g . NavInit Default ResultRectRel = nav_bb_rel ;
g . NavInit ResultId = id ;
g . NavInit ResultRectRel = nav_bb_rel ;
}
}
@ -2245,10 +2245,10 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
if ( id ! = 0 )
{
// Navigation processing runs prior to clipping early-out
// (a) So that NavInit Default Request can be honored, for newly opened windows to select a default widget
// (a) So that NavInit Request can be honored, for newly opened windows to select a default widget
// (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests unfortunately, but it is still limited to one window.
// it may not scale very well for windows with ten of thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
// We could early out with `if (is_clipped && !g.NavInitDefaultRequest) return false;` but when we wouldn't be able to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick)
// We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick)
window - > DC . NavLayerActiveMaskNext | = window - > DC . NavLayerCurrentMask ;
if ( g . NavWindow = = window - > RootNavWindow )
if ( g . NavId = = id | | g . NavAnyRequest )
@ -2511,10 +2511,10 @@ static void NavInitWindow(ImGuiWindow* window, bool force_reinit)
if ( init_for_nav )
{
SetNavId ( 0 , g . NavLayer ) ;
g . NavInit Default Request = true ;
g . NavInit Default ResultId = 0 ;
g . NavInit Default ResultExplicit = false ;
g . NavInit Default ResultRectRel = ImRect ( ) ;
g . NavInit Request = true ;
g . NavInit ResultId = 0 ;
g . NavInit ResultExplicit = false ;
g . NavInit ResultRectRel = ImRect ( ) ;
NavUpdateAnyRequestFlag ( ) ;
}
else
@ -2616,18 +2616,18 @@ static void NavUpdate()
g . IO . WantMoveMouse = false ;
// Process navigation init request (select first/default focus)
if ( g . NavInit Default ResultId ! = 0 & & ( ! g . NavDisableHighlight | | g . NavIni tDefaul tResultExplicit) )
if ( g . NavInit ResultId ! = 0 & & ( ! g . NavDisableHighlight | | g . NavIni tResultExplicit) )
{
// Apply result from previous navigation init request (typically select the first item, unless SetItemDefaultFocus() has been called)
IM_ASSERT ( g . NavWindow ) ;
SetNavId ( g . NavInit Default ResultId, g . NavLayer ) ;
g . NavWindow - > NavRectRel [ g . NavLayer ] = g . NavInit Default ResultRectRel;
SetNavId ( g . NavInit ResultId, g . NavLayer ) ;
g . NavWindow - > NavRectRel [ g . NavLayer ] = g . NavInit ResultRectRel;
if ( g . NavDisableMouseHover )
g . NavMousePosDirty = true ;
}
g . NavInit Default Request = false ;
g . NavInit Default ResultExplicit = false ;
g . NavInit Default ResultId = 0 ;
g . NavInit Request = false ;
g . NavInit ResultExplicit = false ;
g . NavInit ResultId = 0 ;
g . NavJustNavigatedId = 0 ;
// Process navigation move request
@ -2775,7 +2775,7 @@ static void NavUpdate()
// Set output flags for user application
g . IO . NavUsable = g . NavWindow & & ! ( g . NavWindow - > Flags & ImGuiWindowFlags_NoNavInputs ) ;
g . IO . NavActive = ( g . IO . NavUsable & & g . NavId ! = 0 & & ! g . NavDisableHighlight ) | | ( g . NavWindowingTarget ! = NULL ) | | g . NavInit Default Request;
g . IO . NavActive = ( g . IO . NavUsable & & g . NavId ! = 0 & & ! g . NavDisableHighlight ) | | ( g . NavWindowingTarget ! = NULL ) | | g . NavInit Request;
// Process NavCancel input (to close a popup, get back to parent, clear focus)
if ( IsNavInputPressed ( ImGuiNavInput_PadCancel , ImGuiNavReadMode_Pressed ) )
@ -2872,8 +2872,8 @@ static void NavUpdate()
// If we initiate a movement request and have no current NavId, we initiate a InitDefautRequest that will be used as a fallback if the direction fails to find a match
if ( g . NavMoveRequest & & g . NavId = = 0 )
{
g . NavInit Default Request = g . NavIni tDefaul tResultExplicit = true ;
g . NavInit Default ResultId = 0 ;
g . NavInit Request = g . NavIni tResultExplicit = true ;
g . NavInit ResultId = 0 ;
g . NavDisableHighlight = false ;
}
@ -6429,12 +6429,12 @@ void ImGui::SetKeyboardFocusHere(int offset)
void ImGui : : SetItemDefaultFocus ( )
{
ImGuiContext & g = * GImGui ;
if ( g . NavWindow = = g . CurrentWindow - > RootNavWindow & & ( g . NavInit Default Request | | g . NavIni tDefaul tResultId ! = 0 ) & & g . NavLayer = = g . NavWindow - > DC . NavLayerCurrent )
if ( g . NavWindow = = g . CurrentWindow - > RootNavWindow & & ( g . NavInit Request | | g . NavIni tResultId ! = 0 ) & & g . NavLayer = = g . NavWindow - > DC . NavLayerCurrent )
{
g . NavInit Default Request = false ;
g . NavInit Default ResultExplicit = true ;
g . NavInit Default ResultId = g . NavWindow - > DC . LastItemId ;
g . NavInit Default ResultRectRel = ImRect ( g . NavWindow - > DC . LastItemRect . Min - g . NavWindow - > Pos , g . NavWindow - > DC . LastItemRect . Max - g . NavWindow - > Pos ) ;
g . NavInit Request = false ;
g . NavInit ResultExplicit = true ;
g . NavInit ResultId = g . NavWindow - > DC . LastItemId ;
g . NavInit ResultRectRel = ImRect ( g . NavWindow - > DC . LastItemRect . Min - g . NavWindow - > Pos , g . NavWindow - > DC . LastItemRect . Max - g . NavWindow - > Pos ) ;
NavUpdateAnyRequestFlag ( ) ;
if ( ! IsItemVisible ( ) )
SetScrollHere ( ) ;