@ -4636,7 +4636,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
static ImVec2 CalcSizeAfterConstraint ( ImGuiWindow * window , ImVec2 new_size )
{
ImGuiContext & g = * GImGui ;
if ( g . NextWindowData . SizeConstraintCond ! = 0 )
if ( g . NextWindowData . Flags & ImGuiNextWindowDataFlags_Has SizeConstraint)
{
// Using -1,-1 on either X/Y axis to preserve the current size.
ImRect cr = g . NextWindowData . SizeConstraintRect ;
@ -4993,13 +4993,12 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
{
ImU32 bg_col = GetColorU32 ( GetWindowBgColorIdxFromFlags ( flags ) ) ;
float alpha = 1.0f ;
if ( g . NextWindowData . BgAlphaCond ! = 0 )
if ( g . NextWindowData . Flags & ImGuiNextWindowDataFlags_Has BgAlpha)
alpha = g . NextWindowData . BgAlphaVal ;
if ( alpha ! = 1.0f )
bg_col = ( bg_col & ~ IM_COL32_A_MASK ) | ( IM_F32_TO_INT8_SAT ( alpha ) < < IM_COL32_A_SHIFT ) ;
window - > DrawList - > AddRectFilled ( window - > Pos + ImVec2 ( 0 , window - > TitleBarHeight ( ) ) , window - > Pos + window - > Size , bg_col , window_rounding , ( flags & ImGuiWindowFlags_NoTitleBar ) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot ) ;
}
g . NextWindowData . BgAlphaCond = 0 ;
// Title bar
if ( ! ( flags & ImGuiWindowFlags_NoTitleBar ) )
@ -5130,7 +5129,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
const bool window_just_created = ( window = = NULL ) ;
if ( window_just_created )
{
ImVec2 size_on_first_use = ( g . NextWindowData . SizeCond ! = 0 ) ? g . NextWindowData . SizeVal : ImVec2 ( 0.0f , 0.0f ) ; // Any condition flag will do since we are creating a new window here.
ImVec2 size_on_first_use = ( g . NextWindowData . Flags & ImGuiNextWindowDataFlags_HasSize ) ? g . NextWindowData . SizeVal : ImVec2 ( 0.0f , 0.0f ) ; // Any condition flag will do since we are creating a new window here.
window = CreateNewWindow ( name , size_on_first_use , flags ) ;
}
@ -5194,7 +5193,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Process SetNextWindow***() calls
bool window_pos_set_by_api = false ;
bool window_size_x_set_by_api = false , window_size_y_set_by_api = false ;
if ( g . NextWindowData . PosCond )
if ( g . NextWindowData . Flags & ImGuiNextWindowDataFlags_HasPos )
{
window_pos_set_by_api = ( window - > SetWindowPosAllowFlags & g . NextWindowData . PosCond ) ! = 0 ;
if ( window_pos_set_by_api & & ImLengthSqr ( g . NextWindowData . PosPivotVal ) > 0.00001f )
@ -5210,13 +5209,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
SetWindowPos ( window , g . NextWindowData . PosVal , g . NextWindowData . PosCond ) ;
}
}
if ( g . NextWindowData . SizeCond )
if ( g . NextWindowData . Flags & ImGuiNextWindowDataFlags_HasSize )
{
window_size_x_set_by_api = ( window - > SetWindowSizeAllowFlags & g . NextWindowData . SizeCond ) ! = 0 & & ( g . NextWindowData . SizeVal . x > 0.0f ) ;
window_size_y_set_by_api = ( window - > SetWindowSizeAllowFlags & g . NextWindowData . SizeCond ) ! = 0 & & ( g . NextWindowData . SizeVal . y > 0.0f ) ;
SetWindowSize ( window , g . NextWindowData . SizeVal , g . NextWindowData . SizeCond ) ;
}
if ( g . NextWindowData . ContentSizeCond )
if ( g . NextWindowData . Flags & ImGuiNextWindowDataFlags_Has ContentSize)
{
// Adjust passed "client size" to become a "window size"
window - > SizeContentsExplicit = g . NextWindowData . ContentSizeVal ;
@ -5227,9 +5226,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
{
window - > SizeContentsExplicit = ImVec2 ( 0.0f , 0.0f ) ;
}
if ( g . NextWindowData . CollapsedCon d)
if ( g . NextWindowData . Flags & ImGuiNextWindowDataFlags_Has Collapsed)
SetWindowCollapsed ( window , g . NextWindowData . CollapsedVal , g . NextWindowData . CollapsedCond ) ;
if ( g . NextWindowData . F ocusCond )
if ( g . NextWindowData . F lags & ImGuiNextWindowDataFlags_HasF ocus)
FocusWindow ( window ) ;
if ( window - > Appearing )
SetWindowConditionAllowFlags ( window , ImGuiCond_Appearing , false ) ;
@ -5607,7 +5606,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window - > WriteAccessed = false ;
window - > BeginCount + + ;
g . NextWindowData . Clear ( ) ;
g . NextWindowData . Clear Flags ( ) ;
if ( flags & ImGuiWindowFlags_ChildWindow )
{
@ -6397,6 +6396,7 @@ void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pi
{
ImGuiContext & g = * GImGui ;
IM_ASSERT ( cond = = 0 | | ImIsPowerOfTwo ( cond ) ) ; // Make sure the user doesn't attempt to combine multiple condition flags.
g . NextWindowData . Flags | = ImGuiNextWindowDataFlags_HasPos ;
g . NextWindowData . PosVal = pos ;
g . NextWindowData . PosPivotVal = pivot ;
g . NextWindowData . PosCond = cond ? cond : ImGuiCond_Always ;
@ -6406,6 +6406,7 @@ void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond)
{
ImGuiContext & g = * GImGui ;
IM_ASSERT ( cond = = 0 | | ImIsPowerOfTwo ( cond ) ) ; // Make sure the user doesn't attempt to combine multiple condition flags.
g . NextWindowData . Flags | = ImGuiNextWindowDataFlags_HasSize ;
g . NextWindowData . SizeVal = size ;
g . NextWindowData . SizeCond = cond ? cond : ImGuiCond_Always ;
}
@ -6413,7 +6414,7 @@ void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond)
void ImGui : : SetNextWindowSizeConstraints ( const ImVec2 & size_min , const ImVec2 & size_max , ImGuiSizeCallback custom_callback , void * custom_callback_user_data )
{
ImGuiContext & g = * GImGui ;
g . NextWindowData . SizeConstraintCond = ImGuiCond_Always ;
g . NextWindowData . Flags | = ImGuiNextWindowDataFlags_HasSizeConstraint ;
g . NextWindowData . SizeConstraintRect = ImRect ( size_min , size_max ) ;
g . NextWindowData . SizeCallback = custom_callback ;
g . NextWindowData . SizeCallbackUserData = custom_callback_user_data ;
@ -6422,14 +6423,15 @@ void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& s
void ImGui : : SetNextWindowContentSize ( const ImVec2 & size )
{
ImGuiContext & g = * GImGui ;
g . NextWindowData . Flags | = ImGuiNextWindowDataFlags_HasContentSize ;
g . NextWindowData . ContentSizeVal = size ; // In Begin() we will add the size of window decorations (title bar, menu etc.) to that to form a SizeContents value.
g . NextWindowData . ContentSizeCond = ImGuiCond_Always ;
}
void ImGui : : SetNextWindowCollapsed ( bool collapsed , ImGuiCond cond )
{
ImGuiContext & g = * GImGui ;
IM_ASSERT ( cond = = 0 | | ImIsPowerOfTwo ( cond ) ) ; // Make sure the user doesn't attempt to combine multiple condition flags.
g . NextWindowData . Flags | = ImGuiNextWindowDataFlags_HasCollapsed ;
g . NextWindowData . CollapsedVal = collapsed ;
g . NextWindowData . CollapsedCond = cond ? cond : ImGuiCond_Always ;
}
@ -6437,14 +6439,14 @@ void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond)
void ImGui : : SetNextWindowFocus ( )
{
ImGuiContext & g = * GImGui ;
g . NextWindowData . F ocusCond = ImGuiCond_Always ; // Using a Cond member for consistency (may transition all of them to single flag set for fast Clear() op)
g . NextWindowData . F lags | = ImGuiNextWindowDataFlags_HasFocus ;
}
void ImGui : : SetNextWindowBgAlpha ( float alpha )
{
ImGuiContext & g = * GImGui ;
g . NextWindowData . Flags | = ImGuiNextWindowDataFlags_HasBgAlpha ;
g . NextWindowData . BgAlphaVal = alpha ;
g . NextWindowData . BgAlphaCond = ImGuiCond_Always ; // Using a Cond member for consistency (may transition all of them to single flag set for fast Clear() op)
}
// FIXME: This is in window space (not screen space!). We should try to obsolete all those functions.
@ -7144,7 +7146,7 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags)
ImGuiContext & g = * GImGui ;
if ( ! IsPopupOpen ( id ) )
{
g . NextWindowData . Clear ( ) ; // We behave like Begin() and need to consume those values
g . NextWindowData . Clear Flags ( ) ; // We behave like Begin() and need to consume those values
return false ;
}
@ -7166,7 +7168,7 @@ bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
ImGuiContext & g = * GImGui ;
if ( g . OpenPopupStack . Size < = g . BeginPopupStack . Size ) // Early out for performance
{
g . NextWindowData . Clear ( ) ; // We behave like Begin() and need to consume those values
g . NextWindowData . Clear Flags ( ) ; // We behave like Begin() and need to consume those values
return false ;
}
flags | = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings ;
@ -7182,13 +7184,13 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags fla
const ImGuiID id = window - > GetID ( name ) ;
if ( ! IsPopupOpen ( id ) )
{
g . NextWindowData . Clear ( ) ; // We behave like Begin() and need to consume those values
g . NextWindowData . Clear Flags ( ) ; // We behave like Begin() and need to consume those values
return false ;
}
// Center modal windows by default
// FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window.
if ( g . NextWindowData . PosCond = = 0 )
if ( ( g . NextWindowData . Flags & ImGuiNextWindowDataFlags_HasPos ) = = 0 )
SetNextWindowPos ( g . IO . DisplaySize * 0.5f , ImGuiCond_Appearing , ImVec2 ( 0.5f , 0.5f ) ) ;
flags | = ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings ;