Skip to content

Commit 4abc2a8

Browse files
committed
Columns: Made the right-most edge reaches up to the clipping rectangle (removing WindowPadding.x*0.5 worth of asymmetrical/extraneous padding). (#125, #2666)
+ Moved a few things in BeginColumns().
1 parent 493795c commit 4abc2a8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

docs/CHANGELOG.txt

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ Other Changes:
5858
- TabBar: Fixed unfocused tab bar separator color (was using ImGuiCol_Tab, should use ImGuiCol_TabUnfocusedActive).
5959
- Columns: Fixed a regression from 1.71 where the right-side of the contents rectangle within each column
6060
would wrongly use a WindowPadding.x instead of ItemSpacing.x like it always did. (#125, #2666)
61+
- Columns: Made the right-most edge reaches up to the clipping rectangle (removing half of WindowPadding.x
62+
worth of asymmetrical/extraneous padding, note that there's another half that conservatively has to offset
63+
the right-most column, otherwise it's clipping width won't match the other column). (#125, #2666)
6164
- Word-wrapping: Fixed overzealous word-wrapping when glyph edge lands exactly on the limit. Because
6265
of this, auto-fitting exactly unwrapped text would make it wrap. (fixes initial 1.15 commit, 78645a7d).
6366
- Scrolling: Added SetScrollHereX(), SetScrollFromPosX() for completeness. (#1580) [@kevreco]

imgui_widgets.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -7304,13 +7304,13 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
73047304
columns->HostWorkRect = window->WorkRect;
73057305

73067306
// Set state for first column
7307+
// We aim so that the right-most column will have the same clipping width as other after being clipped by parent ClipRect
73077308
const float column_padding = g.Style.ItemSpacing.x;
7309+
const float half_clip_extend_x = ImFloor(ImMax(window->WindowPadding.x * 0.5f, window->WindowBorderSize));
73087310
columns->OffMinX = window->DC.Indent.x - column_padding;
7309-
columns->OffMaxX = window->WorkRect.Max.x - window->Pos.x;
7311+
columns->OffMaxX = window->WorkRect.Max.x + half_clip_extend_x - window->Pos.x;
73107312
columns->OffMaxX = ImMax(columns->OffMaxX, columns->OffMinX + 1.0f);
73117313
columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y;
7312-
window->DC.ColumnsOffset.x = 0.0f;
7313-
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
73147314

73157315
// Clear data if columns count changed
73167316
if (columns->Columns.Size != 0 && columns->Columns.Size != columns_count + 1)
@@ -7346,10 +7346,13 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
73467346
PushColumnClipRect(0);
73477347
}
73487348

7349+
// We don't generally store Indent.x inside ColumnsOffset because it may be manipulated by the user.
73497350
float offset_0 = GetColumnOffset(columns->Current);
73507351
float offset_1 = GetColumnOffset(columns->Current + 1);
73517352
float width = offset_1 - offset_0;
73527353
PushItemWidth(width * 0.65f);
7354+
window->DC.ColumnsOffset.x = 0.0f;
7355+
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
73537356
window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding;
73547357
}
73557358

0 commit comments

Comments
 (0)