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
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
16 changes: 2 additions & 14 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class BranchesView : Subview
[NonSerialized] private int listID = -1;
[NonSerialized] private BranchesMode targetMode;

[SerializeField] private BranchesTree treeLocals;
[SerializeField] private BranchesTree treeRemotes;
[SerializeField] private BranchesTree treeLocals = new BranchesTree { Title = LocalTitle };
[SerializeField] private BranchesTree treeRemotes = new BranchesTree { Title = RemoteTitle, IsRemote = true };
[SerializeField] private BranchesMode mode = BranchesMode.Default;
[SerializeField] private string newBranchName;
[SerializeField] private Vector2 scroll;
Expand Down Expand Up @@ -155,18 +155,6 @@ private void Render()

private void BuildTree()
{
if (treeLocals == null)
{
treeLocals = new BranchesTree();
treeLocals.Title = LocalTitle;

treeRemotes = new BranchesTree();
treeRemotes.Title = RemoteTitle;
treeRemotes.IsRemote = true;

TreeOnEnable();
}

localBranches.Sort(CompareBranches);
remoteBranches.Sort(CompareBranches);

Expand Down
14 changes: 2 additions & 12 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/ChangesView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ChangesView : Subview
[SerializeField] private string currentBranch = "[unknown]";

[SerializeField] private Vector2 treeScroll;
[SerializeField] private ChangesTree treeChanges;
[SerializeField] private ChangesTree treeChanges = new ChangesTree { DisplayRootNode = false, IsCheckable = true };

[SerializeField] private HashSet<string> gitLocks;
[SerializeField] private List<GitStatusEntry> gitStatusEntries;
Expand Down Expand Up @@ -212,17 +212,7 @@ private void MaybeUpdateData()

private void BuildTree()
{
if (treeChanges == null)
{
treeChanges = new ChangesTree();
treeChanges.Title = "Changes";
treeChanges.DisplayRootNode = false;
treeChanges.IsCheckable = true;
treeChanges.PathSeparator = Environment.FileSystem.DirectorySeparatorChar.ToString();

TreeOnEnable();
}

treeChanges.PathSeparator = Environment.FileSystem.DirectorySeparatorChar.ToString();
treeChanges.Load(gitStatusEntries.Select(entry => new GitStatusEntryTreeData(entry, gitLocks.Contains(entry.Path))));
Redraw();
}
Expand Down
54 changes: 47 additions & 7 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/HistoryView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ class HistoryView : Subview

[SerializeField] private int statusAhead;
[SerializeField] private int statusBehind;

[SerializeField] private ChangesTree treeChanges = new ChangesTree { IsSelectable = false, DisplayRootNode = false };

[SerializeField] private CacheUpdateEvent lastCurrentRemoteChangedEvent;
[SerializeField] private CacheUpdateEvent lastLogChangedEvent;
Expand All @@ -349,6 +351,7 @@ class HistoryView : Subview
public override void OnEnable()
{
base.OnEnable();
TreeOnEnable();
AttachHandlers(Repository);

if (Repository != null)
Expand All @@ -372,11 +375,6 @@ public override void OnDataUpdate()
}

public override void OnGUI()
{
OnEmbeddedGUI();
}

public void OnEmbeddedGUI()
{
// History toolbar
GUILayout.BeginHorizontal(EditorStyles.toolbar);
Expand Down Expand Up @@ -448,6 +446,7 @@ public void OnEmbeddedGUI()
var requiresRepaint = historyControl.Render(historyControlRect,
entry => {
selectedEntry = entry;
BuildTree();
},
entry => { },
entry => { });
Expand Down Expand Up @@ -482,10 +481,35 @@ public void OnEmbeddedGUI()
GUILayout.Label("Files changed", EditorStyles.boldLabel);
GUILayout.Space(-5);

rect = GUILayoutUtility.GetLastRect();
GUILayout.BeginHorizontal(Styles.HistoryFileTreeBoxStyle);
GUILayout.BeginVertical();
{
//changesetTree.OnGUI();
var borderLeft = Styles.Label.margin.left;
var treeControlRect = new Rect(rect.x + borderLeft, rect.y, Position.width - borderLeft * 2, Position.height - rect.height + Styles.CommitAreaPadding);
var treeRect = Rect.zero;
if (treeChanges != null)
{
treeChanges.FolderStyle = Styles.Foldout;
treeChanges.TreeNodeStyle = Styles.TreeNode;
treeChanges.ActiveTreeNodeStyle = Styles.ActiveTreeNode;
treeChanges.FocusedTreeNodeStyle = Styles.FocusedTreeNode;
treeChanges.FocusedActiveTreeNodeStyle = Styles.FocusedActiveTreeNode;

treeRect = treeChanges.Render(treeControlRect, detailsScroll,
node => { },
node => {
},
node => {
});

if (treeChanges.RequiresRepaint)
Redraw();
}

GUILayout.Space(treeRect.y - treeControlRect.y);
}
GUILayout.EndVertical();
GUILayout.EndHorizontal();

GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
Expand All @@ -497,7 +521,7 @@ public void OnEmbeddedGUI()
private void HistoryDetailsEntry(GitLogEntry entry)
{
GUILayout.BeginVertical(Styles.HeaderBoxStyle);
GUILayout.Label(entry.Summary, Styles.HistoryDetailsTitleStyle, GUILayout.Width(Position.width));
GUILayout.Label(entry.Summary, Styles.HistoryDetailsTitleStyle);

GUILayout.Space(-5);

Expand Down Expand Up @@ -690,6 +714,22 @@ private void Fetch()
.Start();
}

private void BuildTree()
{
treeChanges.PathSeparator = Environment.FileSystem.DirectorySeparatorChar.ToString();
treeChanges.Load(selectedEntry.changes.Select(entry => new GitStatusEntryTreeData(entry)));
Redraw();
}

private void TreeOnEnable()
{
if (treeChanges != null)
{
treeChanges.OnEnable();
treeChanges.UpdateIcons(Styles.FolderIcon);
}
}

public override bool IsBusy
{
get { return false; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public TreeNodeRenderResult Render(Rect rect, float indentation, bool isSelected
return renderResult;

var fillRect = rect;
var nodeStartX = Level * indentation;
var nodeStartX = Level * indentation + rect.x;
nodeStartX += 2 * level;

var nodeRect = new Rect(nodeStartX, rect.y, fillRect.width - nodeStartX, rect.height);
Expand Down