@ -4466,23 +4466,23 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Calculate auto-fit size, handle automatic resize
// Calculate auto-fit size, handle automatic resize
const ImVec2 size_auto_fit = CalcSizeAutoFit ( window ) ;
const ImVec2 size_auto_fit = CalcSizeAutoFit ( window ) ;
ImVec2 size_for_scrollbars_visibility = window - > SizeFullAtLastBegin ;
ImVec2 size_full_modified ( FLT_MAX , FLT_MAX ) ;
if ( flags & ImGuiWindowFlags_AlwaysAutoResize & & ! window - > Collapsed )
if ( flags & ImGuiWindowFlags_AlwaysAutoResize & & ! window - > Collapsed )
{
{
// Using SetNextWindowSize() overrides ImGuiWindowFlags_AlwaysAutoResize, so it can be used on tooltips/popups, etc.
// Using SetNextWindowSize() overrides ImGuiWindowFlags_AlwaysAutoResize, so it can be used on tooltips/popups, etc.
if ( ! window_size_x_set_by_api )
if ( ! window_size_x_set_by_api )
window - > SizeFull . x = size_f or_scrollbars_visibility . x = size_auto_fit . x ;
window - > SizeFull . x = size_f ull_modified . x = size_auto_fit . x ;
if ( ! window_size_y_set_by_api )
if ( ! window_size_y_set_by_api )
window - > SizeFull . y = size_f or_scrollbars_visibility . y = size_auto_fit . y ;
window - > SizeFull . y = size_f ull_modified . y = size_auto_fit . y ;
}
}
else if ( window - > AutoFitFramesX > 0 | | window - > AutoFitFramesY > 0 )
else if ( window - > AutoFitFramesX > 0 | | window - > AutoFitFramesY > 0 )
{
{
// Auto-fit only grows during the first few frames
// Auto-fit only grows during the first few frames
// We still process initial auto-fit on collapsed windows to get a window width, but otherwise don't honor ImGuiWindowFlags_AlwaysAutoResize ImGuiWindowFlags_AlwaysAutoResize.
// We still process initial auto-fit on collapsed windows to get a window width, but otherwise don't honor ImGuiWindowFlags_AlwaysAutoResize ImGuiWindowFlags_AlwaysAutoResize.
if ( ! window_size_x_set_by_api & & window - > AutoFitFramesX > 0 )
if ( ! window_size_x_set_by_api & & window - > AutoFitFramesX > 0 )
window - > SizeFull . x = size_f or_scrollbars_visibility . x = window - > AutoFitOnlyGrows ? ImMax ( window - > SizeFull . x , size_auto_fit . x ) : size_auto_fit . x ;
window - > SizeFull . x = size_f ull_modified . x = window - > AutoFitOnlyGrows ? ImMax ( window - > SizeFull . x , size_auto_fit . x ) : size_auto_fit . x ;
if ( ! window_size_y_set_by_api & & window - > AutoFitFramesY > 0 )
if ( ! window_size_y_set_by_api & & window - > AutoFitFramesY > 0 )
window - > SizeFull . y = size_f or_scrollbars_visibility . y = window - > AutoFitOnlyGrows ? ImMax ( window - > SizeFull . y , size_auto_fit . y ) : size_auto_fit . y ;
window - > SizeFull . y = size_f ull_modified . y = window - > AutoFitOnlyGrows ? ImMax ( window - > SizeFull . y , size_auto_fit . y ) : size_auto_fit . y ;
if ( ! window - > Collapsed )
if ( ! window - > Collapsed )
MarkIniSettingsDirty ( window ) ;
MarkIniSettingsDirty ( window ) ;
}
}
@ -4501,10 +4501,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Update scrollbar status (based on the Size that was effective during last frame or the auto-resized Size).
// Update scrollbar status (based on the Size that was effective during last frame or the auto-resized Size).
if ( ! window - > Collapsed )
if ( ! window - > Collapsed )
{
{
window - > ScrollbarY = ( flags & ImGuiWindowFlags_AlwaysVerticalScrollbar ) | | ( ( window - > SizeContents . y > size_for_scrollbars_visibility . y ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ) ;
// When reading the current size we need to read it after size constraints have been applied
window - > ScrollbarX = ( flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar ) | | ( ( window - > SizeContents . x > size_for_scrollbars_visibility . x - ( window - > ScrollbarY ? style . ScrollbarSize : 0.0f ) - window - > WindowPadding . x ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) & & ( flags & ImGuiWindowFlags_HorizontalScrollbar ) ) ;
float size_x_for_scrollbars = size_full_modified . x ! = FLT_MAX ? window - > SizeFull . x : window - > SizeFullAtLastBegin . x ;
float size_y_for_scrollbars = size_full_modified . y ! = FLT_MAX ? window - > SizeFull . y : window - > SizeFullAtLastBegin . y ;
window - > ScrollbarY = ( flags & ImGuiWindowFlags_AlwaysVerticalScrollbar ) | | ( ( window - > SizeContents . y > size_y_for_scrollbars ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ) ;
window - > ScrollbarX = ( flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar ) | | ( ( window - > SizeContents . x > size_x_for_scrollbars - ( window - > ScrollbarY ? style . ScrollbarSize : 0.0f ) - window - > WindowPadding . x ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) & & ( flags & ImGuiWindowFlags_HorizontalScrollbar ) ) ;
if ( window - > ScrollbarX & & ! window - > ScrollbarY )
if ( window - > ScrollbarX & & ! window - > ScrollbarY )
window - > ScrollbarY = ( window - > SizeContents . y > size_for_scrollbars_visibility . y + style . ScrollbarSize ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ;
window - > ScrollbarY = ( window - > SizeContents . y > size_ y_ for_scrollbars + style . ScrollbarSize ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ;
window - > ScrollbarSizes = ImVec2 ( window - > ScrollbarY ? style . ScrollbarSize : 0.0f , window - > ScrollbarX ? style . ScrollbarSize : 0.0f ) ;
window - > ScrollbarSizes = ImVec2 ( window - > ScrollbarY ? style . ScrollbarSize : 0.0f , window - > ScrollbarX ? style . ScrollbarSize : 0.0f ) ;
}
}