Demo tweaks. Moved Tabs to Widgets section. Added to Tables demo. Increased version following 00b35c08.
diff --git a/imgui.h b/imgui.h
index 586fe8e..9e8a055 100644
--- a/imgui.h
+++ b/imgui.h
@@ -59,7 +59,7 @@
// 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)
#define IMGUI_VERSION "1.80 WIP"
-#define IMGUI_VERSION_NUM 17910
+#define IMGUI_VERSION_NUM 17911
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
#define IMGUI_HAS_TABLE
@@ -692,7 +692,7 @@
// Headers are required to perform: reordering, sorting, and opening the context menu (but context menu can also be available in columns body using ImGuiTableFlags_ContextMenuInBody).
// - You may manually submit headers using TableNextRow() + TableHeader() calls, but this is only useful in some advanced cases (e.g. adding custom widgets in header row).
// - Use TableSetupScrollFreeze() to lock columns (from the right) or rows (from the top) so they stay visible when scrolled.
- IMGUI_API void TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = -1.0f, ImU32 user_id = 0);
+ IMGUI_API void TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = 0.0f, ImU32 user_id = 0);
IMGUI_API void TableSetupScrollFreeze(int cols, int rows); // lock columns/rows so they stay visible when scrolled.
IMGUI_API void TableHeadersRow(); // submit all headers cells based on data provided to TableSetupColumn() + submit context menu
IMGUI_API void TableHeader(const char* label); // submit one header cell manually (rarely used)
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index 8fcbafe..1dd2776 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -1352,9 +1352,149 @@
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;
@@ -2378,144 +2518,6 @@
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(
@@ -4180,16 +4182,44 @@
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();
+ }
- if (ImGui::BeginTable("##table1", 4, flags))
+ 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.");
+
+ 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);
@@ -4203,8 +4233,9 @@
{
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();
@@ -4742,10 +4773,10 @@
// - 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();
@@ -4948,11 +4979,11 @@
// 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", ImGuiTableColumnFlags_WidthStretch, 0.0f, MyItemColumnID_Description);
ImGui::TableSetupColumn("Hidden", ImGuiTableColumnFlags_DefaultHide | ImGuiTableColumnFlags_NoSort);
ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows);
diff --git a/imgui_tables.cpp b/imgui_tables.cpp
index 38857c5..2841b6e 100644
--- a/imgui_tables.cpp
+++ b/imgui_tables.cpp
@@ -1313,7 +1313,8 @@
outer_window->DC.CurrentTableIdx = g.CurrentTable ? g.Tables.GetIndex(g.CurrentTable) : -1;
}
-// See "COLUMN SIZING POLICIES" comments at the top of this file
+// See "COLUMN SIZING POLICIES" comments at the top of this file
+// If (init_width_or_weight <= 0.0f) it is ignored
void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, float init_width_or_weight, ImGuiID user_id)
{
ImGuiContext& g = *GImGui;
@@ -1341,8 +1342,6 @@
flags = column->Flags;
// Initialize defaults
- if (flags & ImGuiTableColumnFlags_WidthStretch)
- IM_ASSERT(init_width_or_weight != 0.0f && "Need to provide a valid weight!");
column->InitStretchWeightOrWidth = init_width_or_weight;
if (table->IsInitializing)
{
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index e365886..006e3aa 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -6233,6 +6233,11 @@
// - PlotLines()
// - PlotHistogram()
//-------------------------------------------------------------------------
+// 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
+//-------------------------------------------------------------------------
int ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size)
{