mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 05:27:01 +00:00
Tables: (breaking) rename ImGuiTableFlags_ColumnsWidthStretch > ImGuiTableFlags_SizingPolicyStretch, ImGuiTableFlags_ColumnsWidthFixed > ImGuiTableFlags_SizingPolicyFixed in prevision for other policies.
This commit is contained in:
parent
b015ea93fd
commit
3573195112
28
imgui.h
28
imgui.h
@ -59,7 +59,7 @@ Index of this file:
|
|||||||
// Version
|
// Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||||
#define IMGUI_VERSION "1.80 WIP"
|
#define IMGUI_VERSION "1.80 WIP"
|
||||||
#define IMGUI_VERSION_NUM 17907
|
#define IMGUI_VERSION_NUM 17908
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
|
|
||||||
@ -1038,10 +1038,10 @@ enum ImGuiTabItemFlags_
|
|||||||
// - Important! Sizing policies have complex and subtle side effects, more so than you would expect.
|
// - Important! Sizing policies have complex and subtle side effects, more so than you would expect.
|
||||||
// Read comments/demos carefully + experiment with live demos to get acquainted with them.
|
// Read comments/demos carefully + experiment with live demos to get acquainted with them.
|
||||||
// - The DEFAULT policy depends on whether the _ScrollX flag is set on the table, and whether _AlwaysAutoResize flag is set on window.
|
// - The DEFAULT policy depends on whether the _ScrollX flag is set on the table, and whether _AlwaysAutoResize flag is set on window.
|
||||||
// - ImGuiTableFlags_ColumnsWidthStretch is the default if ScrollX if off.
|
// - ImGuiTableFlags_SizingPolicyStretch is the default if ScrollX if off.
|
||||||
// - ImGuiTableFlags_ColumnsWidthFixed is the default if ScrollX is on, or if host window has ImGuiWindowFlags_AlwaysAutoResize.
|
// - ImGuiTableFlags_SizingPolicyFixed is the default if ScrollX is on, or if host window has ImGuiWindowFlags_AlwaysAutoResize.
|
||||||
// - When ScrollX is off:
|
// - When ScrollX is off:
|
||||||
// - Table defaults to ImGuiTableFlags_ColumnsWidthStretch -> all Columns defaults to ImGuiTableColumnFlags_WidthStretch.
|
// - Table defaults to ImGuiTableFlags_SizingPolicyStretch -> all Columns defaults to ImGuiTableColumnFlags_WidthStretch.
|
||||||
// - Columns sizing policy allowed: Stretch (default), Fixed/Auto.
|
// - Columns sizing policy allowed: Stretch (default), Fixed/Auto.
|
||||||
// - Fixed Columns will generally obtain their requested width (unless the table cannot fit them all).
|
// - Fixed Columns will generally obtain their requested width (unless the table cannot fit them all).
|
||||||
// - Stretch Columns will share the remaining width.
|
// - Stretch Columns will share the remaining width.
|
||||||
@ -1049,7 +1049,7 @@ enum ImGuiTabItemFlags_
|
|||||||
// The typical use of mixing sizing policies is: any number of LEADING Fixed columns, followed by one or two TRAILING Stretch columns.
|
// The typical use of mixing sizing policies is: any number of LEADING Fixed columns, followed by one or two TRAILING Stretch columns.
|
||||||
// (this is because the visible order of columns have subtle but necessary effects on how they react to manual resizing).
|
// (this is because the visible order of columns have subtle but necessary effects on how they react to manual resizing).
|
||||||
// - When ScrollX is on:
|
// - When ScrollX is on:
|
||||||
// - Table defaults to ImGuiTableFlags_ColumnsWidthFixed -> all Columns defaults to ImGuiTableColumnFlags_WidthFixed or ImGuiTableColumnFlags_WidthAuto.
|
// - Table defaults to ImGuiTableFlags_SizingPolicyFixed -> all Columns defaults to ImGuiTableColumnFlags_WidthFixed or ImGuiTableColumnFlags_WidthAuto.
|
||||||
// - Columns sizing policy allowed: Fixed/Auto mostly.
|
// - Columns sizing policy allowed: Fixed/Auto mostly.
|
||||||
// - Fixed Columns can be enlarged as needed. Table will show an horizontal scrollbar if needed.
|
// - Fixed Columns can be enlarged as needed. Table will show an horizontal scrollbar if needed.
|
||||||
// - Using Stretch columns OFTEN DOES NOT MAKE SENSE if ScrollX is on, UNLESS you have specified a value for 'inner_width' in BeginTable().
|
// - Using Stretch columns OFTEN DOES NOT MAKE SENSE if ScrollX is on, UNLESS you have specified a value for 'inner_width' in BeginTable().
|
||||||
@ -1078,9 +1078,10 @@ enum ImGuiTableFlags_
|
|||||||
ImGuiTableFlags_Borders = ImGuiTableFlags_BordersInner | ImGuiTableFlags_BordersOuter, // Draw all borders.
|
ImGuiTableFlags_Borders = ImGuiTableFlags_BordersInner | ImGuiTableFlags_BordersOuter, // Draw all borders.
|
||||||
ImGuiTableFlags_NoBordersInBody = 1 << 11, // [ALPHA] Disable vertical borders in columns Body (borders will always appears in Headers). -> May move to style
|
ImGuiTableFlags_NoBordersInBody = 1 << 11, // [ALPHA] Disable vertical borders in columns Body (borders will always appears in Headers). -> May move to style
|
||||||
ImGuiTableFlags_NoBordersInBodyUntilResize = 1 << 12, // [ALPHA] Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers). -> May move to style
|
ImGuiTableFlags_NoBordersInBodyUntilResize = 1 << 12, // [ALPHA] Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers). -> May move to style
|
||||||
// Sizing
|
// Sizing Policy
|
||||||
ImGuiTableFlags_ColumnsWidthStretch = 1 << 13, // Default if ScrollX is off. Columns will default to use _WidthStretch. Read description above for more details.
|
ImGuiTableFlags_SizingPolicyFixed = 1 << 13, // [Default if ScrollX is on] Columns default to _WidthFixed (if resizable) or _WidthAuto (if not resizable), matching contents width.
|
||||||
ImGuiTableFlags_ColumnsWidthFixed = 1 << 14, // Default if ScrollX is on. Columns will default to use _WidthFixed or _WidthAuto policy (if Resizable is off). Read description above for more details.
|
ImGuiTableFlags_SizingPolicyStretch = 1 << 14, // [Default if ScrollX is off] Columns default to _WidthStretch with same weights.
|
||||||
|
// Sizing Extra Options
|
||||||
ImGuiTableFlags_SameWidths = 1 << 15, // Make all columns the same widths which is useful with Fixed columns policy (but granted by default with Stretch policy + no resize). Implicitly enable ImGuiTableFlags_NoKeepColumnsVisible and disable ImGuiTableFlags_Resizable.
|
ImGuiTableFlags_SameWidths = 1 << 15, // Make all columns the same widths which is useful with Fixed columns policy (but granted by default with Stretch policy + no resize). Implicitly enable ImGuiTableFlags_NoKeepColumnsVisible and disable ImGuiTableFlags_Resizable.
|
||||||
ImGuiTableFlags_NoHostExtendY = 1 << 16, // Disable extending table past the limit set by outer_size.y. Only meaningful when neither ScrollX nor ScrollY are set (data below the limit will be clipped and not visible)
|
ImGuiTableFlags_NoHostExtendY = 1 << 16, // Disable extending table past the limit set by outer_size.y. Only meaningful when neither ScrollX nor ScrollY are set (data below the limit will be clipped and not visible)
|
||||||
ImGuiTableFlags_NoKeepColumnsVisible = 1 << 17, // Disable keeping column always minimally visible when ScrollX is off and table gets too small. Not recommended if columns are resizable.
|
ImGuiTableFlags_NoKeepColumnsVisible = 1 << 17, // Disable keeping column always minimally visible when ScrollX is off and table gets too small. Not recommended if columns are resizable.
|
||||||
@ -1097,6 +1098,11 @@ enum ImGuiTableFlags_
|
|||||||
// Sorting
|
// Sorting
|
||||||
ImGuiTableFlags_SortMulti = 1 << 25, // Hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1).
|
ImGuiTableFlags_SortMulti = 1 << 25, // Hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1).
|
||||||
ImGuiTableFlags_SortTristate = 1 << 26 // Allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).
|
ImGuiTableFlags_SortTristate = 1 << 26 // Allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).
|
||||||
|
|
||||||
|
// Obsolete names (will be removed soon)
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
, ImGuiTableFlags_ColumnsWidthFixed = ImGuiTableFlags_SizingPolicyFixed, ImGuiTableFlags_ColumnsWidthStretch = ImGuiTableFlags_SizingPolicyStretch
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::TableSetupColumn()
|
// Flags for ImGui::TableSetupColumn()
|
||||||
@ -1106,9 +1112,9 @@ enum ImGuiTableColumnFlags_
|
|||||||
ImGuiTableColumnFlags_None = 0,
|
ImGuiTableColumnFlags_None = 0,
|
||||||
ImGuiTableColumnFlags_DefaultHide = 1 << 0, // Default as a hidden/disabled column.
|
ImGuiTableColumnFlags_DefaultHide = 1 << 0, // Default as a hidden/disabled column.
|
||||||
ImGuiTableColumnFlags_DefaultSort = 1 << 1, // Default as a sorting column.
|
ImGuiTableColumnFlags_DefaultSort = 1 << 1, // Default as a sorting column.
|
||||||
ImGuiTableColumnFlags_WidthStretch = 1 << 2, // Column will stretch. Preferable with horizontal scrolling disabled (default if table sizing policy is _ColumnsWidthStretch).
|
ImGuiTableColumnFlags_WidthStretch = 1 << 2, // Column will stretch. Preferable with horizontal scrolling disabled (default if table sizing policy is _SizingPolicyStretch).
|
||||||
ImGuiTableColumnFlags_WidthFixed = 1 << 3, // Column will not stretch. Preferable with horizontal scrolling enabled (default if table sizing policy is _ColumnsWidthFixed and table is resizable).
|
ImGuiTableColumnFlags_WidthFixed = 1 << 3, // Column will not stretch. Preferable with horizontal scrolling enabled (default if table sizing policy is _SizingPolicyFixed and table is resizable).
|
||||||
ImGuiTableColumnFlags_WidthAuto = 1 << 4, // Column will not stretch and keep resizing based on submitted contents (default if table sizing policy is _ColumnsWidthFixed and table is not resizable). Generally compatible with using right-most fitting widgets (e.g. SetNextItemWidth(-FLT_MIN))
|
ImGuiTableColumnFlags_WidthAuto = 1 << 4, // Column will not stretch and keep resizing based on submitted contents (default if table sizing policy is _SizingPolicyFixed and table is not resizable). Generally compatible with using right-most fitting widgets (e.g. SetNextItemWidth(-FLT_MIN))
|
||||||
ImGuiTableColumnFlags_NoResize = 1 << 5, // Disable manual resizing.
|
ImGuiTableColumnFlags_NoResize = 1 << 5, // Disable manual resizing.
|
||||||
ImGuiTableColumnFlags_NoReorder = 1 << 6, // Disable manual reordering this column, this will also prevent other columns from crossing over this column.
|
ImGuiTableColumnFlags_NoReorder = 1 << 6, // Disable manual reordering this column, this will also prevent other columns from crossing over this column.
|
||||||
ImGuiTableColumnFlags_NoHide = 1 << 7, // Disable ability to hide/disable this column.
|
ImGuiTableColumnFlags_NoHide = 1 << 7, // Disable ability to hide/disable this column.
|
||||||
|
@ -3585,15 +3585,15 @@ static void ShowDemoWindowTables()
|
|||||||
ImGui::SetNextItemOpen(open_action != 0);
|
ImGui::SetNextItemOpen(open_action != 0);
|
||||||
if (ImGui::TreeNode("Resizable, fixed"))
|
if (ImGui::TreeNode("Resizable, fixed"))
|
||||||
{
|
{
|
||||||
// Here we use ImGuiTableFlags_ColumnsWidthFixed (even though _ScrollX is not set)
|
// Here we use ImGuiTableFlags_SizingPolicyFixed (even though _ScrollX is not set)
|
||||||
// So columns will adopt the "Fixed" policy and will maintain a fixed width regardless of the whole available width (unless table is small)
|
// 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.
|
// 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
|
// FIXME-TABLE: Providing a stretch-on-init would make sense especially for tables which don't have saved settings
|
||||||
HelpMarker(
|
HelpMarker(
|
||||||
"Using _Resizable + _ColumnsWidthFixed flags.\n"
|
"Using _Resizable + _SizingPolicyFixed flags.\n"
|
||||||
"Fixed-width columns generally makes more sense if you want to use horizontal scrolling.\n\n"
|
"Fixed-width columns generally makes more sense if you want to use horizontal scrolling.\n\n"
|
||||||
"Double-click a column border to auto-fit the column to its contents.");
|
"Double-click a column border to auto-fit the column to its contents.");
|
||||||
static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_ColumnsWidthFixed | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody;
|
static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingPolicyFixed | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody;
|
||||||
static bool use_all_width = true;
|
static bool use_all_width = true;
|
||||||
if (ImGui::RadioButton("fit", use_all_width == false)) { use_all_width = false; }
|
if (ImGui::RadioButton("fit", use_all_width == false)) { use_all_width = false; }
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -3620,7 +3620,7 @@ static void ShowDemoWindowTables()
|
|||||||
if (ImGui::TreeNode("Resizable, mixed"))
|
if (ImGui::TreeNode("Resizable, mixed"))
|
||||||
{
|
{
|
||||||
HelpMarker("Using columns flag to alter resizing policy on a per-column basis.");
|
HelpMarker("Using columns flag to alter resizing policy on a per-column basis.");
|
||||||
static ImGuiTableFlags flags = ImGuiTableFlags_ColumnsWidthFixed | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
|
static ImGuiTableFlags flags = ImGuiTableFlags_SizingPolicyFixed | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
|
||||||
|
|
||||||
if (ImGui::BeginTable("##table1", 3, flags))
|
if (ImGui::BeginTable("##table1", 3, flags))
|
||||||
{
|
{
|
||||||
@ -3697,7 +3697,7 @@ static void ShowDemoWindowTables()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use outer_size.x == 0.0f instead of default to make the table as tight as possible (only valid when no scrolling and no stretch column)
|
// Use outer_size.x == 0.0f instead of default to make the table as tight as possible (only valid when no scrolling and no stretch column)
|
||||||
if (ImGui::BeginTable("##table2", 3, flags | ImGuiTableFlags_ColumnsWidthFixed, ImVec2(0.0f, 0.0f)))
|
if (ImGui::BeginTable("##table2", 3, flags | ImGuiTableFlags_SizingPolicyFixed, ImVec2(0.0f, 0.0f)))
|
||||||
{
|
{
|
||||||
ImGui::TableSetupColumn("One");
|
ImGui::TableSetupColumn("One");
|
||||||
ImGui::TableSetupColumn("Two");
|
ImGui::TableSetupColumn("Two");
|
||||||
@ -3837,7 +3837,7 @@ static void ShowDemoWindowTables()
|
|||||||
|
|
||||||
if (ImGui::BeginTable("##table1", 4, flags))
|
if (ImGui::BeginTable("##table1", 4, flags))
|
||||||
{
|
{
|
||||||
// We could also set ImGuiTableFlags_ColumnsWidthFixed on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
|
// We could also set ImGuiTableFlags_SizingPolicyFixed on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
|
||||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 100.0f);
|
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 100.0f);
|
||||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 15.0f);
|
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 15.0f);
|
||||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 30.0f);
|
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 30.0f);
|
||||||
@ -3905,7 +3905,7 @@ static void ShowDemoWindowTables()
|
|||||||
if (ImGui::TreeNode("Horizontal scrolling"))
|
if (ImGui::TreeNode("Horizontal scrolling"))
|
||||||
{
|
{
|
||||||
HelpMarker(
|
HelpMarker(
|
||||||
"When ScrollX is enabled, the default sizing policy becomes ImGuiTableFlags_ColumnsWidthFixed,"
|
"When ScrollX is enabled, the default sizing policy becomes ImGuiTableFlags_SizingPolicyFixed,"
|
||||||
"as automatically stretching columns doesn't make much sense with horizontal scrolling.\n\n"
|
"as automatically stretching columns doesn't make much sense with horizontal scrolling.\n\n"
|
||||||
"Also note that as of the current version, you will almost always want to enable ScrollY along with ScrollX,"
|
"Also note that as of the current version, you will almost always want to enable ScrollY along with ScrollX,"
|
||||||
"because the container window won't automatically extend vertically to fix contents (this may be improved in future versions).");
|
"because the container window won't automatically extend vertically to fix contents (this may be improved in future versions).");
|
||||||
@ -3996,7 +3996,7 @@ static void ShowDemoWindowTables()
|
|||||||
// We use a scrolling table to be able to showcase the difference between the _IsEnabled and _IsVisible flags above, otherwise in
|
// We use a scrolling table to be able to showcase the difference between the _IsEnabled and _IsVisible flags above, otherwise in
|
||||||
// a non-scrolling table columns are always visible (unless using ImGuiTableFlags_NoKeepColumnsVisible + resizing the parent window down)
|
// a non-scrolling table columns are always visible (unless using ImGuiTableFlags_NoKeepColumnsVisible + resizing the parent window down)
|
||||||
const ImGuiTableFlags flags
|
const ImGuiTableFlags flags
|
||||||
= ImGuiTableFlags_ColumnsWidthFixed | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY
|
= ImGuiTableFlags_SizingPolicyFixed | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY
|
||||||
| ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV
|
| ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV
|
||||||
| ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable;
|
| ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable;
|
||||||
ImVec2 size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 9);
|
ImVec2 size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 9);
|
||||||
@ -4095,11 +4095,11 @@ static void ShowDemoWindowTables()
|
|||||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV);
|
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV);
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX);
|
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX);
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY);
|
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY);
|
||||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthStretch", &flags, ImGuiTableFlags_ColumnsWidthStretch))
|
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretch", &flags, ImGuiTableFlags_SizingPolicyStretch))
|
||||||
flags &= ~ImGuiTableFlags_ColumnsWidthFixed; // Can't specify both sizing polices so we clear the other
|
flags &= ~ImGuiTableFlags_SizingPolicyFixed; // Can't specify both sizing polices so we clear the other
|
||||||
ImGui::SameLine(); HelpMarker("Default if _ScrollX if disabled. Makes columns use _WidthStretch policy by default.");
|
ImGui::SameLine(); HelpMarker("Default if _ScrollX if disabled. Makes columns use _WidthStretch policy by default.");
|
||||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthFixed", &flags, ImGuiTableFlags_ColumnsWidthFixed))
|
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixed", &flags, ImGuiTableFlags_SizingPolicyFixed))
|
||||||
flags &= ~ImGuiTableFlags_ColumnsWidthStretch; // Can't specify both sizing polices so we clear the other
|
flags &= ~ImGuiTableFlags_SizingPolicyStretch; // Can't specify both sizing polices so we clear the other
|
||||||
ImGui::SameLine(); HelpMarker("Default if _ScrollX if enabled. Makes columns use _WidthFixed by default, or _WidthFixedResize if _Resizable is not set.");
|
ImGui::SameLine(); HelpMarker("Default if _ScrollX if enabled. Makes columns use _WidthFixed by default, or _WidthFixedResize if _Resizable is not set.");
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths);
|
ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths);
|
||||||
ImGui::SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.");
|
ImGui::SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.");
|
||||||
@ -4177,20 +4177,20 @@ static void ShowDemoWindowTables()
|
|||||||
"Showcase using Stretch columns + ScrollX together: "
|
"Showcase using Stretch columns + ScrollX together: "
|
||||||
"this is rather unusual and only makes sense when specifying an 'inner_width' for the table!\n"
|
"this is rather unusual and only makes sense when specifying an 'inner_width' for the table!\n"
|
||||||
"Without an explicit value, inner_width is == outer_size.x and therefore using Stretch columns + ScrollX together doesn't make sense.");
|
"Without an explicit value, inner_width is == outer_size.x and therefore using Stretch columns + ScrollX together doesn't make sense.");
|
||||||
static ImGuiTableFlags flags3 = ImGuiTableFlags_ColumnsWidthStretch | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg;
|
static ImGuiTableFlags flags3 = ImGuiTableFlags_SizingPolicyStretch | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg;
|
||||||
static float inner_width = 1000.0f;
|
static float inner_width = 1000.0f;
|
||||||
PushStyleCompact();
|
PushStyleCompact();
|
||||||
ImGui::PushID("flags3");
|
ImGui::PushID("flags3");
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags3, ImGuiTableFlags_ScrollX);
|
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags3, ImGuiTableFlags_ScrollX);
|
||||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthStretch", &flags3, ImGuiTableFlags_ColumnsWidthStretch))
|
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretch", &flags3, ImGuiTableFlags_SizingPolicyStretch))
|
||||||
flags3 &= ~ImGuiTableFlags_ColumnsWidthFixed; // Can't specify both sizing polices so we clear the other
|
flags3 &= ~ImGuiTableFlags_SizingPolicyFixed; // Can't specify both sizing polices so we clear the other
|
||||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthFixed", &flags3, ImGuiTableFlags_ColumnsWidthFixed))
|
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixed", &flags3, ImGuiTableFlags_SizingPolicyFixed))
|
||||||
flags3 &= ~ImGuiTableFlags_ColumnsWidthStretch; // Can't specify both sizing polices so we clear the other
|
flags3 &= ~ImGuiTableFlags_SizingPolicyStretch; // Can't specify both sizing polices so we clear the other
|
||||||
ImGui::SetNextItemWidth(TEXT_BASE_WIDTH * 10.0f);
|
ImGui::SetNextItemWidth(TEXT_BASE_WIDTH * 10.0f);
|
||||||
ImGui::DragFloat("inner_width", &inner_width, 1.0f, 0.0f, FLT_MAX, "%.1f");
|
ImGui::DragFloat("inner_width", &inner_width, 1.0f, 0.0f, FLT_MAX, "%.1f");
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
PopStyleCompact();
|
PopStyleCompact();
|
||||||
if (ImGui::BeginTable("##table3", 7, flags3 | ImGuiTableFlags_ColumnsWidthStretch | ImGuiTableFlags_ContextMenuInBody, outer_size, inner_width))
|
if (ImGui::BeginTable("##table3", 7, flags3 | ImGuiTableFlags_SizingPolicyStretch | ImGuiTableFlags_ContextMenuInBody, outer_size, inner_width))
|
||||||
{
|
{
|
||||||
for (int cell = 0; cell < 20 * 7; cell++)
|
for (int cell = 0; cell < 20 * 7; cell++)
|
||||||
{
|
{
|
||||||
@ -4230,7 +4230,7 @@ static void ShowDemoWindowTables()
|
|||||||
// The default value of outer_size.x is -FLT_MIN which right-align tables.
|
// The default value of outer_size.x is -FLT_MIN which right-align tables.
|
||||||
// Using outer_size.x == 0.0f on a table with no scrolling and no stretch column we can make them tighter.
|
// Using outer_size.x == 0.0f on a table with no scrolling and no stretch column we can make them tighter.
|
||||||
ImGui::Text("Using auto/all width, using NoHostExtendY:");
|
ImGui::Text("Using auto/all width, using NoHostExtendY:");
|
||||||
static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_ContextMenuInBody | ImGuiTableFlags_RowBg | ImGuiTableFlags_ColumnsWidthFixed;
|
static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_ContextMenuInBody | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingPolicyFixed;
|
||||||
static bool use_all_width = false;
|
static bool use_all_width = false;
|
||||||
ImGui::Checkbox("Use all width", &use_all_width);
|
ImGui::Checkbox("Use all width", &use_all_width);
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);
|
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);
|
||||||
@ -4502,7 +4502,7 @@ static void ShowDemoWindowTables()
|
|||||||
// [2.2] Right-click on the ".." to open a custom popup
|
// [2.2] Right-click on the ".." to open a custom popup
|
||||||
// [2.3] Right-click in columns to open another custom popup
|
// [2.3] Right-click in columns to open another custom popup
|
||||||
HelpMarker("Demonstrate mixing table context menu (over header), item context button (over button) and custom per-colum context menu (over column body).");
|
HelpMarker("Demonstrate mixing table context menu (over header), item context button (over button) and custom per-colum context menu (over column body).");
|
||||||
ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_ColumnsWidthFixed | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders;
|
ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingPolicyFixed | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders;
|
||||||
if (ImGui::BeginTable("##table2", COLUMNS_COUNT, flags2))
|
if (ImGui::BeginTable("##table2", COLUMNS_COUNT, flags2))
|
||||||
{
|
{
|
||||||
ImGui::TableSetupColumn("One");
|
ImGui::TableSetupColumn("One");
|
||||||
@ -4576,7 +4576,7 @@ static void ShowDemoWindowTables()
|
|||||||
char buf[32];
|
char buf[32];
|
||||||
sprintf(buf, "Synced Table %d", n);
|
sprintf(buf, "Synced Table %d", n);
|
||||||
bool open = ImGui::CollapsingHeader(buf, ImGuiTreeNodeFlags_DefaultOpen);
|
bool open = ImGui::CollapsingHeader(buf, ImGuiTreeNodeFlags_DefaultOpen);
|
||||||
if (open && ImGui::BeginTable("Table", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_ColumnsWidthFixed | ImGuiTableFlags_NoSavedSettings))
|
if (open && ImGui::BeginTable("Table", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingPolicyFixed | ImGuiTableFlags_NoSavedSettings))
|
||||||
{
|
{
|
||||||
ImGui::TableSetupColumn("One");
|
ImGui::TableSetupColumn("One");
|
||||||
ImGui::TableSetupColumn("Two");
|
ImGui::TableSetupColumn("Two");
|
||||||
@ -4692,7 +4692,7 @@ static void ShowDemoWindowTables()
|
|||||||
| ImGuiTableFlags_Sortable | ImGuiTableFlags_SortMulti
|
| ImGuiTableFlags_Sortable | ImGuiTableFlags_SortMulti
|
||||||
| ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_NoBordersInBody
|
| ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_NoBordersInBody
|
||||||
| ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY
|
| ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY
|
||||||
| ImGuiTableFlags_ColumnsWidthFixed;
|
| ImGuiTableFlags_SizingPolicyFixed;
|
||||||
|
|
||||||
enum ContentsType { CT_Text, CT_Button, CT_SmallButton, CT_FillButton, CT_Selectable, CT_SelectableSpanRow };
|
enum ContentsType { CT_Text, CT_Button, CT_SmallButton, CT_FillButton, CT_Selectable, CT_SelectableSpanRow };
|
||||||
static int contents_type = CT_SelectableSpanRow;
|
static int contents_type = CT_SelectableSpanRow;
|
||||||
@ -4741,11 +4741,11 @@ static void ShowDemoWindowTables()
|
|||||||
|
|
||||||
if (ImGui::TreeNodeEx("Sizing:", ImGuiTreeNodeFlags_DefaultOpen))
|
if (ImGui::TreeNodeEx("Sizing:", ImGuiTreeNodeFlags_DefaultOpen))
|
||||||
{
|
{
|
||||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthStretch", &flags, ImGuiTableFlags_ColumnsWidthStretch))
|
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretch", &flags, ImGuiTableFlags_SizingPolicyStretch))
|
||||||
flags &= ~ImGuiTableFlags_ColumnsWidthFixed; // Can't specify both sizing polices so we clear the other
|
flags &= ~ImGuiTableFlags_SizingPolicyFixed; // Can't specify both sizing polices so we clear the other
|
||||||
ImGui::SameLine(); HelpMarker("[Default if ScrollX is off]\nFit all columns within available width (or specified inner_width). Fixed and Stretch columns allowed.");
|
ImGui::SameLine(); HelpMarker("[Default if ScrollX is off]\nFit all columns within available width (or specified inner_width). Fixed and Stretch columns allowed.");
|
||||||
if (ImGui::CheckboxFlags("ImGuiTableFlags_ColumnsWidthFixed", &flags, ImGuiTableFlags_ColumnsWidthFixed))
|
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixed", &flags, ImGuiTableFlags_SizingPolicyFixed))
|
||||||
flags &= ~ImGuiTableFlags_ColumnsWidthStretch; // Can't specify both sizing polices so we clear the other
|
flags &= ~ImGuiTableFlags_SizingPolicyStretch; // Can't specify both sizing polices so we clear the other
|
||||||
ImGui::SameLine(); HelpMarker("[Default if ScrollX is on]\nEnlarge as needed: enable scrollbar if ScrollX is enabled, otherwise extend parent window's contents rectangle. Only Fixed columns allowed. Stretched columns will calculate their width assuming no scrolling.");
|
ImGui::SameLine(); HelpMarker("[Default if ScrollX is on]\nEnlarge as needed: enable scrollbar if ScrollX is enabled, otherwise extend parent window's contents rectangle. Only Fixed columns allowed. Stretched columns will calculate their width assuming no scrolling.");
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);
|
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags, ImGuiTableFlags_NoKeepColumnsVisible);
|
ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags, ImGuiTableFlags_NoKeepColumnsVisible);
|
||||||
@ -4792,6 +4792,7 @@ static void ShowDemoWindowTables()
|
|||||||
{
|
{
|
||||||
ImGui::Checkbox("show_headers", &show_headers);
|
ImGui::Checkbox("show_headers", &show_headers);
|
||||||
ImGui::Checkbox("show_wrapped_text", &show_wrapped_text);
|
ImGui::Checkbox("show_wrapped_text", &show_wrapped_text);
|
||||||
|
|
||||||
ImGui::DragFloat2("##OuterSize", &outer_size_value.x);
|
ImGui::DragFloat2("##OuterSize", &outer_size_value.x);
|
||||||
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
|
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
|
||||||
ImGui::Checkbox("outer_size", &outer_size_enabled);
|
ImGui::Checkbox("outer_size", &outer_size_enabled);
|
||||||
@ -4803,12 +4804,14 @@ static void ShowDemoWindowTables()
|
|||||||
"- OuterSize.y then becomes the minimum size for the table, which will extend vertically if there are more rows (unless NoHostExtendY is set).");
|
"- OuterSize.y then becomes the minimum size for the table, which will extend vertically if there are more rows (unless NoHostExtendY is set).");
|
||||||
|
|
||||||
// From a user point of view we will tend to use 'inner_width' differently depending on whether our table is embedding scrolling.
|
// From a user point of view we will tend to use 'inner_width' differently depending on whether our table is embedding scrolling.
|
||||||
// To facilitate experimentation we expose two values and will select the right one depending on active flags.
|
// To facilitate toying with this demo we will actually pass 0.0f to the BeginTable() when ScrollX is disabled.
|
||||||
ImGui::DragFloat("inner_width (when ScrollX active)", &inner_width_with_scroll, 1.0f, 0.0f, FLT_MAX);
|
ImGui::DragFloat("inner_width (when ScrollX active)", &inner_width_with_scroll, 1.0f, 0.0f, FLT_MAX);
|
||||||
|
|
||||||
ImGui::DragFloat("row_min_height", &row_min_height, 1.0f, 0.0f, FLT_MAX);
|
ImGui::DragFloat("row_min_height", &row_min_height, 1.0f, 0.0f, FLT_MAX);
|
||||||
ImGui::SameLine(); HelpMarker("Specify height of the Selectable item.");
|
ImGui::SameLine(); HelpMarker("Specify height of the Selectable item.");
|
||||||
|
|
||||||
ImGui::DragInt("items_count", &items_count, 0.1f, 0, 9999);
|
ImGui::DragInt("items_count", &items_count, 0.1f, 0, 9999);
|
||||||
ImGui::Combo("contents_type (first column)", &contents_type, contents_type_names, IM_ARRAYSIZE(contents_type_names));
|
ImGui::Combo("items_type (first column)", &contents_type, contents_type_names, IM_ARRAYSIZE(contents_type_names));
|
||||||
//filter.Draw("filter");
|
//filter.Draw("filter");
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
@ -111,9 +111,9 @@ Index of this file:
|
|||||||
// and you can fit a 100.0f wide item in it without clipping and with full padding.
|
// and you can fit a 100.0f wide item in it without clipping and with full padding.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// About default width policy (if you don't specify a ImGuiTableColumnFlags_WidthXXXX flag)
|
// About default width policy (if you don't specify a ImGuiTableColumnFlags_WidthXXXX flag)
|
||||||
// - When Table policy ImGuiTableFlags_ColumnsWidthStretch --> default Column policy is ImGuiTableColumnFlags_WidthStretch
|
// - When Table policy ImGuiTableFlags_SizingPolicyStretch --> default Column policy is ImGuiTableColumnFlags_WidthStretch
|
||||||
// - When Table policy ImGuiTableFlags_ColumnsWidthFixed and (Table is Resizable or init_width > 0) --> default Column policy is ImGuiTableColumnFlags_WidthFixed
|
// - When Table policy ImGuiTableFlags_SizingPolicyFixed and (Table is Resizable or init_width > 0) --> default Column policy is ImGuiTableColumnFlags_WidthFixed
|
||||||
// - When Table policy ImGuiTableFlags_ColumnsWidthFixed and (Table is not Resizable and init_width <= 0) --> default Column policy is ImGuiTableColumnFlags_WidthAuto
|
// - When Table policy ImGuiTableFlags_SizingPolicyFixed and (Table is not Resizable and init_width <= 0) --> default Column policy is ImGuiTableColumnFlags_WidthAuto
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -214,8 +214,8 @@ static const float TABLE_RESIZE_SEPARATOR_FEEDBACK_TIMER = 0.06f; // Delay/tim
|
|||||||
inline ImGuiTableFlags TableFixFlags(ImGuiTableFlags flags, ImGuiWindow* outer_window)
|
inline ImGuiTableFlags TableFixFlags(ImGuiTableFlags flags, ImGuiWindow* outer_window)
|
||||||
{
|
{
|
||||||
// Adjust flags: set default sizing policy
|
// Adjust flags: set default sizing policy
|
||||||
if ((flags & (ImGuiTableFlags_ColumnsWidthStretch | ImGuiTableFlags_ColumnsWidthFixed)) == 0)
|
if ((flags & (ImGuiTableFlags_SizingPolicyStretch | ImGuiTableFlags_SizingPolicyFixed)) == 0)
|
||||||
flags |= ((flags & ImGuiTableFlags_ScrollX) || (outer_window->Flags & ImGuiWindowFlags_AlwaysAutoResize)) ? ImGuiTableFlags_ColumnsWidthFixed : ImGuiTableFlags_ColumnsWidthStretch;
|
flags |= ((flags & ImGuiTableFlags_ScrollX) || (outer_window->Flags & ImGuiWindowFlags_AlwaysAutoResize)) ? ImGuiTableFlags_SizingPolicyFixed : ImGuiTableFlags_SizingPolicyStretch;
|
||||||
|
|
||||||
// Adjust flags: disable Resizable when using SameWidths (done above enforcing BordersInnerV)
|
// Adjust flags: disable Resizable when using SameWidths (done above enforcing BordersInnerV)
|
||||||
if (flags & ImGuiTableFlags_SameWidths)
|
if (flags & ImGuiTableFlags_SameWidths)
|
||||||
@ -587,7 +587,7 @@ static void TableSetupColumnFlags(ImGuiTable* table, ImGuiTableColumn* column, I
|
|||||||
if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0)
|
if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0)
|
||||||
{
|
{
|
||||||
// FIXME-TABLE: Inconsistent to promote columns to WidthAuto
|
// FIXME-TABLE: Inconsistent to promote columns to WidthAuto
|
||||||
if (table->Flags & ImGuiTableFlags_ColumnsWidthFixed)
|
if (table->Flags & ImGuiTableFlags_SizingPolicyFixed)
|
||||||
flags |= ((table->Flags & ImGuiTableFlags_Resizable) && !(flags & ImGuiTableColumnFlags_NoResize)) ? ImGuiTableColumnFlags_WidthFixed : ImGuiTableColumnFlags_WidthAuto;
|
flags |= ((table->Flags & ImGuiTableFlags_Resizable) && !(flags & ImGuiTableColumnFlags_NoResize)) ? ImGuiTableColumnFlags_WidthFixed : ImGuiTableColumnFlags_WidthAuto;
|
||||||
else
|
else
|
||||||
flags |= ImGuiTableColumnFlags_WidthStretch;
|
flags |= ImGuiTableColumnFlags_WidthStretch;
|
||||||
@ -1295,7 +1295,7 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, flo
|
|||||||
// When passing a width automatically enforce WidthFixed policy
|
// When passing a width automatically enforce WidthFixed policy
|
||||||
// (whereas TableSetupColumnFlags would default to WidthAuto if table is not Resizable)
|
// (whereas TableSetupColumnFlags would default to WidthAuto if table is not Resizable)
|
||||||
if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0)
|
if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0)
|
||||||
if ((table->Flags & ImGuiTableFlags_ColumnsWidthFixed) && (init_width_or_weight > 0.0f))
|
if ((table->Flags & ImGuiTableFlags_SizingPolicyFixed) && (init_width_or_weight > 0.0f))
|
||||||
flags |= ImGuiTableColumnFlags_WidthFixed;
|
flags |= ImGuiTableColumnFlags_WidthFixed;
|
||||||
|
|
||||||
TableSetupColumnFlags(table, column, flags);
|
TableSetupColumnFlags(table, column, flags);
|
||||||
|
Loading…
Reference in New Issue
Block a user