Create example tree data (this allocates _many_ more times than most other code in either Dear ImGui or others demo)
| 783 | // Create example tree data |
| 784 | // (this allocates _many_ more times than most other code in either Dear ImGui or others demo) |
| 785 | static ExampleTreeNode* ExampleTree_CreateDemoTree() |
| 786 | { |
| 787 | static const char* root_names[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pear", "Pineapple", "Strawberry", "Watermelon" }; |
| 788 | const size_t NAME_MAX_LEN = sizeof(ExampleTreeNode::Name); |
| 789 | char name_buf[NAME_MAX_LEN]; |
| 790 | int uid = 0; |
| 791 | ExampleTreeNode* node_L0 = ExampleTree_CreateNode("<ROOT>", ++uid, NULL); |
| 792 | const int root_items_multiplier = 2; |
| 793 | for (int idx_L0 = 0; idx_L0 < IM_ARRAYSIZE(root_names) * root_items_multiplier; idx_L0++) |
| 794 | { |
| 795 | snprintf(name_buf, IM_ARRAYSIZE(name_buf), "%s %d", root_names[idx_L0 / root_items_multiplier], idx_L0 % root_items_multiplier); |
| 796 | ExampleTreeNode* node_L1 = ExampleTree_CreateNode(name_buf, ++uid, node_L0); |
| 797 | const int number_of_childs = (int)strlen(node_L1->Name); |
| 798 | for (int idx_L1 = 0; idx_L1 < number_of_childs; idx_L1++) |
| 799 | { |
| 800 | snprintf(name_buf, IM_ARRAYSIZE(name_buf), "Child %d", idx_L1); |
| 801 | ExampleTreeNode* node_L2 = ExampleTree_CreateNode(name_buf, ++uid, node_L1); |
| 802 | node_L2->HasData = true; |
| 803 | if (idx_L1 == 0) |
| 804 | { |
| 805 | snprintf(name_buf, IM_ARRAYSIZE(name_buf), "Sub-child %d", 0); |
| 806 | ExampleTreeNode* node_L3 = ExampleTree_CreateNode(name_buf, ++uid, node_L2); |
| 807 | node_L3->HasData = true; |
| 808 | } |
| 809 | } |
| 810 | } |
| 811 | return node_L0; |
| 812 | } |
| 813 | |
| 814 | //----------------------------------------------------------------------------- |
| 815 | // [SECTION] DemoWindowWidgetsBasic() |
no test coverage detected