Ejemplo n.º 1
0
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());
}
Ejemplo n.º 2
0
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);
}