@ -931,9 +931,9 @@ static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted
// Settings
static void WindowSettingsHandler_ClearAll ( ImGuiContext * , ImGuiSettingsHandler * ) ;
static void WindowSettingsHandler_ApplyAll ( ImGuiContext * , ImGuiSettingsHandler * ) ;
static void * WindowSettingsHandler_ReadOpen ( ImGuiContext * , ImGuiSettingsHandler * , const char * name ) ;
static void WindowSettingsHandler_ReadLine ( ImGuiContext * , ImGuiSettingsHandler * , void * entry , const char * line ) ;
static void WindowSettingsHandler_ApplyAll ( ImGuiContext * , ImGuiSettingsHandler * ) ;
static void WindowSettingsHandler_WriteAll ( ImGuiContext * , ImGuiSettingsHandler * , ImGuiTextBuffer * buf ) ;
// Platform Dependents default implementation for IO functions
@ -949,6 +949,7 @@ static void NavUpdateWindowingOverlay();
static void NavUpdateMoveResult ( ) ;
static float NavUpdatePageUpPageDown ( ) ;
static inline void NavUpdateAnyRequestFlag ( ) ;
static void NavEndFrame ( ) ;
static bool NavScoreItem ( ImGuiNavMoveResult * result , ImRect cand ) ;
static void NavProcessItem ( ImGuiWindow * window , const ImRect & nav_bb , ImGuiID id ) ;
static ImVec2 NavCalcPreferredRefPos ( ) ;
@ -4133,9 +4134,9 @@ void ImGui::Initialize(ImGuiContext* context)
ini_handler . TypeName = " Window " ;
ini_handler . TypeHash = ImHashStr ( " Window " ) ;
ini_handler . ClearAllFn = WindowSettingsHandler_ClearAll ;
ini_handler . ApplyAllFn = WindowSettingsHandler_ApplyAll ;
ini_handler . ReadOpenFn = WindowSettingsHandler_ReadOpen ;
ini_handler . ReadLineFn = WindowSettingsHandler_ReadLine ;
ini_handler . ApplyAllFn = WindowSettingsHandler_ApplyAll ;
ini_handler . WriteAllFn = WindowSettingsHandler_WriteAll ;
g . SettingsHandlers . push_back ( ini_handler ) ;
}
@ -4484,9 +4485,8 @@ void ImGui::EndFrame()
// Draw modal whitening background on _other_ viewports than the one the modal is one
EndFrameDrawDimmedBackgrounds ( ) ;
// Show CTRL+TAB list window
if ( g . NavWindowingTarget ! = NULL )
NavUpdateWindowingOverlay ( ) ;
// Update navigation: CTRL+Tab, wrap-around requests
NavEndFrame ( ) ;
SetCurrentViewport ( NULL , NULL ) ;
@ -6793,6 +6793,15 @@ void ImGui::FocusWindow(ImGuiWindow* window)
// Close popups if any
ClosePopupsOverWindow ( window , false ) ;
// Move the root window to the top of the pile
IM_ASSERT ( window = = NULL | | window - > RootWindow ! = NULL ) ;
ImGuiWindow * focus_front_window = window ? window - > RootWindowDockStop : NULL ;
ImGuiWindow * display_front_window = window ? window - > RootWindow : NULL ;
// Steal focus on active widgets
if ( g . ActiveId ! = 0 & & g . ActiveIdWindow & & g . ActiveIdWindow - > RootWindowDockStop ! = focus_front_window )
ClearActiveID ( ) ;
// Passing NULL allow to disable keyboard focus
if ( ! window )
return ;
@ -6802,16 +6811,6 @@ void ImGui::FocusWindow(ImGuiWindow* window)
if ( window - > DockNode & & window - > DockNode - > TabBar )
window - > DockNode - > TabBar - > SelectedTabId = window - > DockNode - > TabBar - > NextSelectedTabId = window - > ID ;
// Move the root window to the top of the pile
IM_ASSERT ( window - > RootWindow ! = NULL ) ;
ImGuiWindow * focus_front_window = window - > RootWindowDockStop ;
ImGuiWindow * display_front_window = window - > RootWindow ;
// Steal focus on active widgets
if ( focus_front_window - > Flags & ImGuiWindowFlags_Popup ) // FIXME: This statement may be unnecessary? Need further testing before removing it..
if ( g . ActiveId ! = 0 & & g . ActiveIdWindow & & g . ActiveIdWindow - > RootWindow ! = focus_front_window )
ClearActiveID ( ) ;
// Bring to front
BringWindowToFocusFront ( focus_front_window ) ;
if ( ( ( window - > Flags | focus_front_window - > Flags | display_front_window - > Flags ) & ImGuiWindowFlags_NoBringToFrontOnFocus ) = = 0 )
@ -8564,7 +8563,8 @@ void ImGui::EndPopup()
IM_ASSERT ( g . BeginPopupStack . Size > 0 ) ;
// Make all menus and popups wrap around for now, may need to expose that policy.
NavMoveRequestTryWrapping ( window , ImGuiNavMoveFlags_LoopY ) ;
if ( g . NavWindow = = window )
NavMoveRequestTryWrapping ( window , ImGuiNavMoveFlags_LoopY ) ;
// Child-popups don't need to be laid out
IM_ASSERT ( g . WithinEndChild = = false ) ;
@ -9060,36 +9060,11 @@ void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const Im
void ImGui : : NavMoveRequestTryWrapping ( ImGuiWindow * window , ImGuiNavMoveFlags move_flags )
{
ImGuiContext & g = * GImGui ;
if ( g . NavWindow ! = window | | ! NavMoveRequestButNoResultYet ( ) | | g . NavMoveRequestForward ! = ImGuiNavForward_None | | g . NavLayer ! = ImGuiNavLayer_Main )
return ;
IM_ASSERT ( move_flags ! = 0 ) ; // No points calling this with no wrapping
ImRect bb_rel = window - > NavRectRel [ 0 ] ;
ImGuiDir clip_dir = g . NavMoveDir ;
if ( g . NavMoveDir = = ImGuiDir_Left & & ( move_flags & ( ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX ) ) )
{
bb_rel . Min . x = bb_rel . Max . x = ImMax ( window - > SizeFull . x , window - > ContentSize . x + window - > WindowPadding . x * 2.0f ) - window - > Scroll . x ;
if ( move_flags & ImGuiNavMoveFlags_WrapX ) { bb_rel . TranslateY ( - bb_rel . GetHeight ( ) ) ; clip_dir = ImGuiDir_Up ; }
NavMoveRequestForward ( g . NavMoveDir , clip_dir , bb_rel , move_flags ) ;
}
if ( g . NavMoveDir = = ImGuiDir_Right & & ( move_flags & ( ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX ) ) )
{
bb_rel . Min . x = bb_rel . Max . x = - window - > Scroll . x ;
if ( move_flags & ImGuiNavMoveFlags_WrapX ) { bb_rel . TranslateY ( + bb_rel . GetHeight ( ) ) ; clip_dir = ImGuiDir_Down ; }
NavMoveRequestForward ( g . NavMoveDir , clip_dir , bb_rel , move_flags ) ;
}
if ( g . NavMoveDir = = ImGuiDir_Up & & ( move_flags & ( ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY ) ) )
{
bb_rel . Min . y = bb_rel . Max . y = ImMax ( window - > SizeFull . y , window - > ContentSize . y + window - > WindowPadding . y * 2.0f ) - window - > Scroll . y ;
if ( move_flags & ImGuiNavMoveFlags_WrapY ) { bb_rel . TranslateX ( - bb_rel . GetWidth ( ) ) ; clip_dir = ImGuiDir_Left ; }
NavMoveRequestForward ( g . NavMoveDir , clip_dir , bb_rel , move_flags ) ;
}
if ( g . NavMoveDir = = ImGuiDir_Down & & ( move_flags & ( ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY ) ) )
{
bb_rel . Min . y = bb_rel . Max . y = - window - > Scroll . y ;
if ( move_flags & ImGuiNavMoveFlags_WrapY ) { bb_rel . TranslateX ( + bb_rel . GetWidth ( ) ) ; clip_dir = ImGuiDir_Right ; }
NavMoveRequestForward ( g . NavMoveDir , clip_dir , bb_rel , move_flags ) ;
}
// Navigation wrap-around logic is delayed to the end of the frame because this operation is only valid after entire
// popup is assembled and in case of appended popups it is not clear which EndPopup() call is final.
g . NavWrapRequestWindow = window ;
g . NavWrapRequestFlags = move_flags ;
}
// FIXME: This could be replaced by updating a frame number in each window when (window == NavWindow) and (NavLayer == 0).
@ -9224,6 +9199,8 @@ static void ImGui::NavUpdate()
{
ImGuiContext & g = * GImGui ;
g . IO . WantSetMousePos = false ;
g . NavWrapRequestWindow = NULL ;
g . NavWrapRequestFlags = ImGuiNavMoveFlags_None ;
#if 0
if ( g . NavScoringCount > 0 ) IMGUI_DEBUG_LOG ( " NavScoringCount %d for '%s' layer %d (Init:%d, Move:%d) \n " , g . FrameCount , g . NavScoringCount , g . NavWindow ? g . NavWindow - > Name : " NULL " , g . NavLayer , g . NavInitRequest | | g . NavInitResultId ! = 0 , g . NavMoveRequest ) ;
# endif
@ -9637,6 +9614,68 @@ static float ImGui::NavUpdatePageUpPageDown()
return 0.0f ;
}
static void ImGui : : NavEndFrame ( )
{
ImGuiContext & g = * GImGui ;
// Show CTRL+TAB list window
if ( g . NavWindowingTarget ! = NULL )
NavUpdateWindowingOverlay ( ) ;
// Perform wrap-around in menus
ImGuiWindow * window = g . NavWrapRequestWindow ;
ImGuiNavMoveFlags move_flags = g . NavWrapRequestFlags ;
if ( window ! = NULL & & g . NavWindow = = window & & NavMoveRequestButNoResultYet ( ) & & g . NavMoveRequestForward = = ImGuiNavForward_None & & g . NavLayer = = ImGuiNavLayer_Main )
{
IM_ASSERT ( move_flags ! = 0 ) ; // No points calling this with no wrapping
ImRect bb_rel = window - > NavRectRel [ 0 ] ;
ImGuiDir clip_dir = g . NavMoveDir ;
if ( g . NavMoveDir = = ImGuiDir_Left & & ( move_flags & ( ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX ) ) )
{
bb_rel . Min . x = bb_rel . Max . x =
ImMax ( window - > SizeFull . x , window - > ContentSize . x + window - > WindowPadding . x * 2.0f ) - window - > Scroll . x ;
if ( move_flags & ImGuiNavMoveFlags_WrapX )
{
bb_rel . TranslateY ( - bb_rel . GetHeight ( ) ) ;
clip_dir = ImGuiDir_Up ;
}
NavMoveRequestForward ( g . NavMoveDir , clip_dir , bb_rel , move_flags ) ;
}
if ( g . NavMoveDir = = ImGuiDir_Right & & ( move_flags & ( ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX ) ) )
{
bb_rel . Min . x = bb_rel . Max . x = - window - > Scroll . x ;
if ( move_flags & ImGuiNavMoveFlags_WrapX )
{
bb_rel . TranslateY ( + bb_rel . GetHeight ( ) ) ;
clip_dir = ImGuiDir_Down ;
}
NavMoveRequestForward ( g . NavMoveDir , clip_dir , bb_rel , move_flags ) ;
}
if ( g . NavMoveDir = = ImGuiDir_Up & & ( move_flags & ( ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY ) ) )
{
bb_rel . Min . y = bb_rel . Max . y =
ImMax ( window - > SizeFull . y , window - > ContentSize . y + window - > WindowPadding . y * 2.0f ) - window - > Scroll . y ;
if ( move_flags & ImGuiNavMoveFlags_WrapY )
{
bb_rel . TranslateX ( - bb_rel . GetWidth ( ) ) ;
clip_dir = ImGuiDir_Left ;
}
NavMoveRequestForward ( g . NavMoveDir , clip_dir , bb_rel , move_flags ) ;
}
if ( g . NavMoveDir = = ImGuiDir_Down & & ( move_flags & ( ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY ) ) )
{
bb_rel . Min . y = bb_rel . Max . y = - window - > Scroll . y ;
if ( move_flags & ImGuiNavMoveFlags_WrapY )
{
bb_rel . TranslateX ( + bb_rel . GetWidth ( ) ) ;
clip_dir = ImGuiDir_Right ;
}
NavMoveRequestForward ( g . NavMoveDir , clip_dir , bb_rel , move_flags ) ;
}
}
}
static int ImGui : : FindWindowFocusIndex ( ImGuiWindow * window ) // FIXME-OPT O(N)
{
ImGuiContext & g = * GImGui ;
@ -10617,24 +10656,11 @@ static void WindowSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandl
g . SettingsWindows . clear ( ) ;
}
// Apply to existing windows (if any)
static void WindowSettingsHandler_ApplyAll ( ImGuiContext * ctx , ImGuiSettingsHandler * )
{
ImGuiContext & g = * ctx ;
for ( ImGuiWindowSettings * settings = g . SettingsWindows . begin ( ) ; settings ! = NULL ; settings = g . SettingsWindows . next_chunk ( settings ) )
if ( settings - > WantApply )
{
if ( ImGuiWindow * window = ImGui : : FindWindowByID ( settings - > ID ) )
ApplyWindowSettings ( window , settings ) ;
settings - > WantApply = false ;
}
}
static void * WindowSettingsHandler_ReadOpen ( ImGuiContext * , ImGuiSettingsHandler * , const char * name )
{
ImGuiWindowSettings * settings = ImGui : : FindOrCreateWindowSettings ( name ) ;
ImGuiID id = settings - > ID ;
* settings = ImGuiWindowSettings ( ) ;
* settings = ImGuiWindowSettings ( ) ; // Clear existing if recycling previous entry
settings - > ID = id ;
settings - > WantApply = true ;
return ( void * ) settings ;
@ -10656,6 +10682,19 @@ static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*,
else if ( sscanf ( line , " ClassId=0x%X " , & u1 ) = = 1 ) { settings - > ClassId = u1 ; }
}
// Apply to existing windows (if any)
static void WindowSettingsHandler_ApplyAll ( ImGuiContext * ctx , ImGuiSettingsHandler * )
{
ImGuiContext & g = * ctx ;
for ( ImGuiWindowSettings * settings = g . SettingsWindows . begin ( ) ; settings ! = NULL ; settings = g . SettingsWindows . next_chunk ( settings ) )
if ( settings - > WantApply )
{
if ( ImGuiWindow * window = ImGui : : FindWindowByID ( settings - > ID ) )
ApplyWindowSettings ( window , settings ) ;
settings - > WantApply = false ;
}
}
static void WindowSettingsHandler_WriteAll ( ImGuiContext * ctx , ImGuiSettingsHandler * handler , ImGuiTextBuffer * buf )
{
// Gather data from windows that were active during this session