@ -5286,6 +5286,27 @@ static void ApplyWindowSettings(ImGuiWindow* window, ImGuiWindowSettings* settin
window - > Collapsed = settings - > Collapsed ;
window - > Collapsed = settings - > Collapsed ;
}
}
static void UpdateWindowInFocusOrderList ( ImGuiWindow * window , bool just_created , ImGuiWindowFlags new_flags )
{
ImGuiContext & g = * GImGui ;
const ImGuiWindowFlags old_flags = window - > Flags ;
const bool child_flag_changed = ( new_flags & ImGuiWindowFlags_ChildWindow ) ! = ( old_flags & ImGuiWindowFlags_ChildWindow ) ;
if ( ( just_created | | child_flag_changed ) & & ! ( new_flags & ImGuiWindowFlags_ChildWindow ) )
{
g . WindowsFocusOrder . push_back ( window ) ;
window - > FocusOrder = ( short ) ( g . WindowsFocusOrder . Size - 1 ) ;
}
else if ( child_flag_changed & & ( new_flags & ImGuiWindowFlags_ChildWindow ) )
{
IM_ASSERT ( g . WindowsFocusOrder [ window - > FocusOrder ] = = window ) ;
for ( int n = window - > FocusOrder + 1 ; n < g . WindowsFocusOrder . Size ; n + + )
g . WindowsFocusOrder [ n ] - > FocusOrder - - ;
g . WindowsFocusOrder . erase ( g . WindowsFocusOrder . Data + window - > FocusOrder ) ;
window - > FocusOrder = - 1 ;
}
}
static ImGuiWindow * CreateNewWindow ( const char * name , ImGuiWindowFlags flags )
static ImGuiWindow * CreateNewWindow ( const char * name , ImGuiWindowFlags flags )
{
{
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
@ -5325,16 +5346,12 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags)
window - > AutoFitOnlyGrows = ( window - > AutoFitFramesX > 0 ) | | ( window - > AutoFitFramesY > 0 ) ;
window - > AutoFitOnlyGrows = ( window - > AutoFitFramesX > 0 ) | | ( window - > AutoFitFramesY > 0 ) ;
}
}
if ( ! ( flags & ImGuiWindowFlags_ChildWindow ) )
{
g . WindowsFocusOrder . push_back ( window ) ;
window - > FocusOrder = ( short ) ( g . WindowsFocusOrder . Size - 1 ) ;
}
if ( flags & ImGuiWindowFlags_NoBringToFrontOnFocus )
if ( flags & ImGuiWindowFlags_NoBringToFrontOnFocus )
g . Windows . push_front ( window ) ; // Quite slow but rare and only once
g . Windows . push_front ( window ) ; // Quite slow but rare and only once
else
else
g . Windows . push_back ( window ) ;
g . Windows . push_back ( window ) ;
UpdateWindowInFocusOrderList ( window , true , window - > Flags ) ;
return window ;
return window ;
}
}
@ -5934,6 +5951,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
const bool window_just_created = ( window = = NULL ) ;
const bool window_just_created = ( window = = NULL ) ;
if ( window_just_created )
if ( window_just_created )
window = CreateNewWindow ( name , flags ) ;
window = CreateNewWindow ( name , flags ) ;
else
UpdateWindowInFocusOrderList ( window , window_just_created , flags ) ;
// Automatically disable manual moving/resizing when NoInputs is set
// Automatically disable manual moving/resizing when NoInputs is set
if ( ( flags & ImGuiWindowFlags_NoInputs ) = = ImGuiWindowFlags_NoInputs )
if ( ( flags & ImGuiWindowFlags_NoInputs ) = = ImGuiWindowFlags_NoInputs )