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

Commit f2ba4f0

Browse files
Merge branch 'enhancements/history-detail-tree-view-rollup' into enhancements/history-list-view
2 parents 6090cd8 + 0cc336b commit f2ba4f0

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/GitHub.Api/UI/TreeBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void Load(IEnumerable<TData> treeDatas)
3636

3737
var displayRootLevel = DisplayRootNode ? 1 : 0;
3838

39-
var isSelected = selectedNodePath != null && Title == selectedNodePath;
39+
var isSelected = IsSelectable && selectedNodePath != null && Title == selectedNodePath;
4040
AddNode(Title, Title, -1 + displayRootLevel, true, false, false, false, isSelected, null);
4141

4242
var hideChildren = false;
@@ -318,6 +318,7 @@ private void ToggleParentFoldersChecked(int idx, TNode node, bool isChecked)
318318
protected abstract List<TNode> Nodes { get; }
319319
public abstract string Title { get; set; }
320320
public abstract bool DisplayRootNode { get; set; }
321+
public abstract bool IsSelectable { get; set; }
321322
public abstract bool IsCheckable { get; set; }
322323
public abstract string PathSeparator { get; set; }
323324
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class ChangesTree : Tree<ChangesTreeNode, GitStatusEntryTreeData>
3838
[SerializeField] public string title = string.Empty;
3939
[SerializeField] public string pathSeparator = "/";
4040
[SerializeField] public bool displayRootNode = true;
41+
[SerializeField] public bool isSelectable = true;
4142
[SerializeField] public bool isCheckable = false;
4243
[SerializeField] private List<ChangesTreeNode> nodes = new List<ChangesTreeNode>();
4344
[SerializeField] private ChangesTreeNode selectedNode = null;
@@ -60,6 +61,12 @@ public override bool IsCheckable
6061
set { isCheckable = value; }
6162
}
6263

64+
public override bool IsSelectable
65+
{
66+
get { return isSelectable; }
67+
set { isSelectable = value; }
68+
}
69+
6370
public override string PathSeparator
6471
{
6572
get { return pathSeparator; }

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public Rect Render(Rect containingRect, Rect rect, Vector2 scroll, Action<TNode>
157157
public void Focus()
158158
{
159159
bool selectionChanged = false;
160-
if (Event.current.type == EventType.KeyDown)
160+
if (IsSelectable && Event.current.type == EventType.KeyDown)
161161
{
162162
int directionY = Event.current.keyCode == KeyCode.UpArrow ? -1 : Event.current.keyCode == KeyCode.DownArrow ? 1 : 0;
163163
int directionX = Event.current.keyCode == KeyCode.LeftArrow ? -1 : Event.current.keyCode == KeyCode.RightArrow ? 1 : 0;
@@ -191,7 +191,11 @@ private bool HandleInput(Rect rect, TNode currentNode, int index, Action<TNode>
191191
Event.current.Use();
192192
GUIUtility.keyboardControl = controlId;
193193

194-
SelectedNode = currentNode;
194+
if (IsSelectable)
195+
{
196+
SelectedNode = currentNode;
197+
}
198+
195199
requiresRepaint = true;
196200
var clickCount = Event.current.clickCount;
197201
var mouseButton = Event.current.button;
@@ -212,7 +216,7 @@ private bool HandleInput(Rect rect, TNode currentNode, int index, Action<TNode>
212216
}
213217

214218
// Keyboard navigation if this child is the current selection
215-
if (GUIUtility.keyboardControl == controlId && currentNode == SelectedNode && Event.current.type == EventType.KeyDown)
219+
if (IsSelectable && GUIUtility.keyboardControl == controlId && currentNode == SelectedNode && Event.current.type == EventType.KeyDown)
216220
{
217221
int directionY = Event.current.keyCode == KeyCode.UpArrow ? -1 : Event.current.keyCode == KeyCode.DownArrow ? 1 : 0;
218222
int directionX = Event.current.keyCode == KeyCode.LeftArrow ? -1 : Event.current.keyCode == KeyCode.RightArrow ? 1 : 0;
@@ -529,6 +533,7 @@ public class BranchesTree : Tree<TreeNode, GitBranchTreeData>
529533
[SerializeField] public string title = string.Empty;
530534
[SerializeField] public string pathSeparator = "/";
531535
[SerializeField] public bool displayRootNode = true;
536+
[SerializeField] public bool isSelectable = true;
532537
[SerializeField] public bool isCheckable = false;
533538
[SerializeField] private List<TreeNode> nodes = new List<TreeNode>();
534539
[SerializeField] private TreeNode selectedNode = null;
@@ -551,6 +556,12 @@ public override bool IsCheckable
551556
set { isCheckable = value; }
552557
}
553558

559+
public override bool IsSelectable
560+
{
561+
get { return isSelectable; }
562+
set { isSelectable = value; }
563+
}
564+
554565
public override string PathSeparator
555566
{
556567
get { return pathSeparator; }

0 commit comments

Comments
 (0)