Browse Source

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)

omar 6 years ago
parent
commit
e28d20c3e2
2 changed files with 12 additions and 6 deletions
  1. 2 0
      docs/CHANGELOG.txt
  2. 10 6
      imgui_widgets.cpp

+ 2 - 0
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.
 - 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.
 - 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).
 - 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
 - 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).
   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]
 - Scrolling: Added SetScrollHereX(), SetScrollFromPosX() for completeness. (#1580) [@kevreco]

+ 10 - 6
imgui_widgets.cpp

@@ -7295,8 +7295,10 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
     window->DC.CurrentColumns = columns;
     window->DC.CurrentColumns = columns;
 
 
     // Set state for first column
     // 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->HostCursorPosY = window->DC.CursorPos.y;
     columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x;
     columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x;
     columns->HostClipRect = window->ClipRect;
     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 offset_1 = GetColumnOffset(columns->Current + 1);
     float width = offset_1 - offset_0;
     float width = offset_1 - offset_0;
     PushItemWidth(width * 0.65f);
     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()
 void ImGui::NextColumn()
@@ -7364,17 +7366,19 @@ void ImGui::NextColumn()
     PopItemWidth();
     PopItemWidth();
     PopClipRect();
     PopClipRect();
 
 
+    const float column_padding = g.Style.ItemSpacing.x;
     columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
     columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
     if (++columns->Current < columns->Count)
     if (++columns->Current < columns->Count)
     {
     {
-        // Columns 1+ cancel out IndentX
+        // Columns 1+ ignore IndentX (by canceling it out)
         // FIXME-COLUMNS: Unnecessary, could be locked?
         // 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);
         window->DrawList->ChannelsSetCurrent(columns->Current + 1);
     }
     }
     else
     else
     {
     {
         // New row/line
         // New row/line
+        // Column 0 honor IndentX
         window->DC.ColumnsOffset.x = 0.0f;
         window->DC.ColumnsOffset.x = 0.0f;
         window->DrawList->ChannelsSetCurrent(1);
         window->DrawList->ChannelsSetCurrent(1);
         columns->Current = 0;
         columns->Current = 0;
@@ -7392,7 +7396,7 @@ void ImGui::NextColumn()
     float offset_1 = GetColumnOffset(columns->Current + 1);
     float offset_1 = GetColumnOffset(columns->Current + 1);
     float width = offset_1 - offset_0;
     float width = offset_1 - offset_0;
     PushItemWidth(width * 0.65f);
     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()
 void ImGui::EndColumns()