Exemplo n.º 1
0
		private void Check () 
		{
			if (side == 0)
				side = defaultSide;
			if (knobTexture == null)
				ReloadKnobTexture ();
		}
Exemplo n.º 2
0
        public override void Insert(Node child, int?index, NodeSide side)
        {
            if (side != NodeSide.Auto)
            {
                if (side == NodeSide.Right)
                {
                    Add(rightChildren, child, index, NodeSide.Right);
                }
                else
                {
                    Add(leftChildren, child, index, NodeSide.Left);
                }
            }
            else
            {
                if (rightChildren.Count <= leftChildren.Count)
                {
                    Add(rightChildren, child, index, NodeSide.Right);
                }
                else
                {
                    Add(leftChildren, child, index, NodeSide.Left);
                }
            }

            OnPropertyChanged(nameof(HasChildren));
        }
Exemplo n.º 3
0
		private void Check () 
		{
			if (Side == 0)
				Side = DefaultSide;
			if (KnobTexture == null)
				ReloadKnobTexture ();
		}
Exemplo n.º 4
0
        /// <summary>
        /// Creates and input on this Node of the given type at the specified NodeSide and position.
        /// </summary>
        public NodeInput CreateInput(string inputName, string inputType, NodeSide nodeSide, float sidePosition)
        {
            var ret = NodeInput.Create(this, inputName, inputType, nodeSide, sidePosition);

            RePositionInputKnobs();
            return(ret);
        }
Exemplo n.º 5
0
 public AttachTarget(NodeBase node, NodeSide nodeSide, int?index, Vector2 position)
 {
     this.node     = node;
     this.index    = index;
     this.nodeSide = nodeSide;
     this.position = position;
 }
Exemplo n.º 6
0
        public InsertChildCommand(NodeBase parent, int?index, NodeSide side, Node child = null)
            : base(parent, child)
        {
            this.side = side;

            this.index = index;
        }
Exemplo n.º 7
0
 public void Init(Node body, string name, Direction dir, NodeSide nodeSide, float nodeSidePosition = 0)
 {
     base.Init(body, name);
     direction          = dir;
     maxConnectionCount = dir == Direction.In? ConnectionCount.Single : ConnectionCount.Multi;
     side         = nodeSide;
     sidePosition = nodeSidePosition;
 }
Exemplo n.º 8
0
        public float sideOffset   = 0;       // Offset from the side

        public void Init(Node body, string name, Direction dir)
        {
            base.Init(body, name);
            direction          = dir;
            maxConnectionCount = dir == Direction.In? ConnectionCount.Single : ConnectionCount.Multi;
            side         = dir == Direction.Out? NodeSide.Right : NodeSide.Left;
            sidePosition = 0;
        }
Exemplo n.º 9
0
        private static void ChangeSide(Node node, NodeSide side)
        {
            node.NodeSide = side;

            foreach (var child in node.Children)
            {
                ChangeSide(child, side);
            }
        }
Exemplo n.º 10
0
        public void ShowPreviewElement(Vector2 position, NodeBase parent, NodeSide anchor)
        {
            var parentNode = TryAdd(parent);

            previewNode.Parent = parentNode;

            previewNode.MoveToLayout(position, anchor);
            previewNode.Show();
        }
Exemplo n.º 11
0
 /// <summary>
 /// Sets the knob's position at the specified nodeSide, from Top->Bottom and Left->Right
 /// </summary>
 public void SetPosition(float position, NodeSide nodeSide)
 {
     if (side != nodeSide)
     {
         side = nodeSide;
         ReloadKnobTexture();
     }
     SetPosition(position);
 }
Exemplo n.º 12
0
        public float sideOffset   = 0;       // Offset from the side

        /// <summary>
        /// Inits the base node and subscribes it in the node body for drawing and requests to load the texture through 'ReloadTexture'
        /// </summary>
        protected void InitBase(Node nodeBody, NodeSide nodeSide, float nodeSidePosition, string knobName)
        {
            body         = nodeBody;
            side         = nodeSide;
            sidePosition = nodeSidePosition;
            name         = knobName;
            nodeBody.nodeKnobs.Add(this);
            ReloadKnobTexture();
        }
Exemplo n.º 13
0
        public static NodeSide OppositeSide(this NodeSide side)
        {
            if (side == NodeSide.Right)
            {
                return(NodeSide.Left);
            }

            return(side == NodeSide.Left ? NodeSide.Right : NodeSide.Auto);
        }
Exemplo n.º 14
0
        protected override void Execute(bool isRedo)
        {
            oldSide = Child.NodeSide;

            Node.Remove(Child, out oldIndex);

            if (isRedo)
            {
                Node.Select();
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// Checks the texture and requests to load it again if necessary
 /// </summary>
 internal void Check()
 {
     if (side == 0)
     {
         side = defaultSide;
     }
     if (knobTexture == null)
     {
         ReloadKnobTexture();
     }
 }
Exemplo n.º 16
0
 internal void Check()
 {
     if (side == (NodeSide)0)
     {
         side = defaultSide;
     }
     if ((UnityEngine.Object)knobTexture == (UnityEngine.Object)null)
     {
         ReloadKnobTexture();
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Checks the texture and requests to load it again if necessary
 /// </summary>
 internal void CheckKnobTexture()
 {
     if (side == 0)
     {
         side = defaultSide;
     }
     if (knobTexture == null)
     {
         UpdateKnobTexture();
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Sets the knob's position at the specified nodeSide, from Top->Bottom and Left->Right
 /// </summary>
 public void SetPosition(float position, NodeSide nodeSide)
 {
     if (body.ignoreGUIKnobPlacement)
     {
         return;
     }
     if (side != nodeSide)
     {
         side = nodeSide;
         UpdateKnobTexture();
     }
     SetPosition(position);
 }
Exemplo n.º 19
0
        public void MoveToLayout(Vector2 position, NodeSide anchor)
        {
            layoutPosition = position;

            targetLayoutPosition = new Vector2(
                layoutPosition.X,
                layoutPosition.Y - (0.5f * RenderSize.Y));

            if (anchor == NodeSide.Right)
            {
                targetLayoutPosition.X -= RenderSize.X;
            }
            else if (anchor == NodeSide.Auto)
            {
                targetLayoutPosition.X -= 0.5f * RenderSize.X;
            }
        }
Exemplo n.º 20
0
        // The rule of two red nodes to the same side
        // if the nodes of the tree are stacked in one direction and the two stacked nodes are red
        // the middle node comes up to the parent and the top node becomes the left or right hand child.
        private void TwoRedNodesOnSameSideRebalancing(Node <T> node)
        {
            Node <T> parent           = node.Parent;
            Node <T> grandParent      = parent.Parent;
            Node <T> greatGrandParent = grandParent.Parent;
            NodeSide grandParentSide  = grandParent.WhichSideAmIOn();

            // set my great, grand parent, to point at my parent
            if (greatGrandParent != null)
            {
                if (grandParentSide == NodeSide.Left)
                {
                    greatGrandParent.LeftLink = parent;
                }
                else
                {
                    greatGrandParent.RightLink = parent;
                }
            }

            NodeSide nodeSide = node.WhichSideAmIOn();

            if (nodeSide == NodeSide.Left)
            {
                // set my parents right to my grandParent
                parent.RightLink     = grandParent;
                grandParent.LeftLink = null;
            }
            else if (nodeSide == NodeSide.Right)
            {
                // set my parents right to my grandParent
                parent.LeftLink       = grandParent;
                grandParent.RightLink = null;
            }

            // reset the parent, update the root
            parent.Parent = greatGrandParent;
            if (greatGrandParent == null)
            {
                this.root = parent;
            }

            grandParent.Parent = parent;
            parent.Color       = NodeColor.Black;
            grandParent.Color  = NodeColor.Red;
        }
        private void CalculateAttachOnTargetChildren()
        {
            var root = parent as RootNode;

            if (root != null)
            {
                side = movingNode.NodeSide;

                children = movingNode.NodeSide == NodeSide.Right ? root.RightChildren : root.LeftChildren;
            }
            else
            {
                side = parent.NodeSide;

                children = ((Node)parent).Children;
            }
        }
Exemplo n.º 22
0
    private void UpdateConnectKnobPosition(ConnectionKnob knob, NodeSide defaultSide, float defaultOffset)
    {
        if (knob.connected())
        {
            Vector2 selfPos  = center;
            Vector2 otherPos = knob.connections[0].body.center;

            Vector2 bottomLeft  = new Vector2(rect.xMin, rect.yMax);
            Vector2 bottomRight = new Vector2(rect.xMax, rect.yMax);
            Vector2 topRight    = new Vector2(rect.xMax, rect.yMin);
            Vector2 topLeft     = new Vector2(rect.xMin, rect.yMin);

            Vector2 intersectPos = Vector2.zero;

            // top
            if (HMathf.SegmentIntersect(selfPos, otherPos, topLeft, topRight, ref intersectPos))
            {
                knob.side         = NodeSide.Top;
                knob.sidePosition = (intersectPos.x - rect.xMin);
            }
            // right
            else if (HMathf.SegmentIntersect(selfPos, otherPos, topRight, bottomRight, ref intersectPos))
            {
                knob.side         = NodeSide.Right;
                knob.sidePosition = (intersectPos.y - rect.yMin);
            }
            // bottom
            else if (HMathf.SegmentIntersect(selfPos, otherPos, bottomRight, bottomLeft, ref intersectPos))
            {
                knob.side         = NodeSide.Bottom;
                knob.sidePosition = (intersectPos.x - rect.xMin);
            }
            // left
            else if (HMathf.SegmentIntersect(selfPos, otherPos, bottomLeft, topLeft, ref intersectPos))
            {
                knob.side         = NodeSide.Left;
                knob.sidePosition = (intersectPos.y - rect.yMin);
            }
        }
        else
        {
            knob.side         = defaultSide;
            knob.sidePosition = defaultOffset;
        }
    }
Exemplo n.º 23
0
 /// <summary>
 /// Set the knob position at the specified side, from Top->Bottom and Left->Right
 /// </summary>
 public void SetPosition(float position, NodeSide nodeSide)
 {
     if (side != nodeSide)
     {
         int cur = (int)side, next = (int)nodeSide;
         if (next < cur)
         {
             next += 4;
         }
         while (cur < next)
         {
             knobTexture = NodeEditorGUI.RotateTexture90Degrees(knobTexture);
             cur++;
         }
     }
     side = nodeSide;
     SetPosition(position);
 }
Exemplo n.º 24
0
        protected void Add(List <Node> collection, Node child, int?index, NodeSide side)
        {
            if (index.HasValue)
            {
                collection.Insert(index.Value, child);
            }
            else
            {
                collection.Add(child);
            }

            ChangeSide(child, side);

            child.LinkToParent(this);

            if (Document != null)
            {
                Document.Add(child);
            }
        }
Exemplo n.º 25
0
        public InsertChildCommand(PropertiesBag properties, Document document)
            : base(properties, document)
        {
            int value;

            if (properties.TryParseInt32(PropertyNodeSide, out value) && Enum.IsDefined(typeof(NodeShape), value))
            {
                side = (NodeSide)value;
            }
            else
            {
                side = NodeSide.Right;
            }

            var isIndexParsed =
                properties.TryParseNullableInt32(PropertyIndex, out index) ||
                properties.TryParseNullableInt32(PropertyIndexOld, out index);

            if (!isIndexParsed)
            {
                index = null;
            }
        }
        private void FindReorderTarget(IReadOnlyList <Node> collection, NodeSide targetSide)
        {
            double centerY = movementCenter.Y;

            var nodeIndex = collection.IndexOf(movingNode);

            insertIndex = 0;

            for (var i = collection.Count - 1; i >= 0; i--)
            {
                var otherNode = collection[i];

                var bounds = Scene.FindRenderNode(otherNode).RenderBounds;

                if (centerY <= bounds.CenterY)
                {
                    continue;
                }

                renderIndex = i + 1;
                insertIndex = i + 1;

                if (nodeIndex >= 0 && i >= nodeIndex)
                {
                    insertIndex--;
                }

                break;
            }

            if (nodeIndex != insertIndex)
            {
                children = collection;

                side = targetSide;
            }
        }
Exemplo n.º 27
0
 /// <summary>
 /// Creates and input on this Node of the given type at the specified NodeSide.
 /// </summary>
 public void CreateInput(string inputName, string inputType, NodeSide nodeSide)
 {
     NodeInput.Create(this, inputName, inputType, nodeSide);
 }
Exemplo n.º 28
0
 /// <summary>
 /// Creates and output on this Node of the given type at the specified NodeSide and position.
 /// </summary>
 public void CreateOutput(string outputName, string outputType, NodeSide nodeSide, float sidePosition)
 {
     NodeOutput.Create(this, outputName, outputType, nodeSide, sidePosition);
 }
Exemplo n.º 29
0
 /// <summary>
 /// Creates and output on this Node of the given type at the specified NodeSide.
 /// </summary>
 public void CreateOutput(string outputName, string outputType, NodeSide nodeSide)
 {
     NodeOutput.Create(this, outputName, outputType, nodeSide);
 }
Exemplo n.º 30
0
        /// <summary>
        /// Creates a new NodeInput in NodeBody of specified type at the specified NodeSide and position
        /// </summary>
        public static NodeInput Create(Node nodeBody, string inputName, string inputType, NodeSide nodeSide, float sidePosition)
        {
            NodeInput input = CreateInstance <NodeInput> ();

            input.typeID = inputType;
            input.InitBase(nodeBody, nodeSide, sidePosition, inputName);
            nodeBody.Inputs.Add(input);
            return(input);
        }
Exemplo n.º 31
0
 /// <summary>
 /// Creates a new NodeInput in NodeBody of specified type at the specified NodeSide
 /// </summary>
 public static NodeInput Create(Node nodeBody, string inputName, string inputType, NodeSide nodeSide)
 {
     return(Create(nodeBody, inputName, inputType, nodeSide, 20));
 }
Exemplo n.º 32
0
		/// <summary>
		/// Gets the rotation steps anti-clockwise from NodeSide A to B
		/// </summary>
		internal static int GetRotationStepsAntiCW (NodeSide sideA, NodeSide sideB) 
		{
			return sideB - sideA + (sideA>sideB? 4 : 0);
		}
Exemplo n.º 33
0
 /// <summary>
 /// Sets the knob's position at the specified nodeSide, from Top->Bottom and Left->Right
 /// </summary>
 public void SetPosition(float position, NodeSide nodeSide)
 {
     if (side != nodeSide)
     {
         side = nodeSide;
         ReloadKnobTexture ();
     }
     SetPosition (position);
 }
Exemplo n.º 34
0
 /// <summary>
 /// Creates and input on this Node of the given type at the specified NodeSide and position.
 /// </summary>
 public void CreateInput(string inputName, string inputType, NodeSide nodeSide, float sidePosition)
 {
     NodeInput.Create(this, inputName, inputType, nodeSide, sidePosition);
 }
Exemplo n.º 35
0
 /// <summary>
 /// Set the knob position at the specified side, from Top->Bottom and Left->Right
 /// </summary>
 public void SetPosition(float position, NodeSide nodeSide)
 {
     NodeSide oldSide = side;
     side = nodeSide;
     if (oldSide != nodeSide)
         ReloadKnobTexture ();
     SetPosition (position);
 }
Exemplo n.º 36
0
 /// <summary>
 /// Inits the base node and subscribes it in the node body for drawing and requests to load the texture through 'ReloadTexture'
 /// </summary>
 protected void InitBase(Node nodeBody, NodeSide nodeSide, float nodeSidePosition, string knobName)
 {
     body = nodeBody;
     side = nodeSide;
     sidePosition = nodeSidePosition;
     name = knobName;
     nodeBody.nodeKnobs.Add (this);
     ReloadKnobTexture ();
 }
Exemplo n.º 37
0
 /// <summary>
 /// Creates and input on this Node of the given type at the specified NodeSide.
 /// </summary>
 public void CreateInput(string inputName, string inputType, NodeSide nodeSide)
 {
     NodeInput.Create (this, inputName, inputType, nodeSide);
 }
Exemplo n.º 38
0
 /// <summary>
 /// Creates and input on this Node of the given type at the specified NodeSide and position.
 /// </summary>
 public void CreateInput(string inputName, string inputType, NodeSide nodeSide, float sidePosition)
 {
     NodeInput.Create (this, inputName, inputType, nodeSide, sidePosition);
 }
Exemplo n.º 39
0
 /// <summary>
 /// Gets the rotation steps anti-clockwise from NodeSide A to B
 /// </summary>
 private static int getRotationStepsAntiCW(NodeSide sideA, NodeSide sideB)
 {
     return sideB - sideA + (sideA>sideB? 4 : 0);
 }
Exemplo n.º 40
0
 /// <summary>
 /// Creates and output on this Node of the given type at the specified NodeSide.
 /// </summary>
 public void CreateOutput(string outputName, string outputType, NodeSide nodeSide)
 {
     NodeOutput.Create (this, outputName, outputType, nodeSide);
 }
Exemplo n.º 41
0
 /// <summary>
 /// Creates and output on this Node of the given type at the specified NodeSide and position.
 /// </summary>
 public void CreateOutput(string outputName, string outputType, NodeSide nodeSide, float sidePosition)
 {
     NodeOutput.Create (this, outputName, outputType, nodeSide, sidePosition);
 }