mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 21:21:06 +01:00 
			
		
		
		
	Demo tweaks. Moved Tabs to Widgets section. Added to Tables demo. Increased version following 00b35c08.
				
					
				
			This commit is contained in:
		
							
								
								
									
										347
									
								
								imgui_demo.cpp
									
									
									
									
									
								
							
							
						
						
									
										347
									
								
								imgui_demo.cpp
									
									
									
									
									
								
							| @@ -1352,9 +1352,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; | ||||
| @@ -2378,144 +2518,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( | ||||
| @@ -4180,16 +4182,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(); | ||||
|         } | ||||
|  | ||||
|         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 @@ 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(); | ||||
| @@ -4742,10 +4773,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(); | ||||
|  | ||||
| @@ -4948,11 +4979,11 @@ static void ShowDemoWindowTables() | ||||
|             // 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); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user