/// <summary> /// Formats the tree to look nicely. /// </summary> public static void PositionNodesNicely(BonsaiNode root, Vector2 anchor) { // Sort parent-child connections so formatter uses latest changes. foreach (BonsaiNode node in TreeTraversal.PreOrder(root)) { node.SortChildren(); } var positioning = new FormatPositioning(); foreach (BonsaiNode node in TreeTraversal.PostOrder(root)) { PositionHorizontal(node, positioning); } foreach (BonsaiNode node in TreeTraversal.PreOrder(root)) { PositionVertical(node); } // Move the entire subtree to the anchor. Vector2 offset = EditorSingleDrag.StartDrag(root, root.Center); EditorSingleDrag.SetSubtreePosition(root, anchor, offset); }
public static void Drag(Vector2 dragPosition, IReadOnlyList <DraggingNode> nodes) { foreach (DraggingNode root in nodes) { EditorSingleDrag.SetSubtreePosition(root.node, dragPosition, root.offset); } }
/// <summary> /// Formats the tree to look nicely. /// </summary> public static void PositionNodesNicely(BonsaiNode root, Vector2 anchor) { // Sort parent-child connections so formatter uses latest changes. TreeIterator <BonsaiNode> .Traverse( root, node => node.SortChildren()); var positioning = new FormatPositioning(); TreeIterator <BonsaiNode> .Traverse( root, node => PositionHorizontal(node, positioning), Traversal.PostOrder); TreeIterator <BonsaiNode> .Traverse( root, node => PositionVertical(node)); // Move the entire subtree to the anchor. Vector2 offset = EditorSingleDrag.StartDrag(root, root.Center); EditorSingleDrag.SetSubtreePosition(root, anchor, offset); }