Skip to content

Commit 7b5fb33

Browse files
committed
Tables: Internals: renamed CellPaddingY to RowCellPaddingY.
1 parent bdc4dfe commit 7b5fb33

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

imgui_internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,7 @@ struct IMGUI_API ImGuiTable
26172617
float RowPosY1;
26182618
float RowPosY2;
26192619
float RowMinHeight; // Height submitted to TableNextRow()
2620+
float RowCellPaddingY; // Top and bottom padding. Reloaded during row change.
26202621
float RowTextBaseline;
26212622
float RowIndentOffsetX;
26222623
ImGuiTableRowFlags RowFlags : 16; // Current row flags, see ImGuiTableRowFlags_
@@ -2631,7 +2632,6 @@ struct IMGUI_API ImGuiTable
26312632
float MinColumnWidth;
26322633
float OuterPaddingX;
26332634
float CellPaddingX; // Padding from each borders. Locked in BeginTable()/Layout.
2634-
float CellPaddingY; // Top and bottom padding. Reloaded during row change.
26352635
float CellSpacingX1; // Spacing between non-bordered cells. Locked in BeginTable()/Layout.
26362636
float CellSpacingX2;
26372637
float InnerWidth; // User value passed to BeginTable(), see comments at the top of BeginTable() for details.

imgui_tables.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,6 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
452452
table->CellSpacingX1 = inner_spacing_explicit + inner_spacing_for_border;
453453
table->CellSpacingX2 = inner_spacing_explicit;
454454
table->CellPaddingX = inner_padding_explicit;
455-
table->CellPaddingY = g.Style.CellPadding.y;
456455

457456
const float outer_padding_for_border = (flags & ImGuiTableFlags_BordersOuterV) ? TABLE_BORDER_SIZE : 0.0f;
458457
const float outer_padding_explicit = pad_outer_x ? g.Style.CellPadding.x : 0.0f;
@@ -469,6 +468,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
469468

470469
table->RowPosY1 = table->RowPosY2 = table->WorkRect.Min.y; // This is needed somehow
471470
table->RowTextBaseline = 0.0f; // This will be cleared again by TableBeginRow()
471+
table->RowCellPaddingY = 0.0f;
472472
table->FreezeRowsRequest = table->FreezeRowsCount = 0; // This will be setup by TableSetupScrollFreeze(), if any
473473
table->FreezeColumnsRequest = table->FreezeColumnsCount = 0;
474474
table->IsUnfrozenRows = true;
@@ -1745,22 +1745,22 @@ void ImGui::TableNextRow(ImGuiTableRowFlags row_flags, float row_min_height)
17451745

17461746
table->LastRowFlags = table->RowFlags;
17471747
table->RowFlags = row_flags;
1748+
table->RowCellPaddingY = g.Style.CellPadding.y;
17481749
table->RowMinHeight = row_min_height;
17491750
TableBeginRow(table);
17501751

17511752
// We honor min_row_height requested by user, but cannot guarantee per-row maximum height,
17521753
// because that would essentially require a unique clipping rectangle per-cell.
1753-
table->RowPosY2 += table->CellPaddingY * 2.0f;
1754+
table->RowPosY2 += table->RowCellPaddingY * 2.0f;
17541755
table->RowPosY2 = ImMax(table->RowPosY2, table->RowPosY1 + row_min_height);
17551756

17561757
// Disable output until user calls TableNextColumn()
17571758
table->InnerWindow->SkipItems = true;
17581759
}
17591760

1760-
// [Internal] Called by TableNextRow()
1761+
// [Internal] Only called by TableNextRow()
17611762
void ImGui::TableBeginRow(ImGuiTable* table)
17621763
{
1763-
ImGuiContext& g = *GImGui;
17641764
ImGuiWindow* window = table->InnerWindow;
17651765
IM_ASSERT(!table->IsInsideRow);
17661766

@@ -1779,10 +1779,9 @@ void ImGui::TableBeginRow(ImGuiTable* table)
17791779
table->RowPosY1 = table->RowPosY2 = next_y1;
17801780
table->RowTextBaseline = 0.0f;
17811781
table->RowIndentOffsetX = window->DC.Indent.x - table->HostIndentX; // Lock indent
1782-
table->CellPaddingY = g.Style.CellPadding.y;
17831782

17841783
window->DC.PrevLineTextBaseOffset = 0.0f;
1785-
window->DC.CursorPosPrevLine = ImVec2(window->DC.CursorPos.x, window->DC.CursorPos.y + table->CellPaddingY); // This allows users to call SameLine() to share LineSize between columns.
1784+
window->DC.CursorPosPrevLine = ImVec2(window->DC.CursorPos.x, window->DC.CursorPos.y + table->RowCellPaddingY); // This allows users to call SameLine() to share LineSize between columns.
17861785
window->DC.PrevLineSize = window->DC.CurrLineSize = ImVec2(0.0f, 0.0f); // This allows users to call SameLine() to share LineSize between columns, and to call it from first column too.
17871786
window->DC.IsSameLine = window->DC.IsSetPos = false;
17881787
window->DC.CursorMaxPos.y = next_y1;
@@ -2017,7 +2016,7 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
20172016
start_x += table->RowIndentOffsetX; // ~~ += window.DC.Indent.x - table->HostIndentX, except we locked it for the row.
20182017

20192018
window->DC.CursorPos.x = start_x;
2020-
window->DC.CursorPos.y = table->RowPosY1 + table->CellPaddingY;
2019+
window->DC.CursorPos.y = table->RowPosY1 + table->RowCellPaddingY;
20212020
window->DC.CursorMaxPos.x = window->DC.CursorPos.x;
20222021
window->DC.ColumnsOffset.x = start_x - window->Pos.x - window->DC.Indent.x; // FIXME-WORKRECT
20232022
window->DC.CursorPosPrevLine.x = window->DC.CursorPos.x; // PrevLine.y is preserved. This allows users to call SameLine() to share LineSize between columns.
@@ -2075,7 +2074,7 @@ void ImGui::TableEndCell(ImGuiTable* table)
20752074
p_max_pos_x = table->IsUnfrozenRows ? &column->ContentMaxXUnfrozen : &column->ContentMaxXFrozen;
20762075
*p_max_pos_x = ImMax(*p_max_pos_x, window->DC.CursorMaxPos.x);
20772076
if (column->IsEnabled)
2078-
table->RowPosY2 = ImMax(table->RowPosY2, window->DC.CursorMaxPos.y + table->CellPaddingY);
2077+
table->RowPosY2 = ImMax(table->RowPosY2, window->DC.CursorMaxPos.y + table->RowCellPaddingY);
20792078
column->ItemWidth = window->DC.ItemWidth;
20802079

20812080
// Propagate text baseline for the entire row
@@ -2957,7 +2956,7 @@ void ImGui::TableHeader(const char* label)
29572956
// If we already got a row height, there's use that.
29582957
// FIXME-TABLE: Padding problem if the correct outer-padding CellBgRect strays off our ClipRect?
29592958
ImRect cell_r = TableGetCellBgRect(table, column_n);
2960-
float label_height = ImMax(label_size.y, table->RowMinHeight - table->CellPaddingY * 2.0f);
2959+
float label_height = ImMax(label_size.y, table->RowMinHeight - table->RowCellPaddingY * 2.0f);
29612960

29622961
// Calculate ideal size for sort order arrow
29632962
float w_arrow = 0.0f;

0 commit comments

Comments
 (0)