コード例 #1
0
ファイル: NodeKnob.cs プロジェクト: Avatarchik/Node_Editor
		private void Check () 
		{
			if (side == 0)
				side = defaultSide;
			if (knobTexture == null)
				ReloadKnobTexture ();
		}
コード例 #2
0
ファイル: RootNode.cs プロジェクト: Win10Mindapp/Mindmap
        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));
        }
コード例 #3
0
ファイル: NodeKnob.cs プロジェクト: Zeloder/Node_Editor
		private void Check () 
		{
			if (Side == 0)
				Side = DefaultSide;
			if (KnobTexture == null)
				ReloadKnobTexture ();
		}
コード例 #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);
        }
コード例 #5
0
ファイル: AttachTarget.cs プロジェクト: Win10Mindapp/Mindmap
 public AttachTarget(NodeBase node, NodeSide nodeSide, int?index, Vector2 position)
 {
     this.node     = node;
     this.index    = index;
     this.nodeSide = nodeSide;
     this.position = position;
 }
コード例 #6
0
        public InsertChildCommand(NodeBase parent, int?index, NodeSide side, Node child = null)
            : base(parent, child)
        {
            this.side = side;

            this.index = index;
        }
コード例 #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;
 }
コード例 #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;
        }
コード例 #9
0
ファイル: NodeBase.cs プロジェクト: Win10Mindapp/Mindmap
        private static void ChangeSide(Node node, NodeSide side)
        {
            node.NodeSide = side;

            foreach (var child in node.Children)
            {
                ChangeSide(child, side);
            }
        }
コード例 #10
0
        public void ShowPreviewElement(Vector2 position, NodeBase parent, NodeSide anchor)
        {
            var parentNode = TryAdd(parent);

            previewNode.Parent = parentNode;

            previewNode.MoveToLayout(position, anchor);
            previewNode.Show();
        }
コード例 #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);
 }
コード例 #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();
        }
コード例 #13
0
        public static NodeSide OppositeSide(this NodeSide side)
        {
            if (side == NodeSide.Right)
            {
                return(NodeSide.Left);
            }

            return(side == NodeSide.Left ? NodeSide.Right : NodeSide.Auto);
        }
コード例 #14
0
        protected override void Execute(bool isRedo)
        {
            oldSide = Child.NodeSide;

            Node.Remove(Child, out oldIndex);

            if (isRedo)
            {
                Node.Select();
            }
        }
コード例 #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();
     }
 }
コード例 #16
0
 internal void Check()
 {
     if (side == (NodeSide)0)
     {
         side = defaultSide;
     }
     if ((UnityEngine.Object)knobTexture == (UnityEngine.Object)null)
     {
         ReloadKnobTexture();
     }
 }
コード例 #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();
     }
 }
コード例 #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);
 }
コード例 #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;
            }
        }
コード例 #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;
        }
コード例 #21
0
        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;
            }
        }
コード例 #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;
        }
    }
コード例 #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);
 }
コード例 #24
0
ファイル: NodeBase.cs プロジェクト: Win10Mindapp/Mindmap
        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);
            }
        }
コード例 #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;
            }
        }
コード例 #26
0
        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;
            }
        }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
        }
コード例 #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));
 }
コード例 #32
0
ファイル: NodeKnob.cs プロジェクト: Zeloder/Node_Editor
		/// <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);
		}
コード例 #33
0
ファイル: NodeKnob.cs プロジェクト: Angel07/Node_Editor
 /// <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);
 }
コード例 #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);
 }
コード例 #35
0
ファイル: NodeKnob.cs プロジェクト: RokkiGH/Node_Editor
 /// <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);
 }
コード例 #36
0
ファイル: NodeKnob.cs プロジェクト: Angel07/Node_Editor
 /// <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 ();
 }
コード例 #37
0
ファイル: Node.cs プロジェクト: zardchim/Node_Editor
 /// <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);
 }
コード例 #38
0
ファイル: Node.cs プロジェクト: zardchim/Node_Editor
 /// <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);
 }
コード例 #39
0
ファイル: NodeKnob.cs プロジェクト: Angel07/Node_Editor
 /// <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);
 }
コード例 #40
0
ファイル: Node.cs プロジェクト: zardchim/Node_Editor
 /// <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);
 }
コード例 #41
0
ファイル: Node.cs プロジェクト: zardchim/Node_Editor
 /// <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);
 }