From aa9cdeb10dfd71bcd16d70aa899c194c358883b6 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Thu, 14 Dec 2017 13:58:20 -0500 Subject: [PATCH 1/2] Disabling the tree when it is busy --- .../Editor/GitHub.Unity/UI/ChangesView.cs | 12 ++++++--- .../Editor/GitHub.Unity/UI/TreeControl.cs | 25 ++++++++++++++++--- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/ChangesView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/ChangesView.cs index 6603c035c..0acdfb56b 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/ChangesView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/ChangesView.cs @@ -264,7 +264,7 @@ private void OnCommitDetailsAreaGUI() GUILayout.Space(Styles.CommitAreaPadding); // Disable committing when already committing or if we don't have all the data needed - EditorGUI.BeginDisabledGroup(isBusy || string.IsNullOrEmpty(commitMessage) || !treeChanges.GetCheckedFiles().Any()); + EditorGUI.BeginDisabledGroup(IsBusy || string.IsNullOrEmpty(commitMessage) || !treeChanges.GetCheckedFiles().Any()); { GUILayout.BeginHorizontal(); { @@ -301,7 +301,7 @@ private void SelectNone() private void Commit() { // Do not allow new commits before we have received one successful update - isBusy = true; + SetBusy(true); var files = treeChanges.GetCheckedFiles().ToList(); ITask addTask; @@ -320,10 +320,16 @@ private void Commit() { commitMessage = ""; commitBody = ""; - isBusy = false; + SetBusy(false); }).Start(); } + private void SetBusy(bool value) + { + treeChanges.IsBusy = value; + isBusy = value; + } + public override bool IsBusy { get { return isBusy; } diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs index f3710516f..63d242d05 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs @@ -28,6 +28,7 @@ public abstract class Tree: TreeBase [NonSerialized] private TNode rightClickNextRenderNode; [NonSerialized] private int controlId; + [NonSerialized] private bool isBusy; public bool IsInitialized { get { return Nodes != null && Nodes.Count > 0 && !String.IsNullOrEmpty(Nodes[0].Path); } } public bool RequiresRepaint { get; private set; } @@ -75,7 +76,7 @@ public Rect Render(Rect treeDisplayRect, Vector2 scroll, Action singleCli if (titleDisplay) { var isSelected = SelectedNode != null && SelectedNode.Path == titleNode.Path; - renderResult = titleNode.Render(rect, Styles.TreeIndentation, isSelected, FolderStyle, treeNodeStyle, activeTreeNodeStyle); + renderResult = titleNode.Render(rect, Styles.TreeIndentation, isSelected, IsBusy, FolderStyle, treeNodeStyle, activeTreeNodeStyle); } if (renderResult == TreeNodeRenderResult.VisibilityChange) @@ -109,7 +110,7 @@ public Rect Render(Rect treeDisplayRect, Vector2 scroll, Action singleCli if (display) { var isSelected = SelectedNode != null && SelectedNode.Path == node.Path; - renderResult = node.Render(rect, Styles.TreeIndentation, isSelected, FolderStyle, treeNodeStyle, activeTreeNodeStyle); + renderResult = node.Render(rect, Styles.TreeIndentation, isSelected, IsBusy, FolderStyle, treeNodeStyle, activeTreeNodeStyle); } if (renderResult == TreeNodeRenderResult.VisibilityChange) @@ -153,6 +154,12 @@ protected bool TreeHasFocus public abstract bool ViewHasFocus { get; set; } + public bool IsBusy + { + get { return isBusy; } + set { isBusy = value; } + } + public void Focus() { bool selectionChanged = false; @@ -406,10 +413,15 @@ public void Load() content = new GUIContent(Label, Icon); } - public TreeNodeRenderResult Render(Rect rect, float indentation, bool isSelected, GUIStyle toggleStyle, GUIStyle nodeStyle, GUIStyle activeNodeStyle) + public TreeNodeRenderResult Render(Rect rect, float indentation, bool isSelected, bool treeIsBusy, GUIStyle toggleStyle, GUIStyle nodeStyle, GUIStyle activeNodeStyle) { var renderResult = TreeNodeRenderResult.None; + if (treeIsBusy) + { + GUI.enabled = false; + } + if (IsHidden) return renderResult; @@ -453,7 +465,7 @@ public TreeNodeRenderResult Render(Rect rect, float indentation, bool isSelected if (Event.current.type == EventType.repaint) { - toggleStyle.Draw(toggleRect, GUIContent.none, false, false, styleOn, isSelected); + toggleStyle.Draw(toggleRect, GUIContent.none, isHover: false, isActive: false, @on: styleOn, hasKeyboardFocus: isSelected); } EditorGUI.BeginChangeCheck(); @@ -500,6 +512,11 @@ public TreeNodeRenderResult Render(Rect rect, float indentation, bool isSelected GUI.DrawTexture(statusRect, IconBadge); } + if (treeIsBusy) + { + GUI.enabled = true; + } + return renderResult; } From 1858a98cea0c26a588fbad24dbe6587689addb8c Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Thu, 14 Dec 2017 15:08:31 -0500 Subject: [PATCH 2/2] Undoing a code edit --- src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs index 63d242d05..22710594a 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs @@ -465,7 +465,7 @@ public TreeNodeRenderResult Render(Rect rect, float indentation, bool isSelected if (Event.current.type == EventType.repaint) { - toggleStyle.Draw(toggleRect, GUIContent.none, isHover: false, isActive: false, @on: styleOn, hasKeyboardFocus: isSelected); + toggleStyle.Draw(toggleRect, GUIContent.none, false, false, styleOn, isSelected); } EditorGUI.BeginChangeCheck();