Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'imgui/imgui_demo.cpp')
-rw-r--r--imgui/imgui_demo.cpp472
1 files changed, 250 insertions, 222 deletions
diff --git a/imgui/imgui_demo.cpp b/imgui/imgui_demo.cpp
index e9691bc6..1377425f 100644
--- a/imgui/imgui_demo.cpp
+++ b/imgui/imgui_demo.cpp
@@ -1,4 +1,4 @@
-// dear imgui, v1.80 WIP
+// dear imgui, v1.80
// (demo code)
// Help:
@@ -473,7 +473,9 @@ void ImGui::ShowDemoWindow(bool* p_open)
}
ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink);
- ImGui::SameLine(); HelpMarker("Set to false to disable blinking cursor, for users who consider it distracting");
+ ImGui::SameLine(); HelpMarker("Enable blinking cursor (optional as some users consider it to be distracting)");
+ ImGui::Checkbox("io.ConfigDragClickToInputText", &io.ConfigDragClickToInputText);
+ ImGui::SameLine(); HelpMarker("Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving).");
ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges);
ImGui::SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback.");
ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWindowsMoveFromTitleBarOnly);
@@ -1408,9 +1410,149 @@ static void ShowDemoWindowWidgets()
ImGui::TreePop();
}
- // Plot/Graph widgets are currently fairly limited.
- // Consider writing your own plotting widget, or using a third-party one
- // (for third-party Plot widgets, see 'Wiki->Useful Widgets' or https://github.com/ocornut/imgui/labels/plot%2Fgraph)
+ // Tabs
+ if (ImGui::TreeNode("Tabs"))
+ {
+ if (ImGui::TreeNode("Basic"))
+ {
+ ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None;
+ if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
+ {
+ if (ImGui::BeginTabItem("Avocado"))
+ {
+ ImGui::Text("This is the Avocado tab!\nblah blah blah blah blah");
+ ImGui::EndTabItem();
+ }
+ if (ImGui::BeginTabItem("Broccoli"))
+ {
+ ImGui::Text("This is the Broccoli tab!\nblah blah blah blah blah");
+ ImGui::EndTabItem();
+ }
+ if (ImGui::BeginTabItem("Cucumber"))
+ {
+ ImGui::Text("This is the Cucumber tab!\nblah blah blah blah blah");
+ ImGui::EndTabItem();
+ }
+ ImGui::EndTabBar();
+ }
+ ImGui::Separator();
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Advanced & Close Button"))
+ {
+ // Expose a couple of the available flags. In most cases you may just call BeginTabBar() with no flags (0).
+ static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_Reorderable;
+ ImGui::CheckboxFlags("ImGuiTabBarFlags_Reorderable", &tab_bar_flags, ImGuiTabBarFlags_Reorderable);
+ ImGui::CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", &tab_bar_flags, ImGuiTabBarFlags_AutoSelectNewTabs);
+ ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton);
+ ImGui::CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", &tab_bar_flags, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton);
+ if ((tab_bar_flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
+ tab_bar_flags |= ImGuiTabBarFlags_FittingPolicyDefault_;
+ if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
+ tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown);
+ if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll))
+ tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll);
+
+ // Tab Bar
+ const char* names[4] = { "Artichoke", "Beetroot", "Celery", "Daikon" };
+ static bool opened[4] = { true, true, true, true }; // Persistent user state
+ for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
+ {
+ if (n > 0) { ImGui::SameLine(); }
+ ImGui::Checkbox(names[n], &opened[n]);
+ }
+
+ // Passing a bool* to BeginTabItem() is similar to passing one to Begin():
+ // the underlying bool will be set to false when the tab is closed.
+ if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
+ {
+ for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
+ if (opened[n] && ImGui::BeginTabItem(names[n], &opened[n], ImGuiTabItemFlags_None))
+ {
+ ImGui::Text("This is the %s tab!", names[n]);
+ if (n & 1)
+ ImGui::Text("I am an odd tab.");
+ ImGui::EndTabItem();
+ }
+ ImGui::EndTabBar();
+ }
+ ImGui::Separator();
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("TabItemButton & Leading/Trailing flags"))
+ {
+ static ImVector<int> active_tabs;
+ static int next_tab_id = 0;
+ if (next_tab_id == 0) // Initialize with some default tabs
+ for (int i = 0; i < 3; i++)
+ active_tabs.push_back(next_tab_id++);
+
+ // TabItemButton() and Leading/Trailing flags are distinct features which we will demo together.
+ // (It is possible to submit regular tabs with Leading/Trailing flags, or TabItemButton tabs without Leading/Trailing flags...
+ // but they tend to make more sense together)
+ static bool show_leading_button = true;
+ static bool show_trailing_button = true;
+ ImGui::Checkbox("Show Leading TabItemButton()", &show_leading_button);
+ ImGui::Checkbox("Show Trailing TabItemButton()", &show_trailing_button);
+
+ // Expose some other flags which are useful to showcase how they interact with Leading/Trailing tabs
+ static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_AutoSelectNewTabs | ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_FittingPolicyResizeDown;
+ ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton);
+ if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
+ tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown);
+ if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll))
+ tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll);
+
+ if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
+ {
+ // Demo a Leading TabItemButton(): click the "?" button to open a menu
+ if (show_leading_button)
+ if (ImGui::TabItemButton("?", ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_NoTooltip))
+ ImGui::OpenPopup("MyHelpMenu");
+ if (ImGui::BeginPopup("MyHelpMenu"))
+ {
+ ImGui::Selectable("Hello!");
+ ImGui::EndPopup();
+ }
+
+ // Demo Trailing Tabs: click the "+" button to add a new tab (in your app you may want to use a font icon instead of the "+")
+ // Note that we submit it before the regular tabs, but because of the ImGuiTabItemFlags_Trailing flag it will always appear at the end.
+ if (show_trailing_button)
+ if (ImGui::TabItemButton("+", ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoTooltip))
+ active_tabs.push_back(next_tab_id++); // Add new tab
+
+ // Submit our regular tabs
+ for (int n = 0; n < active_tabs.Size; )
+ {
+ bool open = true;
+ char name[16];
+ snprintf(name, IM_ARRAYSIZE(name), "%04d", active_tabs[n]);
+ if (ImGui::BeginTabItem(name, &open, ImGuiTabItemFlags_None))
+ {
+ ImGui::Text("This is the %s tab!", name);
+ ImGui::EndTabItem();
+ }
+
+ if (!open)
+ active_tabs.erase(active_tabs.Data + n);
+ else
+ n++;
+ }
+
+ ImGui::EndTabBar();
+ }
+ ImGui::Separator();
+ ImGui::TreePop();
+ }
+ ImGui::TreePop();
+ }
+
+ // Plot/Graph widgets are not very good.
+ // Consider writing your own, or using a third-party one, see:
+ // - ImPlot https://github.com/epezent/implot
+ // - others https://github.com/ocornut/imgui/wiki/Useful-Widgets
if (ImGui::TreeNode("Plots Widgets"))
{
static bool animate = true;
@@ -2437,144 +2579,6 @@ static void ShowDemoWindowLayout()
ImGui::TreePop();
}
- if (ImGui::TreeNode("Tabs"))
- {
- if (ImGui::TreeNode("Basic"))
- {
- ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None;
- if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
- {
- if (ImGui::BeginTabItem("Avocado"))
- {
- ImGui::Text("This is the Avocado tab!\nblah blah blah blah blah");
- ImGui::EndTabItem();
- }
- if (ImGui::BeginTabItem("Broccoli"))
- {
- ImGui::Text("This is the Broccoli tab!\nblah blah blah blah blah");
- ImGui::EndTabItem();
- }
- if (ImGui::BeginTabItem("Cucumber"))
- {
- ImGui::Text("This is the Cucumber tab!\nblah blah blah blah blah");
- ImGui::EndTabItem();
- }
- ImGui::EndTabBar();
- }
- ImGui::Separator();
- ImGui::TreePop();
- }
-
- if (ImGui::TreeNode("Advanced & Close Button"))
- {
- // Expose a couple of the available flags. In most cases you may just call BeginTabBar() with no flags (0).
- static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_Reorderable;
- ImGui::CheckboxFlags("ImGuiTabBarFlags_Reorderable", &tab_bar_flags, ImGuiTabBarFlags_Reorderable);
- ImGui::CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", &tab_bar_flags, ImGuiTabBarFlags_AutoSelectNewTabs);
- ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton);
- ImGui::CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", &tab_bar_flags, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton);
- if ((tab_bar_flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
- tab_bar_flags |= ImGuiTabBarFlags_FittingPolicyDefault_;
- if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
- tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown);
- if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll))
- tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll);
-
- // Tab Bar
- const char* names[4] = { "Artichoke", "Beetroot", "Celery", "Daikon" };
- static bool opened[4] = { true, true, true, true }; // Persistent user state
- for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
- {
- if (n > 0) { ImGui::SameLine(); }
- ImGui::Checkbox(names[n], &opened[n]);
- }
-
- // Passing a bool* to BeginTabItem() is similar to passing one to Begin():
- // the underlying bool will be set to false when the tab is closed.
- if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
- {
- for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
- if (opened[n] && ImGui::BeginTabItem(names[n], &opened[n], ImGuiTabItemFlags_None))
- {
- ImGui::Text("This is the %s tab!", names[n]);
- if (n & 1)
- ImGui::Text("I am an odd tab.");
- ImGui::EndTabItem();
- }
- ImGui::EndTabBar();
- }
- ImGui::Separator();
- ImGui::TreePop();
- }
-
- if (ImGui::TreeNode("TabItemButton & Leading/Trailing flags"))
- {
- static ImVector<int> active_tabs;
- static int next_tab_id = 0;
- if (next_tab_id == 0) // Initialize with some default tabs
- for (int i = 0; i < 3; i++)
- active_tabs.push_back(next_tab_id++);
-
- // TabItemButton() and Leading/Trailing flags are distinct features which we will demo together.
- // (It is possible to submit regular tabs with Leading/Trailing flags, or TabItemButton tabs without Leading/Trailing flags...
- // but they tend to make more sense together)
- static bool show_leading_button = true;
- static bool show_trailing_button = true;
- ImGui::Checkbox("Show Leading TabItemButton()", &show_leading_button);
- ImGui::Checkbox("Show Trailing TabItemButton()", &show_trailing_button);
-
- // Expose some other flags which are useful to showcase how they interact with Leading/Trailing tabs
- static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_AutoSelectNewTabs | ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_FittingPolicyResizeDown;
- ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton);
- if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
- tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown);
- if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll))
- tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll);
-
- if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
- {
- // Demo a Leading TabItemButton(): click the "?" button to open a menu
- if (show_leading_button)
- if (ImGui::TabItemButton("?", ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_NoTooltip))
- ImGui::OpenPopup("MyHelpMenu");
- if (ImGui::BeginPopup("MyHelpMenu"))
- {
- ImGui::Selectable("Hello!");
- ImGui::EndPopup();
- }
-
- // Demo Trailing Tabs: click the "+" button to add a new tab (in your app you may want to use a font icon instead of the "+")
- // Note that we submit it before the regular tabs, but because of the ImGuiTabItemFlags_Trailing flag it will always appear at the end.
- if (show_trailing_button)
- if (ImGui::TabItemButton("+", ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoTooltip))
- active_tabs.push_back(next_tab_id++); // Add new tab
-
- // Submit our regular tabs
- for (int n = 0; n < active_tabs.Size; )
- {
- bool open = true;
- char name[16];
- snprintf(name, IM_ARRAYSIZE(name), "%04d", active_tabs[n]);
- if (ImGui::BeginTabItem(name, &open, ImGuiTabItemFlags_None))
- {
- ImGui::Text("This is the %s tab!", name);
- ImGui::EndTabItem();
- }
-
- if (!open)
- active_tabs.erase(active_tabs.Data + n);
- else
- n++;
- }
-
- ImGui::EndTabBar();
- }
- ImGui::Separator();
- ImGui::TreePop();
- }
- ImGui::TreePop();
- }
-
if (ImGui::TreeNode("Groups"))
{
HelpMarker(
@@ -3463,8 +3467,6 @@ static void EditTableColumnsFlags(ImGuiTableColumnFlags* p_flags)
*p_flags &= ~(ImGuiTableColumnFlags_WidthMask_ ^ ImGuiTableColumnFlags_WidthStretch);
if (ImGui::CheckboxFlags("_WidthFixed", p_flags, ImGuiTableColumnFlags_WidthFixed))
*p_flags &= ~(ImGuiTableColumnFlags_WidthMask_ ^ ImGuiTableColumnFlags_WidthFixed);
- if (ImGui::CheckboxFlags("_WidthAuto", p_flags, ImGuiTableColumnFlags_WidthAuto))
- *p_flags &= ~(ImGuiTableColumnFlags_WidthMask_ ^ ImGuiTableColumnFlags_WidthAuto);
ImGui::CheckboxFlags("_NoResize", p_flags, ImGuiTableColumnFlags_NoResize);
ImGui::CheckboxFlags("_NoReorder", p_flags, ImGuiTableColumnFlags_NoReorder);
ImGui::CheckboxFlags("_NoHide", p_flags, ImGuiTableColumnFlags_NoHide);
@@ -3537,7 +3539,7 @@ static void ShowDemoWindowTables()
// [Method 1] Using TableNextRow() to create a new row, and TableSetColumnIndex() to select the column.
// In many situations, this is the most flexible and easy to use pattern.
HelpMarker("Using TableNextRow() + calling TableSetColumnIndex() _before_ each cell, in a loop.");
- if (ImGui::BeginTable("##table1", 3))
+ if (ImGui::BeginTable("table1", 3))
{
for (int row = 0; row < 4; row++)
{
@@ -3554,7 +3556,7 @@ static void ShowDemoWindowTables()
// [Method 2] Using TableNextColumn() called multiple times, instead of using a for loop + TableSetColumnIndex().
// This is generally more convenient when you have code manually submitting the contents of each columns.
HelpMarker("Using TableNextRow() + calling TableNextColumn() _before_ each cell, manually.");
- if (ImGui::BeginTable("##table2", 3))
+ if (ImGui::BeginTable("table2", 3))
{
for (int row = 0; row < 4; row++)
{
@@ -3575,7 +3577,7 @@ static void ShowDemoWindowTables()
HelpMarker(
"Only using TableNextColumn(), which tends to be convenient for tables where every cells contains the same type of contents.\n"
"This is also more similar to the old NextColumn() function of the Columns API, and provided to facilitate the Columns->Tables API transition.");
- if (ImGui::BeginTable("##table3", 3))
+ if (ImGui::BeginTable("table3", 3))
{
for (int item = 0; item < 14; item++)
{
@@ -3627,7 +3629,7 @@ static void ShowDemoWindowTables()
ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appears in Headers");
PopStyleCompact();
- if (ImGui::BeginTable("##table1", 3, flags))
+ if (ImGui::BeginTable("table1", 3, flags))
{
// Display headers so we can inspect their interaction with borders.
// (Headers are not the main purpose of this section of the demo, so we are not elaborating on them too much. See other sections for details)
@@ -3671,7 +3673,7 @@ static void ShowDemoWindowTables()
ImGui::SameLine(); HelpMarker("Using the _Resizable flag automatically enables the _BordersInnerV flag as well, this is why the resize borders are still showing when unchecking this.");
PopStyleCompact();
- if (ImGui::BeginTable("##table1", 3, flags))
+ if (ImGui::BeginTable("table1", 3, flags))
{
for (int row = 0; row < 5; row++)
{
@@ -3701,12 +3703,10 @@ static void ShowDemoWindowTables()
"Double-click a column border to auto-fit the column to its contents.");
PushStyleCompact();
static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody;
- static bool fixed_fill = true;
- ImGui::Checkbox("fill", &fixed_fill);
+ ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX);
PopStyleCompact();
- ImVec2 outer_size(fixed_fill ? -FLT_MIN : 0.0f, 0.0f);
- if (ImGui::BeginTable("##table1", 3, flags, outer_size))
+ if (ImGui::BeginTable("table1", 3, flags))
{
for (int row = 0; row < 5; row++)
{
@@ -3731,7 +3731,7 @@ static void ShowDemoWindowTables()
"When combining Fixed and Stretch columns, generally you only want one, maybe two trailing columns to use _WidthStretch.");
static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
- if (ImGui::BeginTable("##table1", 3, flags))
+ if (ImGui::BeginTable("table1", 3, flags))
{
ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("BBB", ImGuiTableColumnFlags_WidthFixed);
@@ -3748,7 +3748,7 @@ static void ShowDemoWindowTables()
}
ImGui::EndTable();
}
- if (ImGui::BeginTable("##table2", 6, flags))
+ if (ImGui::BeginTable("table2", 6, flags))
{
ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("BBB", ImGuiTableColumnFlags_WidthFixed);
@@ -3787,7 +3787,7 @@ static void ShowDemoWindowTables()
ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers)");
PopStyleCompact();
- if (ImGui::BeginTable("##table1", 3, flags))
+ if (ImGui::BeginTable("table1", 3, flags))
{
// Submit columns name with TableSetupColumn() and call TableHeadersRow() to create a row with a header in each column.
// (Later we will show how TableSetupColumn() has other uses, optional flags, sizing weight etc.)
@@ -3808,7 +3808,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)
- if (ImGui::BeginTable("##table2", 3, flags | ImGuiTableFlags_SizingFixedFit, ImVec2(0.0f, 0.0f)))
+ if (ImGui::BeginTable("table2", 3, flags | ImGuiTableFlags_SizingFixedFit, ImVec2(0.0f, 0.0f)))
{
ImGui::TableSetupColumn("One");
ImGui::TableSetupColumn("Two");
@@ -3857,7 +3857,7 @@ static void ShowDemoWindowTables()
ImGui::Checkbox("show_headers", &show_headers);
PopStyleCompact();
- if (ImGui::BeginTable("##table1", 3, flags1))
+ if (ImGui::BeginTable("table_padding", 3, flags1))
{
if (show_headers)
{
@@ -3910,7 +3910,7 @@ static void ShowDemoWindowTables()
PopStyleCompact();
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, cell_padding);
- if (ImGui::BeginTable("##table2", 3, flags2))
+ if (ImGui::BeginTable("table_padding_2", 3, flags2))
{
static char text_bufs[3 * 5][16]; // Mini text storage for 3x5 cells
static bool init = true;
@@ -3940,18 +3940,12 @@ static void ShowDemoWindowTables()
ImGui::SetNextItemOpen(open_action != 0);
if (ImGui::TreeNode("Sizing policies"))
{
- static bool fixed_fill = true;
static ImGuiTableFlags flags1 = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_RowBg | ImGuiTableFlags_ContextMenuInBody;
PushStyleCompact();
- ImGui::Checkbox("fill", &fixed_fill);
- ImGui::SameLine(); HelpMarker(
- "Value passed to outer_size only affects tables with _SizingFixedFit or _SizingFixedSame sizing policies.\n\n"
- " - outer_size.x == 0: table fit to columns total contents.\n"
- " - outer_size.x == -FLT_MIN: table fill until right-most edge.");
ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags1, ImGuiTableFlags_Resizable);
+ ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags1, ImGuiTableFlags_NoHostExtendX);
PopStyleCompact();
- ImVec2 outer_size = ImVec2(fixed_fill ? -FLT_MIN : 0.0f, 0.0f);
static ImGuiTableFlags sizing_policy_flags[4] = { ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_SizingFixedSame, ImGuiTableFlags_SizingStretchProp, ImGuiTableFlags_SizingStretchSame };
for (int table_n = 0; table_n < 4; table_n++)
{
@@ -3961,7 +3955,7 @@ static void ShowDemoWindowTables()
// To make it easier to understand the different sizing policy,
// For each policy: we display one table where the columns have equal contents width, and one where the columns have different contents width.
- if (ImGui::BeginTable("##table1", 3, sizing_policy_flags[table_n] | flags1, outer_size))
+ if (ImGui::BeginTable("table1", 3, sizing_policy_flags[table_n] | flags1))
{
for (int row = 0; row < 3; row++)
{
@@ -3972,7 +3966,7 @@ static void ShowDemoWindowTables()
}
ImGui::EndTable();
}
- if (ImGui::BeginTable("##table2", 3, sizing_policy_flags[table_n] | flags1, outer_size))
+ if (ImGui::BeginTable("table2", 3, sizing_policy_flags[table_n] | flags1))
{
for (int row = 0; row < 3; row++)
{
@@ -4017,8 +4011,7 @@ static void ShowDemoWindowTables()
ImGui::PopID();
PopStyleCompact();
- outer_size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 7);
- if (ImGui::BeginTable("##table2", column_count, flags, outer_size))
+ if (ImGui::BeginTable("table2", column_count, flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 7)))
{
for (int cell = 0; cell < 10 * column_count; cell++)
{
@@ -4059,8 +4052,8 @@ static void ShowDemoWindowTables()
// When using ScrollX or ScrollY we need to specify a size for our table container!
// Otherwise by default the table will fit all available space, like a BeginChild() call.
- ImVec2 size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 8);
- if (ImGui::BeginTable("##table1", 3, flags, size))
+ ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8);
+ if (ImGui::BeginTable("table_scrolly", 3, flags, outer_size))
{
ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible
ImGui::TableSetupColumn("One", ImGuiTableColumnFlags_None);
@@ -4113,8 +4106,8 @@ static void ShowDemoWindowTables()
// When using ScrollX or ScrollY we need to specify a size for our table container!
// Otherwise by default the table will fit all available space, like a BeginChild() call.
- ImVec2 outer_size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 8);
- if (ImGui::BeginTable("##table1", 7, flags, outer_size))
+ ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8);
+ if (ImGui::BeginTable("table_scrollx", 7, flags, outer_size))
{
ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows);
ImGui::TableSetupColumn("Line #", ImGuiTableColumnFlags_NoHide); // Make the first column not hideable to match our use of TableSetupScrollFreeze()
@@ -4164,7 +4157,7 @@ static void ShowDemoWindowTables()
ImGui::PopItemWidth();
ImGui::PopID();
PopStyleCompact();
- if (ImGui::BeginTable("##table2", 7, flags2, outer_size, inner_width))
+ if (ImGui::BeginTable("table2", 7, flags2, outer_size, inner_width))
{
for (int cell = 0; cell < 20 * 7; cell++)
{
@@ -4186,7 +4179,7 @@ static void ShowDemoWindowTables()
static ImGuiTableColumnFlags column_flags[column_count] = { ImGuiTableColumnFlags_DefaultSort, ImGuiTableColumnFlags_None, ImGuiTableColumnFlags_DefaultHide };
static ImGuiTableColumnFlags column_flags_out[column_count] = { 0, 0, 0 }; // Output from TableGetColumnFlags()
- if (ImGui::BeginTable("##flags", column_count, ImGuiTableFlags_None))
+ if (ImGui::BeginTable("table_columns_flags_checkboxes", column_count, ImGuiTableFlags_None))
{
PushStyleCompact();
for (int column = 0; column < column_count; column++)
@@ -4214,8 +4207,8 @@ static void ShowDemoWindowTables()
= ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY
| ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV
| ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable;
- ImVec2 size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 9);
- if (ImGui::BeginTable("##table", column_count, flags, size))
+ ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 9);
+ if (ImGui::BeginTable("table_columns_flags", column_count, flags, outer_size))
{
for (int column = 0; column < column_count; column++)
ImGui::TableSetupColumn(column_names[column], column_flags[column]);
@@ -4244,16 +4237,44 @@ static void ShowDemoWindowTables()
ImGui::SetNextItemOpen(open_action != 0);
if (ImGui::TreeNode("Columns widths"))
{
- HelpMarker("Using TableSetupColumn() to setup explicit width.");
+ HelpMarker("Using TableSetupColumn() to setup default width.");
- static ImGuiTableFlags flags = ImGuiTableFlags_None;
+ static ImGuiTableFlags flags1 = ImGuiTableFlags_Borders | ImGuiTableFlags_NoBordersInBodyUntilResize;
PushStyleCompact();
- ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags, ImGuiTableFlags_NoKeepColumnsVisible);
- ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags, ImGuiTableFlags_BordersInnerV);
- ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV);
+ ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags1, ImGuiTableFlags_Resizable);
+ ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags1, ImGuiTableFlags_NoBordersInBodyUntilResize);
PopStyleCompact();
+ if (ImGui::BeginTable("table1", 3, flags1))
+ {
+ // We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
+ ImGui::TableSetupColumn("one", ImGuiTableColumnFlags_WidthFixed, 100.0f); // Default to 100.0f
+ ImGui::TableSetupColumn("two", ImGuiTableColumnFlags_WidthFixed, 200.0f); // Default to 200.0f
+ ImGui::TableSetupColumn("three", ImGuiTableColumnFlags_WidthFixed); // Default to auto
+ ImGui::TableHeadersRow();
+ for (int row = 0; row < 4; row++)
+ {
+ ImGui::TableNextRow();
+ for (int column = 0; column < 3; column++)
+ {
+ ImGui::TableSetColumnIndex(column);
+ if (row == 0)
+ ImGui::Text("(w: %5.1f)", ImGui::GetContentRegionAvail().x);
+ else
+ ImGui::Text("Hello %d,%d", column, row);
+ }
+ }
+ ImGui::EndTable();
+ }
+
+ HelpMarker("Using TableSetupColumn() to setup explicit width.\n\nUnless _NoKeepColumnsVisible is set, fixed columns with set width may still be shrunk down if there's not enough space in the host.");
- if (ImGui::BeginTable("##table1", 4, flags))
+ static ImGuiTableFlags flags2 = ImGuiTableFlags_None;
+ PushStyleCompact();
+ ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags2, ImGuiTableFlags_NoKeepColumnsVisible);
+ ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags2, ImGuiTableFlags_BordersInnerV);
+ ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags2, ImGuiTableFlags_BordersOuterV);
+ PopStyleCompact();
+ if (ImGui::BeginTable("table2", 4, flags2))
{
// We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 100.0f);
@@ -4267,8 +4288,9 @@ static void ShowDemoWindowTables()
{
ImGui::TableSetColumnIndex(column);
if (row == 0)
- ImGui::Text("(%.2f)", ImGui::GetContentRegionAvail().x);
- ImGui::Text("Hello %d,%d", column, row);
+ ImGui::Text("(w: %5.1f)", ImGui::GetContentRegionAvail().x);
+ else
+ ImGui::Text("Hello %d,%d", column, row);
}
}
ImGui::EndTable();
@@ -4282,7 +4304,7 @@ static void ShowDemoWindowTables()
{
HelpMarker("This demonstrate embedding a table into another table cell.");
- if (ImGui::BeginTable("nested1", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
+ if (ImGui::BeginTable("table_nested1", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
{
ImGui::TableSetupColumn("A0");
ImGui::TableSetupColumn("A1");
@@ -4292,7 +4314,7 @@ static void ShowDemoWindowTables()
ImGui::Text("A0 Cell 0");
{
float rows_height = TEXT_BASE_HEIGHT * 2;
- if (ImGui::BeginTable("nested2", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
+ if (ImGui::BeginTable("table_nested2", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
{
ImGui::TableSetupColumn("B0");
ImGui::TableSetupColumn("B1");
@@ -4325,7 +4347,7 @@ static void ShowDemoWindowTables()
if (ImGui::TreeNode("Row height"))
{
HelpMarker("You can pass a 'min_row_height' to TableNextRow().\n\nRows are padded with 'style.CellPadding.y' on top and bottom, so effectively the minimum row height will always be >= 'style.CellPadding.y * 2.0f'.\n\nWe cannot honor a _maximum_ row height as that would requires a unique clipping rectangle per row.");
- if (ImGui::BeginTable("##Table", 1, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerV))
+ if (ImGui::BeginTable("table_row_height", 1, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerV))
{
for (int row = 0; row < 10; row++)
{
@@ -4343,19 +4365,19 @@ static void ShowDemoWindowTables()
ImGui::SetNextItemOpen(open_action != 0);
if (ImGui::TreeNode("Outer size"))
{
- // Showcasing use of outer_size.x == 0.0f and ImGuiTableFlags_NoHostExtendY
- // 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.
- ImGui::Text("Using auto/all width, using NoHostExtendY:");
+ // Showcasing use of ImGuiTableFlags_NoHostExtendX and ImGuiTableFlags_NoHostExtendY
+ // Important to that note how the two flags have slightly different behaviors!
+ ImGui::Text("Using NoHostExtendX and NoHostExtendY:");
PushStyleCompact();
- static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_ContextMenuInBody | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit;
- static bool fixed_fill = false;
- ImGui::Checkbox("fill", &fixed_fill);
+ static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_ContextMenuInBody | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoHostExtendX;
+ ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX);
+ ImGui::SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used.");
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);
+ ImGui::SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible.");
PopStyleCompact();
- ImVec2 outer_size = ImVec2(fixed_fill ? -FLT_MIN : 0.0f, TEXT_BASE_HEIGHT * 5.5f);
- if (ImGui::BeginTable("##table3", 3, flags, outer_size))
+ ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 5.5f);
+ if (ImGui::BeginTable("table1", 3, flags, outer_size))
{
for (int row = 0; row < 10; row++)
{
@@ -4374,7 +4396,7 @@ static void ShowDemoWindowTables()
ImGui::Spacing();
ImGui::Text("Using explicit size:");
- if (ImGui::BeginTable("##table1", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
+ if (ImGui::BeginTable("table2", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
{
for (int row = 0; row < 5; row++)
{
@@ -4388,7 +4410,7 @@ static void ShowDemoWindowTables()
ImGui::EndTable();
}
ImGui::SameLine();
- if (ImGui::BeginTable("##table2", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
+ if (ImGui::BeginTable("table3", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
{
for (int row = 0; row < 3; row++)
{
@@ -4426,7 +4448,7 @@ static void ShowDemoWindowTables()
IM_ASSERT(cell_bg_type >= 0 && cell_bg_type <= 1);
PopStyleCompact();
- if (ImGui::BeginTable("##Table", 5, flags))
+ if (ImGui::BeginTable("table1", 5, flags))
{
for (int row = 0; row < 6; row++)
{
@@ -4468,7 +4490,7 @@ static void ShowDemoWindowTables()
{
static ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
- if (ImGui::BeginTable("##3ways", 3, flags))
+ if (ImGui::BeginTable("3ways", 3, flags))
{
// The first column will use the default _WidthStretch when ScrollX is Off and _WidthFixed when ScrollX is On
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_NoHide);
@@ -4540,7 +4562,7 @@ static void ShowDemoWindowTables()
HelpMarker(
"Showcase using PushItemWidth() and how it is preserved on a per-column basis.\n\n"
"Note that on auto-resizing non-resizable fixed columns, querying the content width for e.g. right-alignment doesn't make sense.");
- if (ImGui::BeginTable("##table2", 3, ImGuiTableFlags_Borders))
+ if (ImGui::BeginTable("table_item_width", 3, ImGuiTableFlags_Borders))
{
ImGui::TableSetupColumn("small");
ImGui::TableSetupColumn("half");
@@ -4583,7 +4605,7 @@ static void ShowDemoWindowTables()
if (ImGui::TreeNode("Custom headers"))
{
const int COLUMNS_COUNT = 3;
- if (ImGui::BeginTable("##table1", COLUMNS_COUNT, ImGuiTableFlags_Borders | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
+ if (ImGui::BeginTable("table_custom_headers", COLUMNS_COUNT, ImGuiTableFlags_Borders | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
{
ImGui::TableSetupColumn("Apricot");
ImGui::TableSetupColumn("Banana");
@@ -4633,14 +4655,14 @@ static void ShowDemoWindowTables()
static ImGuiTableFlags flags1 = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_ContextMenuInBody;
PushStyleCompact();
- ImGui::CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", (unsigned int*)&flags1, ImGuiTableFlags_ContextMenuInBody);
+ ImGui::CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", &flags1, ImGuiTableFlags_ContextMenuInBody);
PopStyleCompact();
// Context Menus: first example
// [1.1] Right-click on the TableHeadersRow() line to open the default table context menu.
// [1.2] Right-click in columns also open the default table context menu (if ImGuiTableFlags_ContextMenuInBody is set)
const int COLUMNS_COUNT = 3;
- if (ImGui::BeginTable("##table1", COLUMNS_COUNT, flags1))
+ if (ImGui::BeginTable("table_context_menu", COLUMNS_COUNT, flags1))
{
ImGui::TableSetupColumn("One");
ImGui::TableSetupColumn("Two");
@@ -4668,7 +4690,7 @@ static void ShowDemoWindowTables()
// [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).");
ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders;
- if (ImGui::BeginTable("##table2", COLUMNS_COUNT, flags2))
+ if (ImGui::BeginTable("table_context_menu_2", COLUMNS_COUNT, flags2))
{
ImGui::TableSetupColumn("One");
ImGui::TableSetupColumn("Two");
@@ -4797,7 +4819,7 @@ static void ShowDemoWindowTables()
ImGui::SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).");
PopStyleCompact();
- if (ImGui::BeginTable("##table", 4, flags, ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 15), 0.0f))
+ if (ImGui::BeginTable("table_sorting", 4, flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 15), 0.0f))
{
// Declare columns
// We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications.
@@ -4806,10 +4828,10 @@ static void ShowDemoWindowTables()
// - ImGuiTableColumnFlags_DefaultSort
// - ImGuiTableColumnFlags_NoSort / ImGuiTableColumnFlags_NoSortAscending / ImGuiTableColumnFlags_NoSortDescending
// - ImGuiTableColumnFlags_PreferSortAscending / ImGuiTableColumnFlags_PreferSortDescending
- ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_ID);
- ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_Name);
- ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_Action);
- ImGui::TableSetupColumn("Quantity", ImGuiTableColumnFlags_PreferSortDescending | ImGuiTableColumnFlags_WidthStretch, -1.0f, MyItemColumnID_Quantity);
+ ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_ID);
+ ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Name);
+ ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Action);
+ ImGui::TableSetupColumn("Quantity", ImGuiTableColumnFlags_PreferSortDescending | ImGuiTableColumnFlags_WidthStretch, 0.0f, MyItemColumnID_Quantity);
ImGui::TableSetupScrollFreeze(0, 1); // Make row always visible
ImGui::TableHeadersRow();
@@ -4867,7 +4889,7 @@ static void ShowDemoWindowTables()
static int freeze_cols = 1;
static int freeze_rows = 1;
static int items_count = IM_ARRAYSIZE(template_items_names) * 2;
- static ImVec2 outer_size_value = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 12);
+ static ImVec2 outer_size_value = ImVec2(0.0f, TEXT_BASE_HEIGHT * 12);
static float row_min_height = 0.0f; // Auto
static float inner_width_with_scroll = 0.0f; // Auto-extend
static bool outer_size_enabled = true;
@@ -4910,7 +4932,10 @@ static void ShowDemoWindowTables()
{
EditTableSizingFlags(&flags);
ImGui::SameLine(); HelpMarker("In the Advanced demo we override the policy of each column so those table-wide settings have less effect that typical.");
+ ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX);
+ ImGui::SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used.");
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);
+ ImGui::SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible.");
ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags, ImGuiTableFlags_NoKeepColumnsVisible);
ImGui::SameLine(); HelpMarker("Only available if ScrollX is disabled.");
ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths);
@@ -5007,16 +5032,16 @@ static void ShowDemoWindowTables()
const ImDrawList* table_draw_list = NULL; // "
const float inner_width_to_use = (flags & ImGuiTableFlags_ScrollX) ? inner_width_with_scroll : 0.0f;
- if (ImGui::BeginTable("##table", 6, flags, outer_size_enabled ? outer_size_value : ImVec2(0, 0), inner_width_to_use))
+ if (ImGui::BeginTable("table_advanced", 6, flags, outer_size_enabled ? outer_size_value : ImVec2(0, 0), inner_width_to_use))
{
// Declare columns
// We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications.
// This is so our sort function can identify a column given our own identifier. We could also identify them based on their index!
- ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoHide, -1.0f, MyItemColumnID_ID);
- ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_Name);
- ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_Action);
- ImGui::TableSetupColumn("Quantity", ImGuiTableColumnFlags_PreferSortDescending, -1.0f, MyItemColumnID_Quantity);
- ImGui::TableSetupColumn("Description", ImGuiTableColumnFlags_WidthStretch, -1.0f, MyItemColumnID_Description);
+ ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoHide, 0.0f, MyItemColumnID_ID);
+ ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Name);
+ ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Action);
+ ImGui::TableSetupColumn("Quantity", ImGuiTableColumnFlags_PreferSortDescending, 0.0f, MyItemColumnID_Quantity);
+ ImGui::TableSetupColumn("Description", (flags & ImGuiTableFlags_NoHostExtendX) ? 0 : ImGuiTableColumnFlags_WidthStretch, 0.0f, MyItemColumnID_Description);
ImGui::TableSetupColumn("Hidden", ImGuiTableColumnFlags_DefaultHide | ImGuiTableColumnFlags_NoSort);
ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows);
@@ -5614,6 +5639,9 @@ void ImGui::ShowAboutWindow(bool* p_open)
#ifdef _MSC_VER
ImGui::Text("define: _MSC_VER=%d", _MSC_VER);
#endif
+#ifdef _MSVC_LANG
+ ImGui::Text("define: _MSVC_LANG=%d", (int)_MSVC_LANG);
+#endif
#ifdef __MINGW32__
ImGui::Text("define: __MINGW32__");
#endif
@@ -7088,7 +7116,7 @@ static void ShowExampleAppCustomRendering(bool* p_open)
{
if (ImGui::BeginTabItem("Primitives"))
{
- ImGui::PushItemWidth(-ImGui::GetFontSize() * 10);
+ ImGui::PushItemWidth(-ImGui::GetFontSize() * 15);
ImDrawList* draw_list = ImGui::GetWindowDrawList();
// Draw gradients
@@ -7182,7 +7210,7 @@ static void ShowExampleAppCustomRendering(bool* p_open)
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col); x += sz; // Pixel (faster than AddLine)
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x + sz, y + sz), IM_COL32(0, 0, 0, 255), IM_COL32(255, 0, 0, 255), IM_COL32(255, 255, 0, 255), IM_COL32(0, 255, 0, 255));
- ImGui::Dummy(ImVec2((sz + spacing) * 8.8f, (sz + spacing) * 3.0f));
+ ImGui::Dummy(ImVec2((sz + spacing) * 10.2f, (sz + spacing) * 3.0f));
ImGui::PopItemWidth();
ImGui::EndTabItem();
}