Tables: sneakily honor ImGuiNextWindowDataFlags_HasChildFlags/ImGuiNextWindowDataFlags_HasWindowFlags as a way to facilitate various hacks/workarounds.

This commit is contained in:
ocornut
2025-02-07 22:57:15 +01:00
parent e368015d79
commit 50dbb086f2
2 changed files with 9 additions and 4 deletions
+4 -2
View File
@@ -1194,8 +1194,9 @@ enum ImGuiNextWindowDataFlags_
ImGuiNextWindowDataFlags_HasFocus = 1 << 5, ImGuiNextWindowDataFlags_HasFocus = 1 << 5,
ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6, ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6,
ImGuiNextWindowDataFlags_HasScroll = 1 << 7, ImGuiNextWindowDataFlags_HasScroll = 1 << 7,
ImGuiNextWindowDataFlags_HasChildFlags = 1 << 8, ImGuiNextWindowDataFlags_HasWindowFlags = 1 << 8,
ImGuiNextWindowDataFlags_HasRefreshPolicy = 1 << 9, ImGuiNextWindowDataFlags_HasChildFlags = 1 << 9,
ImGuiNextWindowDataFlags_HasRefreshPolicy = 1 << 10,
}; };
// Storage for SetNexWindow** functions // Storage for SetNexWindow** functions
@@ -1212,6 +1213,7 @@ struct ImGuiNextWindowData
ImVec2 SizeVal; ImVec2 SizeVal;
ImVec2 ContentSizeVal; ImVec2 ContentSizeVal;
ImVec2 ScrollVal; ImVec2 ScrollVal;
ImGuiWindowFlags WindowFlags; // Only honored by BeginTable()
ImGuiChildFlags ChildFlags; ImGuiChildFlags ChildFlags;
bool CollapsedVal; bool CollapsedVal;
ImRect SizeConstraintRect; ImRect SizeConstraintRect;
+5 -2
View File
@@ -420,8 +420,11 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
SetNextWindowScroll(ImVec2(0.0f, 0.0f)); SetNextWindowScroll(ImVec2(0.0f, 0.0f));
// Create scrolling region (without border and zero window padding) // Create scrolling region (without border and zero window padding)
ImGuiWindowFlags child_window_flags = (flags & ImGuiTableFlags_ScrollX) ? ImGuiWindowFlags_HorizontalScrollbar : ImGuiWindowFlags_None; ImGuiChildFlags child_child_flags = (g.NextWindowData.HasFlags & ImGuiNextWindowDataFlags_HasChildFlags) ? g.NextWindowData.ChildFlags : ImGuiChildFlags_None;
BeginChildEx(name, instance_id, outer_rect.GetSize(), ImGuiChildFlags_None, child_window_flags); ImGuiWindowFlags child_window_flags = (g.NextWindowData.HasFlags & ImGuiNextWindowDataFlags_HasWindowFlags) ? g.NextWindowData.WindowFlags : ImGuiWindowFlags_None;
if (flags & ImGuiTableFlags_ScrollX)
child_window_flags |= ImGuiWindowFlags_HorizontalScrollbar;
BeginChildEx(name, instance_id, outer_rect.GetSize(), child_child_flags, child_window_flags);
table->InnerWindow = g.CurrentWindow; table->InnerWindow = g.CurrentWindow;
table->WorkRect = table->InnerWindow->WorkRect; table->WorkRect = table->InnerWindow->WorkRect;
table->OuterRect = table->InnerWindow->Rect(); table->OuterRect = table->InnerWindow->Rect();