|
@@ -6357,17 +6357,17 @@ static void ShowDemoWindowTables()
|
|
|
IMGUI_DEMO_MARKER("Tables/Tree view");
|
|
|
if (ImGui::TreeNode("Tree view"))
|
|
|
{
|
|
|
- static ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
|
|
|
+ static ImGuiTableFlags table_flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
|
|
|
|
|
|
- static ImGuiTreeNodeFlags tree_node_flags = ImGuiTreeNodeFlags_SpanAllColumns;
|
|
|
- ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", &tree_node_flags, ImGuiTreeNodeFlags_SpanFullWidth);
|
|
|
- ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanTextWidth", &tree_node_flags, ImGuiTreeNodeFlags_SpanTextWidth);
|
|
|
- ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", &tree_node_flags, ImGuiTreeNodeFlags_SpanAllColumns);
|
|
|
- ImGui::CheckboxFlags("ImGuiTreeNodeFlags_LabelSpanAllColumns", &tree_node_flags, ImGuiTreeNodeFlags_LabelSpanAllColumns);
|
|
|
+ static ImGuiTreeNodeFlags tree_node_flags_base = ImGuiTreeNodeFlags_SpanAllColumns;
|
|
|
+ ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", &tree_node_flags_base, ImGuiTreeNodeFlags_SpanFullWidth);
|
|
|
+ ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanTextWidth", &tree_node_flags_base, ImGuiTreeNodeFlags_SpanTextWidth);
|
|
|
+ ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", &tree_node_flags_base, ImGuiTreeNodeFlags_SpanAllColumns);
|
|
|
+ ImGui::CheckboxFlags("ImGuiTreeNodeFlags_LabelSpanAllColumns", &tree_node_flags_base, ImGuiTreeNodeFlags_LabelSpanAllColumns);
|
|
|
ImGui::SameLine(); HelpMarker("Useful if you know that you aren't displaying contents in other columns");
|
|
|
|
|
|
HelpMarker("See \"Columns flags\" section to configure how indentation is applied to individual columns.");
|
|
|
- if (ImGui::BeginTable("3ways", 3, flags))
|
|
|
+ if (ImGui::BeginTable("3ways", 3, table_flags))
|
|
|
{
|
|
|
// The first column will use the default _WidthStretch when ScrollX is Off and _WidthFixed when ScrollX is On
|
|
|
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_NoHide);
|
|
@@ -6388,13 +6388,21 @@ static void ShowDemoWindowTables()
|
|
|
ImGui::TableNextRow();
|
|
|
ImGui::TableNextColumn();
|
|
|
const bool is_folder = (node->ChildCount > 0);
|
|
|
+
|
|
|
+ ImGuiTreeNodeFlags node_flags = tree_node_flags_base;
|
|
|
+ if (node != &all_nodes[0])
|
|
|
+ node_flags &= ~ImGuiTreeNodeFlags_LabelSpanAllColumns; // Only demonstrate this on the root node.
|
|
|
+
|
|
|
if (is_folder)
|
|
|
{
|
|
|
- bool open = ImGui::TreeNodeEx(node->Name, tree_node_flags);
|
|
|
- ImGui::TableNextColumn();
|
|
|
- ImGui::TextDisabled("--");
|
|
|
- ImGui::TableNextColumn();
|
|
|
- ImGui::TextUnformatted(node->Type);
|
|
|
+ bool open = ImGui::TreeNodeEx(node->Name, node_flags);
|
|
|
+ if ((node_flags & ImGuiTreeNodeFlags_LabelSpanAllColumns) == 0)
|
|
|
+ {
|
|
|
+ ImGui::TableNextColumn();
|
|
|
+ ImGui::TextDisabled("--");
|
|
|
+ ImGui::TableNextColumn();
|
|
|
+ ImGui::TextUnformatted(node->Type);
|
|
|
+ }
|
|
|
if (open)
|
|
|
{
|
|
|
for (int child_n = 0; child_n < node->ChildCount; child_n++)
|
|
@@ -6404,7 +6412,7 @@ static void ShowDemoWindowTables()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ImGui::TreeNodeEx(node->Name, tree_node_flags | ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_Bullet | ImGuiTreeNodeFlags_NoTreePushOnOpen);
|
|
|
+ ImGui::TreeNodeEx(node->Name, node_flags | ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_Bullet | ImGuiTreeNodeFlags_NoTreePushOnOpen);
|
|
|
ImGui::TableNextColumn();
|
|
|
ImGui::Text("%d", node->Size);
|
|
|
ImGui::TableNextColumn();
|
|
@@ -6414,7 +6422,7 @@ static void ShowDemoWindowTables()
|
|
|
};
|
|
|
static const MyTreeNode nodes[] =
|
|
|
{
|
|
|
- { "Root", "Folder", -1, 1, 3 }, // 0
|
|
|
+ { "Root with Long Name", "Folder", -1, 1, 3 }, // 0
|
|
|
{ "Music", "Folder", -1, 4, 2 }, // 1
|
|
|
{ "Textures", "Folder", -1, 6, 3 }, // 2
|
|
|
{ "desktop.ini", "System file", 1024, -1,-1 }, // 3
|