When closing a node: 1) close and unselect all child nodes, 2) select parent if any child was selected. FIXME: This is currently handled by user logic but I'm hoping to eventually provide tree node features to do this automatically, e.g. a ImGuiTreeNodeFlags_AutoCloseChildNodes etc.
| 3045 | // FIXME: This is currently handled by user logic but I'm hoping to eventually provide tree node |
| 3046 | // features to do this automatically, e.g. a ImGuiTreeNodeFlags_AutoCloseChildNodes etc. |
| 3047 | static int TreeCloseAndUnselectChildNodes(ExampleTreeNode* node, ImGuiSelectionBasicStorage* selection, int depth = 0) |
| 3048 | { |
| 3049 | // Recursive close (the test for depth == 0 is because we call this on a node that was just closed!) |
| 3050 | int unselected_count = selection->Contains((ImGuiID)node->UID) ? 1 : 0; |
| 3051 | if (depth == 0 || TreeNodeGetOpen(node)) |
| 3052 | { |
| 3053 | for (ExampleTreeNode* child : node->Childs) |
| 3054 | unselected_count += TreeCloseAndUnselectChildNodes(child, selection, depth + 1); |
| 3055 | TreeNodeSetOpen(node, false); |
| 3056 | } |
| 3057 | |
| 3058 | // Select root node if any of its child was selected, otherwise unselect |
| 3059 | selection->SetItemSelected((ImGuiID)node->UID, (depth == 0 && unselected_count > 0)); |
| 3060 | return unselected_count; |
| 3061 | } |
| 3062 | |
| 3063 | // Apply multi-selection requests |
| 3064 | static void ApplySelectionRequests(ImGuiMultiSelectIO* ms_io, ExampleTreeNode* tree, ImGuiSelectionBasicStorage* selection) |
nothing calls this directly
no test coverage detected