@ -3966,19 +3966,19 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
IM_ASSERT ( parent_window ! = NULL | | ! ( flags & ImGuiWindowFlags_ChildWindow ) ) ;
// FIXME: This is currently true if we call Begin() multiple times in a row on a same window.
bool window_ activated = ( window - > LastFrameActive ! = current_frame - 1 ) ; // Not using !WasActive because the implicit "Debug" window would always toggle off->on
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_ activated | = ( window - > PopupId ! = popup_ref . PopupId ) ; // We recycle popups so treat window as activated if popup id changed
window_ activated | = ( window ! = popup_ref . Window ) ;
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_ appearing_after_being _hidden = ( window - > HiddenFrames = = 1 ) ;
window - > Appearing = ( window_ activated | | window _appearing_after_being_ hidden) ;
const bool window_ just_ appearing_after_hidden_for_resize = ( window - > HiddenFrames = = 1 ) ;
window - > Appearing = ( window_ just_ activated_by_user | | window _just _appearing_after_hidden_for_resize ) ;
// Process SetNextWindow***() calls
bool window_pos_set_by_api = false , window_size_set_by_api = false ;
@ -4059,7 +4059,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
else
PushClipRect ( fullscreen_rect . Min , fullscreen_rect . Max , true ) ;
if ( window_ activated)
if ( window_ just_ activated_by_user )
{
// Popup first latch mouse position, will position itself when it appears next frame
window - > AutoPosLastDirection = - 1 ;
@ -4093,7 +4093,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
// Hide popup/tooltip window when first appearing while we measure size (because we recycle them)
if ( window - > HiddenFrames > 0 )
window - > HiddenFrames - - ;
if ( ( flags & ( ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip ) ) ! = 0 & & window_ activated)
if ( ( flags & ( ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip ) ) ! = 0 & & window_ just_ activated_by_user )
{
window - > HiddenFrames = 1 ;
if ( flags & ImGuiWindowFlags_AlwaysAutoResize )
@ -4173,7 +4173,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
bool window_pos_center = false ;
window_pos_center | = ( window - > SetWindowPosCenterWanted & & window - > HiddenFrames = = 0 ) ;
window_pos_center | = ( ( flags & ImGuiWindowFlags_Modal ) & & ! window_pos_set_by_api & & window_ appearing_after_being _hidden) ;
window_pos_center | = ( ( flags & ImGuiWindowFlags_Modal ) & & ! window_pos_set_by_api & & window_ just_ appearing_after_hidden_for_resize ) ;
if ( window_pos_center )
{
// Center (any sort of window)
@ -4192,7 +4192,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
rect_to_avoid = ImRect ( parent_window - > Pos . x + horizontal_overlap , - FLT_MAX , parent_window - > Pos . x + parent_window - > Size . x - horizontal_overlap - parent_window - > ScrollbarSizes . x , FLT_MAX ) ;
window - > PosFloat = FindBestPopupWindowPos ( window - > PosFloat , window - > Size , & window - > AutoPosLastDirection , rect_to_avoid ) ;
}
else if ( ( flags & ImGuiWindowFlags_Popup ) ! = 0 & & ! window_pos_set_by_api & & window_ appearing_after_being _hidden)
else if ( ( flags & ImGuiWindowFlags_Popup ) ! = 0 & & ! window_pos_set_by_api & & window_ just_ appearing_after_hidden_for_resize )
{
ImRect rect_to_avoid ( window - > PosFloat . x - 1 , window - > PosFloat . y - 1 , window - > PosFloat . x + 1 , window - > PosFloat . y + 1 ) ;
window - > PosFloat = FindBestPopupWindowPos ( window - > PosFloat , window - > Size , & window - > AutoPosLastDirection , rect_to_avoid ) ;
@ -4387,7 +4387,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
window - > DC . TreeDepth = 0 ;
window - > DC . StateStorage = & window - > StateStorage ;
window - > DC . GroupStack . resize ( 0 ) ;
window - > MenuColumns . Update ( 3 , style . ItemSpacing . x , window_ activated) ;
window - > MenuColumns . Update ( 3 , style . ItemSpacing . x , window_ just_ activated_by_user ) ;
if ( window - > AutoFitFramesX > 0 )
window - > AutoFitFramesX - - ;
@ -4395,7 +4395,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
window - > AutoFitFramesY - - ;
// New windows appears in front (we need to do that AFTER setting DC.CursorStartPos so our initial navigation reference rectangle can start around there)
if ( window_ activated & & ! ( flags & ImGuiWindowFlags_NoFocusOnAppearing ) )
if ( window_ just_ activated_by_user & & ! ( flags & ImGuiWindowFlags_NoFocusOnAppearing ) )
if ( ! ( flags & ( ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Tooltip ) ) | | ( flags & ImGuiWindowFlags_Popup ) )
FocusWindow ( window ) ;