@@ -26,10 +26,10 @@ class Window : BaseWindow
26
26
[ NonSerialized ] private double notificationClearTime = - 1 ;
27
27
28
28
[ SerializeField ] private SubTab activeTab = SubTab . History ;
29
- [ SerializeField ] private BranchesView branchesTab = new BranchesView ( ) ;
30
- [ SerializeField ] private ChangesView changesTab = new ChangesView ( ) ;
31
- [ SerializeField ] private HistoryView historyTab = new HistoryView ( ) ;
32
- [ SerializeField ] private SettingsView settingsTab = new SettingsView ( ) ;
29
+ [ SerializeField ] private BranchesView branchesView = new BranchesView ( ) ;
30
+ [ SerializeField ] private ChangesView changesView = new ChangesView ( ) ;
31
+ [ SerializeField ] private HistoryView historyView = new HistoryView ( ) ;
32
+ [ SerializeField ] private SettingsView settingsView = new SettingsView ( ) ;
33
33
34
34
[ SerializeField ] private string repoBranch ;
35
35
[ SerializeField ] private string repoUrl ;
@@ -71,10 +71,10 @@ public override void Initialize(IApplicationManager applicationManager)
71
71
{
72
72
base . Initialize ( applicationManager ) ;
73
73
74
- HistoryTab . InitializeView ( this ) ;
75
- ChangesTab . InitializeView ( this ) ;
76
- BranchesTab . InitializeView ( this ) ;
77
- SettingsTab . InitializeView ( this ) ;
74
+ HistoryView . InitializeView ( this ) ;
75
+ ChangesView . InitializeView ( this ) ;
76
+ BranchesView . InitializeView ( this ) ;
77
+ SettingsView . InitializeView ( this ) ;
78
78
}
79
79
80
80
public override void OnEnable ( )
@@ -88,15 +88,15 @@ public override void OnEnable()
88
88
// Set window title
89
89
titleContent = new GUIContent ( Title , Styles . SmallLogo ) ;
90
90
91
- if ( ActiveTab != null )
92
- ActiveTab . OnEnable ( ) ;
91
+ if ( ActiveView != null )
92
+ ActiveView . OnEnable ( ) ;
93
93
}
94
94
95
95
public override void OnDisable ( )
96
96
{
97
97
base . OnDisable ( ) ;
98
- if ( ActiveTab != null )
99
- ActiveTab . OnDisable ( ) ;
98
+ if ( ActiveView != null )
99
+ ActiveView . OnDisable ( ) ;
100
100
}
101
101
102
102
public override void OnDataUpdate ( )
@@ -117,8 +117,8 @@ public override void OnDataUpdate()
117
117
}
118
118
}
119
119
120
- if ( ActiveTab != null )
121
- ActiveTab . OnDataUpdate ( ) ;
120
+ if ( ActiveView != null )
121
+ ActiveView . OnDataUpdate ( ) ;
122
122
}
123
123
124
124
public override void OnRepositoryChanged ( IRepository oldRepository )
@@ -128,22 +128,22 @@ public override void OnRepositoryChanged(IRepository oldRepository)
128
128
DetachHandlers ( oldRepository ) ;
129
129
AttachHandlers ( Repository ) ;
130
130
131
- if ( ActiveTab != null )
132
- ActiveTab . OnRepositoryChanged ( oldRepository ) ;
131
+ if ( ActiveView != null )
132
+ ActiveView . OnRepositoryChanged ( oldRepository ) ;
133
133
}
134
134
135
135
public override void OnSelectionChange ( )
136
136
{
137
137
base . OnSelectionChange ( ) ;
138
- if ( ActiveTab != null )
139
- ActiveTab . OnSelectionChange ( ) ;
138
+ if ( ActiveView != null )
139
+ ActiveView . OnSelectionChange ( ) ;
140
140
}
141
141
142
142
public override void Refresh ( )
143
143
{
144
144
base . Refresh ( ) ;
145
- if ( ActiveTab != null )
146
- ActiveTab . Refresh ( ) ;
145
+ if ( ActiveView != null )
146
+ ActiveView . Refresh ( ) ;
147
147
Repaint ( ) ;
148
148
}
149
149
@@ -159,9 +159,9 @@ public override void OnUI()
159
159
DoToolbarGUI ( ) ;
160
160
161
161
// GUI for the active tab
162
- if ( ActiveTab != null )
162
+ if ( ActiveView != null )
163
163
{
164
- ActiveTab . OnGUI ( ) ;
164
+ ActiveView . OnGUI ( ) ;
165
165
}
166
166
}
167
167
@@ -238,16 +238,6 @@ private void DetachHandlers(IRepository repository)
238
238
repository . OnRepositoryInfoChanged -= RefreshOnMainThread ;
239
239
}
240
240
241
-
242
- private void SwitchView ( Subview from , Subview to )
243
- {
244
- GUI . FocusControl ( null ) ;
245
- if ( from != null )
246
- from . OnDisable ( ) ;
247
- to . OnEnable ( ) ;
248
- Refresh ( ) ;
249
- }
250
-
251
241
private void DoHeaderGUI ( )
252
242
{
253
243
GUILayout . BeginHorizontal ( Styles . HeaderBoxStyle ) ;
@@ -278,26 +268,25 @@ private void DoToolbarGUI()
278
268
// Subtabs & toolbar
279
269
Rect mainNavRect = EditorGUILayout . BeginHorizontal ( EditorStyles . toolbar ) ;
280
270
{
281
- SubTab tab = activeTab ;
271
+ SubTab changeTab = activeTab ;
282
272
EditorGUI . BeginChangeCheck ( ) ;
283
273
{
284
274
if ( HasRepository )
285
275
{
286
- tab = TabButton ( SubTab . Changes , ChangesTitle , tab ) ;
287
- tab = TabButton ( SubTab . History , HistoryTitle , tab ) ;
288
- tab = TabButton ( SubTab . Branches , BranchesTitle , tab ) ;
276
+ changeTab = TabButton ( SubTab . Changes , ChangesTitle , changeTab ) ;
277
+ changeTab = TabButton ( SubTab . History , HistoryTitle , changeTab ) ;
278
+ changeTab = TabButton ( SubTab . Branches , BranchesTitle , changeTab ) ;
289
279
}
290
280
else
291
281
{
292
- tab = TabButton ( SubTab . History , HistoryTitle , tab ) ;
282
+ changeTab = TabButton ( SubTab . History , HistoryTitle , changeTab ) ;
293
283
}
294
- tab = TabButton ( SubTab . Settings , SettingsTitle , tab ) ;
284
+ changeTab = TabButton ( SubTab . Settings , SettingsTitle , changeTab ) ;
295
285
}
286
+
296
287
if ( EditorGUI . EndChangeCheck ( ) )
297
288
{
298
- var from = ActiveTab ;
299
- activeTab = tab ;
300
- SwitchView ( from , ActiveTab ) ;
289
+ SetActiveTab ( changeTab ) ;
301
290
}
302
291
303
292
GUILayout . FlexibleSpace ( ) ;
@@ -308,6 +297,28 @@ private void DoToolbarGUI()
308
297
EditorGUILayout . EndHorizontal ( ) ;
309
298
}
310
299
300
+ private void SetActiveTab ( SubTab changeTab )
301
+ {
302
+ if ( changeTab != activeTab )
303
+ {
304
+ var fromView = ActiveView ;
305
+ activeTab = changeTab ;
306
+ SwitchView ( fromView , ActiveView ) ;
307
+ }
308
+ }
309
+
310
+ private void SwitchView ( Subview fromView , Subview toView )
311
+ {
312
+ GUI . FocusControl ( null ) ;
313
+
314
+ if ( fromView != null )
315
+ fromView . OnDisable ( ) ;
316
+
317
+ toView . OnEnable ( ) ;
318
+
319
+ Refresh ( ) ;
320
+ }
321
+
311
322
private void DoAccountDropdown ( )
312
323
{
313
324
GenericMenu accountMenu = new GenericMenu ( ) ;
@@ -369,27 +380,27 @@ private static SubTab TabButton(SubTab tab, string title, SubTab activeTab)
369
380
return GUILayout . Toggle ( activeTab == tab , title , EditorStyles . toolbarButton ) ? tab : activeTab ;
370
381
}
371
382
372
- public HistoryView HistoryTab
383
+ public HistoryView HistoryView
373
384
{
374
- get { return historyTab ; }
385
+ get { return historyView ; }
375
386
}
376
387
377
- public ChangesView ChangesTab
388
+ public ChangesView ChangesView
378
389
{
379
- get { return changesTab ; }
390
+ get { return changesView ; }
380
391
}
381
392
382
- public BranchesView BranchesTab
393
+ public BranchesView BranchesView
383
394
{
384
- get { return branchesTab ; }
395
+ get { return branchesView ; }
385
396
}
386
397
387
- public SettingsView SettingsTab
398
+ public SettingsView SettingsView
388
399
{
389
- get { return settingsTab ; }
400
+ get { return settingsView ; }
390
401
}
391
402
392
- private Subview ActiveTab
403
+ private Subview ActiveView
393
404
{
394
405
get
395
406
{
@@ -402,14 +413,14 @@ private Subview ToView(SubTab tab)
402
413
switch ( tab )
403
414
{
404
415
case SubTab . History :
405
- return historyTab ;
416
+ return historyView ;
406
417
case SubTab . Changes :
407
- return changesTab ;
418
+ return changesView ;
408
419
case SubTab . Branches :
409
- return branchesTab ;
420
+ return branchesView ;
410
421
case SubTab . Settings :
411
422
default :
412
- return settingsTab ;
423
+ return settingsView ;
413
424
}
414
425
}
415
426
0 commit comments