Interpolate in *user-visible order* AND only *over opened nodes*. If you have a sequential mapping tables (e.g. generated after a filter/search pass) this would be simpler. Here the tricks are that: - we store/maintain ExampleTreeNode::IndexInParent which allows implementing a linear iterator easily, without searches, without recursion. this could be replaced by a search in parent, aka 'int index_
| 3100 | // - we call SetNextItemStorageID() before our TreeNode() calls with an ID which doesn't relate to UI stack, |
| 3101 | // making it easier to call TreeNodeGetOpen()/TreeNodeSetOpen() from any location. |
| 3102 | static ExampleTreeNode* TreeGetNextNodeInVisibleOrder(ExampleTreeNode* curr_node, ExampleTreeNode* last_node) |
| 3103 | { |
| 3104 | // Reached last node |
| 3105 | if (curr_node == last_node) |
| 3106 | return NULL; |
| 3107 | |
| 3108 | // Recurse into childs. Query storage to tell if the node is open. |
| 3109 | if (curr_node->Childs.Size > 0 && TreeNodeGetOpen(curr_node)) |
| 3110 | return curr_node->Childs[0]; |
| 3111 | |
| 3112 | // Next sibling, then into our own parent |
| 3113 | while (curr_node->Parent != NULL) |
| 3114 | { |
| 3115 | if (curr_node->IndexInParent + 1 < curr_node->Parent->Childs.Size) |
| 3116 | return curr_node->Parent->Childs[curr_node->IndexInParent + 1]; |
| 3117 | curr_node = curr_node->Parent; |
| 3118 | } |
| 3119 | return NULL; |
| 3120 | } |
| 3121 | |
| 3122 | }; // ExampleTreeFuncs |
| 3123 |
nothing calls this directly
no outgoing calls
no test coverage detected