Begin(): renamed locals.

This commit is contained in:
omar 2017-09-04 13:26:46 +02:00
parent a9c6a0f6ec
commit 6400f2900a

View File

@ -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);