mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Tables: Comments on Sizing Policies + Rename border V/H flags HInner -> InnerH + offset every flags by two.
This commit is contained in:
parent
30e21eb280
commit
0847373b98
70
imgui.h
70
imgui.h
@ -1009,10 +1009,22 @@ enum ImGuiTabItemFlags_
|
||||
};
|
||||
|
||||
// Flags for ImGui::BeginTable()
|
||||
// - Columns can either varying resizing policy: "Fixed", "Stretch" or "AlwaysAutoResize". Toggling ScrollX needs to alter default sizing policy.
|
||||
// - Sizing policy have many subtle side effects which may be hard to fully comprehend at first.. They'll eventually make sense.
|
||||
// - with SizingPolicyFixedX (default is ScrollX is on): Columns can be enlarged as needed. Enable scrollbar if ScrollX is enabled, otherwise extend parent window's contents rect. Only Fixed columns allowed. Weighted columns will calculate their width assuming no scrolling.
|
||||
// - with SizingPolicyStretchX (default is ScrollX is off): Fit all columns within available table width (so it doesn't make sense to use ScrollX with Stretch columns!). Fixed and Weighted columns allowed.
|
||||
// - Important! Sizing policies have particularly complex and subtle side effects, more so than you would expect.
|
||||
// Read comments/demos carefully + experiment with live demos to get acquainted with them.
|
||||
// - The default sizing policy for columns depends on whether the ScrollX flag is set on the table:
|
||||
// When ScrollX is off:
|
||||
// - Table defaults to ImGuiTableFlags_SizingPolicyStretchX -> all Columns defaults to ImGuiTableColumnFlags_WidthStretch.
|
||||
// - Columns sizing policy allowed: Fixed/Auto or Stretch.
|
||||
// - Stretch Columns will share the width available in table.
|
||||
// - Fixed Columns will generally obtain their requested width unless the Table cannot fit them all.
|
||||
// When ScrollX is on:
|
||||
// - Table defaults to ImGuiTableFlags_SizingPolicyFixedX -> all Columns defaults to ImGuiTableColumnFlags_WidthFixed.
|
||||
// - Columns sizing policy allowed: Fixed/Auto mostly! Using Stretch columns OFTEN DOES NOT MAKE SENSE if ScrollX is on, UNLESS you have specified a value for 'inner_width' in BeginTable().
|
||||
// - Fixed Columns can be enlarged as needed. Table will show an horizontal scrollbar if needed.
|
||||
// - Stretch Columns, if any, will calculate their width using inner_width, assuming no scrolling (it really doesn't make sense to do otherwise).
|
||||
// - Mixing up columns with different sizing policy is possible BUT can be tricky and has some side-effects and restrictions.
|
||||
// (their visible order and the scrolling state have subtle but necessary effects on how they can be manually resized).
|
||||
// The typical use of mixing sizing policies is to have ScrollX disabled, one or two Stretch Column and many Fixed Columns.
|
||||
enum ImGuiTableFlags_
|
||||
{
|
||||
// Features
|
||||
@ -1025,38 +1037,38 @@ enum ImGuiTableFlags_
|
||||
ImGuiTableFlags_NoSavedSettings = 1 << 5, // Disable persisting columns order, width and sort settings in the .ini file.
|
||||
// Decoration
|
||||
ImGuiTableFlags_RowBg = 1 << 6, // Use ImGuiCol_TableRowBg and ImGuiCol_TableRowBgAlt colors behind each rows.
|
||||
ImGuiTableFlags_BordersHInner = 1 << 7, // Draw horizontal borders between rows.
|
||||
ImGuiTableFlags_BordersHOuter = 1 << 8, // Draw horizontal borders at the top and bottom.
|
||||
ImGuiTableFlags_BordersVInner = 1 << 9, // Draw vertical borders between columns.
|
||||
ImGuiTableFlags_BordersVOuter = 1 << 10, // Draw vertical borders on the left and right sides.
|
||||
ImGuiTableFlags_BordersH = ImGuiTableFlags_BordersHInner | ImGuiTableFlags_BordersHOuter, // Draw horizontal borders.
|
||||
ImGuiTableFlags_BordersV = ImGuiTableFlags_BordersVInner | ImGuiTableFlags_BordersVOuter, // Draw vertical borders.
|
||||
ImGuiTableFlags_BordersInner = ImGuiTableFlags_BordersVInner | ImGuiTableFlags_BordersHInner, // Draw inner borders.
|
||||
ImGuiTableFlags_BordersOuter = ImGuiTableFlags_BordersVOuter | ImGuiTableFlags_BordersHOuter, // Draw outer borders.
|
||||
ImGuiTableFlags_BordersInnerH = 1 << 7, // Draw horizontal borders between rows.
|
||||
ImGuiTableFlags_BordersOuterH = 1 << 8, // Draw horizontal borders at the top and bottom.
|
||||
ImGuiTableFlags_BordersInnerV = 1 << 9, // Draw vertical borders between columns.
|
||||
ImGuiTableFlags_BordersOuterV = 1 << 10, // Draw vertical borders on the left and right sides.
|
||||
ImGuiTableFlags_BordersH = ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_BordersOuterH, // Draw horizontal borders.
|
||||
ImGuiTableFlags_BordersV = ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_BordersOuterV, // Draw vertical borders.
|
||||
ImGuiTableFlags_BordersInner = ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_BordersInnerH, // Draw inner borders.
|
||||
ImGuiTableFlags_BordersOuter = ImGuiTableFlags_BordersOuterV | ImGuiTableFlags_BordersOuterH, // Draw outer borders.
|
||||
ImGuiTableFlags_Borders = ImGuiTableFlags_BordersInner | ImGuiTableFlags_BordersOuter, // Draw all borders.
|
||||
ImGuiTableFlags_BordersVFullHeight = 1 << 11, // Borders covers all rows even when Headers are being used. Allow resizing from any rows.
|
||||
ImGuiTableFlags_BordersFullHeightV = 1 << 11, // Borders covers all rows even when Headers are being used. Allow resizing from any rows.
|
||||
// Padding, Sizing
|
||||
ImGuiTableFlags_NoClipX = 1 << 12, // Disable pushing clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow)
|
||||
ImGuiTableFlags_SizingPolicyFixedX = 1 << 13, // Default if ScrollX is on. Columns will default to use _WidthFixed or _WidthAlwaysAutoResize policy. Read description above for more details.
|
||||
ImGuiTableFlags_SizingPolicyStretchX = 1 << 14, // Default if ScrollX is off. Columns will default to use _WidthStretch policy. Read description above for more details.
|
||||
ImGuiTableFlags_NoHeadersWidth = 1 << 15, // Disable header width contribution to automatic width calculation.
|
||||
ImGuiTableFlags_NoHostExtendY = 1 << 16, // (FIXME-TABLE: Reword as SizingPolicy?) Disable extending past the limit set by outer_size.y, only meaningful when neither of ScrollX|ScrollY are set (data below the limit will be clipped and not visible)
|
||||
ImGuiTableFlags_NoKeepColumnsVisible = 1 << 17, // (FIXME-TABLE) Disable code that keeps column always minimally visible when table width gets too small and horizontal scrolling is off.
|
||||
ImGuiTableFlags_NoClipX = 1 << 14, // Disable pushing clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow)
|
||||
ImGuiTableFlags_SizingPolicyFixedX = 1 << 15, // Default if ScrollX is on. Columns will default to use _WidthFixed or _WidthAlwaysAutoResize policy. Read description above for more details.
|
||||
ImGuiTableFlags_SizingPolicyStretchX = 1 << 16, // Default if ScrollX is off. Columns will default to use _WidthStretch policy. Read description above for more details.
|
||||
ImGuiTableFlags_NoHeadersWidth = 1 << 17, // Disable header width contribution to automatic width calculation.
|
||||
ImGuiTableFlags_NoHostExtendY = 1 << 18, // (FIXME-TABLE: Reword as SizingPolicy?) Disable extending past the limit set by outer_size.y, only meaningful when neither of ScrollX|ScrollY are set (data below the limit will be clipped and not visible)
|
||||
ImGuiTableFlags_NoKeepColumnsVisible = 1 << 19, // (FIXME-TABLE) Disable code that keeps column always minimally visible when table width gets too small and horizontal scrolling is off.
|
||||
// Scrolling
|
||||
ImGuiTableFlags_ScrollX = 1 << 18, // Enable horizontal scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. Because this create a child window, ScrollY is currently generally recommended when using ScrollX.
|
||||
ImGuiTableFlags_ScrollY = 1 << 19, // Enable vertical scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size.
|
||||
ImGuiTableFlags_ScrollX = 1 << 20, // Enable horizontal scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. Because this create a child window, ScrollY is currently generally recommended when using ScrollX.
|
||||
ImGuiTableFlags_ScrollY = 1 << 21, // Enable vertical scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size.
|
||||
ImGuiTableFlags_Scroll = ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY,
|
||||
ImGuiTableFlags_ScrollFreezeTopRow = 1 << 20, // We can lock 1 to 3 rows (starting from the top). Use with ScrollY enabled.
|
||||
ImGuiTableFlags_ScrollFreeze2Rows = 2 << 20,
|
||||
ImGuiTableFlags_ScrollFreeze3Rows = 3 << 20,
|
||||
ImGuiTableFlags_ScrollFreezeLeftColumn = 1 << 22, // We can lock 1 to 3 columns (starting from the left). Use with ScrollX enabled.
|
||||
ImGuiTableFlags_ScrollFreeze2Columns = 2 << 22,
|
||||
ImGuiTableFlags_ScrollFreeze3Columns = 3 << 22,
|
||||
ImGuiTableFlags_ScrollFreezeTopRow = 1 << 22, // We can lock 1 to 3 rows (starting from the top). Use with ScrollY enabled.
|
||||
ImGuiTableFlags_ScrollFreeze2Rows = 2 << 22,
|
||||
ImGuiTableFlags_ScrollFreeze3Rows = 3 << 22,
|
||||
ImGuiTableFlags_ScrollFreezeLeftColumn = 1 << 24, // We can lock 1 to 3 columns (starting from the left). Use with ScrollX enabled.
|
||||
ImGuiTableFlags_ScrollFreeze2Columns = 2 << 24,
|
||||
ImGuiTableFlags_ScrollFreeze3Columns = 3 << 24,
|
||||
|
||||
// [Internal] Combinations and masks
|
||||
ImGuiTableFlags_SizingPolicyMaskX_ = ImGuiTableFlags_SizingPolicyStretchX | ImGuiTableFlags_SizingPolicyFixedX,
|
||||
ImGuiTableFlags_ScrollFreezeRowsShift_ = 20,
|
||||
ImGuiTableFlags_ScrollFreezeColumnsShift_ = 22,
|
||||
ImGuiTableFlags_ScrollFreezeRowsShift_ = 22,
|
||||
ImGuiTableFlags_ScrollFreezeColumnsShift_ = 24,
|
||||
ImGuiTableFlags_ScrollFreezeRowsMask_ = 0x03 << ImGuiTableFlags_ScrollFreezeRowsShift_,
|
||||
ImGuiTableFlags_ScrollFreezeColumnsMask_ = 0x03 << ImGuiTableFlags_ScrollFreezeColumnsShift_
|
||||
};
|
||||
|
@ -3388,19 +3388,19 @@ static void ShowDemoWindowTables()
|
||||
static bool display_width = false;
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", (unsigned int*)&flags, ImGuiTableFlags_RowBg);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_Borders", (unsigned int*)&flags, ImGuiTableFlags_Borders);
|
||||
ImGui::SameLine(); HelpMarker("ImGuiTableFlags_Borders\n = ImGuiTableFlags_BordersVInner\n | ImGuiTableFlags_BordersVOuter\n | ImGuiTableFlags_BordersHInner\n | ImGuiTableFlags_BordersHOuter");
|
||||
ImGui::SameLine(); HelpMarker("ImGuiTableFlags_Borders\n = ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterV\n | ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterH");
|
||||
ImGui::Indent();
|
||||
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", (unsigned int*)&flags, ImGuiTableFlags_BordersH);
|
||||
ImGui::Indent();
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersHOuter", (unsigned int*)&flags, ImGuiTableFlags_BordersHOuter);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersHInner", (unsigned int*)&flags, ImGuiTableFlags_BordersHInner);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", (unsigned int*)&flags, ImGuiTableFlags_BordersOuterH);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", (unsigned int*)&flags, ImGuiTableFlags_BordersInnerH);
|
||||
ImGui::Unindent();
|
||||
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", (unsigned int*)&flags, ImGuiTableFlags_BordersV);
|
||||
ImGui::Indent();
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersVOuter", (unsigned int*)&flags, ImGuiTableFlags_BordersVOuter);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersVInner", (unsigned int*)&flags, ImGuiTableFlags_BordersVInner);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", (unsigned int*)&flags, ImGuiTableFlags_BordersOuterV);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", (unsigned int*)&flags, ImGuiTableFlags_BordersInnerV);
|
||||
ImGui::Unindent();
|
||||
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuter", (unsigned int*)&flags, ImGuiTableFlags_BordersOuter);
|
||||
@ -3476,7 +3476,7 @@ static void ShowDemoWindowTables()
|
||||
if (ImGui::TreeNode("Resizable, fixed"))
|
||||
{
|
||||
// Here we use ImGuiTableFlags_SizingPolicyFixedX (even though _ScrollX is not set)
|
||||
// So columns will adopt the "Fixed" policy and will maintain a fixed weight regardless of the whole available width.
|
||||
// So columns will adopt the "Fixed" policy and will maintain a fixed width regardless of the whole available width (unless table is small)
|
||||
// If there is not enough available width to fit all columns, they will however be resized down.
|
||||
// FIXME-TABLE: Providing a stretch-on-init would make sense especially for tables which don't have saved settings
|
||||
HelpMarker("Using _Resizable + _SizingPolicyFixedX flags.\nFixed-width columns generally makes more sense if you want to use horizontal scrolling.");
|
||||
@ -3767,7 +3767,7 @@ static void ShowDemoWindowTables()
|
||||
{
|
||||
HelpMarker("This demonstrate embedding a table into another table cell.");
|
||||
|
||||
if (ImGui::BeginTable("recurse1", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_BordersVFullHeight | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable))
|
||||
if (ImGui::BeginTable("recurse1", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_BordersFullHeightV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable))
|
||||
{
|
||||
ImGui::TableSetupColumn("A0");
|
||||
ImGui::TableSetupColumn("A1");
|
||||
@ -3776,7 +3776,7 @@ static void ShowDemoWindowTables()
|
||||
ImGui::TableNextRow(); ImGui::Text("A0 Cell 0");
|
||||
{
|
||||
float rows_height = ImGui::GetTextLineHeightWithSpacing() * 2;
|
||||
if (ImGui::BeginTable("recurse2", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_BordersVFullHeight | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable))
|
||||
if (ImGui::BeginTable("recurse2", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_BordersFullHeightV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable))
|
||||
{
|
||||
ImGui::TableSetupColumn("B0");
|
||||
ImGui::TableSetupColumn("B1");
|
||||
@ -3813,10 +3813,10 @@ static void ShowDemoWindowTables()
|
||||
ImGui::Combo("Contents", &contents_type, "Short Text\0Long Text\0Button\0Fill Button\0InputText\0");
|
||||
|
||||
static ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg;
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersHInner", (unsigned int*)&flags, ImGuiTableFlags_BordersHInner);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersHOuter", (unsigned int*)&flags, ImGuiTableFlags_BordersHOuter);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersVInner", (unsigned int*)&flags, ImGuiTableFlags_BordersVInner);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersVOuter", (unsigned int*)&flags, ImGuiTableFlags_BordersVOuter);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", (unsigned int*)&flags, ImGuiTableFlags_BordersInnerH);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", (unsigned int*)&flags, ImGuiTableFlags_BordersOuterH);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", (unsigned int*)&flags, ImGuiTableFlags_BordersInnerV);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", (unsigned int*)&flags, ImGuiTableFlags_BordersOuterV);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", (unsigned int*)&flags, ImGuiTableFlags_ScrollX);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", (unsigned int*)&flags, ImGuiTableFlags_ScrollY);
|
||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretchX", (unsigned int*)&flags, ImGuiTableFlags_SizingPolicyStretchX))
|
||||
@ -3922,7 +3922,7 @@ static void ShowDemoWindowTables()
|
||||
ImGui::SetNextItemOpen(open_action != 0);
|
||||
if (ImGui::TreeNode("Tree view"))
|
||||
{
|
||||
static ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersHOuter | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg;
|
||||
static ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg;
|
||||
//ImGui::CheckboxFlags("ImGuiTableFlags_Scroll", (unsigned int*)&flags, ImGuiTableFlags_Scroll);
|
||||
//ImGui::CheckboxFlags("ImGuiTableFlags_ScrollFreezeLeftColumn", (unsigned int*)&flags, ImGuiTableFlags_ScrollFreezeLeftColumn);
|
||||
|
||||
@ -4230,12 +4230,12 @@ static void ShowDemoWindowTables()
|
||||
ImGui::Indent();
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", (unsigned int*)&flags, ImGuiTableFlags_RowBg);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", (unsigned int*)&flags, ImGuiTableFlags_BordersV);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersVOuter", (unsigned int*)&flags, ImGuiTableFlags_BordersVOuter);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersVInner", (unsigned int*)&flags, ImGuiTableFlags_BordersVInner);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", (unsigned int*)&flags, ImGuiTableFlags_BordersOuterV);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", (unsigned int*)&flags, ImGuiTableFlags_BordersInnerV);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", (unsigned int*)&flags, ImGuiTableFlags_BordersH);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersHOuter", (unsigned int*)&flags, ImGuiTableFlags_BordersHOuter);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersHInner", (unsigned int*)&flags, ImGuiTableFlags_BordersHInner);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersVFullHeight", (unsigned int*)&flags, ImGuiTableFlags_BordersVFullHeight);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", (unsigned int*)&flags, ImGuiTableFlags_BordersOuterH);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", (unsigned int*)&flags, ImGuiTableFlags_BordersInnerH);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersFullHeightV", (unsigned int*)&flags, ImGuiTableFlags_BordersFullHeightV);
|
||||
ImGui::Unindent();
|
||||
|
||||
ImGui::BulletText("Padding, Sizing:");
|
||||
|
@ -2056,7 +2056,7 @@ struct ImGuiTableColumnSettings
|
||||
ImS8 SortOrder;
|
||||
ImU8 SortDirection : 2;
|
||||
ImU8 IsVisible : 1;
|
||||
ImU8 IsWeighted : 1;
|
||||
ImU8 IsStretch : 1;
|
||||
|
||||
ImGuiTableColumnSettings()
|
||||
{
|
||||
@ -2066,7 +2066,7 @@ struct ImGuiTableColumnSettings
|
||||
DisplayOrder = SortOrder = -1;
|
||||
SortDirection = ImGuiSortDirection_None;
|
||||
IsVisible = 1;
|
||||
IsWeighted = 0;
|
||||
IsStretch = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -67,7 +67,7 @@
|
||||
// | BeginChild() - (if ScrollX/ScrollY is set)
|
||||
// | TableBeginUpdateColumns() - apply resize/order requests, lock columns active state, order
|
||||
// | - TableSetColumnWidth() - apply resizing width (for mouse resize, often requested by previous frame)
|
||||
// | - TableUpdateColumnsWeightFromWidth()- recompute columns weights (of weighted columns) from their respective width
|
||||
// | - TableUpdateColumnsWeightFromWidth()- recompute columns weights (of stretch columns) from their respective width
|
||||
// - TableSetupColumn() user submit columns details (optional)
|
||||
// - TableAutoHeaders() or TableHeader() user submit a headers row (optional)
|
||||
// | TableSortSpecsClickColumn() - when left-clicked: alter sort order and sort direction
|
||||
@ -109,7 +109,7 @@ inline ImGuiTableFlags TableFixFlags(ImGuiTableFlags flags)
|
||||
|
||||
// Adjust flags: enforce borders when resizable
|
||||
if (flags & ImGuiTableFlags_Resizable)
|
||||
flags |= ImGuiTableFlags_BordersVInner;
|
||||
flags |= ImGuiTableFlags_BordersInnerV;
|
||||
|
||||
// Adjust flags: disable top rows freezing if there's no scrolling.
|
||||
// We could want to assert if ScrollFreeze was set without the corresponding scroll flag, but that would hinder demos.
|
||||
@ -258,11 +258,11 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
||||
|
||||
// Borders
|
||||
// - None ........Content..... Pad .....Content........
|
||||
// - VOuter | Pad ..Content..... Pad .....Content.. Pad | // FIXME-TABLE: Not handled properly
|
||||
// - VInner ........Content.. Pad | Pad ..Content........ // FIXME-TABLE: Not handled properly
|
||||
// - VOuter+VInner | Pad ..Content.. Pad | Pad ..Content.. Pad |
|
||||
// - OuterV | Pad ..Content..... Pad .....Content.. Pad | // FIXME-TABLE: Not handled properly
|
||||
// - InnerV ........Content.. Pad | Pad ..Content........ // FIXME-TABLE: Not handled properly
|
||||
// - OuterV+InnerV | Pad ..Content.. Pad | Pad ..Content.. Pad |
|
||||
|
||||
const bool has_cell_padding_x = (flags & ImGuiTableFlags_BordersVOuter) != 0;
|
||||
const bool has_cell_padding_x = (flags & ImGuiTableFlags_BordersOuterV) != 0;
|
||||
table->CellPaddingX1 = has_cell_padding_x ? g.Style.CellPadding.x + 1.0f : 0.0f;
|
||||
table->CellPaddingX2 = has_cell_padding_x ? g.Style.CellPadding.x : 0.0f;
|
||||
table->CellPaddingY = g.Style.CellPadding.y;
|
||||
@ -513,7 +513,7 @@ void ImGui::TableUpdateDrawChannels(ImGuiTable* table)
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust flags: default width mode + weighted columns are not allowed when auto extending
|
||||
// Adjust flags: default width mode + stretch columns are not allowed when auto extending
|
||||
static ImGuiTableColumnFlags TableFixColumnFlags(ImGuiTable* table, ImGuiTableColumnFlags flags)
|
||||
{
|
||||
// Sizing Policy
|
||||
@ -684,7 +684,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
column->WidthRequest = IM_FLOOR(ImMax(width_avail_for_stretched_columns * weight_ratio, min_column_width) + 0.01f);
|
||||
width_remaining_for_stretched_columns -= column->WidthRequest;
|
||||
|
||||
// [Resize Rule 2] Resizing from right-side of a weighted column preceding a fixed column
|
||||
// [Resize Rule 2] Resizing from right-side of a stretch column preceding a fixed column
|
||||
// needs to forward resizing to left-side of fixed column. We also need to copy the NoResize flag..
|
||||
if (column->NextVisibleColumn != -1)
|
||||
if (ImGuiTableColumn* next_column = &table->Columns[column->NextVisibleColumn])
|
||||
@ -918,7 +918,7 @@ void ImGui::TableUpdateBorders(ImGuiTable* table)
|
||||
// use the final height from last frame. Because this is only affecting _interaction_ with columns, it is not
|
||||
// really problematic (whereas the actual visual will be displayed in EndTable() and using the current frame height).
|
||||
// Actual columns highlight/render will be performed in EndTable() and not be affected.
|
||||
const bool borders_full_height = (table->IsUsingHeaders == false) || (table->Flags & ImGuiTableFlags_BordersVFullHeight);
|
||||
const bool borders_full_height = (table->IsUsingHeaders == false) || (table->Flags & ImGuiTableFlags_BordersFullHeightV);
|
||||
const float hit_half_width = TABLE_RESIZE_SEPARATOR_HALF_THICKNESS;
|
||||
const float hit_y1 = table->OuterRect.Min.y;
|
||||
const float hit_y2_full = ImMax(table->OuterRect.Max.y, hit_y1 + table->LastOuterHeight);
|
||||
@ -943,7 +943,7 @@ void ImGui::TableUpdateBorders(ImGuiTable* table)
|
||||
bool pressed = ButtonBehavior(hit_rect, column_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnDoubleClick);
|
||||
if (pressed && IsMouseDoubleClicked(0) && !(column->Flags & ImGuiTableColumnFlags_WidthStretch))
|
||||
{
|
||||
// FIXME-TABLE: Double-clicking on column edge could auto-fit weighted column?
|
||||
// FIXME-TABLE: Double-clicking on column edge could auto-fit Stretch column?
|
||||
TableSetColumnAutofit(table, column_n);
|
||||
ClearActiveID();
|
||||
held = hovered = false;
|
||||
@ -1121,7 +1121,7 @@ void ImGui::TableDrawBorders(ImGuiTable* table)
|
||||
float draw_y2_base = (table->FreezeRowsCount >= 1 ? table->OuterRect.Min.y : table->WorkRect.Min.y) + table->LastFirstRowHeight;
|
||||
float draw_y2_full = table->OuterRect.Max.y;
|
||||
ImU32 border_base_col;
|
||||
if (!table->IsUsingHeaders || (table->Flags & ImGuiTableFlags_BordersVFullHeight))
|
||||
if (!table->IsUsingHeaders || (table->Flags & ImGuiTableFlags_BordersFullHeightV))
|
||||
{
|
||||
draw_y2_base = draw_y2_full;
|
||||
border_base_col = table->BorderColorLight;
|
||||
@ -1131,10 +1131,10 @@ void ImGui::TableDrawBorders(ImGuiTable* table)
|
||||
border_base_col = table->BorderColorStrong;
|
||||
}
|
||||
|
||||
if ((table->Flags & ImGuiTableFlags_BordersVOuter) && (table->InnerWindow == table->OuterWindow))
|
||||
if ((table->Flags & ImGuiTableFlags_BordersOuterV) && (table->InnerWindow == table->OuterWindow))
|
||||
inner_drawlist->AddLine(ImVec2(table->OuterRect.Min.x, draw_y1), ImVec2(table->OuterRect.Min.x, draw_y2_base), border_base_col, border_size);
|
||||
|
||||
if (table->Flags & ImGuiTableFlags_BordersVInner)
|
||||
if (table->Flags & ImGuiTableFlags_BordersInnerV)
|
||||
{
|
||||
for (int order_n = 0; order_n < table->ColumnsCount; order_n++)
|
||||
{
|
||||
@ -1182,18 +1182,18 @@ void ImGui::TableDrawBorders(ImGuiTable* table)
|
||||
{
|
||||
outer_drawlist->AddRect(outer_border.Min, outer_border.Max, outer_col, 0.0f, ~0, border_size);
|
||||
}
|
||||
else if (table->Flags & ImGuiTableFlags_BordersVOuter)
|
||||
else if (table->Flags & ImGuiTableFlags_BordersOuterV)
|
||||
{
|
||||
outer_drawlist->AddLine(outer_border.Min, ImVec2(outer_border.Min.x, outer_border.Max.y), outer_col, border_size);
|
||||
outer_drawlist->AddLine(ImVec2(outer_border.Max.x, outer_border.Min.y), outer_border.Max, outer_col, border_size);
|
||||
}
|
||||
else if (table->Flags & ImGuiTableFlags_BordersHOuter)
|
||||
else if (table->Flags & ImGuiTableFlags_BordersOuterH)
|
||||
{
|
||||
outer_drawlist->AddLine(outer_border.Min, ImVec2(outer_border.Max.x, outer_border.Min.y), outer_col, border_size);
|
||||
outer_drawlist->AddLine(ImVec2(outer_border.Min.x, outer_border.Max.y), outer_border.Max, outer_col, border_size);
|
||||
}
|
||||
}
|
||||
if ((table->Flags & ImGuiTableFlags_BordersHInner) && table->RowPosY2 < table->OuterRect.Max.y)
|
||||
if ((table->Flags & ImGuiTableFlags_BordersInnerH) && table->RowPosY2 < table->OuterRect.Max.y)
|
||||
{
|
||||
// Draw bottom-most row border
|
||||
const float border_y = table->RowPosY2;
|
||||
@ -1262,7 +1262,7 @@ void ImGui::TableSetColumnWidth(ImGuiTable* table, ImGuiTableColumn* column_0, f
|
||||
// Scenarios:
|
||||
// - F1 F2 F3 resize from F1| or F2| --> ok: alter ->WidthRequested of Fixed column. Subsequent columns will be offset.
|
||||
// - F1 F2 F3 resize from F3| --> ok: alter ->WidthRequested of Fixed column. If active, ScrollX extent can be altered.
|
||||
// - F1 F2 W3 resize from F1| or F2| --> ok: alter ->WidthRequested of Fixed column. If active, ScrollX extent can be altered, but it doesn't make much sense as the Weighted column will always be minimal size.
|
||||
// - F1 F2 W3 resize from F1| or F2| --> ok: alter ->WidthRequested of Fixed column. If active, ScrollX extent can be altered, but it doesn't make much sense as the Stretch column will always be minimal size.
|
||||
// - F1 F2 W3 resize from W3| --> ok: no-op (disabled by Resize Rule 1)
|
||||
// - W1 W2 W3 resize from W1| or W2| --> FIXME
|
||||
// - W1 W2 W3 resize from W3| --> ok: no-op (disabled by Resize Rule 1)
|
||||
@ -1669,7 +1669,7 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
||||
const float border_size = TABLE_BORDER_SIZE;
|
||||
if (table->CurrentRow != 0 || table->InnerWindow == table->OuterWindow)
|
||||
{
|
||||
if (table->Flags & ImGuiTableFlags_BordersHInner)
|
||||
if (table->Flags & ImGuiTableFlags_BordersInnerH)
|
||||
{
|
||||
//if (table->CurrentRow == 0 && table->InnerWindow == table->OuterWindow)
|
||||
// border_col = table->BorderOuterColor;
|
||||
@ -2492,7 +2492,7 @@ void ImGui::TableSaveSettings(ImGuiTable* table)
|
||||
column_settings->SortOrder = column->SortOrder;
|
||||
column_settings->SortDirection = column->SortDirection;
|
||||
column_settings->IsVisible = column->IsVisible;
|
||||
column_settings->IsWeighted = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? 1 : 0;
|
||||
column_settings->IsStretch = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? 1 : 0;
|
||||
if ((column->Flags & ImGuiTableColumnFlags_WidthStretch) == 0)
|
||||
save_ref_scale = true;
|
||||
|
||||
@ -2549,7 +2549,7 @@ void ImGui::TableLoadSettings(ImGuiTable* table)
|
||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||
if (settings->SaveFlags & ImGuiTableFlags_Resizable)
|
||||
{
|
||||
if (column_settings->IsWeighted)
|
||||
if (column_settings->IsStretch)
|
||||
column->WidthStretchWeight = column_settings->WidthOrWeight;
|
||||
else
|
||||
column->WidthRequest = column_settings->WidthOrWeight;
|
||||
@ -2626,8 +2626,8 @@ static void TableSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*,
|
||||
ImGuiTableColumnSettings* column = settings->GetColumnSettings() + column_n;
|
||||
column->Index = (ImS8)column_n;
|
||||
if (sscanf(line, "UserID=0x%08X%n", (ImU32*)&n, &r)==1) { line = ImStrSkipBlank(line + r); column->UserID = (ImGuiID)n; }
|
||||
if (sscanf(line, "Width=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->WidthOrWeight = (float)n; column->IsWeighted = 0; settings->SaveFlags |= ImGuiTableFlags_Resizable; }
|
||||
if (sscanf(line, "Weight=%f%n", &f, &r) == 1) { line = ImStrSkipBlank(line + r); column->WidthOrWeight = f; column->IsWeighted = 1; settings->SaveFlags |= ImGuiTableFlags_Resizable; }
|
||||
if (sscanf(line, "Width=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->WidthOrWeight = (float)n; column->IsStretch = 0; settings->SaveFlags |= ImGuiTableFlags_Resizable; }
|
||||
if (sscanf(line, "Weight=%f%n", &f, &r) == 1) { line = ImStrSkipBlank(line + r); column->WidthOrWeight = f; column->IsStretch = 1; settings->SaveFlags |= ImGuiTableFlags_Resizable; }
|
||||
if (sscanf(line, "Visible=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->IsVisible = (ImU8)n; settings->SaveFlags |= ImGuiTableFlags_Hideable; }
|
||||
if (sscanf(line, "Order=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->DisplayOrder = (ImS8)n; settings->SaveFlags |= ImGuiTableFlags_Reorderable; }
|
||||
if (sscanf(line, "Sort=%d%c%n", &n, &c, &r) == 2) { line = ImStrSkipBlank(line + r); column->SortOrder = (ImS8)n; column->SortDirection = (c == '^') ? ImGuiSortDirection_Descending : ImGuiSortDirection_Ascending; settings->SaveFlags |= ImGuiTableFlags_Sortable; }
|
||||
@ -2661,8 +2661,8 @@ static void TableSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandle
|
||||
// "Column 0 UserID=0x42AD2D21 Width=100 Visible=1 Order=0 Sort=0v"
|
||||
buf->appendf("Column %-2d", column_n);
|
||||
if (column->UserID != 0) buf->appendf(" UserID=%08X", column->UserID);
|
||||
if (save_size && column->IsWeighted) buf->appendf(" Weight=%.4f", column->WidthOrWeight);
|
||||
if (save_size && !column->IsWeighted) buf->appendf(" Width=%d", (int)column->WidthOrWeight);
|
||||
if (save_size && column->IsStretch) buf->appendf(" Weight=%.4f", column->WidthOrWeight);
|
||||
if (save_size && !column->IsStretch) buf->appendf(" Width=%d", (int)column->WidthOrWeight);
|
||||
if (save_visible) buf->appendf(" Visible=%d", column->IsVisible);
|
||||
if (save_order) buf->appendf(" Order=%d", column->DisplayOrder);
|
||||
if (save_sort && column->SortOrder != -1) buf->appendf(" Sort=%d%c", column->SortOrder, (column->SortDirection == ImGuiSortDirection_Ascending) ? 'v' : '^');
|
||||
|
Loading…
Reference in New Issue
Block a user