int TreeNodeWrapper::get_child_index(mforms::TreeNodeRef node) const { TreeNodeWrapper *child = (TreeNodeWrapper *)node.ptr(); std::vector<TreeNodeWrapper*>::const_iterator i = std::find(_children.begin(), _children.end(), child); if (i == _children.end()) return -1; return (int)(i - _children.begin()); }
void TreeNodeWrapper::move_child(mforms::TreeNodeRef node, int new_index) { TreeNodeWrapper *child = (TreeNodeWrapper *)node.ptr(); std::vector<TreeNodeWrapper*>::iterator i = std::find(_children.begin(), _children.end(), child); if (i == _children.end()) return; int old_index = int(i - _children.begin()); if (old_index == new_index) return; _children.erase(i); if (old_index < new_index) --new_index; _children.insert(_children.begin() + new_index, child); }