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

Commit 00ddff9

Browse files
Changes made after rebase
1 parent cc9d641 commit 00ddff9

File tree

2 files changed

+66
-28
lines changed

2 files changed

+66
-28
lines changed

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

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ChangesView : Subview
2828
[SerializeField] private Vector2 scroll;
2929
[SerializeField] private CacheUpdateEvent lastCurrentBranchChangedEvent;
3030
[SerializeField] private CacheUpdateEvent lastStatusChangedEvent;
31-
[SerializeField] private Tree treeChanges;
31+
[SerializeField] private ChangesTree treeChanges;
3232
[SerializeField] private List<GitStatusEntry> gitStatusEntries;
3333

3434
public override void OnEnable()
@@ -186,7 +186,7 @@ private void BuildTree()
186186
{
187187
if (treeChanges == null)
188188
{
189-
treeChanges = new Tree();
189+
treeChanges = new ChangesTree();
190190
treeChanges.DisplayRootNode = false;
191191
treeChanges.Checkable = true;
192192
treeChanges.PathIgnoreRoot = Environment.RepositoryPath + Environment.FileSystem.DirectorySeparatorChar;
@@ -201,26 +201,9 @@ private void BuildTree()
201201

202202
private void UpdateTreeIcons()
203203
{
204-
var loaded = false;
205-
206204
if (treeChanges != null)
207205
{
208-
if (treeChanges.NodeIcon == null)
209-
{
210-
loaded = true;
211-
treeChanges.NodeIcon = Styles.BranchIcon;
212-
}
213-
214-
if (treeChanges.FolderIcon == null)
215-
{
216-
loaded = true;
217-
treeChanges.FolderIcon = Styles.FolderIcon;
218-
}
219-
}
220-
221-
if (loaded)
222-
{
223-
treeChanges.LoadNodeIcons();
206+
treeChanges.UpdateIcons(Styles.ActiveBranchIcon, Styles.BranchIcon, Styles.FolderIcon, Styles.GlobeIcon);
224207
}
225208
}
226209

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

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,14 +561,19 @@ public override string ToString()
561561
}
562562

563563
[Serializable]
564-
public class BranchesTree: Tree
564+
public class BranchesTree : Tree
565565
{
566-
[SerializeField] public bool IsRemote;
567-
568-
[NonSerialized] public Texture2D ActiveBranchIcon;
569-
[NonSerialized] public Texture2D BranchIcon;
570-
[NonSerialized] public Texture2D FolderIcon;
571-
[NonSerialized] public Texture2D GlobeIcon;
566+
[SerializeField]
567+
public bool IsRemote;
568+
569+
[NonSerialized]
570+
public Texture2D ActiveBranchIcon;
571+
[NonSerialized]
572+
public Texture2D BranchIcon;
573+
[NonSerialized]
574+
public Texture2D FolderIcon;
575+
[NonSerialized]
576+
public Texture2D GlobeIcon;
572577

573578
protected override Texture2D GetNodeIcon(TreeNode node)
574579
{
@@ -605,7 +610,57 @@ public void UpdateIcons(Texture2D activeBranchIcon, Texture2D branchIcon, Textur
605610
}
606611
}
607612
}
608-
613+
[Serializable]
614+
public class ChangesTree : Tree
615+
{
616+
[SerializeField]
617+
public bool IsRemote;
618+
619+
[NonSerialized]
620+
public Texture2D ActiveBranchIcon;
621+
[NonSerialized]
622+
public Texture2D BranchIcon;
623+
[NonSerialized]
624+
public Texture2D FolderIcon;
625+
[NonSerialized]
626+
public Texture2D GlobeIcon;
627+
628+
protected override Texture2D GetNodeIcon(TreeNode node)
629+
{
630+
Texture2D nodeIcon;
631+
if (node.IsActive)
632+
{
633+
nodeIcon = ActiveBranchIcon;
634+
}
635+
else if (node.IsFolder)
636+
{
637+
nodeIcon = IsRemote && node.Level == 1
638+
? GlobeIcon
639+
: FolderIcon;
640+
}
641+
else
642+
{
643+
nodeIcon = BranchIcon;
644+
}
645+
return nodeIcon;
646+
}
647+
648+
649+
public void UpdateIcons(Texture2D activeBranchIcon, Texture2D branchIcon, Texture2D folderIcon, Texture2D globeIcon)
650+
{
651+
var needsLoad = ActiveBranchIcon == null || BranchIcon == null || FolderIcon == null || GlobeIcon == null;
652+
if (needsLoad)
653+
{
654+
ActiveBranchIcon = activeBranchIcon;
655+
BranchIcon = branchIcon;
656+
FolderIcon = folderIcon;
657+
GlobeIcon = globeIcon;
658+
659+
LoadNodeIcons();
660+
}
661+
}
662+
}
663+
609664
public enum TreeNodeRenderResult
610665
{
611666
None,

0 commit comments

Comments
 (0)