Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/ChangesView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
{
Expand Down Expand Up @@ -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;
Expand All @@ -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; }
Expand Down
23 changes: 20 additions & 3 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public abstract class Tree<TNode, TData>: TreeBase<TNode, TData>
[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; }
Expand Down Expand Up @@ -75,7 +76,7 @@ public Rect Render(Rect treeDisplayRect, Vector2 scroll, Action<TNode> 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)
Expand Down Expand Up @@ -109,7 +110,7 @@ public Rect Render(Rect treeDisplayRect, Vector2 scroll, Action<TNode> 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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -500,6 +512,11 @@ public TreeNodeRenderResult Render(Rect rect, float indentation, bool isSelected
GUI.DrawTexture(statusRect, IconBadge);
}

if (treeIsBusy)
{
GUI.enabled = true;
}

return renderResult;
}

Expand Down