@ -5416,26 +5416,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Decoration size
const float decoration_up_height = window - > TitleBarHeight ( ) + window - > MenuBarHeight ( ) ;
// SCROLLBAR VISIBILITY
// Update scrollbar visibility (based on the Size that was effective during last frame or the auto-resized Size).
if ( ! window - > Collapsed )
{
// When reading the current size we need to read it after size constraints have been applied.
// When we use InnerRect here we are intentionally reading last frame size, same for ScrollbarSizes values before we set them again.
ImVec2 avail_size_from_current_frame = ImVec2 ( window - > SizeFull . x , window - > SizeFull . y - decoration_up_height ) ;
ImVec2 avail_size_from_last_frame = window - > InnerRect . GetSize ( ) + window - > ScrollbarSizes ;
ImVec2 needed_size_from_last_frame = window_just_created ? ImVec2 ( 0 , 0 ) : window - > ContentSize + window - > WindowPadding * 2.0f ;
float size_x_for_scrollbars = use_current_size_for_scrollbar_x ? avail_size_from_current_frame . x : avail_size_from_last_frame . x ;
float size_y_for_scrollbars = use_current_size_for_scrollbar_y ? avail_size_from_current_frame . y : avail_size_from_last_frame . y ;
//bool scrollbar_y_from_last_frame = window->ScrollbarY; // FIXME: May want to use that in the ScrollbarX expression? How many pros vs cons?
window - > ScrollbarY = ( flags & ImGuiWindowFlags_AlwaysVerticalScrollbar ) | | ( ( needed_size_from_last_frame . y > size_y_for_scrollbars ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ) ;
window - > ScrollbarX = ( flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar ) | | ( ( needed_size_from_last_frame . x > size_x_for_scrollbars - ( window - > ScrollbarY ? style . ScrollbarSize : 0.0f ) ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) & & ( flags & ImGuiWindowFlags_HorizontalScrollbar ) ) ;
if ( window - > ScrollbarX & & ! window - > ScrollbarY )
window - > ScrollbarY = ( needed_size_from_last_frame . y > size_y_for_scrollbars ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ;
window - > ScrollbarSizes = ImVec2 ( window - > ScrollbarY ? style . ScrollbarSize : 0.0f , window - > ScrollbarX ? style . ScrollbarSize : 0.0f ) ;
}
// POSITION
// Popup latch its initial position, will position itself when it appears next frame
@ -5466,7 +5446,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
else if ( ( flags & ImGuiWindowFlags_Tooltip ) ! = 0 & & ! window_pos_set_by_api & & ! window_is_child_tooltip )
window - > Pos = FindBestWindowPosForPopup ( window ) ;
// Clamp position so it stays visible
// Clamp position /size so it stays visible
// Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
ImRect viewport_rect ( GetViewportRect ( ) ) ;
if ( ! window_pos_set_by_api & & ! ( flags & ImGuiWindowFlags_ChildWindow ) & & window - > AutoFitFramesX < = 0 & & window - > AutoFitFramesY < = 0 )
@ -5501,11 +5481,25 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
UpdateManualResize ( window , size_auto_fit , & border_held , resize_grip_count , & resize_grip_col [ 0 ] ) ;
window - > ResizeBorderHeld = ( signed char ) border_held ;
// Default item width. Make it proportional to window size if window manually resizes
if ( window - > Size . x > 0.0f & & ! ( flags & ImGuiWindowFlags_Tooltip ) & & ! ( flags & ImGuiWindowFlags_AlwaysAutoResize ) )
window - > ItemWidthDefault = ( float ) ( int ) ( window - > Size . x * 0.65f ) ;
else
window - > ItemWidthDefault = ( float ) ( int ) ( g . FontSize * 16.0f ) ;
// SCROLLBAR VISIBILITY
// Update scrollbar visibility (based on the Size that was effective during last frame or the auto-resized Size).
if ( ! window - > Collapsed )
{
// When reading the current size we need to read it after size constraints have been applied.
// When we use InnerRect here we are intentionally reading last frame size, same for ScrollbarSizes values before we set them again.
ImVec2 avail_size_from_current_frame = ImVec2 ( window - > SizeFull . x , window - > SizeFull . y - decoration_up_height ) ;
ImVec2 avail_size_from_last_frame = window - > InnerRect . GetSize ( ) + window - > ScrollbarSizes ;
ImVec2 needed_size_from_last_frame = window_just_created ? ImVec2 ( 0 , 0 ) : window - > ContentSize + window - > WindowPadding * 2.0f ;
float size_x_for_scrollbars = use_current_size_for_scrollbar_x ? avail_size_from_current_frame . x : avail_size_from_last_frame . x ;
float size_y_for_scrollbars = use_current_size_for_scrollbar_y ? avail_size_from_current_frame . y : avail_size_from_last_frame . y ;
//bool scrollbar_y_from_last_frame = window->ScrollbarY; // FIXME: May want to use that in the ScrollbarX expression? How many pros vs cons?
window - > ScrollbarY = ( flags & ImGuiWindowFlags_AlwaysVerticalScrollbar ) | | ( ( needed_size_from_last_frame . y > size_y_for_scrollbars ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ) ;
window - > ScrollbarX = ( flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar ) | | ( ( needed_size_from_last_frame . x > size_x_for_scrollbars - ( window - > ScrollbarY ? style . ScrollbarSize : 0.0f ) ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) & & ( flags & ImGuiWindowFlags_HorizontalScrollbar ) ) ;
if ( window - > ScrollbarX & & ! window - > ScrollbarY )
window - > ScrollbarY = ( needed_size_from_last_frame . y > size_y_for_scrollbars ) & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ;
window - > ScrollbarSizes = ImVec2 ( window - > ScrollbarY ? style . ScrollbarSize : 0.0f , window - > ScrollbarX ? style . ScrollbarSize : 0.0f ) ;
}
// UPDATE RECTANGLES (1- THOSE NOT AFFECTED BY SCROLLING)
// Update various regions. Variables they depends on should be set above in this function.
@ -5547,6 +5541,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window - > InnerClipRect . Max . y = ImFloor ( 0.5f + window - > InnerRect . Max . y - window - > WindowBorderSize ) ;
window - > InnerClipRect . ClipWithFull ( host_rect ) ;
// Default item width. Make it proportional to window size if window manually resizes
if ( window - > Size . x > 0.0f & & ! ( flags & ImGuiWindowFlags_Tooltip ) & & ! ( flags & ImGuiWindowFlags_AlwaysAutoResize ) )
window - > ItemWidthDefault = ( float ) ( int ) ( window - > Size . x * 0.65f ) ;
else
window - > ItemWidthDefault = ( float ) ( int ) ( g . FontSize * 16.0f ) ;
// SCROLLING
// Lock down maximum scrolling