@@ -25,7 +25,7 @@ class Window : BaseWindow
25
25
private const string Window_RepoBranchTooltip = "Active branch" ;
26
26
27
27
[ NonSerialized ] private double notificationClearTime = - 1 ;
28
- [ SerializeField ] private SubTab nextTab = SubTab . History ;
28
+ [ SerializeField ] private SubTab changeTab = SubTab . History ;
29
29
[ SerializeField ] private SubTab activeTab = SubTab . History ;
30
30
[ SerializeField ] private InitProjectView initProjectView = new InitProjectView ( ) ;
31
31
[ SerializeField ] private BranchesView branchesView = new BranchesView ( ) ;
@@ -73,6 +73,9 @@ public override void Initialize(IApplicationManager applicationManager)
73
73
{
74
74
base . Initialize ( applicationManager ) ;
75
75
76
+ if ( ! HasRepository && activeTab != SubTab . InitProject && activeTab != SubTab . Settings )
77
+ changeTab = activeTab = SubTab . InitProject ;
78
+
76
79
HistoryView . InitializeView ( this ) ;
77
80
ChangesView . InitializeView ( this ) ;
78
81
BranchesView . InitializeView ( this ) ;
@@ -120,21 +123,6 @@ public override void OnDataUpdate()
120
123
}
121
124
}
122
125
123
- if ( nextTab != activeTab )
124
- {
125
- var fromView = ActiveView ;
126
- activeTab = nextTab ;
127
-
128
- GUI . FocusControl ( null ) ;
129
-
130
- if ( fromView != null )
131
- fromView . OnDisable ( ) ;
132
-
133
- ActiveView . OnEnable ( ) ;
134
-
135
- Refresh ( ) ;
136
- }
137
-
138
126
if ( ActiveView != null )
139
127
ActiveView . OnDataUpdate ( ) ;
140
128
}
@@ -146,8 +134,16 @@ public override void OnRepositoryChanged(IRepository oldRepository)
146
134
DetachHandlers ( oldRepository ) ;
147
135
AttachHandlers ( Repository ) ;
148
136
137
+ if ( Repository != null && activeTab == SubTab . InitProject )
138
+ {
139
+ changeTab = SubTab . History ;
140
+ }
141
+
142
+ UpdateActiveTab ( ) ;
143
+
149
144
if ( ActiveView != null )
150
145
ActiveView . OnRepositoryChanged ( oldRepository ) ;
146
+
151
147
}
152
148
153
149
public override void OnSelectionChange ( )
@@ -207,15 +203,6 @@ private bool MaybeUpdateData(out string repoRemote)
207
203
bool repoDataChanged = false ;
208
204
if ( Repository != null )
209
205
{
210
- if ( activeTab == SubTab . InitProject )
211
- {
212
- if ( nextTab == SubTab . InitProject )
213
- {
214
- nextTab = SubTab . History ;
215
- repoDataChanged = true ;
216
- }
217
- }
218
-
219
206
var currentBranchString = ( Repository . CurrentBranch . HasValue ? Repository . CurrentBranch . Value . Name : null ) ;
220
207
if ( repoBranch != currentBranchString )
221
208
{
@@ -235,15 +222,6 @@ private bool MaybeUpdateData(out string repoRemote)
235
222
}
236
223
else
237
224
{
238
- if ( ! ( activeTab == SubTab . InitProject || activeTab == SubTab . Settings ) )
239
- {
240
- if ( ! ( nextTab == SubTab . InitProject || activeTab == SubTab . Settings ) )
241
- {
242
- nextTab = SubTab . InitProject ;
243
- repoDataChanged = true ;
244
- }
245
- }
246
-
247
225
if ( repoBranch != null )
248
226
{
249
227
repoBranch = null ;
@@ -303,7 +281,7 @@ private void DoToolbarGUI()
303
281
// Subtabs & toolbar
304
282
Rect mainNavRect = EditorGUILayout . BeginHorizontal ( EditorStyles . toolbar ) ;
305
283
{
306
- SubTab changeTab = activeTab ;
284
+ changeTab = activeTab ;
307
285
EditorGUI . BeginChangeCheck ( ) ;
308
286
{
309
287
if ( HasRepository )
@@ -321,7 +299,7 @@ private void DoToolbarGUI()
321
299
322
300
if ( EditorGUI . EndChangeCheck ( ) )
323
301
{
324
- nextTab = changeTab ;
302
+ UpdateActiveTab ( ) ;
325
303
}
326
304
327
305
GUILayout . FlexibleSpace ( ) ;
@@ -332,6 +310,28 @@ private void DoToolbarGUI()
332
310
EditorGUILayout . EndHorizontal ( ) ;
333
311
}
334
312
313
+ private void UpdateActiveTab ( )
314
+ {
315
+ if ( changeTab != activeTab )
316
+ {
317
+ var fromView = ActiveView ;
318
+ activeTab = changeTab ;
319
+ SwitchView ( fromView , ActiveView ) ;
320
+ }
321
+ }
322
+
323
+ private void SwitchView ( Subview fromView , Subview toView )
324
+ {
325
+ GUI . FocusControl ( null ) ;
326
+
327
+ if ( fromView != null )
328
+ fromView . OnDisable ( ) ;
329
+ toView . OnEnable ( ) ;
330
+
331
+ // this triggers a repaint
332
+ Repaint ( ) ;
333
+ }
334
+
335
335
private void DoAccountDropdown ( )
336
336
{
337
337
GenericMenu accountMenu = new GenericMenu ( ) ;
@@ -393,6 +393,25 @@ private static SubTab TabButton(SubTab tab, string title, SubTab activeTab)
393
393
return GUILayout . Toggle ( activeTab == tab , title , EditorStyles . toolbarButton ) ? tab : activeTab ;
394
394
}
395
395
396
+ private Subview ToView ( SubTab tab )
397
+ {
398
+ switch ( tab )
399
+ {
400
+ case SubTab . InitProject :
401
+ return initProjectView ;
402
+ case SubTab . History :
403
+ return historyView ;
404
+ case SubTab . Changes :
405
+ return changesView ;
406
+ case SubTab . Branches :
407
+ return branchesView ;
408
+ case SubTab . Settings :
409
+ return settingsView ;
410
+ default :
411
+ throw new ArgumentOutOfRangeException ( ) ;
412
+ }
413
+ }
414
+
396
415
public HistoryView HistoryView
397
416
{
398
417
get { return historyView ; }
@@ -420,29 +439,7 @@ public InitProjectView InitProjectView
420
439
421
440
private Subview ActiveView
422
441
{
423
- get
424
- {
425
- return ToView ( activeTab ) ;
426
- }
427
- }
428
-
429
- private Subview ToView ( SubTab tab )
430
- {
431
- switch ( tab )
432
- {
433
- case SubTab . InitProject :
434
- return initProjectView ;
435
- case SubTab . History :
436
- return historyView ;
437
- case SubTab . Changes :
438
- return changesView ;
439
- case SubTab . Branches :
440
- return branchesView ;
441
- case SubTab . Settings :
442
- return settingsView ;
443
- default :
444
- throw new ArgumentOutOfRangeException ( ) ;
445
- }
442
+ get { return ToView ( activeTab ) ; }
446
443
}
447
444
448
445
public override bool IsBusy
@@ -452,6 +449,7 @@ public override bool IsBusy
452
449
453
450
private enum SubTab
454
451
{
452
+ None ,
455
453
InitProject ,
456
454
History ,
457
455
Changes ,
0 commit comments