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

Commit 7c20494

Browse files
Merge branch 'branches-view' into fixes/branches-view-expands-on-reload
2 parents ed8820e + 87c63f0 commit 7c20494

File tree

10 files changed

+789
-415
lines changed

10 files changed

+789
-415
lines changed

src/GitHub.Api/Git/GitBranch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace GitHub.Unity
44
{
5-
interface ITreeData
5+
public interface ITreeData
66
{
77
string Name { get; }
88
bool IsActive { get; }

src/UnityExtension/Assets/Editor/GitHub.Unity/GitHub.Unity.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
<Compile Include="UI\LoadingView.cs" />
104104
<Compile Include="UI\PublishView.cs" />
105105
<Compile Include="UI\InitProjectView.cs" />
106+
<Compile Include="UI\TreeControl.cs" />
106107
<Compile Include="UI\UserSettingsView.cs" />
107108
<Compile Include="UI\GitPathView.cs" />
108109
<Compile Include="UI\SettingsView.cs" />
@@ -207,6 +208,10 @@
207208
</None>
208209
<None Include="packages.config" />
209210
</ItemGroup>
211+
<ItemGroup>
212+
<EmbeddedResource Include="IconsAndLogos\globe%402x.png" />
213+
<EmbeddedResource Include="IconsAndLogos\globe.png" />
214+
</ItemGroup>
210215
<Import Project="..\..\..\..\..\common\nativelibraries.props" />
211216
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
212217
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -217,4 +222,4 @@
217222
</Target>
218223
-->
219224
<Import Project="..\..\..\..\..\common\build.targets" />
220-
</Project>
225+
</Project>
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

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

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ class Styles
2727
MinCommitTreePadding = 20f,
2828
FoldoutWidth = 11f,
2929
FoldoutIndentation = -2f,
30+
TreePadding = 12f,
3031
TreeIndentation = 12f,
3132
TreeRootIndentation = -5f,
3233
TreeVerticalSpacing = 3f,
3334
CommitIconSize = 16f,
3435
CommitIconHorizontalPadding = -5f,
3536
BranchListIndentation = 20f,
36-
BranchListSeperation = 15f,
37+
BranchListSeparation = 15f,
3738
RemotesTotalHorizontalMargin = 37f,
3839
RemotesNameRatio = .2f,
3940
RemotesUserRatio = .2f,
@@ -194,7 +195,7 @@ public static GUIStyle Label
194195
label = new GUIStyle(GUI.skin.label);
195196
label.name = "CustomLabel";
196197

197-
var hierarchyStyle = GUI.skin.FindStyle("PR Label");
198+
GUIStyle hierarchyStyle = GUI.skin.FindStyle("PR Label");
198199
label.onNormal.background = hierarchyStyle.onNormal.background;
199200
label.onNormal.textColor = hierarchyStyle.onNormal.textColor;
200201
label.onFocused.background = hierarchyStyle.onFocused.background;
@@ -829,5 +830,79 @@ public static Texture2D DropdownListIcon
829830
return dropdownListIcon;
830831
}
831832
}
833+
834+
private static Texture2D rootFolderIcon;
835+
public static Texture2D RootFolderIcon
836+
{
837+
get
838+
{
839+
if (rootFolderIcon == null)
840+
{
841+
rootFolderIcon = Utility.GetIcon("globe.png", "[email protected]");
842+
}
843+
return rootFolderIcon;
844+
}
845+
}
846+
847+
private static GUIStyle foldout;
848+
public static GUIStyle Foldout
849+
{
850+
get
851+
{
852+
if (foldout == null)
853+
{
854+
foldout = new GUIStyle(EditorStyles.foldout);
855+
foldout.name = "CustomFoldout";
856+
857+
foldout.focused.textColor = Color.white;
858+
foldout.onFocused.textColor = Color.white;
859+
foldout.focused.background = foldout.active.background;
860+
foldout.onFocused.background = foldout.onActive.background;
861+
}
862+
863+
return foldout;
864+
}
865+
}
866+
867+
private static GUIStyle treeNode;
868+
public static GUIStyle TreeNode
869+
{
870+
get
871+
{
872+
if (treeNode == null)
873+
{
874+
treeNode = new GUIStyle(GUI.skin.label);
875+
treeNode.name = "Custom TreeNode";
876+
877+
var color = new Color(62f / 255f, 125f / 255f, 231f / 255f);
878+
var texture = Utility.GetTextureFromColor(color);
879+
treeNode.focused.background = texture;
880+
treeNode.onFocused.background = texture;
881+
treeNode.focused.textColor = Color.white;
882+
treeNode.onFocused.textColor = Color.white;
883+
}
884+
885+
return treeNode;
886+
}
887+
}
888+
889+
private static GUIStyle treeNodeActive;
890+
public static GUIStyle TreeNodeActive
891+
{
892+
get
893+
{
894+
if (treeNodeActive == null)
895+
{
896+
treeNodeActive = new GUIStyle(TreeNode);
897+
treeNodeActive.name = "Custom TreeNode Active";
898+
treeNodeActive.fontStyle = FontStyle.Bold;
899+
treeNodeActive.focused.textColor = Color.white;
900+
treeNodeActive.active.textColor = Color.white;
901+
}
902+
903+
return treeNodeActive;
904+
}
905+
}
906+
832907
}
833908
}

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,40 @@
77

88
namespace GitHub.Unity
99
{
10+
[Serializable]
11+
public class SerializableTexture2D
12+
{
13+
[SerializeField] private byte[] bytes;
14+
[SerializeField] private int height;
15+
[SerializeField] private int width;
16+
[SerializeField] private TextureFormat format;
17+
[SerializeField] private bool mipmap;
18+
[SerializeField] private Texture2D texture;
19+
20+
public Texture2D Texture
21+
{
22+
get
23+
{
24+
if (texture == null)
25+
{
26+
texture = new Texture2D(width, height, format, mipmap);
27+
texture.LoadRawTextureData(bytes);
28+
texture.Apply();
29+
}
30+
return texture;
31+
}
32+
set
33+
{
34+
texture = value;
35+
bytes = value.GetRawTextureData();
36+
height = value.height;
37+
width = value.width;
38+
format = value.format;
39+
mipmap = value.mipmapCount > 1;
40+
}
41+
}
42+
}
43+
1044
class Utility : ScriptableObject
1145
{
1246
public static Texture2D GetIcon(string filename, string filename2x = "")
@@ -23,6 +57,18 @@ public static Texture2D GetIcon(string filename, string filename2x = "")
2357
var iconPath = EntryPoint.Environment.ExtensionInstallPath.Combine("IconsAndLogos", filename).ToString(SlashMode.Forward);
2458
return AssetDatabase.LoadAssetAtPath<Texture2D>(iconPath);
2559
}
60+
61+
public static Texture2D GetTextureFromColor(Color color)
62+
{
63+
Color[] pix = new Color[1];
64+
pix[0] = color;
65+
66+
Texture2D result = new Texture2D(1, 1);
67+
result.SetPixels(pix);
68+
result.Apply();
69+
70+
return result;
71+
}
2672
}
2773

2874
static class StreamExtensions

src/UnityExtension/Assets/Editor/GitHub.Unity/Services/AuthenticationService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using GitHub.Unity;
32

43
namespace GitHub.Unity
54
{

0 commit comments

Comments
 (0)