コード例 #1
0
 private void DrawInputsNodesRecursively(List <DependencyViewerNode> nodes, NodeInputSide inputSide)
 {
     for (int i = 0; i < nodes.Count; ++i)
     {
         DrawNode(nodes[i]);
         DrawInputsNodesRecursively(inputSide == NodeInputSide.Left ? nodes[i].LeftInputs : nodes[i].RightInputs, inputSide);
     }
 }
コード例 #2
0
    private void ForeachChildrenRecursively(NodeInputSide treeSide, DependencyViewerNode node, Action <DependencyViewerNode> onEachNodeCallback)
    {
        var children = node.GetChildren(treeSide);

        for (int i = 0; i < children.Count; ++i)
        {
            ForeachChildrenRecursively(treeSide, children[i], onEachNodeCallback);
        }

        onEachNodeCallback(node);
    }
コード例 #3
0
    public DependencyViewerNode GetLastSibling(NodeInputSide treeSide)
    {
        var parent = GetParent(treeSide);

        if (parent == null)
        {
            return(this);
        }

        var childNodes = parent.GetChildren(treeSide);

        return(childNodes.Count > 0 ? childNodes[childNodes.Count - 1] : null);
    }
コード例 #4
0
    public DependencyViewerNode GetNextSibling(NodeInputSide treeSide)
    {
        var parent = GetParent(treeSide);

        if (parent == null)
        {
            return(null);
        }

        var childNodes = parent.GetChildren(treeSide);
        int childIdx   = GetSiblingIndex(treeSide);

        return(childIdx + 1 < childNodes.Count ? childNodes[childIdx + 1] : null);
    }
コード例 #5
0
    public int GetSiblingIndex(NodeInputSide treeSide)
    {
        var parentNode = GetParent(treeSide);

        if (parentNode == null)
        {
            return(0);
        }

        var siblings = parentNode.GetChildren(treeSide);

        for (int siblingIdx = 0; siblingIdx < siblings.Count; ++siblingIdx)
        {
            if (siblings[siblingIdx] == this)
            {
                return(siblingIdx);
            }
        }
        return(-1);
    }
コード例 #6
0
 public void ForeachChildrenRecursively(NodeInputSide treeSide, Action <DependencyViewerNode> onEachNodeCallback)
 {
     ForeachChildrenRecursively(treeSide, this, onEachNodeCallback);
 }
コード例 #7
0
 public int GetNumChildren(NodeInputSide treeSide)
 {
     return(GetChildren(treeSide).Count);
 }
コード例 #8
0
 public bool IsFirstSibling(NodeInputSide treeSide)
 {
     return(GetSiblingIndex(treeSide) == 0);
 }
コード例 #9
0
 public bool IsLeaf(NodeInputSide treeSide)
 {
     return(GetNumChildren(treeSide) == 0);
 }
コード例 #10
0
    public DependencyViewerNode GetLastChild(NodeInputSide treeSide)
    {
        var childNodes = GetChildren(treeSide);

        return(childNodes.Count > 0 ? childNodes[childNodes.Count - 1] : null);
    }
コード例 #11
0
 public List <DependencyViewerNode> GetChildren(NodeInputSide treeSide)
 {
     return(GetInputNodesFromSide(treeSide));
 }
コード例 #12
0
    public DependencyViewerNode GetParent(NodeInputSide treeSide)
    {
        var parentList = (treeSide == NodeInputSide.Left ? _rightInputs : _leftInputs);

        return(parentList.Count > 0 ? parentList[0] : null);
    }
コード例 #13
0
 public List <DependencyViewerNode> GetInputNodesFromSide(NodeInputSide side)
 {
     return(side == NodeInputSide.Left ? _leftInputs : _rightInputs);
 }
コード例 #14
0
    private void DrawNodeLinks(DependencyViewerNode node, List <DependencyViewerNode> inputs, NodeInputSide inputSide)
    {
        for (int i = 0; i < inputs.Count; ++i)
        {
            DependencyViewerNode inputNode = inputs[i];

            DependencyViewerNode leftNode  = (inputSide == NodeInputSide.Left ? node : inputNode);
            DependencyViewerNode rightNode = (inputSide == NodeInputSide.Right ? node : inputNode);


            Vector2 start = GetRelativePosition(leftNode.GetLeftInputAnchorPosition());
            Vector2 end   = GetRelativePosition(rightNode.GetRightInputAnchorPosition());

            Drawing.DrawLine(start, end, LinkColor, LinkWidth);

            DrawNodeLinks(
                inputNode,
                inputSide == NodeInputSide.Left ? inputNode.LeftInputs : inputNode.RightInputs,
                inputSide);
        }
    }