mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-30 18:34:34 +01:00
Tables: renamed somehow-duplicate ContentWidth members (implicitly == Max - Min), renamed StartX to ContentMinX for consistency.
This commit is contained in:
parent
1731ae5a09
commit
51abdd53e3
@ -10519,10 +10519,10 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
else if (rect_type == TRT_BackgroundClipRect) { return table->BackgroundClipRect; }
|
||||
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); }
|
||||
else if (rect_type == TRT_ColumnsClipRect) { ImGuiTableColumn* c = &table->Columns[n]; return c->ClipRect; }
|
||||
else if (rect_type == TRT_ColumnsContentHeadersUsed){ ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->MinX, table->InnerClipRect.Min.y, c->MinX + c->ContentWidthHeadersUsed, table->InnerClipRect.Min.y + table->LastFirstRowHeight); } // Note: y1/y2 not always accurate
|
||||
else if (rect_type == TRT_ColumnsContentHeadersIdeal){ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->MinX, table->InnerClipRect.Min.y, c->MinX + c->ContentWidthHeadersIdeal, table->InnerClipRect.Min.y + table->LastFirstRowHeight); }
|
||||
else if (rect_type == TRT_ColumnsContentFrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->MinX, table->InnerClipRect.Min.y, c->MinX + c->ContentWidthFrozen, table->InnerClipRect.Min.y + table->LastFirstRowHeight); }
|
||||
else if (rect_type == TRT_ColumnsContentUnfrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->MinX, table->InnerClipRect.Min.y + table->LastFirstRowHeight, c->MinX + c->ContentWidthUnfrozen, table->InnerClipRect.Max.y); }
|
||||
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
|
||||
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); }
|
||||
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); }
|
||||
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); }
|
||||
IM_ASSERT(0);
|
||||
return ImRect();
|
||||
}
|
||||
|
@ -1887,7 +1887,7 @@ struct ImGuiTabBar
|
||||
#define IMGUI_TABLE_MAX_COLUMNS 64 // sizeof(ImU64) * 8. This is solely because we frequently encode columns set in a ImU64.
|
||||
#define IMGUI_TABLE_MAX_DRAW_CHANNELS (2 + 64 * 2) // See TableUpdateDrawChannels()
|
||||
|
||||
// [Internal] sizeof() ~ 108
|
||||
// [Internal] sizeof() ~ 100
|
||||
// We use the terminology "Visible" to refer to a column that is not Hidden by user or settings. However it may still be out of view and clipped (see IsClipped).
|
||||
struct ImGuiTableColumn
|
||||
{
|
||||
@ -1902,15 +1902,11 @@ struct ImGuiTableColumn
|
||||
float WidthAuto; // Automatic width
|
||||
float WidthRequest; // Master width absolute value when !(Flags & _WidthStretch). When Stretch this is derived every frame from StretchWeight in TableUpdateLayout()
|
||||
float WidthGiven; // Final/actual width visible == (MaxX - MinX), locked in TableUpdateLayout(). May be > WidthRequest to honor minimum width, may be < WidthRequest to honor shrinking columns down in tight space.
|
||||
float StartX; // Start position for the frame, currently ~(MinX + CellPaddingX)
|
||||
float ContentMaxPosFrozen; // Submitted contents absolute maximum position, from which we can infer width. Kept as float because we need to manipulate those between each cell change.
|
||||
float ContentMaxPosUnfrozen;
|
||||
float ContentMaxPosHeadersUsed;
|
||||
float ContentMaxPosHeadersIdeal;
|
||||
ImS16 ContentWidthFrozen; // Contents width for frozen rows (apart from headers). Encoded as ImS16 because we actually rarely use those width.
|
||||
ImS16 ContentWidthUnfrozen;
|
||||
ImS16 ContentWidthHeadersUsed; // Contents width for headers rows (regardless of freezing). TableHeader() automatically softclip itself + report ideal desired size, to avoid creating extraneous draw calls
|
||||
ImS16 ContentWidthHeadersIdeal;
|
||||
float ContentMinX; // Start position for the frame, currently ~(MinX + CellPaddingX)
|
||||
float ContentMaxXFrozen; // Contents maximum position for frozen rows (apart from headers), from which we can infer content width.
|
||||
float ContentMaxXUnfrozen;
|
||||
float ContentMaxXHeadersUsed; // Contents maximum position for headers rows (regardless of freezing). TableHeader() automatically softclip itself + report ideal desired size, to avoid creating extraneous draw calls
|
||||
float ContentMaxXHeadersIdeal;
|
||||
ImS16 NameOffset; // Offset into parent ColumnsNames[]
|
||||
bool IsVisible; // Is the column not marked Hidden by the user? (could be clipped by scrolling, etc).
|
||||
bool IsVisibleNextFrame;
|
||||
|
@ -650,8 +650,8 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
|
||||
// Calculate "ideal" column width for nothing to be clipped.
|
||||
// Combine width from regular rows + width from headers unless requested not to.
|
||||
const float content_width_body = (float)ImMax(column->ContentWidthFrozen, column->ContentWidthUnfrozen);
|
||||
const float content_width_headers = (float)column->ContentWidthHeadersIdeal;
|
||||
const float content_width_body = (float)ImMax(column->ContentMaxXFrozen, column->ContentMaxXUnfrozen) - column->ContentMinX;
|
||||
const float content_width_headers = (float)column->ContentMaxXHeadersIdeal - column->ContentMinX;
|
||||
float width_auto = content_width_body;
|
||||
if (!(table->Flags & ImGuiTableFlags_NoHeadersWidth) && !(column->Flags & ImGuiTableColumnFlags_NoHeaderWidth))
|
||||
width_auto = ImMax(width_auto, content_width_headers);
|
||||
@ -811,8 +811,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
{
|
||||
// Hidden column: clear a few fields and we are done with it for the remainder of the function.
|
||||
// We set a zero-width clip rect but set Min.y/Max.y properly to not interfere with the clipper.
|
||||
column->MinX = column->MaxX = offset_x;
|
||||
column->StartX = offset_x;
|
||||
column->MinX = column->MaxX = column->ContentMinX = offset_x;
|
||||
column->WidthGiven = 0.0f;
|
||||
column->ClipRect.Min.x = offset_x;
|
||||
column->ClipRect.Min.y = work_rect.Min.y;
|
||||
@ -841,10 +840,10 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
if (offset_x + column->WidthGiven + table->CellPaddingX * 2.0f > max_x) // FIXME-TABLE: CHECK
|
||||
column->WidthGiven = ImMax(max_x - offset_x - table->CellPaddingX * 2.0f, min_column_width);
|
||||
|
||||
// Min, Max, Starting positions
|
||||
// Min, Max + starting positions
|
||||
column->MinX = offset_x - table->CellSpacingX1;
|
||||
column->MaxX = offset_x + column->WidthGiven + table->CellSpacingX2 + table->CellPaddingX * 2.0f;
|
||||
column->StartX = offset_x + table->CellPaddingX;
|
||||
column->ContentMinX = offset_x + table->CellPaddingX;
|
||||
|
||||
column->ClipRect.Min.x = column->MinX;
|
||||
column->ClipRect.Min.y = work_rect.Min.y;
|
||||
@ -890,8 +889,8 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
// column->StartX = ImLerp(column->StartX, ImMax(column->StartX, column->MaxX - column->ContentWidthRowsUnfrozen), 0.5f);
|
||||
|
||||
// Reset content width variables
|
||||
column->ContentMaxPosFrozen = column->ContentMaxPosUnfrozen = column->StartX;
|
||||
column->ContentMaxPosHeadersUsed = column->ContentMaxPosHeadersIdeal = column->StartX;
|
||||
column->ContentMaxXFrozen = column->ContentMaxXUnfrozen = column->ContentMinX;
|
||||
column->ContentMaxXHeadersUsed = column->ContentMaxXHeadersIdeal = column->ContentMinX;
|
||||
|
||||
// Don't decrement auto-fit counters until container window got a chance to submit its items
|
||||
if (table->HostSkipItems == false)
|
||||
@ -1083,16 +1082,8 @@ void ImGui::EndTable()
|
||||
float max_pos_x = backup_inner_max_pos_x;
|
||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||
{
|
||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||
|
||||
// Store content width (for both Headers and Rows)
|
||||
float ref_x = column->StartX;
|
||||
column->ContentWidthFrozen = (ImS16)ImMax(0.0f, column->ContentMaxPosFrozen - ref_x);
|
||||
column->ContentWidthUnfrozen = (ImS16)ImMax(0.0f, column->ContentMaxPosUnfrozen - ref_x);
|
||||
column->ContentWidthHeadersUsed = (ImS16)ImMax(0.0f, column->ContentMaxPosHeadersUsed - ref_x);
|
||||
column->ContentWidthHeadersIdeal = (ImS16)ImMax(0.0f, column->ContentMaxPosHeadersIdeal - ref_x);
|
||||
|
||||
// Add an extra 1 pixel so we can see the last column vertical line if it lies on the right-most edge.
|
||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||
if (table->VisibleMaskByIndex & ((ImU64)1 << column_n))
|
||||
max_pos_x = ImMax(max_pos_x, column->MaxX);
|
||||
}
|
||||
@ -1450,14 +1441,15 @@ void ImGui::TableReorderDrawChannelsForMerge(ImGuiTable* table)
|
||||
// (note that we assume that rendering didn't stray on the left direction. we should need a CursorMinPos to detect it)
|
||||
if (!(column->Flags & ImGuiTableColumnFlags_NoClipX))
|
||||
{
|
||||
float width_contents;
|
||||
float content_max_x;
|
||||
if (merge_group_sub_count == 1) // No row freeze (same as testing !is_frozen_v)
|
||||
width_contents = ImMax(column->ContentWidthUnfrozen, column->ContentWidthHeadersUsed);
|
||||
content_max_x = ImMax(column->ContentMaxXUnfrozen, column->ContentMaxXHeadersUsed);
|
||||
else if (merge_group_sub_n == 0) // Row freeze: use width before freeze
|
||||
width_contents = ImMax(column->ContentWidthFrozen, column->ContentWidthHeadersUsed);
|
||||
content_max_x = ImMax(column->ContentMaxXFrozen, column->ContentMaxXHeadersUsed);
|
||||
else // Row freeze: use width after freeze
|
||||
width_contents = column->ContentWidthUnfrozen;
|
||||
if (width_contents > column->WidthGiven + table->CellPaddingX * 1.0f)
|
||||
content_max_x = column->ContentMaxXUnfrozen;
|
||||
float content_width = content_max_x - column->ContentMinX;
|
||||
if (content_width > column->WidthGiven + table->CellPaddingX * 1.0f)
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1832,7 +1824,7 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
|
||||
ImGuiWindow* window = table->InnerWindow;
|
||||
|
||||
// Start position is roughly ~~ CellRect.Min + CellPadding + Indent
|
||||
float start_x = column->StartX;
|
||||
float start_x = column->ContentMinX;
|
||||
if (column->Flags & ImGuiTableColumnFlags_IndentEnable)
|
||||
start_x += table->RowIndentOffsetX; // ~~ += window.DC.Indent.x - table->HostIndentX, except we locked it for the row.
|
||||
|
||||
@ -1873,9 +1865,9 @@ void ImGui::TableEndCell(ImGuiTable* table)
|
||||
// Report maximum position so we can infer content size per column.
|
||||
float* p_max_pos_x;
|
||||
if (table->RowFlags & ImGuiTableRowFlags_Headers)
|
||||
p_max_pos_x = &column->ContentMaxPosHeadersUsed; // Useful in case user submit contents in header row that is not a TableHeader() call
|
||||
p_max_pos_x = &column->ContentMaxXHeadersUsed; // Useful in case user submit contents in header row that is not a TableHeader() call
|
||||
else
|
||||
p_max_pos_x = table->IsFreezeRowsPassed ? &column->ContentMaxPosUnfrozen : &column->ContentMaxPosFrozen;
|
||||
p_max_pos_x = table->IsFreezeRowsPassed ? &column->ContentMaxXUnfrozen : &column->ContentMaxXFrozen;
|
||||
*p_max_pos_x = ImMax(*p_max_pos_x, window->DC.CursorMaxPos.x);
|
||||
table->RowPosY2 = ImMax(table->RowPosY2, window->DC.CursorMaxPos.y + table->CellPaddingY);
|
||||
|
||||
@ -2345,8 +2337,8 @@ void ImGui::TableHeader(const char* label)
|
||||
// for merging.
|
||||
// FIXME-TABLE: Clarify policies of how label width and potential decorations (arrows) fit into auto-resize of the column
|
||||
float max_pos_x = label_pos.x + label_size.x + w_sort_text + w_arrow;
|
||||
column->ContentMaxPosHeadersUsed = ImMax(column->ContentMaxPosHeadersUsed, cell_r.Max.x);// ImMin(max_pos_x, cell_r.Max.x));
|
||||
column->ContentMaxPosHeadersIdeal = ImMax(column->ContentMaxPosHeadersIdeal, max_pos_x);
|
||||
column->ContentMaxXHeadersUsed = ImMax(column->ContentMaxXHeadersUsed, cell_r.Max.x);// ImMin(max_pos_x, cell_r.Max.x));
|
||||
column->ContentMaxXHeadersIdeal = ImMax(column->ContentMaxXHeadersIdeal, max_pos_x);
|
||||
|
||||
// We don't use BeginPopupContextItem() because we want the popup to stay up even after the column is hidden
|
||||
if (IsMouseReleased(1) && IsItemHovered())
|
||||
@ -2883,13 +2875,13 @@ void ImGui::DebugNodeTable(ImGuiTable* table)
|
||||
"Column %d order %d name '%s': +%.1f to +%.1f\n"
|
||||
"Visible: %d, Clipped: %d, DrawChannels: %d,%d\n"
|
||||
"WidthGiven: %.2f, Request/Auto: %.2f/%.2f, StretchWeight: %.3f\n"
|
||||
"ContentWidth: Frozen %d, Unfrozen %d, HeadersUsed/Ideal %d/%d\n"
|
||||
"ContentWidth: Frozen %.2f, Unfrozen %.2f, HeadersUsed/Ideal %.2f/%.2f\n"
|
||||
"SortOrder: %d, SortDir: %s\n"
|
||||
"UserID: 0x%08X, Flags: 0x%04X: %s%s%s%s..",
|
||||
n, column->DisplayOrder, name, column->MinX - table->WorkRect.Min.x, column->MaxX - table->WorkRect.Min.x,
|
||||
column->IsVisible, column->IsClipped, column->DrawChannelFrozen, column->DrawChannelUnfrozen,
|
||||
column->WidthGiven, column->WidthRequest, column->WidthAuto, column->StretchWeight,
|
||||
column->ContentWidthFrozen, column->ContentWidthUnfrozen, column->ContentWidthHeadersUsed, column->ContentWidthHeadersIdeal,
|
||||
column->ContentMaxXFrozen - column->ContentMinX, column->ContentMaxXUnfrozen - column->ContentMinX, column->ContentMaxXHeadersUsed - column->ContentMinX, column->ContentMaxXHeadersIdeal - column->ContentMinX,
|
||||
column->SortOrder, (column->SortDirection == ImGuiSortDirection_Ascending) ? "Ascending" : (column->SortDirection == ImGuiSortDirection_Descending) ? "Descending" : "None",
|
||||
column->UserID, column->Flags,
|
||||
(column->Flags & ImGuiTableColumnFlags_WidthFixed) ? "WidthFixed " : "",
|
||||
|
Loading…
Reference in New Issue
Block a user