@@ -17,70 +17,17 @@ public abstract class Tree<TNode, TData>: TreeBase<TNode, TData>
17
17
public static float ItemHeight { get { return EditorGUIUtility . singleLineHeight ; } }
18
18
public static float ItemSpacing { get { return EditorGUIUtility . standardVerticalSpacing ; } }
19
19
20
- [ SerializeField ] public Rect Margin = new Rect ( ) ;
21
- [ SerializeField ] public Rect Padding = new Rect ( ) ;
22
-
23
- [ SerializeField ] public string title = string . Empty ;
24
- [ SerializeField ] public string pathSeparator = "/" ;
25
- [ SerializeField ] public bool displayRootNode = true ;
26
- [ SerializeField ] public bool isCheckable = false ;
27
20
[ NonSerialized ] public GUIStyle FolderStyle ;
28
21
[ NonSerialized ] public GUIStyle TreeNodeStyle ;
29
22
[ NonSerialized ] public GUIStyle ActiveTreeNodeStyle ;
30
23
31
- [ SerializeField ] private List < TNode > nodes = new List < TNode > ( ) ;
32
- [ SerializeField ] private TNode selectedNode = null ;
33
-
34
24
[ NonSerialized ] private Stack < bool > indents = new Stack < bool > ( ) ;
35
25
[ NonSerialized ] private Action < TNode > rightClickNextRender ;
36
26
[ NonSerialized ] private TNode rightClickNextRenderNode ;
37
27
38
28
public bool IsInitialized { get { return Nodes != null && Nodes . Count > 0 && ! String . IsNullOrEmpty ( Nodes [ 0 ] . Path ) ; } }
39
29
public bool RequiresRepaint { get ; private set ; }
40
30
41
- public override TNode SelectedNode
42
- {
43
- get
44
- {
45
- if ( selectedNode != null && String . IsNullOrEmpty ( selectedNode . Path ) )
46
- selectedNode = null ;
47
- return selectedNode ;
48
- }
49
- set
50
- {
51
- selectedNode = value ;
52
- }
53
- }
54
-
55
- public override string Title
56
- {
57
- get { return title ; }
58
- set { title = value ; }
59
- }
60
-
61
- public override bool DisplayRootNode
62
- {
63
- get { return displayRootNode ; }
64
- set { displayRootNode = value ; }
65
- }
66
-
67
- public override bool IsCheckable
68
- {
69
- get { return isCheckable ; }
70
- set { isCheckable = value ; }
71
- }
72
-
73
- public override string PathSeparator
74
- {
75
- get { return pathSeparator ; }
76
- set { pathSeparator = value ; }
77
- }
78
-
79
- protected override List < TNode > Nodes
80
- {
81
- get { return nodes ; }
82
- }
83
-
84
31
public Rect Render ( Rect containingRect , Rect rect , Vector2 scroll , Action < TNode > singleClick = null , Action < TNode > doubleClick = null , Action < TNode > rightClick = null )
85
32
{
86
33
if ( Event . current . type != EventType . Repaint )
@@ -109,7 +56,7 @@ public Rect Render(Rect containingRect, Rect rect, Vector2 scroll, Action<TNode>
109
56
var titleDisplay = ! ( rect . y > endDisplay || rect . yMax < startDisplay ) ;
110
57
if ( titleDisplay )
111
58
{
112
- renderResult = titleNode . Render ( rect , Styles . TreeIndentation , selectedNode == titleNode , FolderStyle , TreeNodeStyle , ActiveTreeNodeStyle ) ;
59
+ renderResult = titleNode . Render ( rect , Styles . TreeIndentation , SelectedNode == titleNode , FolderStyle , TreeNodeStyle , ActiveTreeNodeStyle ) ;
113
60
}
114
61
115
62
if ( renderResult == TreeNodeRenderResult . VisibilityChange )
@@ -142,7 +89,7 @@ public Rect Render(Rect containingRect, Rect rect, Vector2 scroll, Action<TNode>
142
89
var display = ! ( rect . y > endDisplay || rect . yMax < startDisplay ) ;
143
90
if ( display )
144
91
{
145
- renderResult = node . Render ( rect , Styles . TreeIndentation , selectedNode == node , FolderStyle , TreeNodeStyle , ActiveTreeNodeStyle ) ;
92
+ renderResult = node . Render ( rect , Styles . TreeIndentation , SelectedNode == node , FolderStyle , TreeNodeStyle , ActiveTreeNodeStyle ) ;
146
93
}
147
94
148
95
if ( renderResult == TreeNodeRenderResult . VisibilityChange )
@@ -234,7 +181,7 @@ private bool HandleInput(Rect rect, TNode currentNode, int index, Action<TNode>
234
181
}
235
182
236
183
// Keyboard navigation if this child is the current selection
237
- if ( currentNode == selectedNode && Event . current . type == EventType . KeyDown )
184
+ if ( currentNode == SelectedNode && Event . current . type == EventType . KeyDown )
238
185
{
239
186
int directionY = Event . current . keyCode == KeyCode . UpArrow ? - 1 : Event . current . keyCode == KeyCode . DownArrow ? 1 : 0 ;
240
187
int directionX = Event . current . keyCode == KeyCode . LeftArrow ? - 1 : Event . current . keyCode == KeyCode . RightArrow ? 1 : 0 ;
@@ -541,6 +488,56 @@ public class BranchesTree : Tree<TreeNode, GitBranchTreeData>
541
488
[ NonSerialized ] public Texture2D BranchIcon ;
542
489
[ NonSerialized ] public Texture2D FolderIcon ;
543
490
[ NonSerialized ] public Texture2D GlobeIcon ;
491
+ [ SerializeField ] public string title = string . Empty ;
492
+ [ SerializeField ] public string pathSeparator = "/" ;
493
+ [ SerializeField ] public bool displayRootNode = true ;
494
+ [ SerializeField ] public bool isCheckable = false ;
495
+ [ SerializeField ] private List < TreeNode > nodes = new List < TreeNode > ( ) ;
496
+ [ SerializeField ] private TreeNode selectedNode = null ;
497
+
498
+ public override string Title
499
+ {
500
+ get { return title ; }
501
+ set { title = value ; }
502
+ }
503
+
504
+ public override bool DisplayRootNode
505
+ {
506
+ get { return displayRootNode ; }
507
+ set { displayRootNode = value ; }
508
+ }
509
+
510
+ public override bool IsCheckable
511
+ {
512
+ get { return isCheckable ; }
513
+ set { isCheckable = value ; }
514
+ }
515
+
516
+ public override string PathSeparator
517
+ {
518
+ get { return pathSeparator ; }
519
+ set { pathSeparator = value ; }
520
+ }
521
+
522
+ public override TreeNode SelectedNode
523
+ {
524
+ get
525
+ {
526
+ if ( selectedNode != null && String . IsNullOrEmpty ( selectedNode . Path ) )
527
+ selectedNode = null ;
528
+
529
+ return selectedNode ;
530
+ }
531
+ set
532
+ {
533
+ selectedNode = value ;
534
+ }
535
+ }
536
+
537
+ protected override List < TreeNode > Nodes
538
+ {
539
+ get { return nodes ; }
540
+ }
544
541
545
542
public void UpdateIcons ( Texture2D activeBranchIcon , Texture2D branchIcon , Texture2D folderIcon , Texture2D globeIcon )
546
543
{
0 commit comments