diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 0bcc2136..10d36d08 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -56,6 +56,8 @@ Other Changes: - Scrollbar: Avoid overlapping the opposite side when window (often a child window) is forcibly too small. - Combo: Hide arrow when there's not enough space even for the square button. - TabBar: Fixed unfocused tab bar separator color (was using ImGuiCol_Tab, should use ImGuiCol_TabUnfocusedActive). +- 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. (#125, #2666) - Word-wrapping: Fixed overzealous word-wrapping when glyph edge lands exactly on the limit. Because of this, auto-fitting exactly unwrapped text would make it wrap. (fixes initial 1.15 commit, 78645a7d). - Scrolling: Added SetScrollHereX(), SetScrollFromPosX() for completeness. (#1580) [@kevreco] diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 53fab788..25057426 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -7295,8 +7295,10 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag window->DC.CurrentColumns = columns; // Set state for first column - columns->OffMinX = window->DC.Indent.x - g.Style.ItemSpacing.x; - columns->OffMaxX = ImMax(window->WorkRect.Max.x - window->Pos.x, columns->OffMinX + 1.0f); + const float column_padding = g.Style.ItemSpacing.x; + columns->OffMinX = window->DC.Indent.x - column_padding; + columns->OffMaxX = window->WorkRect.Max.x - window->Pos.x; + columns->OffMaxX = ImMax(columns->OffMaxX, columns->OffMinX + 1.0f); columns->HostCursorPosY = window->DC.CursorPos.y; columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x; columns->HostClipRect = window->ClipRect; @@ -7343,7 +7345,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag float offset_1 = GetColumnOffset(columns->Current + 1); float width = offset_1 - offset_0; PushItemWidth(width * 0.65f); - window->WorkRect.Max.x = window->Pos.x + offset_1 - window->WindowPadding.x; + window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding; } void ImGui::NextColumn() @@ -7364,17 +7366,19 @@ void ImGui::NextColumn() PopItemWidth(); PopClipRect(); + const float column_padding = g.Style.ItemSpacing.x; columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y); if (++columns->Current < columns->Count) { - // Columns 1+ cancel out IndentX + // Columns 1+ ignore IndentX (by canceling it out) // FIXME-COLUMNS: Unnecessary, could be locked? - window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + g.Style.ItemSpacing.x; + window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + column_padding; window->DrawList->ChannelsSetCurrent(columns->Current + 1); } else { // New row/line + // Column 0 honor IndentX window->DC.ColumnsOffset.x = 0.0f; window->DrawList->ChannelsSetCurrent(1); columns->Current = 0; @@ -7392,7 +7396,7 @@ void ImGui::NextColumn() float offset_1 = GetColumnOffset(columns->Current + 1); float width = offset_1 - offset_0; PushItemWidth(width * 0.65f); - window->WorkRect.Max.x = window->Pos.x + offset_1 - window->WindowPadding.x; + window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding; } void ImGui::EndColumns()