@@ -45,6 +45,7 @@ class BranchesView : Subview
45
45
[ SerializeField ] private string newBranchName ;
46
46
[ SerializeField ] private Vector2 scroll ;
47
47
[ SerializeField ] private bool disableDelete ;
48
+ [ SerializeField ] private bool disableCreate ;
48
49
49
50
[ SerializeField ] private CacheUpdateEvent lastLocalAndRemoteBranchListChangedEvent ;
50
51
[ NonSerialized ] private bool localAndRemoteBranchListHasUpdate ;
@@ -102,6 +103,7 @@ private void MaybeUpdateData()
102
103
}
103
104
104
105
disableDelete = treeLocals . SelectedNode == null || treeLocals . SelectedNode . IsFolder || treeLocals . SelectedNode . IsActive ;
106
+ disableCreate = treeLocals . SelectedNode == null || treeLocals . SelectedNode . IsFolder || treeLocals . SelectedNode . Level == 0 ;
105
107
}
106
108
107
109
public override void OnGUI ( )
@@ -134,6 +136,16 @@ private void Render()
134
136
OnTreeGUI ( new Rect ( 0f , 0f , Position . width , Position . height - rect . height + Styles . CommitAreaPadding ) ) ;
135
137
}
136
138
GUILayout . EndScrollView ( ) ;
139
+
140
+ if ( Event . current . type == EventType . Repaint )
141
+ {
142
+ // Effectuating mode switch
143
+ if ( mode != targetMode )
144
+ {
145
+ mode = targetMode ;
146
+ Redraw ( ) ;
147
+ }
148
+ }
137
149
}
138
150
139
151
private void BuildTree ( )
@@ -186,10 +198,14 @@ private void OnButtonBarGUI()
186
198
187
199
// Create button
188
200
GUILayout . FlexibleSpace ( ) ;
189
- if ( GUILayout . Button ( CreateBranchButton , EditorStyles . miniButton , GUILayout . ExpandWidth ( false ) ) )
201
+ EditorGUI . BeginDisabledGroup ( disableCreate ) ;
190
202
{
191
- targetMode = BranchesMode . Create ;
203
+ if ( GUILayout . Button ( CreateBranchButton , EditorStyles . miniButton , GUILayout . ExpandWidth ( false ) ) )
204
+ {
205
+ targetMode = BranchesMode . Create ;
206
+ }
192
207
}
208
+ EditorGUI . EndDisabledGroup ( ) ;
193
209
}
194
210
// Branch name + cancel + create
195
211
else if ( mode == BranchesMode . Create )
0 commit comments