Skip to content

Commit e28d20c

Browse files
committed
Columns: Fixed a regression from 1.71 where the right-side of the contents rectangle within each column would wrongly use a WindowPadding.x instead of ItemSpacing.x like it always did. (ocornut#125, ocornut#2666)
1 parent 61c7f01 commit e28d20c

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

docs/CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Other Changes:
5656
- Scrollbar: Avoid overlapping the opposite side when window (often a child window) is forcibly too small.
5757
- Combo: Hide arrow when there's not enough space even for the square button.
5858
- TabBar: Fixed unfocused tab bar separator color (was using ImGuiCol_Tab, should use ImGuiCol_TabUnfocusedActive).
59+
- Columns: Fixed a regression from 1.71 where the right-side of the contents rectangle within each column
60+
would wrongly use a WindowPadding.x instead of ItemSpacing.x like it always did. (#125, #2666)
5961
- Word-wrapping: Fixed overzealous word-wrapping when glyph edge lands exactly on the limit. Because
6062
of this, auto-fitting exactly unwrapped text would make it wrap. (fixes initial 1.15 commit, 78645a7d).
6163
- Scrolling: Added SetScrollHereX(), SetScrollFromPosX() for completeness. (#1580) [@kevreco]

imgui_widgets.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7295,8 +7295,10 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
72957295
window->DC.CurrentColumns = columns;
72967296

72977297
// Set state for first column
7298-
columns->OffMinX = window->DC.Indent.x - g.Style.ItemSpacing.x;
7299-
columns->OffMaxX = ImMax(window->WorkRect.Max.x - window->Pos.x, columns->OffMinX + 1.0f);
7298+
const float column_padding = g.Style.ItemSpacing.x;
7299+
columns->OffMinX = window->DC.Indent.x - column_padding;
7300+
columns->OffMaxX = window->WorkRect.Max.x - window->Pos.x;
7301+
columns->OffMaxX = ImMax(columns->OffMaxX, columns->OffMinX + 1.0f);
73007302
columns->HostCursorPosY = window->DC.CursorPos.y;
73017303
columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x;
73027304
columns->HostClipRect = window->ClipRect;
@@ -7343,7 +7345,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
73437345
float offset_1 = GetColumnOffset(columns->Current + 1);
73447346
float width = offset_1 - offset_0;
73457347
PushItemWidth(width * 0.65f);
7346-
window->WorkRect.Max.x = window->Pos.x + offset_1 - window->WindowPadding.x;
7348+
window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding;
73477349
}
73487350

73497351
void ImGui::NextColumn()
@@ -7364,17 +7366,19 @@ void ImGui::NextColumn()
73647366
PopItemWidth();
73657367
PopClipRect();
73667368

7369+
const float column_padding = g.Style.ItemSpacing.x;
73677370
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
73687371
if (++columns->Current < columns->Count)
73697372
{
7370-
// Columns 1+ cancel out IndentX
7373+
// Columns 1+ ignore IndentX (by canceling it out)
73717374
// FIXME-COLUMNS: Unnecessary, could be locked?
7372-
window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + g.Style.ItemSpacing.x;
7375+
window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + column_padding;
73737376
window->DrawList->ChannelsSetCurrent(columns->Current + 1);
73747377
}
73757378
else
73767379
{
73777380
// New row/line
7381+
// Column 0 honor IndentX
73787382
window->DC.ColumnsOffset.x = 0.0f;
73797383
window->DrawList->ChannelsSetCurrent(1);
73807384
columns->Current = 0;
@@ -7392,7 +7396,7 @@ void ImGui::NextColumn()
73927396
float offset_1 = GetColumnOffset(columns->Current + 1);
73937397
float width = offset_1 - offset_0;
73947398
PushItemWidth(width * 0.65f);
7395-
window->WorkRect.Max.x = window->Pos.x + offset_1 - window->WindowPadding.x;
7399+
window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding;
73967400
}
73977401

73987402
void ImGui::EndColumns()

0 commit comments

Comments
 (0)