@@ -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
@@ -234,16 +234,6 @@ private void DetachHandlers(IRepository repository)
234
234
repository . OnRepositoryInfoChanged -= RefreshOnMainThread ;
235
235
}
236
236
237
-
238
- private void SwitchView ( Subview from , Subview to )
239
- {
240
- GUI . FocusControl ( null ) ;
241
- if ( from != null )
242
- from . OnDisable ( ) ;
243
- to . OnEnable ( ) ;
244
- Refresh ( ) ;
245
- }
246
-
247
237
private void DoHeaderGUI ( )
248
238
{
249
239
GUILayout . BeginHorizontal ( Styles . HeaderBoxStyle ) ;
@@ -274,26 +264,25 @@ private void DoToolbarGUI()
274
264
// Subtabs & toolbar
275
265
Rect mainNavRect = EditorGUILayout . BeginHorizontal ( EditorStyles . toolbar ) ;
276
266
{
277
- SubTab tab = activeTab ;
267
+ SubTab changeTab = activeTab ;
278
268
EditorGUI . BeginChangeCheck ( ) ;
279
269
{
280
270
if ( HasRepository )
281
271
{
282
- tab = TabButton ( SubTab . Changes , ChangesTitle , tab ) ;
283
- tab = TabButton ( SubTab . History , HistoryTitle , tab ) ;
284
- tab = TabButton ( SubTab . Branches , BranchesTitle , tab ) ;
272
+ changeTab = TabButton ( SubTab . Changes , ChangesTitle , changeTab ) ;
273
+ changeTab = TabButton ( SubTab . History , HistoryTitle , changeTab ) ;
274
+ changeTab = TabButton ( SubTab . Branches , BranchesTitle , changeTab ) ;
285
275
}
286
276
else
287
277
{
288
- tab = TabButton ( SubTab . History , HistoryTitle , tab ) ;
278
+ changeTab = TabButton ( SubTab . History , HistoryTitle , changeTab ) ;
289
279
}
290
- tab = TabButton ( SubTab . Settings , SettingsTitle , tab ) ;
280
+ changeTab = TabButton ( SubTab . Settings , SettingsTitle , changeTab ) ;
291
281
}
282
+
292
283
if ( EditorGUI . EndChangeCheck ( ) )
293
284
{
294
- var from = ActiveTab ;
295
- activeTab = tab ;
296
- SwitchView ( from , ActiveTab ) ;
285
+ SetActiveTab ( changeTab ) ;
297
286
}
298
287
299
288
GUILayout . FlexibleSpace ( ) ;
@@ -304,6 +293,28 @@ private void DoToolbarGUI()
304
293
EditorGUILayout . EndHorizontal ( ) ;
305
294
}
306
295
296
+ private void SetActiveTab ( SubTab changeTab )
297
+ {
298
+ if ( changeTab != activeTab )
299
+ {
300
+ var fromView = ActiveView ;
301
+ activeTab = changeTab ;
302
+ SwitchView ( fromView , ActiveView ) ;
303
+ }
304
+ }
305
+
306
+ private void SwitchView ( Subview fromView , Subview toView )
307
+ {
308
+ GUI . FocusControl ( null ) ;
309
+
310
+ if ( fromView != null )
311
+ fromView . OnDisable ( ) ;
312
+
313
+ toView . OnEnable ( ) ;
314
+
315
+ Refresh ( ) ;
316
+ }
317
+
307
318
private void DoAccountDropdown ( )
308
319
{
309
320
GenericMenu accountMenu = new GenericMenu ( ) ;
@@ -365,27 +376,27 @@ private static SubTab TabButton(SubTab tab, string title, SubTab activeTab)
365
376
return GUILayout . Toggle ( activeTab == tab , title , EditorStyles . toolbarButton ) ? tab : activeTab ;
366
377
}
367
378
368
- public HistoryView HistoryTab
379
+ public HistoryView HistoryView
369
380
{
370
- get { return historyTab ; }
381
+ get { return historyView ; }
371
382
}
372
383
373
- public ChangesView ChangesTab
384
+ public ChangesView ChangesView
374
385
{
375
- get { return changesTab ; }
386
+ get { return changesView ; }
376
387
}
377
388
378
- public BranchesView BranchesTab
389
+ public BranchesView BranchesView
379
390
{
380
- get { return branchesTab ; }
391
+ get { return branchesView ; }
381
392
}
382
393
383
- public SettingsView SettingsTab
394
+ public SettingsView SettingsView
384
395
{
385
- get { return settingsTab ; }
396
+ get { return settingsView ; }
386
397
}
387
398
388
- private Subview ActiveTab
399
+ private Subview ActiveView
389
400
{
390
401
get
391
402
{
@@ -398,14 +409,14 @@ private Subview ToView(SubTab tab)
398
409
switch ( tab )
399
410
{
400
411
case SubTab . History :
401
- return historyTab ;
412
+ return historyView ;
402
413
case SubTab . Changes :
403
- return changesTab ;
414
+ return changesView ;
404
415
case SubTab . Branches :
405
- return branchesTab ;
416
+ return branchesView ;
406
417
case SubTab . Settings :
407
418
default :
408
- return settingsTab ;
419
+ return settingsView ;
409
420
}
410
421
}
411
422
0 commit comments