Esempio n. 1
0
        public TinyNode CopyNode(TinyNode source, Vector2 position)
        {
            var node = TinyNode.Create($"{source.Title} Copy", position);

            node.Data = OnCopyNode?.Invoke(source.Data);
            _nodes.Add(node);
            return(node);
        }
Esempio n. 2
0
        public TinyNode CreateNode(string label, Vector2 position, object data = default, TinyNodeType type = TinyNodeType.Regular)
        {
            var node = TinyNode.Create(label, position);

            node.Type = type;
            node.Data = data;
            OnCreateNode?.Invoke(node);
            _nodes.Add(node);
            return(node);
        }
Esempio n. 3
0
        public void AddSingle(TinyNode node)
        {
            if (node == null || IsSelected(node))
            {
                return;
            }

            Out = In = Guid.Empty;
            _selections.Clear();
            _selections.Add(node.Id);
            OnNodeSelectionChanged?.Invoke(node.Id);
        }
Esempio n. 4
0
        public static void DrawNode(TinyNode node, bool selected, bool hasIn = false, bool hasOut = false)
        {
            if (node.Type == TinyNodeType.Regular)
            {
                GUI.Box(GetNodeRect(node.Position), node.Title, selected ? Styles.SelectedNode : Styles.UnSelectedNode);
                GUI.Toggle(GetInRect(node.Position), hasIn, string.Empty, Styles.NodeIn);
                GUI.Toggle(GetOutRect(node.Position), hasOut, string.Empty, Styles.NodeOut);
                return;
            }

            if (node.Type == TinyNodeType.Note)
            {
                GUI.Box(GetNodeRect(node.Position), node.Title, selected ? Styles.SelectedNote : Styles.UnSelectedNote);
            }
        }
Esempio n. 5
0
 public bool IsSelected(TinyNode node) =>
 node != null && _selections.Contains(node.Id);
Esempio n. 6
0
 public bool HasOutEdge(TinyNode node) =>
 _edges.Any(x => x.Out == node.Id);
Esempio n. 7
0
 public bool HasInEdge(TinyNode node) =>
 _edges.Any(x => x.In == node.Id);
Esempio n. 8
0
 public void CreateEdge(TinyNode @out, TinyNode @in, object data = default) =>
 CreateEdge(@out.Id, @in.Id, data);
Esempio n. 9
0
 public static Rect GetOutRect(TinyNode node) =>
 GetOutRect(node.Position);
Esempio n. 10
0
 protected virtual void OnCreateNode(TinyNode node)
 {
 }