private void Check () { if (side == 0) side = defaultSide; if (knobTexture == null) ReloadKnobTexture (); }
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)); }
private void Check () { if (Side == 0) Side = DefaultSide; if (KnobTexture == null) ReloadKnobTexture (); }
/// <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); }
public AttachTarget(NodeBase node, NodeSide nodeSide, int?index, Vector2 position) { this.node = node; this.index = index; this.nodeSide = nodeSide; this.position = position; }
public InsertChildCommand(NodeBase parent, int?index, NodeSide side, Node child = null) : base(parent, child) { this.side = side; this.index = index; }
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; }
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; }
private static void ChangeSide(Node node, NodeSide side) { node.NodeSide = side; foreach (var child in node.Children) { ChangeSide(child, side); } }
public void ShowPreviewElement(Vector2 position, NodeBase parent, NodeSide anchor) { var parentNode = TryAdd(parent); previewNode.Parent = parentNode; previewNode.MoveToLayout(position, anchor); previewNode.Show(); }
/// <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); }
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(); }
public static NodeSide OppositeSide(this NodeSide side) { if (side == NodeSide.Right) { return(NodeSide.Left); } return(side == NodeSide.Left ? NodeSide.Right : NodeSide.Auto); }
protected override void Execute(bool isRedo) { oldSide = Child.NodeSide; Node.Remove(Child, out oldIndex); if (isRedo) { Node.Select(); } }
/// <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(); } }
internal void Check() { if (side == (NodeSide)0) { side = defaultSide; } if ((UnityEngine.Object)knobTexture == (UnityEngine.Object)null) { ReloadKnobTexture(); } }
/// <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(); } }
/// <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); }
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; } }
// 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; } }
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; } }
/// <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); }
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); } }
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; } }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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)); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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 (); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }