@ -4970,12 +4970,8 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
window - > Flags = flags ;
g . WindowsById . SetVoidPtr ( window - > ID , window ) ;
if ( flags & ImGuiWindowFlags_NoSavedSettings )
{
// User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
window - > Size = window - > SizeFull = size ;
}
else
// User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
if ( ! ( flags & ImGuiWindowFlags_NoSavedSettings ) )
{
// Retrieve settings from .ini file
// Use SetWindowPos() or SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
@ -4991,8 +4987,8 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
if ( ImLengthSqr ( settings - > Size ) > 0.00001f )
size = settings - > Size ;
}
window - > Size = window - > SizeFull = size ;
}
window - > Size = window - > SizeFull = window - > SizeFullAtLastBegin = size ;
if ( ( flags & ImGuiWindowFlags_AlwaysAutoResize ) ! = 0 )
{
@ -5183,6 +5179,20 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
else
flags = window - > Flags ;
// Update the Appearing flag
bool window_just_activated_by_user = ( window - > LastFrameActive < current_frame - 1 ) ; // Not using !WasActive because the implicit "Debug" window would always toggle off->on
const bool window_just_appearing_after_hidden_for_resize = ( window - > HiddenFrames = = 1 ) ;
if ( flags & ImGuiWindowFlags_Popup )
{
ImGuiPopupRef & popup_ref = g . OpenPopupStack [ g . CurrentPopupStack . Size ] ;
window_just_activated_by_user | = ( window - > PopupId ! = popup_ref . PopupId ) ; // We recycle popups so treat window as activated if popup id changed
window_just_activated_by_user | = ( window ! = popup_ref . Window ) ;
}
window - > Appearing = ( window_just_activated_by_user | | window_just_appearing_after_hidden_for_resize ) ;
window - > CloseButton = ( p_open ! = NULL ) ;
if ( window - > Appearing )
SetWindowConditionAllowFlags ( window , ImGuiCond_Appearing , true ) ;
// Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack
ImGuiWindow * parent_window = first_begin_of_the_frame ? ( ! g . CurrentWindowStack . empty ( ) ? g . CurrentWindowStack . back ( ) : NULL ) : window - > ParentWindow ;
IM_ASSERT ( parent_window ! = NULL | | ! ( flags & ImGuiWindowFlags_ChildWindow ) ) ;
@ -5191,27 +5201,18 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
g . CurrentWindowStack . push_back ( window ) ;
SetCurrentWindow ( window ) ;
CheckStacksSize ( window , true ) ;
bool window_just_activated_by_user = ( window - > LastFrameActive < current_frame - 1 ) ; // Not using !WasActive because the implicit "Debug" window would always toggle off->on
if ( flags & ImGuiWindowFlags_Popup )
{
ImGuiPopupRef & popup_ref = g . OpenPopupStack [ g . CurrentPopupStack . Size ] ;
window_just_activated_by_user | = ( window - > PopupId ! = popup_ref . PopupId ) ; // We recycle popups so treat window as activated if popup id changed
window_just_activated_by_user | = ( window ! = popup_ref . Window ) ;
popup_ref . Window = window ;
g . CurrentPopupStack . push_back ( popup_ref ) ;
window - > PopupId = popup_ref . PopupId ;
}
const bool window_just_appearing_after_hidden_for_resize = ( window - > HiddenFrames = = 1 ) ;
if ( window_just_appearing_after_hidden_for_resize & & ! ( flags & ImGuiWindowFlags_ChildWindow ) )
window - > NavLastIds [ 0 ] = 0 ;
window - > Appearing = ( window_just_activated_by_user | | window_just_appearing_after_hidden_for_resize ) ;
window - > CloseButton = ( p_open ! = NULL ) ;
// Process SetNextWindow***() calls
if ( window - > Appearing )
SetWindowConditionAllowFlags ( window , ImGuiCond_Appearing , true ) ;
bool window_pos_set_by_api = false , window_size_set_by_api = false ;
if ( g . SetNextWindowPosCond )
{
@ -5380,13 +5381,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// SCROLLBAR STATUS
// Update scrollbar status (based on the Size that was effective during last frame or the auto-resized Size). We need to do this before manual resize (below) is effective.
// Update scrollbar status (based on the Size that was effective during last frame or the auto-resized Size).
if ( ! window - > Collapsed )
{
window - > ScrollbarY = ( flags & ImGuiWindowFlags_AlwaysVerticalScrollbar ) | | ( ( window - > SizeContents . y > window - > SizeFull . y ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ) ;
window - > ScrollbarX = ( flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar ) | | ( ( window - > SizeContents . x > window - > SizeFull . x - ( window - > ScrollbarY ? style . ScrollbarSize : 0.0f ) - window - > WindowPadding . x ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) & & ( flags & ImGuiWindowFlags_HorizontalScrollbar ) ) ;
window - > ScrollbarY = ( flags & ImGuiWindowFlags_AlwaysVerticalScrollbar ) | | ( ( window - > SizeContents . y > window - > SizeFull AtLastBegin . y ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ) ;
window - > ScrollbarX = ( flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar ) | | ( ( window - > SizeContents . x > window - > SizeFull AtLastBegin . x - ( window - > ScrollbarY ? style . ScrollbarSize : 0.0f ) - window - > WindowPadding . x ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) & & ( flags & ImGuiWindowFlags_HorizontalScrollbar ) ) ;
if ( window - > ScrollbarX & & ! window - > ScrollbarY )
window - > ScrollbarY = ( window - > SizeContents . y > window - > SizeFull . y + style . ScrollbarSize ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ;
window - > ScrollbarY = ( window - > SizeContents . y > window - > SizeFull AtLastBegin . y + style . ScrollbarSize ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ;
window - > ScrollbarSizes = ImVec2 ( window - > ScrollbarY ? style . ScrollbarSize : 0.0f , window - > ScrollbarX ? style . ScrollbarSize : 0.0f ) ;
}
@ -5520,11 +5521,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
ImRect resize_rect ( corner , corner + grip . InnerDir * grip_hover_size ) ;
resize_rect . FixInverted ( ) ;
bool hovered , held ;
ButtonBehavior ( resize_rect , window - > GetID ( ( void * ) resize_grip_n ) , & hovered , & held , ImGuiButtonFlags_FlattenChilds | ImGuiButtonFlags_NoNavFocus ) ;
ButtonBehavior ( resize_rect , window - > GetID ( ( void * ) resize_grip_n ) , & hovered , & held , ImGuiButtonFlags_FlattenChilds ) ;
if ( hovered | | held )
g . MouseCursor = ( resize_grip_n & 1 ) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE ;
if ( g . HoveredWindow = = window & & held & & g . IO . MouseDoubleClicked [ 0 ] )
if ( g . HoveredWindow = = window & & held & & g . IO . MouseDoubleClicked [ 0 ] & & resize_grip_n = = 0 )
{
// Manual auto-fit when double-clicking
size_target = CalcSizeFullWithConstraint ( window , size_auto_fit ) ;
@ -5537,6 +5538,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
ImVec2 corner_target = g . IO . MousePos - g . ActiveIdClickOffset + resize_rect . GetSize ( ) * grip . CornerPos ; // Corner of the window corresponding to our corner grip
CalcResizePosSizeFromAnyCorner ( window , corner_target , grip . CornerPos , & pos_target , & size_target ) ;
}
if ( resize_grip_n = = 0 | | held | | hovered )
resize_grip_col [ resize_grip_n ] = GetColorU32 ( held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip ) ;
}
for ( int border_n = 0 ; border_n < resize_border_count ; border_n + + )
@ -5582,6 +5584,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
}
}
}
PopID ( ) ;
// Apply back modified position/size to window
if ( size_target . x ! = FLT_MAX )
@ -5594,6 +5597,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window - > Pos = window - > PosFloat = ImVec2 ( ( float ) ( int ) pos_target . x , ( float ) ( int ) pos_target . y ) ;
MarkIniSettingsDirty ( window ) ;
}
window - > Size = window - > SizeFull ;
title_bar_rect = window - > TitleBarRect ( ) ;
}
@ -5648,6 +5652,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window - > DrawList - > AddLine ( title_bar_rect . GetBL ( ) + ImVec2 ( 1 , - 1 ) , title_bar_rect . GetBR ( ) + ImVec2 ( - 1 , - 1 ) , GetColorU32 ( ImGuiCol_Border ) , style . FrameBorderSize ) ;
}
// Store a backup of SizeFull which we will use next frame to decide if we need scrollbars.
window - > SizeFullAtLastBegin = window - > SizeFull ;
// Update ContentsRegionMax. All the variable it depends on are set above in this function.
window - > ContentsRegionRect . Min . x = - window - > Scroll . x + window - > WindowPadding . x ;
window - > ContentsRegionRect . Min . y = - window - > Scroll . y + window - > WindowPadding . y + window - > TitleBarHeight ( ) + window - > MenuBarHeight ( ) ;