@@ -45,6 +45,7 @@ class BranchesView : Subview
4545 [ SerializeField ] private string newBranchName ;
4646 [ SerializeField ] private Vector2 scroll ;
4747 [ SerializeField ] private bool disableDelete ;
48+ [ SerializeField ] private bool disableCreate ;
4849
4950 [ SerializeField ] private CacheUpdateEvent lastLocalAndRemoteBranchListChangedEvent ;
5051 [ NonSerialized ] private bool localAndRemoteBranchListHasUpdate ;
@@ -102,6 +103,7 @@ private void MaybeUpdateData()
102103 }
103104
104105 disableDelete = treeLocals . SelectedNode == null || treeLocals . SelectedNode . IsFolder || treeLocals . SelectedNode . IsActive ;
106+ disableCreate = treeLocals . SelectedNode == null || treeLocals . SelectedNode . IsFolder || treeLocals . SelectedNode . Level == 0 ;
105107 }
106108
107109 public override void OnGUI ( )
@@ -134,6 +136,16 @@ private void Render()
134136 OnTreeGUI ( new Rect ( 0f , 0f , Position . width , Position . height - rect . height + Styles . CommitAreaPadding ) ) ;
135137 }
136138 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+ }
137149 }
138150
139151 private void BuildTree ( )
@@ -186,10 +198,14 @@ private void OnButtonBarGUI()
186198
187199 // Create button
188200 GUILayout . FlexibleSpace ( ) ;
189- if ( GUILayout . Button ( CreateBranchButton , EditorStyles . miniButton , GUILayout . ExpandWidth ( false ) ) )
201+ EditorGUI . BeginDisabledGroup ( disableCreate ) ;
190202 {
191- targetMode = BranchesMode . Create ;
203+ if ( GUILayout . Button ( CreateBranchButton , EditorStyles . miniButton , GUILayout . ExpandWidth ( false ) ) )
204+ {
205+ targetMode = BranchesMode . Create ;
206+ }
192207 }
208+ EditorGUI . EndDisabledGroup ( ) ;
193209 }
194210 // Branch name + cancel + create
195211 else if ( mode == BranchesMode . Create )
0 commit comments