@@ -8,8 +8,6 @@ namespace GBG.PlayableGraphMonitor.Editor.Node
88{
99 public abstract class GraphViewNode : UNode
1010 {
11- internal static NodeLayoutInfo LayoutInfo ;
12-
1311 public int Depth { get ; }
1412
1513 public IReadOnlyList < Port > InputPorts => InternalInputPorts ;
@@ -20,12 +18,12 @@ public abstract class GraphViewNode : UNode
2018
2119 protected List < Port > InternalOutputPorts { get ; } = new List < Port > ( ) ;
2220
23- protected UGraphView Container { get ; set ; }
24-
2521 // public IReadOnlyList<Edge> InputEdges => InternalInputEdges;
2622
2723 protected List < Edge > InternalInputEdges { get ; } = new List < Edge > ( ) ;
2824
25+ protected UGraphView Container { get ; set ; }
26+
2927 protected GraphViewNode Parent { get ; private set ; }
3028
3129 protected new List < GraphViewNode > Children { get ; } = new List < GraphViewNode > ( ) ;
@@ -34,6 +32,17 @@ public abstract class GraphViewNode : UNode
3432 private Vector2 ? _hierarchySize ;
3533
3634
35+ protected GraphViewNode ( int depth )
36+ {
37+ Depth = depth ;
38+ }
39+
40+ protected Port InstantiatePort < TPort > ( Direction direction )
41+ {
42+ return InstantiatePort ( Orientation . Horizontal , direction , Port . Capacity . Single , typeof ( TPort ) ) ;
43+ }
44+
45+
3746 public Vector2 GetNodeSize ( )
3847 {
3948 return NodeLayoutInfo . StandardNodeSize ;
@@ -69,24 +78,24 @@ public Vector2 GetHierarchySize()
6978 return _hierarchySize . Value ;
7079 }
7180
72- public void CalculateLayout ( Vector2 treeSize , Vector2 origin )
81+ public void CalculateLayout ( Vector2 origin )
7382 {
7483 var subTreeSize = GetHierarchySize ( ) ;
75- var nodePos = CalculateSubTreeRootPosition ( treeSize , subTreeSize , origin ) ;
84+ var nodePos = CalculateSubTreeRootNodePosition ( subTreeSize , origin ) ;
7685 SetPosition ( new Rect ( nodePos , Vector2 . zero ) ) ;
7786
7887 origin . x -= GetNodeSize ( ) . x - NodeLayoutInfo . HorizontalSpace ;
7988 for ( int i = 0 ; i < Children . Count ; i ++ )
8089 {
8190 var childNode = Children [ i ] ;
8291 var childHierarchySize = childNode . GetHierarchySize ( ) ;
83- childNode . CalculateLayout ( treeSize , origin ) ;
92+ childNode . CalculateLayout ( origin ) ;
8493
8594 origin . y += childHierarchySize . y ;
8695 }
8796 }
8897
89- public static Vector2 CalculateSubTreeRootPosition ( Vector2 treeSize , Vector2 subTreeSize , Vector2 subTreeOrigin )
98+ public static Vector2 CalculateSubTreeRootNodePosition ( Vector2 subTreeSize , Vector2 subTreeOrigin )
9099 {
91100 var subTreePos = subTreeOrigin ;
92101 subTreePos . y += subTreeSize . y / 2 ;
@@ -124,16 +133,5 @@ public virtual void RemoveFromContainer()
124133 }
125134
126135 public abstract void CreateAndConnectInputNodes ( ) ;
127-
128-
129- protected GraphViewNode ( int depth )
130- {
131- Depth = depth ;
132- }
133-
134- protected Port InstantiatePort < TPort > ( Direction direction )
135- {
136- return InstantiatePort ( Orientation . Horizontal , direction , Port . Capacity . Single , typeof ( TPort ) ) ;
137- }
138136 }
139137}
0 commit comments