Skip to content

Commit

Permalink
Columns: Fixed destructive small resize. (#1656). The OffsetNorm clam…
Browse files Browse the repository at this point in the history
…p introduced by #913 was ok as it didn't write back into the storage, which #1499 started doing making it destructive. Right now I don't think the clamp is needed at all. It had uses (eg: hide the issue fixed by bf7481e).
  • Loading branch information
ocornut committed Mar 4, 2018
1 parent bf7481e commit 5ed45d0
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12537,19 +12537,10 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
}
}

for (int n = 0; n < columns_count + 1; n++)
for (int n = 0; n < columns_count; n++)
{
// Clamp position
ImGuiColumnData* column = &columns->Columns[n];
float t = column->OffsetNorm;
if (!(columns->Flags & ImGuiColumnsFlags_NoForceWithinWindow))
t = ImMin(t, PixelsToOffsetNorm(columns, (columns->MaxX - columns->MinX) - g.Style.ColumnsMinSpacing * (columns->Count - n)));
column->OffsetNorm = t;

if (n == columns_count)
continue;

// Compute clipping rectangle
ImGuiColumnData* column = &columns->Columns[n];
float clip_x1 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n) - 1.0f);
float clip_x2 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n + 1) - 1.0f);
column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX);
Expand Down

0 comments on commit 5ed45d0

Please sign in to comment.