Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
10 changes: 5 additions & 5 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -831,16 +831,16 @@ public static Texture2D DropdownListIcon
}
}

private static Texture2D rootFolderIcon;
public static Texture2D RootFolderIcon
private static Texture2D globeIcon;
public static Texture2D GlobeIcon
{
get
{
if (rootFolderIcon == null)
if (globeIcon == null)
{
rootFolderIcon = Utility.GetIcon("globe.png", "globe@2x.png");
globeIcon = Utility.GetIcon("globe.png", "globe@2x.png");
}
return rootFolderIcon;
return globeIcon;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ private void BuildTree()
if (treeLocals == null)
{
treeLocals = new BranchesTree();

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

UpdateTreeIcons();
}
Expand All @@ -158,12 +160,12 @@ private void UpdateTreeIcons()
{
if (treeLocals != null)
{
treeLocals.UpdateIcons(Styles.ActiveBranchIcon, Styles.BranchIcon, Styles.FolderIcon, Styles.RootFolderIcon);
treeLocals.UpdateIcons(Styles.ActiveBranchIcon, Styles.BranchIcon, Styles.FolderIcon, Styles.GlobeIcon);
}

if (treeRemotes != null)
{
treeRemotes.UpdateIcons(Styles.ActiveBranchIcon, Styles.BranchIcon, Styles.FolderIcon, Styles.RootFolderIcon);
treeRemotes.UpdateIcons(Styles.ActiveBranchIcon, Styles.BranchIcon, Styles.FolderIcon, Styles.GlobeIcon);
}
}

Expand Down
30 changes: 16 additions & 14 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,41 +467,43 @@ public override string ToString()
[Serializable]
public class BranchesTree: Tree
{
[NonSerialized] public Texture2D ActiveNodeIcon;
[NonSerialized] public Texture2D NodeIcon;
[SerializeField] public bool IsRemote;

[NonSerialized] public Texture2D ActiveBranchIcon;
[NonSerialized] public Texture2D BranchIcon;
[NonSerialized] public Texture2D FolderIcon;
[NonSerialized] public Texture2D RootFolderIcon;
[NonSerialized] public Texture2D GlobeIcon;

protected override Texture2D GetNodeIcon(TreeNode node)
{
Texture2D nodeIcon;
if (node.IsActive)
{
nodeIcon = ActiveNodeIcon;
nodeIcon = ActiveBranchIcon;
}
else if (node.IsFolder)
{
if (node.Level == 1)
nodeIcon = RootFolderIcon;
else
nodeIcon = FolderIcon;
nodeIcon = IsRemote && node.Level == 1
? GlobeIcon
: FolderIcon;
}
else
{
nodeIcon = NodeIcon;
nodeIcon = BranchIcon;
}
return nodeIcon;
}

public void UpdateIcons(Texture2D activeBranchIcon, Texture2D branchIcon, Texture2D folderIcon, Texture2D rootFolderIcon)

public void UpdateIcons(Texture2D activeBranchIcon, Texture2D branchIcon, Texture2D folderIcon, Texture2D globeIcon)
{
var needsLoad = ActiveNodeIcon == null || NodeIcon == null || FolderIcon == null || RootFolderIcon == null;
var needsLoad = ActiveBranchIcon == null || BranchIcon == null || FolderIcon == null || GlobeIcon == null;
if (needsLoad)
{
ActiveNodeIcon = activeBranchIcon;
NodeIcon = branchIcon;
ActiveBranchIcon = activeBranchIcon;
BranchIcon = branchIcon;
FolderIcon = folderIcon;
RootFolderIcon = rootFolderIcon;
GlobeIcon = globeIcon;

LoadNodeIcons();
}
Expand Down