@@ -29,11 +29,11 @@ class Window : BaseWindow
29
29
[ NonSerialized ] private double notificationClearTime = - 1 ;
30
30
31
31
[ SerializeField ] private SubTab activeTab = SubTab . History ;
32
- [ SerializeField ] private InitProjectView initProjectTab = new InitProjectView ( ) ;
33
- [ SerializeField ] private BranchesView branchesTab = new BranchesView ( ) ;
34
- [ SerializeField ] private ChangesView changesTab = new ChangesView ( ) ;
35
- [ SerializeField ] private HistoryView historyTab = new HistoryView ( ) ;
36
- [ SerializeField ] private SettingsView settingsTab = new SettingsView ( ) ;
32
+ [ SerializeField ] private InitProjectView initProjectView = new InitProjectView ( ) ;
33
+ [ SerializeField ] private BranchesView branchesView = new BranchesView ( ) ;
34
+ [ SerializeField ] private ChangesView changesView = new ChangesView ( ) ;
35
+ [ SerializeField ] private HistoryView historyView = new HistoryView ( ) ;
36
+ [ SerializeField ] private SettingsView settingsView = new SettingsView ( ) ;
37
37
38
38
[ SerializeField ] private string repoBranch ;
39
39
[ SerializeField ] private string repoUrl ;
@@ -75,10 +75,11 @@ public override void Initialize(IApplicationManager applicationManager)
75
75
{
76
76
base . Initialize ( applicationManager ) ;
77
77
78
- HistoryTab . InitializeView ( this ) ;
79
- ChangesTab . InitializeView ( this ) ;
80
- BranchesTab . InitializeView ( this ) ;
81
- SettingsTab . InitializeView ( this ) ;
78
+ HistoryView . InitializeView ( this ) ;
79
+ ChangesView . InitializeView ( this ) ;
80
+ BranchesView . InitializeView ( this ) ;
81
+ SettingsView . InitializeView ( this ) ;
82
+ InitProjectView . InitializeView ( this ) ;
82
83
}
83
84
84
85
public override void OnEnable ( )
@@ -92,15 +93,15 @@ public override void OnEnable()
92
93
// Set window title
93
94
titleContent = new GUIContent ( Title , Styles . SmallLogo ) ;
94
95
95
- if ( ActiveTab != null )
96
- ActiveTab . OnEnable ( ) ;
96
+ if ( ActiveView != null )
97
+ ActiveView . OnEnable ( ) ;
97
98
}
98
99
99
100
public override void OnDisable ( )
100
101
{
101
102
base . OnDisable ( ) ;
102
- if ( ActiveTab != null )
103
- ActiveTab . OnDisable ( ) ;
103
+ if ( ActiveView != null )
104
+ ActiveView . OnDisable ( ) ;
104
105
}
105
106
106
107
public override void OnDataUpdate ( )
@@ -121,8 +122,8 @@ public override void OnDataUpdate()
121
122
}
122
123
}
123
124
124
- if ( ActiveTab != null )
125
- ActiveTab . OnDataUpdate ( ) ;
125
+ if ( ActiveView != null )
126
+ ActiveView . OnDataUpdate ( ) ;
126
127
}
127
128
128
129
public override void OnRepositoryChanged ( IRepository oldRepository )
@@ -132,22 +133,22 @@ public override void OnRepositoryChanged(IRepository oldRepository)
132
133
DetachHandlers ( oldRepository ) ;
133
134
AttachHandlers ( Repository ) ;
134
135
135
- if ( ActiveTab != null )
136
- ActiveTab . OnRepositoryChanged ( oldRepository ) ;
136
+ if ( ActiveView != null )
137
+ ActiveView . OnRepositoryChanged ( oldRepository ) ;
137
138
}
138
139
139
140
public override void OnSelectionChange ( )
140
141
{
141
142
base . OnSelectionChange ( ) ;
142
- if ( ActiveTab != null )
143
- ActiveTab . OnSelectionChange ( ) ;
143
+ if ( ActiveView != null )
144
+ ActiveView . OnSelectionChange ( ) ;
144
145
}
145
146
146
147
public override void Refresh ( )
147
148
{
148
149
base . Refresh ( ) ;
149
- if ( ActiveTab != null )
150
- ActiveTab . Refresh ( ) ;
150
+ if ( ActiveView != null )
151
+ ActiveView . Refresh ( ) ;
151
152
Repaint ( ) ;
152
153
}
153
154
@@ -158,14 +159,13 @@ public override void OnUI()
158
159
if ( HasRepository )
159
160
{
160
161
DoHeaderGUI ( ) ;
162
+ DoToolbarGUI ( ) ;
161
163
}
162
164
163
- DoToolbarGUI ( ) ;
164
-
165
165
// GUI for the active tab
166
- if ( ActiveTab != null )
166
+ if ( ActiveView != null )
167
167
{
168
- ActiveTab . OnGUI ( ) ;
168
+ ActiveView . OnGUI ( ) ;
169
169
}
170
170
}
171
171
@@ -210,8 +210,10 @@ private bool MaybeUpdateData(out string repoRemote)
210
210
if ( Repository . CurrentRemote . HasValue )
211
211
repoRemote = Repository . CurrentRemote . Value . Name ;
212
212
}
213
- else if ( ! HasRepository )
213
+ else
214
214
{
215
+
216
+ activeTab = SubTab . InitProject ;
215
217
repoBranch = null ;
216
218
repoUrl = null ;
217
219
}
@@ -238,7 +240,6 @@ private void DetachHandlers(IRepository repository)
238
240
repository . OnRepositoryInfoChanged -= RefreshOnMainThread ;
239
241
}
240
242
241
-
242
243
private void SwitchView ( Subview from , Subview to )
243
244
{
244
245
GUI . FocusControl ( null ) ;
@@ -281,23 +282,17 @@ private void DoToolbarGUI()
281
282
SubTab tab = activeTab ;
282
283
EditorGUI . BeginChangeCheck ( ) ;
283
284
{
284
- if ( HasRepository )
285
- {
286
- tab = TabButton ( SubTab . Changes , ChangesTitle , tab ) ;
287
- tab = TabButton ( SubTab . History , HistoryTitle , tab ) ;
288
- tab = TabButton ( SubTab . Branches , BranchesTitle , tab ) ;
289
- }
290
- else
291
- {
292
- tab = TabButton ( SubTab . History , HistoryTitle , tab ) ;
293
- }
285
+ tab = TabButton ( SubTab . Changes , ChangesTitle , tab ) ;
286
+ tab = TabButton ( SubTab . History , HistoryTitle , tab ) ;
287
+ tab = TabButton ( SubTab . Branches , BranchesTitle , tab ) ;
294
288
tab = TabButton ( SubTab . Settings , SettingsTitle , tab ) ;
295
289
}
290
+
296
291
if ( EditorGUI . EndChangeCheck ( ) )
297
292
{
298
- var from = ActiveTab ;
293
+ var from = ActiveView ;
299
294
activeTab = tab ;
300
- SwitchView ( from , ActiveTab ) ;
295
+ SwitchView ( from , ActiveView ) ;
301
296
}
302
297
303
298
GUILayout . FlexibleSpace ( ) ;
@@ -369,27 +364,32 @@ private static SubTab TabButton(SubTab tab, string title, SubTab activeTab)
369
364
return GUILayout . Toggle ( activeTab == tab , title , EditorStyles . toolbarButton ) ? tab : activeTab ;
370
365
}
371
366
372
- public HistoryView HistoryTab
367
+ public HistoryView HistoryView
373
368
{
374
- get { return historyTab ; }
369
+ get { return historyView ; }
375
370
}
376
371
377
- public ChangesView ChangesTab
372
+ public ChangesView ChangesView
378
373
{
379
- get { return changesTab ; }
374
+ get { return changesView ; }
380
375
}
381
376
382
- public BranchesView BranchesTab
377
+ public BranchesView BranchesView
383
378
{
384
- get { return branchesTab ; }
379
+ get { return branchesView ; }
385
380
}
386
381
387
- public SettingsView SettingsTab
382
+ public SettingsView SettingsView
388
383
{
389
- get { return settingsTab ; }
384
+ get { return settingsView ; }
390
385
}
391
386
392
- private Subview ActiveTab
387
+ public InitProjectView InitProjectView
388
+ {
389
+ get { return InitProjectView ; }
390
+ }
391
+
392
+ private Subview ActiveView
393
393
{
394
394
get
395
395
{
@@ -401,20 +401,29 @@ private Subview ToView(SubTab tab)
401
401
{
402
402
switch ( tab )
403
403
{
404
+ case SubTab . InitProject :
405
+ return initProjectView ;
406
+
404
407
case SubTab . History :
405
- return historyTab ;
408
+ return historyView ;
409
+
406
410
case SubTab . Changes :
407
- return changesTab ;
411
+ return changesView ;
412
+
408
413
case SubTab . Branches :
409
- return branchesTab ;
414
+ return branchesView ;
415
+
410
416
case SubTab . Settings :
417
+ return settingsView ;
418
+
411
419
default :
412
- return settingsTab ;
420
+ throw new ArgumentOutOfRangeException ( ) ;
413
421
}
414
422
}
415
423
416
424
private enum SubTab
417
425
{
426
+ InitProject ,
418
427
History ,
419
428
Changes ,
420
429
Branches ,
0 commit comments