Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        private void StartSingleDrag(BonsaiInputEvent startEvent)
        {
            BonsaiNode node   = startEvent.node;
            Vector2    offset = EditorSingleDrag.StartDrag(node, startEvent.canvasMousePostion);

            MotionAction = (CanvasTransform t) => EditorSingleDrag.Drag(node, BonsaiInput.MousePosition(t), offset);
        }
 public static void Drag(Vector2 dragPosition, IReadOnlyList <DraggingNode> nodes)
 {
     foreach (DraggingNode root in nodes)
     {
         EditorSingleDrag.SetSubtreePosition(root.node, dragPosition, root.offset);
     }
 }
Exemplo n.º 4
0
        /// <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);
        }