| 3068 | struct ExampleTreeFuncs |
| 3069 | { |
| 3070 | static void DrawNode(ExampleTreeNode* node, ImGuiSelectionBasicStorage* selection) |
| 3071 | { |
| 3072 | ImGuiTreeNodeFlags tree_node_flags = ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick; |
| 3073 | tree_node_flags |= ImGuiTreeNodeFlags_NavLeftJumpsToParent; // Enable pressing left to jump to parent |
| 3074 | if (node->Childs.Size == 0) |
| 3075 | tree_node_flags |= ImGuiTreeNodeFlags_Bullet | ImGuiTreeNodeFlags_Leaf; |
| 3076 | if (selection->Contains((ImGuiID)node->UID)) |
| 3077 | tree_node_flags |= ImGuiTreeNodeFlags_Selected; |
| 3078 | |
| 3079 | // Using SetNextItemStorageID() to specify storage id, so we can easily peek into |
| 3080 | // the storage holding open/close stage, using our TreeNodeGetOpen/TreeNodeSetOpen() functions. |
| 3081 | ImGui::SetNextItemSelectionUserData((ImGuiSelectionUserData)(intptr_t)node); |
| 3082 | ImGui::SetNextItemStorageID((ImGuiID)node->UID); |
| 3083 | if (ImGui::TreeNodeEx(node->Name, tree_node_flags)) |
| 3084 | { |
| 3085 | for (ExampleTreeNode* child : node->Childs) |
| 3086 | DrawNode(child, selection); |
| 3087 | ImGui::TreePop(); |
| 3088 | } |
| 3089 | else if (ImGui::IsItemToggledOpen()) |
| 3090 | { |
| 3091 | TreeCloseAndUnselectChildNodes(node, selection); |
| 3092 | } |
| 3093 | } |
| 3094 | |
| 3095 | // When closing a node: 1) close and unselect all child nodes, 2) select parent if any child was selected. |
| 3096 | // FIXME: This is currently handled by user logic but I'm hoping to eventually provide tree node |
nothing calls this directly
no test coverage detected