mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-29 14:56:36 +00:00
Begin: Shuffled some code, _should_ have no side-effect. Clear NextWindowData in one call and more consistently. (merged from viewport branch to minimize branch drift).
This commit is contained in:
parent
e3453d0dc4
commit
9cbca8c127
70
imgui.cpp
70
imgui.cpp
@ -5742,14 +5742,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
{
|
||||
SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond);
|
||||
}
|
||||
g.NextWindowData.PosCond = 0;
|
||||
}
|
||||
if (g.NextWindowData.SizeCond)
|
||||
{
|
||||
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);
|
||||
g.NextWindowData.SizeCond = 0;
|
||||
}
|
||||
if (g.NextWindowData.ContentSizeCond)
|
||||
{
|
||||
@ -5757,22 +5755,15 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->SizeContentsExplicit = g.NextWindowData.ContentSizeVal;
|
||||
if (window->SizeContentsExplicit.y != 0.0f)
|
||||
window->SizeContentsExplicit.y += window->TitleBarHeight() + window->MenuBarHeight();
|
||||
g.NextWindowData.ContentSizeCond = 0;
|
||||
}
|
||||
else if (first_begin_of_the_frame)
|
||||
{
|
||||
window->SizeContentsExplicit = ImVec2(0.0f, 0.0f);
|
||||
}
|
||||
if (g.NextWindowData.CollapsedCond)
|
||||
{
|
||||
SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond);
|
||||
g.NextWindowData.CollapsedCond = 0;
|
||||
}
|
||||
if (g.NextWindowData.FocusCond)
|
||||
{
|
||||
SetWindowFocus();
|
||||
g.NextWindowData.FocusCond = 0;
|
||||
}
|
||||
FocusWindow(window);
|
||||
if (window->Appearing)
|
||||
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false);
|
||||
|
||||
@ -5799,8 +5790,35 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->LastFrameActive = current_frame;
|
||||
window->IDStack.resize(1);
|
||||
|
||||
// Lock window rounding, border size and rounding so that altering the border sizes for children doesn't have side-effects.
|
||||
window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
|
||||
// UPDATE CONTENTS SIZE, UPDATE HIDDEN STATUS
|
||||
|
||||
// Update contents size from last frame for auto-fitting (or use explicit size)
|
||||
window->SizeContents = CalcSizeContents(window);
|
||||
if (window->HiddenFrames > 0)
|
||||
window->HiddenFrames--;
|
||||
|
||||
// Hide new windows for one frame until they calculate their size
|
||||
if (window_just_created && (!window_size_x_set_by_api || !window_size_y_set_by_api))
|
||||
window->HiddenFrames = 1;
|
||||
|
||||
// Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows)
|
||||
// We reset Size/SizeContents for reappearing popups/tooltips early in this function, so further code won't be tempted to use the old size.
|
||||
if (window_just_activated_by_user && (flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0)
|
||||
{
|
||||
window->HiddenFrames = 1;
|
||||
if (flags & ImGuiWindowFlags_AlwaysAutoResize)
|
||||
{
|
||||
if (!window_size_x_set_by_api)
|
||||
window->Size.x = window->SizeFull.x = 0.f;
|
||||
if (!window_size_y_set_by_api)
|
||||
window->Size.y = window->SizeFull.y = 0.f;
|
||||
window->SizeContents = ImVec2(0.f, 0.f);
|
||||
}
|
||||
}
|
||||
|
||||
SetCurrentWindow(window);
|
||||
|
||||
// Lock border size and padding for the frame (so that altering them doesn't cause inconsistencies)
|
||||
window->WindowBorderSize = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildBorderSize : ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize;
|
||||
window->WindowPadding = style.WindowPadding;
|
||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
|
||||
@ -5828,29 +5846,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
|
||||
// SIZE
|
||||
|
||||
// Update contents size from last frame for auto-fitting (unless explicitly specified)
|
||||
window->SizeContents = CalcSizeContents(window);
|
||||
|
||||
// Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows)
|
||||
if (window->HiddenFrames > 0)
|
||||
window->HiddenFrames--;
|
||||
if (window_just_activated_by_user && (flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0)
|
||||
{
|
||||
window->HiddenFrames = 1;
|
||||
if (flags & ImGuiWindowFlags_AlwaysAutoResize)
|
||||
{
|
||||
if (!window_size_x_set_by_api)
|
||||
window->Size.x = window->SizeFull.x = 0.f;
|
||||
if (!window_size_y_set_by_api)
|
||||
window->Size.y = window->SizeFull.y = 0.f;
|
||||
window->SizeContents = ImVec2(0.f, 0.f);
|
||||
}
|
||||
}
|
||||
|
||||
// Hide new windows for one frame until they calculate their size
|
||||
if (window_just_created && (!window_size_x_set_by_api || !window_size_y_set_by_api))
|
||||
window->HiddenFrames = 1;
|
||||
|
||||
// Calculate auto-fit size, handle automatic resize
|
||||
const ImVec2 size_auto_fit = CalcSizeAutoFit(window, window->SizeContents);
|
||||
ImVec2 size_full_modified(FLT_MAX, FLT_MAX);
|
||||
@ -5934,6 +5929,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
}
|
||||
window->Pos = ImFloor(window->Pos);
|
||||
|
||||
// Lock window rounding for the frame (so that altering them doesn't cause inconsistencies)
|
||||
window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
|
||||
|
||||
// Prepare for focus requests
|
||||
window->FocusIdxAllRequestCurrent = (window->FocusIdxAllRequestNext == INT_MAX || window->FocusIdxAllCounter == -1) ? INT_MAX : (window->FocusIdxAllRequestNext + (window->FocusIdxAllCounter+1)) % (window->FocusIdxAllCounter+1);
|
||||
window->FocusIdxTabRequestCurrent = (window->FocusIdxTabRequestNext == INT_MAX || window->FocusIdxTabCounter == -1) ? INT_MAX : (window->FocusIdxTabRequestNext + (window->FocusIdxTabCounter+1)) % (window->FocusIdxTabCounter+1);
|
||||
@ -6225,7 +6223,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->WriteAccessed = false;
|
||||
|
||||
window->BeginCount++;
|
||||
g.NextWindowData.SizeConstraintCond = 0;
|
||||
g.NextWindowData.Clear();
|
||||
|
||||
// Child window can be out of sight and have "negative" clip windows.
|
||||
// Mark them as collapsed so commands are skipped earlier (we can't manually collapse them because they have no title bar).
|
||||
|
Loading…
Reference in New Issue
Block a user