mirror of
https://github.com/Drezil/imgui.git
synced 2025-01-11 16:26:35 +00:00
Begin(): Tidying up some code, should be a no-op.
This commit is contained in:
parent
8fbe8709f9
commit
89cae37b49
17
imgui.cpp
17
imgui.cpp
@ -3965,19 +3965,20 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|||||||
CheckStacksSize(window, true);
|
CheckStacksSize(window, true);
|
||||||
IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow));
|
IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow));
|
||||||
|
|
||||||
bool window_was_active = (window->LastFrameActive == current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on
|
// 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
|
||||||
if (flags & ImGuiWindowFlags_Popup)
|
if (flags & ImGuiWindowFlags_Popup)
|
||||||
{
|
{
|
||||||
ImGuiPopupRef& popup_ref = g.OpenPopupStack[g.CurrentPopupStack.Size];
|
ImGuiPopupRef& popup_ref = g.OpenPopupStack[g.CurrentPopupStack.Size];
|
||||||
window_was_active &= (window->PopupId == popup_ref.PopupId);
|
window_activated |= (window->PopupId != popup_ref.PopupId); // We recycle popups so treat window as activated if popup id changed
|
||||||
window_was_active &= (window == popup_ref.Window);
|
window_activated |= (window != popup_ref.Window);
|
||||||
popup_ref.Window = window;
|
popup_ref.Window = window;
|
||||||
g.CurrentPopupStack.push_back(popup_ref);
|
g.CurrentPopupStack.push_back(popup_ref);
|
||||||
window->PopupId = popup_ref.PopupId;
|
window->PopupId = popup_ref.PopupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool window_appearing_after_being_hidden = (window->HiddenFrames == 1);
|
const bool window_appearing_after_being_hidden = (window->HiddenFrames == 1);
|
||||||
window->Appearing = (!window_was_active || window_appearing_after_being_hidden);
|
window->Appearing = (window_activated || window_appearing_after_being_hidden);
|
||||||
|
|
||||||
// Process SetNextWindow***() calls
|
// Process SetNextWindow***() calls
|
||||||
bool window_pos_set_by_api = false, window_size_set_by_api = false;
|
bool window_pos_set_by_api = false, window_size_set_by_api = false;
|
||||||
@ -4061,7 +4062,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|||||||
else
|
else
|
||||||
PushClipRect(fullscreen_rect.Min, fullscreen_rect.Max, true);
|
PushClipRect(fullscreen_rect.Min, fullscreen_rect.Max, true);
|
||||||
|
|
||||||
if (!window_was_active)
|
if (window_activated)
|
||||||
{
|
{
|
||||||
// Popup first latch mouse position, will position itself when it appears next frame
|
// Popup first latch mouse position, will position itself when it appears next frame
|
||||||
window->AutoPosLastDirection = -1;
|
window->AutoPosLastDirection = -1;
|
||||||
@ -4095,7 +4096,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)
|
// Hide popup/tooltip window when first appearing while we measure size (because we recycle them)
|
||||||
if (window->HiddenFrames > 0)
|
if (window->HiddenFrames > 0)
|
||||||
window->HiddenFrames--;
|
window->HiddenFrames--;
|
||||||
if ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0 && !window_was_active)
|
if ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0 && window_activated)
|
||||||
{
|
{
|
||||||
window->HiddenFrames = 1;
|
window->HiddenFrames = 1;
|
||||||
if (flags & ImGuiWindowFlags_AlwaysAutoResize)
|
if (flags & ImGuiWindowFlags_AlwaysAutoResize)
|
||||||
@ -4389,7 +4390,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|||||||
window->DC.TreeDepth = 0;
|
window->DC.TreeDepth = 0;
|
||||||
window->DC.StateStorage = &window->StateStorage;
|
window->DC.StateStorage = &window->StateStorage;
|
||||||
window->DC.GroupStack.resize(0);
|
window->DC.GroupStack.resize(0);
|
||||||
window->MenuColumns.Update(3, style.ItemSpacing.x, !window_was_active);
|
window->MenuColumns.Update(3, style.ItemSpacing.x, window_activated);
|
||||||
|
|
||||||
if (window->AutoFitFramesX > 0)
|
if (window->AutoFitFramesX > 0)
|
||||||
window->AutoFitFramesX--;
|
window->AutoFitFramesX--;
|
||||||
@ -4397,7 +4398,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|||||||
window->AutoFitFramesY--;
|
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)
|
// 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_was_active && !(flags & ImGuiWindowFlags_NoFocusOnAppearing))
|
if (window_activated && !(flags & ImGuiWindowFlags_NoFocusOnAppearing))
|
||||||
if (!(flags & (ImGuiWindowFlags_ChildWindow|ImGuiWindowFlags_Tooltip)) || (flags & ImGuiWindowFlags_Popup))
|
if (!(flags & (ImGuiWindowFlags_ChildWindow|ImGuiWindowFlags_Tooltip)) || (flags & ImGuiWindowFlags_Popup))
|
||||||
FocusWindow(window);
|
FocusWindow(window);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user