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

Commit c4d641c

Browse files
Merge branch 'enhancements/branches-view-rollup' into fixes/branches-view-folder-clickable-area
# Conflicts: # src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs
2 parents 8107b88 + ea44651 commit c4d641c

File tree

3 files changed

+23
-62
lines changed

3 files changed

+23
-62
lines changed

src/GitHub.Api/Git/GitBranch.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ public struct GitBranch : ITreeData
1717
public string tracking;
1818
public bool isActive;
1919

20-
public string Name { get { return name; } }
21-
public string Tracking { get { return tracking; } }
22-
public bool IsActive { get { return isActive; } }
23-
2420
public GitBranch(string name, string tracking, bool active)
2521
{
2622
Guard.ArgumentNotNullOrWhiteSpace(name, "name");
@@ -30,6 +26,10 @@ public GitBranch(string name, string tracking, bool active)
3026
this.isActive = active;
3127
}
3228

29+
public string Name => name;
30+
public string Tracking => tracking;
31+
public bool IsActive => isActive;
32+
3333
public override string ToString()
3434
{
3535
return $"{Name} Tracking? {Tracking} Active? {IsActive}";

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,9 @@ private void OnTreeGUI(Rect rect)
358358
});
359359

360360
if (treeHadFocus && treeRemotes.SelectedNode == null)
361-
{
362361
treeLocals.Focus();
363-
}
364362
else if (!treeHadFocus && treeRemotes.SelectedNode != null)
365-
{
366363
treeLocals.Blur();
367-
}
368364

369365
if (treeRemotes.RequiresRepaint)
370366
Redraw();
@@ -375,16 +371,6 @@ private void OnTreeGUI(Rect rect)
375371

376372
private int CompareBranches(GitBranch a, GitBranch b)
377373
{
378-
//if (IsFavorite(a.Name))
379-
//{
380-
// return -1;
381-
//}
382-
383-
//if (IsFavorite(b.Name))
384-
//{
385-
// return 1;
386-
//}
387-
388374
if (a.Name.Equals("master"))
389375
{
390376
return -1;
@@ -398,31 +384,6 @@ private int CompareBranches(GitBranch a, GitBranch b)
398384
return a.Name.CompareTo(b.Name);
399385
}
400386

401-
//private bool IsFavorite(string branchName)
402-
//{
403-
// return !String.IsNullOrEmpty(branchName) && favoritesList.Contains(branchName);
404-
//}
405-
406-
//private void SetFavorite(TreeNode branch, bool favorite)
407-
//{
408-
// if (string.IsNullOrEmpty(branch.Name))
409-
// {
410-
// return;
411-
// }
412-
413-
// if (!favorite)
414-
// {
415-
// favorites.Remove(branch);
416-
// Manager.LocalSettings.Set(FavoritesSetting, favorites.Select(x => x.Name).ToList());
417-
// }
418-
// else
419-
// {
420-
// favorites.Remove(branch);
421-
// favorites.Add(branch);
422-
// Manager.LocalSettings.Set(FavoritesSetting, favorites.Select(x => x.Name).ToList());
423-
// }
424-
//}
425-
426387
public override bool IsBusy
427388
{
428389
get { return false; }

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ namespace GitHub.Unity
1111
[Serializable]
1212
public class Tree
1313
{
14-
[SerializeField] public float ItemHeight = EditorGUIUtility.singleLineHeight;
15-
[SerializeField] public float ItemSpacing = EditorGUIUtility.standardVerticalSpacing;
16-
[SerializeField] public float Indentation = 12f;
14+
public static float ItemHeight { get { return EditorGUIUtility.singleLineHeight; } }
15+
public static float ItemSpacing { get { return EditorGUIUtility.standardVerticalSpacing; } }
16+
1717
[SerializeField] public Rect Margin = new Rect();
1818
[SerializeField] public Rect Padding = new Rect();
1919

@@ -169,7 +169,7 @@ public Rect Render(Rect rect, Vector2 scroll, Action<TreeNode> singleClick = nul
169169

170170
if (visible)
171171
{
172-
var changed = node.Render(rect, Indentation, selectedNode == node, FolderStyle, TreeNodeStyle, ActiveTreeNodeStyle);
172+
var changed = node.Render(rect, Styles.TreeIndentation, selectedNode == node, FolderStyle, TreeNodeStyle, ActiveTreeNodeStyle);
173173

174174
if (node.IsFolder && changed)
175175
{
@@ -210,20 +210,18 @@ public void Focus()
210210
{
211211
int directionY = Event.current.keyCode == KeyCode.UpArrow ? -1 : Event.current.keyCode == KeyCode.DownArrow ? 1 : 0;
212212
int directionX = Event.current.keyCode == KeyCode.LeftArrow ? -1 : Event.current.keyCode == KeyCode.RightArrow ? 1 : 0;
213-
if (directionY != 0 || directionX != 0)
213+
214+
if (directionY < 0 || directionX < 0)
214215
{
215-
if (directionY < 0 || directionY < 0)
216-
{
217-
SelectedNode = nodes[nodes.Count - 1];
218-
selectionChanged = true;
219-
Event.current.Use();
220-
}
221-
else if (directionY > 0 || directionX > 0)
222-
{
223-
SelectedNode = nodes[0];
224-
selectionChanged = true;
225-
Event.current.Use();
226-
}
216+
SelectedNode = nodes[nodes.Count - 1];
217+
selectionChanged = true;
218+
Event.current.Use();
219+
}
220+
else if (directionY > 0 || directionX > 0)
221+
{
222+
SelectedNode = nodes[0];
223+
selectionChanged = true;
224+
Event.current.Use();
227225
}
228226
}
229227
RequiresRepaint = selectionChanged;
@@ -437,9 +435,11 @@ public bool Render(Rect rect, float indentation, bool isSelected, GUIStyle folde
437435

438436
if (Event.current.type == EventType.repaint)
439437
{
440-
nodeStyle.Draw(fillRect, "", false, false, false, isSelected);
438+
nodeStyle.Draw(fillRect, GUIContent.none, false, false, false, isSelected);
441439
if (IsFolder)
440+
{
442441
style.Draw(nodeRect, content, false, false, !IsCollapsed, isSelected);
442+
}
443443
else
444444
{
445445
style.Draw(nodeRect, content, false, false, false, isSelected);
@@ -451,7 +451,7 @@ public bool Render(Rect rect, float indentation, bool isSelected, GUIStyle folde
451451
var toggleRect = new Rect(nodeRect.x, nodeRect.y, style.border.horizontal, nodeRect.height);
452452

453453
EditorGUI.BeginChangeCheck();
454-
GUI.Toggle(toggleRect, !IsCollapsed, "", GUIStyle.none);
454+
GUI.Toggle(toggleRect, !IsCollapsed, GUIContent.none, GUIStyle.none);
455455
changed = EditorGUI.EndChangeCheck();
456456
}
457457

0 commit comments

Comments
 (0)