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

Commit 1d3bdf1

Browse files
Merge pull request #469 from github-for-unity/fixes/branches-view-globe-icon
Functionality to mark folder nodes as "root"
2 parents 9f23c84 + 27adae4 commit 1d3bdf1

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -831,16 +831,16 @@ public static Texture2D DropdownListIcon
831831
}
832832
}
833833

834-
private static Texture2D rootFolderIcon;
835-
public static Texture2D RootFolderIcon
834+
private static Texture2D globeIcon;
835+
public static Texture2D GlobeIcon
836836
{
837837
get
838838
{
839-
if (rootFolderIcon == null)
839+
if (globeIcon == null)
840840
{
841-
rootFolderIcon = Utility.GetIcon("globe.png", "[email protected]");
841+
globeIcon = Utility.GetIcon("globe.png", "[email protected]");
842842
}
843-
return rootFolderIcon;
843+
return globeIcon;
844844
}
845845
}
846846

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

Lines changed: 4 additions & 2 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
}
@@ -158,12 +160,12 @@ private void UpdateTreeIcons()
158160
{
159161
if (treeLocals != null)
160162
{
161-
treeLocals.UpdateIcons(Styles.ActiveBranchIcon, Styles.BranchIcon, Styles.FolderIcon, Styles.RootFolderIcon);
163+
treeLocals.UpdateIcons(Styles.ActiveBranchIcon, Styles.BranchIcon, Styles.FolderIcon, Styles.GlobeIcon);
162164
}
163165

164166
if (treeRemotes != null)
165167
{
166-
treeRemotes.UpdateIcons(Styles.ActiveBranchIcon, Styles.BranchIcon, Styles.FolderIcon, Styles.RootFolderIcon);
168+
treeRemotes.UpdateIcons(Styles.ActiveBranchIcon, Styles.BranchIcon, Styles.FolderIcon, Styles.GlobeIcon);
167169
}
168170
}
169171

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -467,41 +467,43 @@ public override string ToString()
467467
[Serializable]
468468
public class BranchesTree: Tree
469469
{
470-
[NonSerialized] public Texture2D ActiveNodeIcon;
471-
[NonSerialized] public Texture2D NodeIcon;
470+
[SerializeField] public bool IsRemote;
471+
472+
[NonSerialized] public Texture2D ActiveBranchIcon;
473+
[NonSerialized] public Texture2D BranchIcon;
472474
[NonSerialized] public Texture2D FolderIcon;
473-
[NonSerialized] public Texture2D RootFolderIcon;
475+
[NonSerialized] public Texture2D GlobeIcon;
474476

475477
protected override Texture2D GetNodeIcon(TreeNode node)
476478
{
477479
Texture2D nodeIcon;
478480
if (node.IsActive)
479481
{
480-
nodeIcon = ActiveNodeIcon;
482+
nodeIcon = ActiveBranchIcon;
481483
}
482484
else if (node.IsFolder)
483485
{
484-
if (node.Level == 1)
485-
nodeIcon = RootFolderIcon;
486-
else
487-
nodeIcon = FolderIcon;
486+
nodeIcon = IsRemote && node.Level == 1
487+
? GlobeIcon
488+
: FolderIcon;
488489
}
489490
else
490491
{
491-
nodeIcon = NodeIcon;
492+
nodeIcon = BranchIcon;
492493
}
493494
return nodeIcon;
494495
}
495496

496-
public void UpdateIcons(Texture2D activeBranchIcon, Texture2D branchIcon, Texture2D folderIcon, Texture2D rootFolderIcon)
497+
498+
public void UpdateIcons(Texture2D activeBranchIcon, Texture2D branchIcon, Texture2D folderIcon, Texture2D globeIcon)
497499
{
498-
var needsLoad = ActiveNodeIcon == null || NodeIcon == null || FolderIcon == null || RootFolderIcon == null;
500+
var needsLoad = ActiveBranchIcon == null || BranchIcon == null || FolderIcon == null || GlobeIcon == null;
499501
if (needsLoad)
500502
{
501-
ActiveNodeIcon = activeBranchIcon;
502-
NodeIcon = branchIcon;
503+
ActiveBranchIcon = activeBranchIcon;
504+
BranchIcon = branchIcon;
503505
FolderIcon = folderIcon;
504-
RootFolderIcon = rootFolderIcon;
506+
GlobeIcon = globeIcon;
505507

506508
LoadNodeIcons();
507509
}

0 commit comments

Comments
 (0)