Skip to content

Commit 91704b7

Browse files
committed
Docking: Fix IsWindowAppearing() and ImGuiCond_Appearing on docked windows. (ocornut#4177, ocornut#3982, ocornut#1497, ocornut#1061)
1 parent 1ad1429 commit 91704b7

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

docs/CHANGELOG.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ Other Changes:
108108
Normally the right way to disable compiling the demo is to set IMGUI_DISABLE_DEMO_WINDOWS, but we want to avoid
109109
implying that the file is required.
110110
- Backends: OpenGL3: Handle GL_CLIP_ORIGIN on <4.5 contexts if "GL_ARB_clip_control" extension is detected. (#4170, #3998)
111-
>>>>>>> master
111+
112+
Docking+Viewports Branch:
113+
114+
- Docking: Fix IsWindowAppearing() and ImGuiCond_Appearing on docked windows. (#4177, #3982, #1497, #1061)
112115

113116

114117
-----------------------------------------------------------------------

imgui.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6100,8 +6100,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
61006100
const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame);
61016101
window->IsFallbackWindow = (g.CurrentWindowStack.Size == 0 && g.WithinFrameScopeWithImplicitWindow);
61026102

6103-
// Update the Appearing flag
6104-
bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on
6103+
// Update the Appearing flag (note: the BeginDocked() path may also set this to true later)
6104+
bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on
61056105
if (flags & ImGuiWindowFlags_Popup)
61066106
{
61076107
ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size];
@@ -6136,6 +6136,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
61366136
{
61376137
bool has_dock_node = (window->DockId != 0 || window->DockNode != NULL);
61386138
bool new_auto_dock_node = !has_dock_node && GetWindowAlwaysWantOwnTabBar(window);
6139+
bool dock_node_was_visible = window->DockNodeIsVisible;
6140+
bool dock_tab_was_visible = window->DockTabIsVisible;
61396141
if (has_dock_node || new_auto_dock_node)
61406142
{
61416143
BeginDocked(window, p_open);
@@ -6146,6 +6148,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
61466148
// Docking currently override constraints
61476149
g.NextWindowData.Flags &= ~ImGuiNextWindowDataFlags_HasSizeConstraint;
61486150
}
6151+
6152+
// Update the Appearing flag (again)
6153+
if (window->DockTabIsVisible && !dock_tab_was_visible && dock_node_was_visible && !window->Appearing)
6154+
{
6155+
window->Appearing = true;
6156+
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true);
6157+
}
61496158
}
61506159

61516160
// Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack
@@ -12957,7 +12966,7 @@ void ImGui::DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* windo
1295712966
window->DockId = 0;
1295812967
window->Collapsed = false;
1295912968
window->DockIsActive = false;
12960-
window->DockTabIsVisible = false;
12969+
window->DockNodeIsVisible = window->DockTabIsVisible = false;
1296112970
window->Size = window->SizeFull = FixLargeWindowsWhenUndocking(window->SizeFull, window->Viewport);
1296212971

1296312972
MarkIniSettingsDirty();
@@ -15503,7 +15512,7 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
1550315512
else
1550415513
{
1550515514
window->DockIsActive = true;
15506-
window->DockTabIsVisible = false;
15515+
window->DockNodeIsVisible = window->DockTabIsVisible = false;
1550715516
}
1550815517
return;
1550915518
}
@@ -15518,7 +15527,7 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
1551815527
if (node->HostWindow == NULL)
1551915528
{
1552015529
window->DockIsActive = (node->State == ImGuiDockNodeState_HostWindowHiddenBecauseWindowsAreResizing);
15521-
window->DockTabIsVisible = false;
15530+
window->DockNodeIsVisible = window->DockTabIsVisible = false;
1552215531
if (node->Windows.Size > 1)
1552315532
DockNodeHideWindowDuringHostWindowCreation(window);
1552415533
return;
@@ -15542,6 +15551,7 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
1554215551
SetNextWindowSize(node->Size);
1554315552
g.NextWindowData.PosUndock = false; // Cancel implicit undocking of SetNextWindowPos()
1554415553
window->DockIsActive = true;
15554+
window->DockNodeIsVisible = true;
1554515555
window->DockTabIsVisible = false;
1554615556
if (node->SharedFlags & ImGuiDockNodeFlags_KeepAliveOnly)
1554715557
return;

imgui_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,7 @@ struct IMGUI_API ImGuiWindow
21012101

21022102
// Docking
21032103
bool DockIsActive :1; // When docking artifacts are actually visible. When this is set, DockNode is guaranteed to be != NULL. ~~ (DockNode != NULL) && (DockNode->Windows.Size > 1).
2104+
bool DockNodeIsVisible :1;
21042105
bool DockTabIsVisible :1; // Is our window visible this frame? ~~ is the corresponding tab selected?
21052106
bool DockTabWantClose :1;
21062107
short DockOrder; // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.

0 commit comments

Comments
 (0)