@ -853,6 +853,7 @@ static void NavUpdate();
static void NavUpdateWindowing ( ) ;
static void NavUpdateWindowing ( ) ;
static void NavUpdateWindowingOverlay ( ) ;
static void NavUpdateWindowingOverlay ( ) ;
static void NavUpdateMoveResult ( ) ;
static void NavUpdateMoveResult ( ) ;
static void NavUpdateInitResult ( ) ;
static float NavUpdatePageUpPageDown ( ) ;
static float NavUpdatePageUpPageDown ( ) ;
static inline void NavUpdateAnyRequestFlag ( ) ;
static inline void NavUpdateAnyRequestFlag ( ) ;
static void NavEndFrame ( ) ;
static void NavEndFrame ( ) ;
@ -9187,7 +9188,7 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
if ( ! ( window - > Flags & ImGuiWindowFlags_NoNavInputs ) )
if ( ! ( window - > Flags & ImGuiWindowFlags_NoNavInputs ) )
if ( ! ( window - > Flags & ImGuiWindowFlags_ChildWindow ) | | ( window - > Flags & ImGuiWindowFlags_Popup ) | | ( window - > NavLastIds [ 0 ] = = 0 ) | | force_reinit )
if ( ! ( window - > Flags & ImGuiWindowFlags_ChildWindow ) | | ( window - > Flags & ImGuiWindowFlags_Popup ) | | ( window - > NavLastIds [ 0 ] = = 0 ) | | force_reinit )
init_for_nav = true ;
init_for_nav = true ;
//IMGUI_DEBUG_LOG("[Nav] NavInitWindow() init_for_nav=%d, window=\"%s\", layer=%d\n", init_for_nav, window->Name, g.NavLayer);
IMGUI_DEBUG_LOG_NAV ( " [nav] NavInitRequest: from NavInitWindow(), init_for_nav=%d, window= \" %s \" , layer=%d \n " , init_for_nav , window - > Name , g . NavLayer ) ;
if ( init_for_nav )
if ( init_for_nav )
{
{
SetNavID ( 0 , g . NavLayer , 0 ) ;
SetNavID ( 0 , g . NavLayer , 0 ) ;
@ -9309,17 +9310,8 @@ static void ImGui::NavUpdate()
io . NavInputsDownDuration [ i ] = ( io . NavInputs [ i ] > 0.0f ) ? ( io . NavInputsDownDuration [ i ] < 0.0f ? 0.0f : io . NavInputsDownDuration [ i ] + io . DeltaTime ) : - 1.0f ;
io . NavInputsDownDuration [ i ] = ( io . NavInputs [ i ] > 0.0f ) ? ( io . NavInputsDownDuration [ i ] < 0.0f ? 0.0f : io . NavInputsDownDuration [ i ] + io . DeltaTime ) : - 1.0f ;
// Process navigation init request (select first/default focus)
// Process navigation init request (select first/default focus)
// In very rare cases g.NavWindow may be null (e.g. clearing focus after requesting an init request, which does happen when releasing Alt while clicking on void)
if ( g . NavInitResultId ! = 0 & & ( ! g . NavDisableHighlight | | g . NavInitRequestFromMove ) )
if ( g . NavInitResultId ! = 0 & & ( ! g . NavDisableHighlight | | g . NavInitRequestFromMove ) & & g . NavWindow )
NavUpdateInitResult ( ) ;
{
// Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
//IMGUI_DEBUG_LOG("[Nav] Apply NavInitRequest result: 0x%08X Layer %d in \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name);
if ( g . NavInitRequestFromMove )
SetNavIDWithRectRel ( g . NavInitResultId , g . NavLayer , 0 , g . NavInitResultRectRel ) ;
else
SetNavID ( g . NavInitResultId , g . NavLayer , 0 ) ;
g . NavWindow - > NavRectRel [ g . NavLayer ] = g . NavInitResultRectRel ;
}
g . NavInitRequest = false ;
g . NavInitRequest = false ;
g . NavInitRequestFromMove = false ;
g . NavInitRequestFromMove = false ;
g . NavInitResultId = 0 ;
g . NavInitResultId = 0 ;
@ -9372,6 +9364,7 @@ static void ImGui::NavUpdate()
// Process NavCancel input (to close a popup, get back to parent, clear focus)
// Process NavCancel input (to close a popup, get back to parent, clear focus)
if ( IsNavInputTest ( ImGuiNavInput_Cancel , ImGuiInputReadMode_Pressed ) )
if ( IsNavInputTest ( ImGuiNavInput_Cancel , ImGuiInputReadMode_Pressed ) )
{
{
IMGUI_DEBUG_LOG_NAV ( " [nav] ImGuiNavInput_Cancel \n " ) ;
if ( g . ActiveId ! = 0 )
if ( g . ActiveId ! = 0 )
{
{
if ( ! IsActiveIdUsingNavInput ( ImGuiNavInput_Cancel ) )
if ( ! IsActiveIdUsingNavInput ( ImGuiNavInput_Cancel ) )
@ -9457,6 +9450,7 @@ static void ImGui::NavUpdate()
// (Preserve g.NavMoveRequestFlags, g.NavMoveClipDir which were set by the NavMoveRequestForward() function)
// (Preserve g.NavMoveRequestFlags, g.NavMoveClipDir which were set by the NavMoveRequestForward() function)
IM_ASSERT ( g . NavMoveDir ! = ImGuiDir_None & & g . NavMoveClipDir ! = ImGuiDir_None ) ;
IM_ASSERT ( g . NavMoveDir ! = ImGuiDir_None & & g . NavMoveClipDir ! = ImGuiDir_None ) ;
IM_ASSERT ( g . NavMoveRequestForward = = ImGuiNavForward_ForwardQueued ) ;
IM_ASSERT ( g . NavMoveRequestForward = = ImGuiNavForward_ForwardQueued ) ;
IMGUI_DEBUG_LOG_NAV ( " [nav] NavMoveRequestForward %d \n " , g . NavMoveDir ) ;
g . NavMoveRequestForward = ImGuiNavForward_ForwardActive ;
g . NavMoveRequestForward = ImGuiNavForward_ForwardActive ;
}
}
@ -9475,7 +9469,7 @@ static void ImGui::NavUpdate()
}
}
if ( g . NavMoveRequest & & g . NavId = = 0 )
if ( g . NavMoveRequest & & g . NavId = = 0 )
{
{
//IMGUI_DEBUG_LOG("[Nav] NavInitRequest from move, window \"%s\", layer=%d\n", g.NavWindow->Name, g.NavLayer);
IMGUI_DEBUG_LOG_NAV ( " [nav] NavInitRequest: from move, window \" %s \" , layer=%d \n " , g . NavWindow - > Name , g . NavLayer ) ;
g . NavInitRequest = g . NavInitRequestFromMove = true ;
g . NavInitRequest = g . NavInitRequestFromMove = true ;
// Reassigning with same value, we're being explicit here.
// Reassigning with same value, we're being explicit here.
g . NavInitResultId = 0 ; // -V1048
g . NavInitResultId = 0 ; // -V1048
@ -9520,6 +9514,7 @@ static void ImGui::NavUpdate()
ImRect window_rect_rel ( window - > InnerRect . Min - window - > Pos - ImVec2 ( 1 , 1 ) , window - > InnerRect . Max - window - > Pos + ImVec2 ( 1 , 1 ) ) ;
ImRect window_rect_rel ( window - > InnerRect . Min - window - > Pos - ImVec2 ( 1 , 1 ) , window - > InnerRect . Max - window - > Pos + ImVec2 ( 1 , 1 ) ) ;
if ( ! window_rect_rel . Contains ( window - > NavRectRel [ g . NavLayer ] ) )
if ( ! window_rect_rel . Contains ( window - > NavRectRel [ g . NavLayer ] ) )
{
{
IMGUI_DEBUG_LOG_NAV ( " [nav] NavMoveRequest: clamp NavRectRel \n " ) ;
float pad = window - > CalcFontSize ( ) * 0.5f ;
float pad = window - > CalcFontSize ( ) * 0.5f ;
window_rect_rel . Expand ( ImVec2 ( - ImMin ( window_rect_rel . GetWidth ( ) , pad ) , - ImMin ( window_rect_rel . GetHeight ( ) , pad ) ) ) ; // Terrible approximation for the intent of starting navigation from first fully visible item
window_rect_rel . Expand ( ImVec2 ( - ImMin ( window_rect_rel . GetWidth ( ) , pad ) , - ImMin ( window_rect_rel . GetHeight ( ) , pad ) ) ) ; // Terrible approximation for the intent of starting navigation from first fully visible item
window - > NavRectRel [ g . NavLayer ] . ClipWithFull ( window_rect_rel ) ;
window - > NavRectRel [ g . NavLayer ] . ClipWithFull ( window_rect_rel ) ;
@ -9546,6 +9541,22 @@ static void ImGui::NavUpdate()
# endif
# endif
}
}
static void ImGui : : NavUpdateInitResult ( )
{
// In very rare cases g.NavWindow may be null (e.g. clearing focus after requesting an init request, which does happen when releasing Alt while clicking on void)
ImGuiContext & g = * GImGui ;
if ( ! g . NavWindow )
return ;
// Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
IMGUI_DEBUG_LOG_NAV ( " [nav] NavInitRequest: result NavID 0x%08X in Layer %d Window \" %s \" \n " , g . NavInitResultId , g . NavLayer , g . NavWindow - > Name ) ;
if ( g . NavInitRequestFromMove )
SetNavIDWithRectRel ( g . NavInitResultId , g . NavLayer , 0 , g . NavInitResultRectRel ) ;
else
SetNavID ( g . NavInitResultId , g . NavLayer , 0 ) ;
g . NavWindow - > NavRectRel [ g . NavLayer ] = g . NavInitResultRectRel ;
}
// Apply result from previous frame navigation directional move request
// Apply result from previous frame navigation directional move request
static void ImGui : : NavUpdateMoveResult ( )
static void ImGui : : NavUpdateMoveResult ( )
{
{
@ -9605,6 +9616,7 @@ static void ImGui::NavUpdateMoveResult()
g . NavJustMovedToFocusScopeId = result - > FocusScopeId ;
g . NavJustMovedToFocusScopeId = result - > FocusScopeId ;
g . NavJustMovedToKeyMods = g . NavMoveRequestKeyMods ;
g . NavJustMovedToKeyMods = g . NavMoveRequestKeyMods ;
}
}
IMGUI_DEBUG_LOG_NAV ( " [nav] NavMoveRequest: result NavID 0x%08X in Layer %d Window \" %s \" \n " , result - > ID , g . NavLayer , g . NavWindow - > Name ) ;
SetNavIDWithRectRel ( result - > ID , g . NavLayer , result - > FocusScopeId , result - > RectRel ) ;
SetNavIDWithRectRel ( result - > ID , g . NavLayer , result - > FocusScopeId , result - > RectRel ) ;
}
}