mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Tables: Moved TableSetColumnIndex() next to TableNextCell() since they are so similar + made NextCell() crash proof.
This commit is contained in:
parent
248960d64c
commit
b1ebf964f5
@ -1850,6 +1850,8 @@ bool ImGui::TableNextCell()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiTable* table = g.CurrentTable;
|
||||
if (!table)
|
||||
return false;
|
||||
|
||||
if (table->CurrentColumn != -1 && table->CurrentColumn + 1 < table->ColumnsCount)
|
||||
{
|
||||
@ -1869,6 +1871,28 @@ bool ImGui::TableNextCell()
|
||||
return (table->VisibleUnclippedMaskByIndex & ((ImU64)1 << column_n)) != 0;
|
||||
}
|
||||
|
||||
bool ImGui::TableSetColumnIndex(int column_n)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiTable* table = g.CurrentTable;
|
||||
if (!table)
|
||||
return false;
|
||||
|
||||
if (table->CurrentColumn != column_n)
|
||||
{
|
||||
if (table->CurrentColumn != -1)
|
||||
TableEndCell(table);
|
||||
IM_ASSERT(column_n >= 0 && table->ColumnsCount);
|
||||
TableBeginCell(table, column_n);
|
||||
}
|
||||
|
||||
// FIXME-TABLE: Need to clarify if we want to allow IsItemHovered() here
|
||||
//g.CurrentWindow->DC.LastItemStatusFlags = (column_n == table->HoveredColumn) ? ImGuiItemStatusFlags_HoveredRect : ImGuiItemStatusFlags_None;
|
||||
|
||||
// FIXME-TABLE: it is likely to alter layout if user skips a columns contents based on clipping.
|
||||
return (table->VisibleUnclippedMaskByIndex & ((ImU64)1 << column_n)) != 0;
|
||||
}
|
||||
|
||||
int ImGui::TableGetColumnCount()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -1908,28 +1932,6 @@ int ImGui::TableGetColumnIndex()
|
||||
return table->CurrentColumn;
|
||||
}
|
||||
|
||||
bool ImGui::TableSetColumnIndex(int column_idx)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiTable* table = g.CurrentTable;
|
||||
if (!table)
|
||||
return false;
|
||||
|
||||
if (table->CurrentColumn != column_idx)
|
||||
{
|
||||
if (table->CurrentColumn != -1)
|
||||
TableEndCell(table);
|
||||
IM_ASSERT(column_idx >= 0 && table->ColumnsCount);
|
||||
TableBeginCell(table, column_idx);
|
||||
}
|
||||
|
||||
// FIXME-TABLE: Need to clarify if we want to allow IsItemHovered() here
|
||||
//g.CurrentWindow->DC.LastItemStatusFlags = (column_n == table->HoveredColumn) ? ImGuiItemStatusFlags_HoveredRect : ImGuiItemStatusFlags_None;
|
||||
|
||||
// FIXME-TABLE: it is likely to alter layout if user skips a columns contents based on clipping.
|
||||
return (table->VisibleUnclippedMaskByIndex & ((ImU64)1 << column_idx)) != 0;
|
||||
}
|
||||
|
||||
// Return the cell rectangle based on currently known height.
|
||||
// Important: we generally don't know our row height until the end of the row, so Max.y will be incorrect in many situations.
|
||||
// The only case where this is correct is if we provided a min_row_height to TableNextRow() and don't go below it.
|
||||
|
Loading…
Reference in New Issue
Block a user