Skip to content

Commit 3e71263

Browse files
committed
Tables: more moving of code in EndTable(), should have no side-effect.
1 parent 626e3e2 commit 3e71263

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

imgui_tables.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -1178,16 +1178,14 @@ void ImGui::EndTable()
11781178
inner_window->DC.PrevLineSize = table->HostBackupPrevLineSize;
11791179
inner_window->DC.CurrLineSize = table->HostBackupCurrLineSize;
11801180
inner_window->DC.CursorMaxPos = table->HostBackupCursorMaxPos;
1181-
1181+
const float inner_content_max_y = table->RowPosY2;
1182+
IM_ASSERT(table->RowPosY2 == inner_window->DC.CursorPos.y);
11821183
if (inner_window != outer_window)
1183-
{
1184-
inner_window->DC.CursorMaxPos.y = table->RowPosY2;
1185-
}
1184+
inner_window->DC.CursorMaxPos.y = inner_content_max_y;
11861185
else if (!(flags & ImGuiTableFlags_NoHostExtendY))
1187-
{
1188-
table->OuterRect.Max.y = table->InnerRect.Max.y = ImMax(table->OuterRect.Max.y, inner_window->DC.CursorPos.y); // Patch OuterRect/InnerRect height
1189-
outer_window->DC.CursorMaxPos.y = table->RowPosY2;
1190-
}
1186+
table->OuterRect.Max.y = table->InnerRect.Max.y = ImMax(table->OuterRect.Max.y, inner_content_max_y); // Patch OuterRect/InnerRect height
1187+
table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y);
1188+
table->LastOuterHeight = table->OuterRect.GetHeight();
11911189

11921190
// Setup inner scrolling range
11931191
// FIXME: This ideally should be done earlier, in BeginTable() SetNextWindowContentSize call, just like writing to inner_window->DC.CursorMaxPos.y,
@@ -1203,9 +1201,7 @@ void ImGui::EndTable()
12031201
table->InnerWindow->DC.CursorMaxPos.x = max_pos_x;
12041202
}
12051203

1206-
table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y);
1207-
table->LastOuterHeight = table->OuterRect.GetHeight();
1208-
1204+
// Pop clipping rect
12091205
if (!(flags & ImGuiTableFlags_NoClip))
12101206
inner_window->DrawList->PopClipRect();
12111207
inner_window->ClipRect = inner_window->DrawList->_ClipRectStack.back();
@@ -1302,6 +1298,10 @@ void ImGui::EndTable()
13021298
else
13031299
outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, table->WorkRect.Min.x + outer_width); // For auto-fit
13041300

1301+
// Override declared contents height
1302+
if (inner_window == outer_window && !(flags & ImGuiTableFlags_NoHostExtendY))
1303+
outer_window->DC.CursorMaxPos.y = ImMax(outer_window->DC.CursorMaxPos.y, inner_content_max_y);
1304+
13051305
// Save settings
13061306
if (table->IsSettingsDirty)
13071307
TableSaveSettings(table);

0 commit comments

Comments
 (0)