Skip to content

Commit a8bdbfd

Browse files
committed
Tables: Fixed top-most and left-most outer border overlapping inner clip-rect when scrolling. (#6765)
1 parent 8db02ef commit a8bdbfd

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

docs/CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Other changes:
107107
so a scrolling table can contribute to initial window size. (#6510)
108108
- Fixed subtle drawing overlap between borders in some situations.
109109
- Fixed bottom-most and right-most outer border offset by one. (#6765, #3752) [@v-ein]
110+
- Fixed top-most and left-most outer border overlapping inner clip-rect when scrolling. (#6765)
110111
- Fixed top-most outer border being drawn with both TableBorderLight and TableBorderStrong
111112
in some situations, causing the earlier to be visible underneath when alpha is not 1.0f.
112113
- Fixed right-clicking right-most section (past right-most column) from highlighting a column.

imgui_tables.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,18 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
445445
temp_data->HostBackupItemWidthStackSize = outer_window->DC.ItemWidthStack.Size;
446446
inner_window->DC.PrevLineSize = inner_window->DC.CurrLineSize = ImVec2(0.0f, 0.0f);
447447

448+
// Make left and top borders not overlap our contents by offsetting HostClipRect (#6765)
449+
// (we normally shouldn't alter HostClipRect as we rely on TableMergeDrawChannels() expanding non-clipped column toward the
450+
// limits of that rectangle, in order for ImDrawListSplitter::Merge() to merge the draw commands. However since the overlap
451+
// problem only affect scrolling tables in this case we can get away with doing it without extra cost).
452+
if (inner_window != outer_window)
453+
{
454+
if (flags & ImGuiTableFlags_BordersOuterV)
455+
table->HostClipRect.Min.x = ImMin(table->HostClipRect.Min.x + TABLE_BORDER_SIZE, table->HostClipRect.Max.x);
456+
if (flags & ImGuiTableFlags_BordersOuterH)
457+
table->HostClipRect.Min.y = ImMin(table->HostClipRect.Min.y + TABLE_BORDER_SIZE, table->HostClipRect.Max.y);
458+
}
459+
448460
// Padding and Spacing
449461
// - None ........Content..... Pad .....Content........
450462
// - PadOuter | Pad ..Content..... Pad .....Content.. Pad |
@@ -1149,7 +1161,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
11491161
table->InnerClipRect.Max.x = ImMin(table->InnerClipRect.Max.x, unused_x1);
11501162
}
11511163
table->InnerWindow->ParentWorkRect = table->WorkRect;
1152-
table->BorderX1 = table->InnerClipRect.Min.x + ((table->Flags & ImGuiTableFlags_BordersOuterV) ? 1.0f : 0.0f);
1164+
table->BorderX1 = table->InnerClipRect.Min.x;
11531165
table->BorderX2 = table->InnerClipRect.Max.x;
11541166

11551167
// Setup window's WorkRect.Max.y for GetContentRegionAvail(). Other values will be updated in each TableBeginCell() call.

0 commit comments

Comments
 (0)