|
|
@@ -1961,7 +1961,7 @@ bool ImGui::IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = GetCurrentWindowRead();
|
|
|
if (!bb.Overlaps(window->ClipRect))
|
|
|
- if (!id || *id != GImGui->ActiveId)
|
|
|
+ if (!id || *id != g.ActiveId)
|
|
|
if (clip_even_when_logged || !g.LogEnabled)
|
|
|
return true;
|
|
|
return false;
|
|
|
@@ -3956,7 +3956,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|
|
window_is_new = true;
|
|
|
}
|
|
|
|
|
|
- const int current_frame = ImGui::GetFrameCount();
|
|
|
+ const int current_frame = g.FrameCount;
|
|
|
const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame);
|
|
|
if (first_begin_of_the_frame)
|
|
|
window->Flags = (ImGuiWindowFlags)flags;
|
|
|
@@ -3970,25 +3970,24 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|
|
CheckStacksSize(window, true);
|
|
|
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
|
|
|
+ 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_was_active &= (window->PopupId == popup_ref.PopupId);
|
|
|
- window_was_active &= (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_was_active || 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;
|
|
|
if (g.SetNextWindowPosCond)
|
|
|
{
|
|
|
- const ImVec2 backup_cursor_pos = window->DC.CursorPos; // FIXME: not sure of the exact reason of this saving/restore anymore :( need to look into that.
|
|
|
if (window->Appearing)
|
|
|
window->SetWindowPosAllowFlags |= ImGuiCond_Appearing;
|
|
|
window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.SetNextWindowPosCond) != 0;
|
|
|
@@ -4001,7 +4000,6 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|
|
{
|
|
|
SetWindowPos(window, g.SetNextWindowPosVal, g.SetNextWindowPosCond);
|
|
|
}
|
|
|
- window->DC.CursorPos = backup_cursor_pos;
|
|
|
g.SetNextWindowPosCond = 0;
|
|
|
}
|
|
|
if (g.SetNextWindowSizeCond)
|
|
|
@@ -4046,7 +4044,6 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|
|
window->RootWindow = g.CurrentWindowStack[root_idx];
|
|
|
window->RootNonPopupWindow = g.CurrentWindowStack[root_non_popup_idx]; // Used to display TitleBgActive color and for selecting which window to use for NavWindowing
|
|
|
|
|
|
-
|
|
|
// When reusing window again multiple times a frame, just append content (don't need to setup again)
|
|
|
if (first_begin_of_the_frame)
|
|
|
{
|
|
|
@@ -4066,7 +4063,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_was_active)
|
|
|
+ if (window_just_activated_by_user)
|
|
|
{
|
|
|
// Popup first latch mouse position, will position itself when it appears next frame
|
|
|
window->AutoPosLastDirection = -1;
|
|
|
@@ -4100,7 +4097,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_was_active)
|
|
|
+ if ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0 && window_just_activated_by_user)
|
|
|
{
|
|
|
window->HiddenFrames = 1;
|
|
|
if (flags & ImGuiWindowFlags_AlwaysAutoResize)
|
|
|
@@ -4180,7 +4177,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)
|
|
|
@@ -4199,7 +4196,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);
|
|
|
@@ -4394,7 +4391,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_was_active);
|
|
|
+ window->MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user);
|
|
|
|
|
|
if (window->AutoFitFramesX > 0)
|
|
|
window->AutoFitFramesX--;
|
|
|
@@ -4402,7 +4399,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_was_active && !(flags & ImGuiWindowFlags_NoFocusOnAppearing))
|
|
|
+ if (window_just_activated_by_user && !(flags & ImGuiWindowFlags_NoFocusOnAppearing))
|
|
|
if (!(flags & (ImGuiWindowFlags_ChildWindow|ImGuiWindowFlags_Tooltip)) || (flags & ImGuiWindowFlags_Popup))
|
|
|
FocusWindow(window);
|
|
|
|