Skip to content

Commit 10db896

Browse files
committed
Tables: store RawData in a simple void* pointer, rename ContentMinX > WorkMinX, misc tidying up.
Removed unnecessary casts when using CheckboxFlags().
1 parent 82cf41d commit 10db896

File tree

5 files changed

+160
-146
lines changed

5 files changed

+160
-146
lines changed

imgui.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10525,10 +10525,10 @@ void ImGui::ShowMetricsWindow(bool* p_open)
1052510525
else if (rect_type == TRT_BackgroundClipRect) { return table->BgClipRect; }
1052610526
else if (rect_type == TRT_ColumnsRect) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->MinX, table->InnerClipRect.Min.y, c->MaxX, table->InnerClipRect.Min.y + table->LastOuterHeight); }
1052710527
else if (rect_type == TRT_ColumnsClipRect) { ImGuiTableColumn* c = &table->Columns[n]; return c->ClipRect; }
10528-
else if (rect_type == TRT_ColumnsContentHeadersUsed){ ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->ContentMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersUsed, table->InnerClipRect.Min.y + table->LastFirstRowHeight); } // Note: y1/y2 not always accurate
10529-
else if (rect_type == TRT_ColumnsContentHeadersIdeal){ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->ContentMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersIdeal, table->InnerClipRect.Min.y + table->LastFirstRowHeight); }
10530-
else if (rect_type == TRT_ColumnsContentFrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->ContentMinX, table->InnerClipRect.Min.y, c->ContentMaxXFrozen, table->InnerClipRect.Min.y + table->LastFirstRowHeight); }
10531-
else if (rect_type == TRT_ColumnsContentUnfrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->ContentMinX, table->InnerClipRect.Min.y + table->LastFirstRowHeight, c->ContentMaxXUnfrozen, table->InnerClipRect.Max.y); }
10528+
else if (rect_type == TRT_ColumnsContentHeadersUsed){ ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersUsed, table->InnerClipRect.Min.y + table->LastFirstRowHeight); } // Note: y1/y2 not always accurate
10529+
else if (rect_type == TRT_ColumnsContentHeadersIdeal){ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersIdeal, table->InnerClipRect.Min.y + table->LastFirstRowHeight); }
10530+
else if (rect_type == TRT_ColumnsContentFrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXFrozen, table->InnerClipRect.Min.y + table->LastFirstRowHeight); }
10531+
else if (rect_type == TRT_ColumnsContentUnfrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y + table->LastFirstRowHeight, c->ContentMaxXUnfrozen, table->InnerClipRect.Max.y); }
1053210532
IM_ASSERT(0);
1053310533
return ImRect();
1053410534
}

imgui.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,8 @@ namespace ImGui
668668
// you may prefer using TableNextColumn() instead of TableNextRow() + TableSetColumnIndex().
669669
// TableNextColumn() will automatically wrap-around into the next row if needed.
670670
// - IMPORTANT: Comparatively to the old Columns() API, we need to call TableNextColumn() for the first column!
671+
// - Both TableSetColumnIndex() and TableNextColumn() return false when the column is not visible, so you can
672+
// skip submitting the contents of a cell but only if you know the contents is not going to alter row height.
671673
// - Summary of possible call flow:
672674
// ----------------------------------------------------------------------------------------------------------
673675
// TableNextRow() -> TableSetColumnIndex(0) -> Text("Hello 0") -> TableSetColumnIndex(1) -> Text("Hello 1") // OK
@@ -680,8 +682,8 @@ namespace ImGui
680682
IMGUI_API bool BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f);
681683
IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true!
682684
IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row.
683-
IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true if column is visible.
684-
IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return true if column is visible.
685+
IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return false when column is not visible.
686+
IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return false when column is not visible.
685687
IMGUI_API int TableGetColumnIndex(); // return current column index.
686688
// Tables: Headers & Columns declaration
687689
// - Use TableSetupColumn() to specify label, resizing policy, default width/weight, id, various other flags etc.

0 commit comments

Comments
 (0)