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

Commit 9922975

Browse files
Merge commit '03d85a800838f06e03cbb4a4150bb5980516408f' into fixes/branches-view-globe-icon
# Conflicts: # src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs # src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs
2 parents ae4825a + 03d85a8 commit 9922975

File tree

2 files changed

+69
-85
lines changed

2 files changed

+69
-85
lines changed

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

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -158,65 +158,14 @@ private void BuildTree()
158158

159159
private void UpdateTreeIcons()
160160
{
161-
var localsLoaded = false;
162-
var remotesLoaded = false;
163-
164161
if (treeLocals != null)
165162
{
166-
if (treeLocals.ActiveNodeIcon == null)
167-
{
168-
localsLoaded = true;
169-
treeLocals.ActiveNodeIcon = Styles.ActiveBranchIcon;
170-
}
171-
172-
if (treeLocals.BranchIcon == null)
173-
{
174-
localsLoaded = true;
175-
treeLocals.BranchIcon = Styles.BranchIcon;
176-
}
177-
178-
if (treeLocals.FolderIcon == null)
179-
{
180-
localsLoaded = true;
181-
treeLocals.FolderIcon = Styles.FolderIcon;
182-
}
163+
treeLocals.UpdateIcons(Styles.ActiveBranchIcon, Styles.BranchIcon, Styles.FolderIcon, Styles.RootFolderIcon);
183164
}
184165

185166
if (treeRemotes != null)
186167
{
187-
if (treeRemotes.ActiveNodeIcon == null)
188-
{
189-
remotesLoaded = true;
190-
treeRemotes.ActiveNodeIcon = Styles.ActiveBranchIcon;
191-
}
192-
193-
if (treeRemotes.BranchIcon == null)
194-
{
195-
remotesLoaded = true;
196-
treeRemotes.BranchIcon = Styles.BranchIcon;
197-
}
198-
199-
if (treeRemotes.RemoteIcon == null)
200-
{
201-
remotesLoaded = true;
202-
treeRemotes.RemoteIcon = Styles.RootFolderIcon;
203-
}
204-
205-
if (treeRemotes.FolderIcon == null)
206-
{
207-
remotesLoaded = true;
208-
treeRemotes.FolderIcon = Styles.FolderIcon;
209-
}
210-
}
211-
212-
if (localsLoaded)
213-
{
214-
treeLocals.LoadNodeIcons();
215-
}
216-
217-
if (remotesLoaded)
218-
{
219-
treeRemotes.LoadNodeIcons();
168+
treeRemotes.UpdateIcons(Styles.ActiveBranchIcon, Styles.BranchIcon, Styles.FolderIcon, Styles.RootFolderIcon);
220169
}
221170
}
222171

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

Lines changed: 67 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,6 @@
88

99
namespace GitHub.Unity
1010
{
11-
[Serializable]
12-
public class BranchesTree: Tree
13-
{
14-
[NonSerialized] public Texture2D ActiveNodeIcon;
15-
[NonSerialized] public Texture2D BranchIcon;
16-
[NonSerialized] public Texture2D FolderIcon;
17-
[NonSerialized] public Texture2D RemoteIcon;
18-
19-
[SerializeField] public bool IsRemote;
20-
21-
protected override Texture2D GetNodeIcon(TreeNode node)
22-
{
23-
Texture2D nodeIcon;
24-
if (node.IsActive)
25-
{
26-
nodeIcon = ActiveNodeIcon;
27-
}
28-
else if (node.IsFolder)
29-
{
30-
nodeIcon = IsRemote && node.Level == 1
31-
? RemoteIcon
32-
: FolderIcon;
33-
}
34-
else
35-
{
36-
nodeIcon = BranchIcon;
37-
}
38-
return nodeIcon;
39-
}
40-
}
41-
4211
[Serializable]
4312
public abstract class Tree
4413
{
@@ -403,7 +372,7 @@ private void SetNodeIcon(TreeNode node)
403372

404373
protected abstract Texture2D GetNodeIcon(TreeNode node);
405374

406-
public void LoadNodeIcons()
375+
protected void LoadNodeIcons()
407376
{
408377
foreach (var treeNode in nodes)
409378
{
@@ -480,4 +449,70 @@ public override string ToString()
480449
Name, Label, Level, IsFolder, IsCollapsed, IsHidden, IsActive);
481450
}
482451
}
452+
453+
[Serializable]
454+
public class BranchesTree: Tree
455+
{
456+
[SerializeField] public bool IsRemote;
457+
458+
[NonSerialized] public Texture2D ActiveNodeIcon;
459+
[NonSerialized] public Texture2D BranchIcon;
460+
[NonSerialized] public Texture2D FolderIcon;
461+
[NonSerialized] public Texture2D RemoteIcon;
462+
463+
protected override Texture2D GetNodeIcon(TreeNode node)
464+
{
465+
Texture2D nodeIcon;
466+
if (node.IsActive)
467+
{
468+
nodeIcon = ActiveNodeIcon;
469+
}
470+
else if (node.IsFolder)
471+
{
472+
nodeIcon = IsRemote && node.Level == 1
473+
? RemoteIcon
474+
: FolderIcon;
475+
}
476+
else
477+
{
478+
nodeIcon = BranchIcon;
479+
}
480+
return nodeIcon;
481+
}
482+
483+
484+
public void UpdateIcons(Texture2D activeBranchIcon, Texture2D branchIcon, Texture2D folderIcon, Texture2D rootFolderIcon)
485+
{
486+
var localsLoaded = false;
487+
488+
if (ActiveNodeIcon == null)
489+
{
490+
localsLoaded = true;
491+
ActiveNodeIcon = activeBranchIcon;
492+
}
493+
494+
if (BranchIcon == null)
495+
{
496+
localsLoaded = true;
497+
BranchIcon = branchIcon;
498+
}
499+
500+
if (FolderIcon == null)
501+
{
502+
localsLoaded = true;
503+
FolderIcon = folderIcon;
504+
}
505+
506+
if (RemoteIcon == null)
507+
{
508+
localsLoaded = true;
509+
RemoteIcon = rootFolderIcon;
510+
}
511+
512+
if (localsLoaded)
513+
{
514+
LoadNodeIcons();
515+
}
516+
}
517+
}
483518
}

0 commit comments

Comments
 (0)