| 9591 | //----------------------------------------------------------------------------- |
| 9592 | |
| 9593 | struct ExampleAppPropertyEditor |
| 9594 | { |
| 9595 | ImGuiTextFilter Filter; |
| 9596 | ExampleTreeNode* SelectedNode = NULL; |
| 9597 | bool UseClipper = false; |
| 9598 | |
| 9599 | void Draw(ExampleTreeNode* root_node) |
| 9600 | { |
| 9601 | IMGUI_DEMO_MARKER("Examples/Property editor"); |
| 9602 | |
| 9603 | // Left side: draw tree |
| 9604 | // - Currently using a table to benefit from RowBg feature |
| 9605 | // - Our tree node are all of equal height, facilitating the use of a clipper. |
| 9606 | if (ImGui::BeginChild("##tree", ImVec2(300, 0), ImGuiChildFlags_ResizeX | ImGuiChildFlags_Borders | ImGuiChildFlags_NavFlattened)) |
| 9607 | { |
| 9608 | ImGui::PushItemFlag(ImGuiItemFlags_NoNavDefaultFocus, true); |
| 9609 | ImGui::Checkbox("Use Clipper", &UseClipper); |
| 9610 | ImGui::SameLine(); |
| 9611 | ImGui::Text("(%d root nodes)", root_node->Childs.Size); |
| 9612 | ImGui::SetNextItemWidth(-FLT_MIN); |
| 9613 | ImGui::SetNextItemShortcut(ImGuiMod_Ctrl | ImGuiKey_F, ImGuiInputFlags_Tooltip); |
| 9614 | if (ImGui::InputTextWithHint("##Filter", "incl,-excl", Filter.InputBuf, IM_COUNTOF(Filter.InputBuf), ImGuiInputTextFlags_EscapeClearsAll)) |
| 9615 | Filter.Build(); |
| 9616 | ImGui::PopItemFlag(); |
| 9617 | |
| 9618 | if (ImGui::BeginTable("##list", 1, ImGuiTableFlags_RowBg)) |
| 9619 | { |
| 9620 | if (UseClipper) |
| 9621 | DrawClippedTree(root_node); |
| 9622 | else |
| 9623 | DrawTree(root_node); |
| 9624 | ImGui::EndTable(); |
| 9625 | } |
| 9626 | } |
| 9627 | ImGui::EndChild(); |
| 9628 | |
| 9629 | // Right side: draw properties |
| 9630 | ImGui::SameLine(); |
| 9631 | |
| 9632 | ImGui::BeginGroup(); // Lock X position |
| 9633 | if (ExampleTreeNode* node = SelectedNode) |
| 9634 | { |
| 9635 | ImGui::Text("%s", node->Name); |
| 9636 | ImGui::TextDisabled("UID: 0x%08X", node->UID); |
| 9637 | ImGui::Separator(); |
| 9638 | if (ImGui::BeginTable("##properties", 2, ImGuiTableFlags_Resizable | ImGuiTableFlags_ScrollY)) |
| 9639 | { |
| 9640 | // Push object ID after we entered the table, so table is shared for all objects |
| 9641 | ImGui::PushID((int)node->UID); |
| 9642 | ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed); |
| 9643 | ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch, 2.0f); // Default twice larger |
| 9644 | if (node->HasData) |
| 9645 | { |
| 9646 | // In a typical application, the structure description would be derived from a data-driven system. |
| 9647 | // - We try to mimic this with our ExampleMemberInfo structure and the ExampleTreeNodeMemberInfos[] array. |
| 9648 | // - Limits and some details are hard-coded to simplify the demo. |
| 9649 | for (const ExampleMemberInfo& field_desc : ExampleTreeNodeMemberInfos) |
| 9650 | { |
nothing calls this directly
no outgoing calls
no test coverage detected