Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 098ad7a

Browse files
Merge branch 'enhancements/history-detail-tree-view' into fixes/global-selection-abuse
2 parents 4af80f7 + b4d23e1 commit 098ad7a

File tree

5 files changed

+428
-373
lines changed

5 files changed

+428
-373
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Styles
6464
headerDescriptionStyle,
6565
historyToolbarButtonStyle,
6666
historyLockStyle,
67+
historyEntrySummaryStyle,
6768
historyEntryDetailsStyle,
6869
historyEntryDetailsRightStyle,
6970
historyFileTreeBoxStyle,
@@ -396,6 +397,20 @@ public static GUIStyle HistoryLockStyle
396397
return historyLockStyle;
397398
}
398399
}
400+
public static GUIStyle HistoryEntrySummaryStyle
401+
{
402+
get
403+
{
404+
if (historyEntrySummaryStyle == null)
405+
{
406+
historyEntrySummaryStyle = new GUIStyle(Label);
407+
historyEntrySummaryStyle.name = "HistoryEntrySummaryStyle";
408+
409+
historyEntrySummaryStyle.contentOffset = new Vector2(BaseSpacing * 2, 0);
410+
}
411+
return historyEntrySummaryStyle;
412+
}
413+
}
399414

400415
public static GUIStyle HistoryEntryDetailsStyle
401416
{
@@ -412,6 +427,8 @@ public static GUIStyle HistoryEntryDetailsStyle
412427
historyEntryDetailsStyle.onNormal.textColor = Label.onNormal.textColor;
413428
historyEntryDetailsStyle.onFocused.background = Label.onFocused.background;
414429
historyEntryDetailsStyle.onFocused.textColor = Label.onFocused.textColor;
430+
431+
historyEntryDetailsStyle.contentOffset = new Vector2(BaseSpacing * 2, 0);
415432
}
416433
return historyEntryDetailsStyle;
417434
}

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class BranchesView : Subview
3939
[NonSerialized] private int listID = -1;
4040
[NonSerialized] private BranchesMode targetMode;
4141

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

156156
private void BuildTree()
157157
{
158-
if (treeLocals == null)
159-
{
160-
treeLocals = new BranchesTree();
161-
treeLocals.Title = LocalTitle;
162-
163-
treeRemotes = new BranchesTree();
164-
treeRemotes.Title = RemoteTitle;
165-
treeRemotes.IsRemote = true;
166-
167-
TreeOnEnable();
168-
}
169-
170158
localBranches.Sort(CompareBranches);
171159
remoteBranches.Sort(CompareBranches);
172160

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/ChangesView.cs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@ class ChangesView : Subview
2626
[SerializeField] private string commitBody = "";
2727
[SerializeField] private string commitMessage = "";
2828
[SerializeField] private string currentBranch = "[unknown]";
29-
[SerializeField] private Vector2 scroll;
30-
[SerializeField] private CacheUpdateEvent lastCurrentBranchChangedEvent;
31-
[SerializeField] private CacheUpdateEvent lastStatusEntriesChangedEvent;
32-
[SerializeField] private CacheUpdateEvent lastLocksChangedEvent;
33-
[SerializeField] private ChangesTree treeChanges;
29+
30+
[SerializeField] private Vector2 treeScroll;
31+
[SerializeField] private ChangesTree treeChanges = new ChangesTree { DisplayRootNode = false, IsCheckable = true };
32+
3433
[SerializeField] private HashSet<string> gitLocks;
3534
[SerializeField] private List<GitStatusEntry> gitStatusEntries;
35+
3636
[SerializeField] private string changedFilesText = NoChangedFilesLabel;
3737

38+
[SerializeField] private CacheUpdateEvent lastCurrentBranchChangedEvent;
39+
[SerializeField] private CacheUpdateEvent lastStatusEntriesChangedEvent;
40+
[SerializeField] private CacheUpdateEvent lastLocksChangedEvent;
41+
3842
public override void OnEnable()
3943
{
4044
base.OnEnable();
@@ -85,7 +89,7 @@ public override void OnGUI()
8589
GUILayout.BeginHorizontal();
8690
GUILayout.BeginVertical(Styles.CommitFileAreaStyle);
8791
{
88-
scroll = GUILayout.BeginScrollView(scroll);
92+
treeScroll = GUILayout.BeginScrollView(treeScroll);
8993
{
9094
OnTreeGUI(new Rect(0f, 0f, Position.width, Position.height - rect.height + Styles.CommitAreaPadding));
9195
}
@@ -114,7 +118,7 @@ private void OnTreeGUI(Rect rect)
114118
treeChanges.FocusedTreeNodeStyle = Styles.FocusedTreeNode;
115119
treeChanges.FocusedActiveTreeNodeStyle = Styles.FocusedActiveTreeNode;
116120

117-
var treeRenderRect = treeChanges.Render(rect, scroll,
121+
var treeRenderRect = treeChanges.Render(rect, treeScroll,
118122
node => { },
119123
node => { },
120124
node => { });
@@ -208,17 +212,7 @@ private void MaybeUpdateData()
208212

209213
private void BuildTree()
210214
{
211-
if (treeChanges == null)
212-
{
213-
treeChanges = new ChangesTree();
214-
treeChanges.Title = "Changes";
215-
treeChanges.DisplayRootNode = false;
216-
treeChanges.IsCheckable = true;
217-
treeChanges.PathSeparator = Environment.FileSystem.DirectorySeparatorChar.ToString();
218-
219-
TreeOnEnable();
220-
}
221-
215+
treeChanges.PathSeparator = Environment.FileSystem.DirectorySeparatorChar.ToString();
222216
treeChanges.Load(gitStatusEntries.Select(entry => new GitStatusEntryTreeData(entry, gitLocks.Contains(entry.Path))));
223217
Redraw();
224218
}

0 commit comments

Comments
 (0)