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

Commit ae4825a

Browse files
Adding functionality to alternate the icon for remote branch trees
1 parent 2ce451c commit ae4825a

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ private void BuildTree()
141141
if (treeLocals == null)
142142
{
143143
treeLocals = new BranchesTree();
144+
144145
treeRemotes = new BranchesTree();
146+
treeRemotes.IsRemote = true;
145147

146148
UpdateTreeIcons();
147149
}
@@ -167,10 +169,10 @@ private void UpdateTreeIcons()
167169
treeLocals.ActiveNodeIcon = Styles.ActiveBranchIcon;
168170
}
169171

170-
if (treeLocals.NodeIcon == null)
172+
if (treeLocals.BranchIcon == null)
171173
{
172174
localsLoaded = true;
173-
treeLocals.NodeIcon = Styles.BranchIcon;
175+
treeLocals.BranchIcon = Styles.BranchIcon;
174176
}
175177

176178
if (treeLocals.FolderIcon == null)
@@ -188,16 +190,16 @@ private void UpdateTreeIcons()
188190
treeRemotes.ActiveNodeIcon = Styles.ActiveBranchIcon;
189191
}
190192

191-
if (treeRemotes.NodeIcon == null)
193+
if (treeRemotes.BranchIcon == null)
192194
{
193195
remotesLoaded = true;
194-
treeRemotes.NodeIcon = Styles.BranchIcon;
196+
treeRemotes.BranchIcon = Styles.BranchIcon;
195197
}
196198

197-
if (treeRemotes.RootFolderIcon == null)
199+
if (treeRemotes.RemoteIcon == null)
198200
{
199201
remotesLoaded = true;
200-
treeRemotes.RootFolderIcon = Styles.RootFolderIcon;
202+
treeRemotes.RemoteIcon = Styles.RootFolderIcon;
201203
}
202204

203205
if (treeRemotes.FolderIcon == null)

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ namespace GitHub.Unity
1212
public class BranchesTree: Tree
1313
{
1414
[NonSerialized] public Texture2D ActiveNodeIcon;
15-
[NonSerialized] public Texture2D NodeIcon;
15+
[NonSerialized] public Texture2D BranchIcon;
1616
[NonSerialized] public Texture2D FolderIcon;
17-
[NonSerialized] public Texture2D RootFolderIcon;
17+
[NonSerialized] public Texture2D RemoteIcon;
18+
19+
[SerializeField] public bool IsRemote;
1820

1921
protected override Texture2D GetNodeIcon(TreeNode node)
2022
{
@@ -25,14 +27,13 @@ protected override Texture2D GetNodeIcon(TreeNode node)
2527
}
2628
else if (node.IsFolder)
2729
{
28-
if (node.Level == 1)
29-
nodeIcon = RootFolderIcon;
30-
else
31-
nodeIcon = FolderIcon;
30+
nodeIcon = IsRemote && node.Level == 1
31+
? RemoteIcon
32+
: FolderIcon;
3233
}
3334
else
3435
{
35-
nodeIcon = NodeIcon;
36+
nodeIcon = BranchIcon;
3637
}
3738
return nodeIcon;
3839
}

0 commit comments

Comments
 (0)