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

Commit 684990d

Browse files
Merge branch 'enhancements/branches-view-rollup' into enhancements/branches-view-right-click
2 parents a5bc4b2 + ea44651 commit 684990d

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
@@ -322,13 +322,9 @@ private void OnTreeGUI(Rect rect)
322322
});
323323

324324
if (treeHadFocus && treeRemotes.SelectedNode == null)
325-
{
326325
treeLocals.Focus();
327-
}
328326
else if (!treeHadFocus && treeRemotes.SelectedNode != null)
329-
{
330327
treeLocals.Blur();
331-
}
332328

333329
if (treeRemotes.RequiresRepaint)
334330
Redraw();
@@ -440,16 +436,6 @@ private GenericMenu CreateContextMenuForRemoteBranchNode(TreeNode node)
440436

441437
private int CompareBranches(GitBranch a, GitBranch b)
442438
{
443-
//if (IsFavorite(a.Name))
444-
//{
445-
// return -1;
446-
//}
447-
448-
//if (IsFavorite(b.Name))
449-
//{
450-
// return 1;
451-
//}
452-
453439
if (a.Name.Equals("master"))
454440
{
455441
return -1;
@@ -463,31 +449,6 @@ private int CompareBranches(GitBranch a, GitBranch b)
463449
return a.Name.CompareTo(b.Name);
464450
}
465451

466-
//private bool IsFavorite(string branchName)
467-
//{
468-
// return !String.IsNullOrEmpty(branchName) && favoritesList.Contains(branchName);
469-
//}
470-
471-
//private void SetFavorite(TreeNode branch, bool favorite)
472-
//{
473-
// if (string.IsNullOrEmpty(branch.Name))
474-
// {
475-
// return;
476-
// }
477-
478-
// if (!favorite)
479-
// {
480-
// favorites.Remove(branch);
481-
// Manager.LocalSettings.Set(FavoritesSetting, favorites.Select(x => x.Name).ToList());
482-
// }
483-
// else
484-
// {
485-
// favorites.Remove(branch);
486-
// favorites.Add(branch);
487-
// Manager.LocalSettings.Set(FavoritesSetting, favorites.Select(x => x.Name).ToList());
488-
// }
489-
//}
490-
491452
public override bool IsBusy
492453
{
493454
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;
@@ -443,9 +441,11 @@ public bool Render(Rect rect, float indentation, bool isSelected, GUIStyle folde
443441

444442
if (Event.current.type == EventType.repaint)
445443
{
446-
nodeStyle.Draw(fillRect, "", false, false, false, isSelected);
444+
nodeStyle.Draw(fillRect, GUIContent.none, false, false, false, isSelected);
447445
if (IsFolder)
446+
{
448447
style.Draw(nodeRect, content, false, false, !IsCollapsed, isSelected);
448+
}
449449
else
450450
{
451451
style.Draw(nodeRect, content, false, false, false, isSelected);
@@ -455,7 +455,7 @@ public bool Render(Rect rect, float indentation, bool isSelected, GUIStyle folde
455455
if (IsFolder)
456456
{
457457
EditorGUI.BeginChangeCheck();
458-
GUI.Toggle(nodeRect, !IsCollapsed, "", GUIStyle.none);
458+
GUI.Toggle(nodeRect, !IsCollapsed, GUIContent.none, GUIStyle.none);
459459
changed = EditorGUI.EndChangeCheck();
460460
}
461461

0 commit comments

Comments
 (0)