@@ -25,9 +25,11 @@ class ChangesView : Subview
25
25
[ SerializeField ] private string commitBody = "" ;
26
26
[ SerializeField ] private string commitMessage = "" ;
27
27
[ SerializeField ] private string currentBranch = "[unknown]" ;
28
- [ SerializeField ] private Vector2 horizontalScroll ;
28
+ [ SerializeField ] private Vector2 scroll ;
29
29
[ SerializeField ] private CacheUpdateEvent lastCurrentBranchChangedEvent ;
30
30
[ SerializeField ] private CacheUpdateEvent lastStatusChangedEvent ;
31
+ [ SerializeField ] private Tree treeChanges = new Tree ( ) ;
32
+ [ SerializeField ] private List < GitStatusEntry > gitStatusEntries ;
31
33
32
34
public override void OnEnable ( )
33
35
{
@@ -83,15 +85,48 @@ public override void OnGUI()
83
85
}
84
86
GUILayout . EndHorizontal ( ) ;
85
87
86
- horizontalScroll = GUILayout . BeginScrollView ( horizontalScroll ) ;
88
+ var rect = GUILayoutUtility . GetLastRect ( ) ;
89
+ scroll = GUILayout . BeginScrollView ( scroll ) ;
87
90
{
91
+ OnTreeGUI ( new Rect ( 0f , 0f , Position . width , Position . height - rect . height + Styles . CommitAreaPadding ) ) ;
88
92
}
89
93
GUILayout . EndScrollView ( ) ;
90
94
91
95
// Do the commit details area
92
96
OnCommitDetailsAreaGUI ( ) ;
93
97
}
94
98
99
+ private void OnTreeGUI ( Rect rect )
100
+ {
101
+ var initialRect = rect ;
102
+
103
+ if ( treeChanges . FolderStyle == null )
104
+ {
105
+ treeChanges . FolderStyle = Styles . Foldout ;
106
+ treeChanges . TreeNodeStyle = Styles . TreeNode ;
107
+ treeChanges . ActiveTreeNodeStyle = Styles . TreeNodeActive ;
108
+ }
109
+
110
+ var treeHadFocus = treeChanges . SelectedNode != null ;
111
+
112
+ rect = treeChanges . Render ( rect , scroll ,
113
+ node => { } ,
114
+ node => {
115
+ } ,
116
+ node => {
117
+ } ) ;
118
+
119
+ if ( treeHadFocus && treeChanges . SelectedNode == null )
120
+ treeChanges . Focus ( ) ;
121
+ else if ( ! treeHadFocus && treeChanges . SelectedNode != null )
122
+ treeChanges . Blur ( ) ;
123
+
124
+ if ( treeChanges . RequiresRepaint )
125
+ Redraw ( ) ;
126
+
127
+ GUILayout . Space ( rect . y - initialRect . y ) ;
128
+ }
129
+
95
130
private void RepositoryOnStatusChanged ( CacheUpdateEvent cacheUpdateEvent )
96
131
{
97
132
if ( ! lastStatusChangedEvent . Equals ( cacheUpdateEvent ) )
@@ -145,9 +180,23 @@ private void MaybeUpdateData()
145
180
if ( currentStatusHasUpdate )
146
181
{
147
182
currentStatusHasUpdate = false ;
183
+ gitStatusEntries = Repository . CurrentStatus . Entries ;
184
+
185
+ BuildTree ( ) ;
148
186
}
149
187
}
150
188
189
+ private void BuildTree ( )
190
+ {
191
+ treeChanges = new Tree ( ) ;
192
+ treeChanges . ActiveNodeIcon = Styles . ActiveBranchIcon ;
193
+ treeChanges . NodeIcon = Styles . BranchIcon ;
194
+ treeChanges . FolderIcon = Styles . FolderIcon ;
195
+
196
+ treeChanges . Load ( gitStatusEntries . Select ( entry => new GitStatusEntryTreeData ( entry ) ) . Cast < ITreeData > ( ) , "Changes" ) ;
197
+ Redraw ( ) ;
198
+ }
199
+
151
200
private void OnCommitDetailsAreaGUI ( )
152
201
{
153
202
GUILayout . BeginHorizontal ( ) ;
0 commit comments