virtual protected void DoItemGUI(Rect rect, int row, TreeViewItem item, bool selected, bool focused, bool useBoldFont) { EditorGUIUtility.SetIconSize(new Vector2(k_IconWidth, k_IconWidth)); // If not set we see icons scaling down if text is being cropped float indent = GetFoldoutIndent(item); int itemControlID = TreeViewController.GetItemControlID(item); bool isDropTarget = false; if (m_TreeView.dragging != null) { isDropTarget = m_TreeView.dragging.GetDropTargetControlID() == itemControlID && m_TreeView.data.CanBeParent(item); } bool isRenamingThisItem = IsRenaming(item.id); bool showFoldout = m_TreeView.data.IsExpandable(item); // Adjust edit field if needed (on repaint since on layout rect.width is invalid when using GUILayout) if (isRenamingThisItem && Event.current.type == EventType.Repaint) { GetRenameOverlay().editFieldRect = GetRenameRect(rect, row, item); } string label = item.displayName; if (isRenamingThisItem) { selected = false; label = ""; } if (Event.current.type == EventType.Repaint) { // Draw background (can be overridden) DrawItemBackground(rect, row, item, selected, focused); // Draw selection if (selected) { selectionStyle.Draw(rect, false, false, true, focused); } // Draw drop marker if (isDropTarget) { Styles.lineStyle.Draw(GetDropTargetRect(rect), GUIContent.none, true, true, false, false); } // Show insertion marker below this item (rendered end of rows) if (m_TreeView.dragging != null && m_TreeView.dragging.GetRowMarkerControlID() == itemControlID) { float yPos = (m_TreeView.dragging.drawRowMarkerAbove ? rect.y : rect.yMax) - insertionStyle.fixedHeight * 0.5f; m_DraggingInsertionMarkerRect = new Rect(rect.x + indent + extraInsertionMarkerIndent + foldoutStyleWidth + lineStyle.margin.left, yPos, rect.width - indent, rect.height); } } // Do additional ui controls (menu button, prefab arrow etc) OnAdditionalGUI(rect, row, item, selected, focused); // Do row content (icon, label, controls etc) OnContentGUI(rect, row, item, label, selected, focused, useBoldFont, false); // Do foldout if (showFoldout) { DoFoldout(rect, item, row); } EditorGUIUtility.SetIconSize(Vector2.zero); }
virtual public bool CanBeMultiSelected(TreeViewItem item) { return(true); }
//---------------------------- // Renaming section virtual public bool IsRenamingItemAllowed(TreeViewItem item) { return(true); }
// This method is called from TreeView and handles: // - Where the dragged items are dropped (above, below or upon) // - Auto expansion of collapsed items when hovering over them // - Setting up the render markers for drop location (horizontal lines) // 'targetItem' is null when not hovering over any target Item, if so the rest of the arguments are invalid public virtual bool DragElement(TreeViewItem targetItem, Rect targetItemRect, int row) { bool perform = Event.current.type == EventType.DragPerform; // Are we dragging outside any items if (targetItem == null) { // If so clear any drop markers if (m_DropData != null) { m_DropData.ClearPerEventState(); } // And let client decide what happens when dragging outside items DragAndDrop.visualMode = DoDrag(null, null, perform, DropPosition.Below); if (DragAndDrop.visualMode != DragAndDropVisualMode.None && perform) { FinalizeDragPerformed(true); } return(false); } DropPosition dropPosition; if (!TryGetDropPosition(targetItem, targetItemRect, row, out dropPosition)) { return(false); } TreeViewItem parentItem = null; TreeViewItem dropRelativeToItem = targetItem; bool didChangeTargetToAncector = false; DropPosition originalDropPosition = dropPosition; switch (dropPosition) { case DropPosition.Upon: // Parent change: Client must decide what happens when dropping upon: e.g: insert last or first in child list parentItem = dropRelativeToItem; break; case DropPosition.Below: case DropPosition.Above: // Sibling change if (getIndentLevelForMouseCursor != null) { int cursorDepth = getIndentLevelForMouseCursor(); HandleSiblingInsertionAtAvailableDepthsAndChangeTargetIfNeeded(ref dropRelativeToItem, row, ref dropPosition, cursorDepth, out didChangeTargetToAncector); } else { if (dropPosition == DropPosition.Below && m_TreeView.data.IsExpanded(dropRelativeToItem) && dropRelativeToItem.hasChildren) { // When hovering between an expanded parent and its first child then make sure we change state to match that dropPosition = DropPosition.Above; dropRelativeToItem = dropRelativeToItem.children[0]; } } parentItem = dropRelativeToItem.parent; break; default: Debug.LogError("Unhandled enum. Report a bug."); break; } if (perform) { DragAndDropVisualMode mode = DragAndDropVisualMode.None; // Try Drop upon target item if (dropPosition == DropPosition.Upon) { mode = DoDrag(dropRelativeToItem, dropRelativeToItem, true, dropPosition); } // Drop between items if (mode == DragAndDropVisualMode.None && parentItem != null) { mode = DoDrag(parentItem, dropRelativeToItem, true, dropPosition); } // Finalize drop if (mode != DragAndDropVisualMode.None) { FinalizeDragPerformed(false); } else { DragCleanup(true); m_TreeView.NotifyListenersThatDragEnded(null, false); } } else // DragUpdate { if (m_DropData == null) { m_DropData = new DropData(); } m_DropData.ClearPerEventState(); // Try drop on top of items if (dropPosition == DropPosition.Upon) { int itemControlID = TreeViewController.GetItemControlID(dropRelativeToItem); HandleAutoExpansion(itemControlID, dropRelativeToItem, targetItemRect); var mode = DoDrag(dropRelativeToItem, dropRelativeToItem, false, dropPosition); if (mode != DragAndDropVisualMode.None) { m_DropData.dropTargetControlID = itemControlID; DragAndDrop.visualMode = mode; } } // Drop between items else if (dropRelativeToItem != null && parentItem != null) { var mode = DoDrag(parentItem, dropRelativeToItem, false, dropPosition); if (mode != DragAndDropVisualMode.None) { drawRowMarkerAbove = dropPosition == DropPosition.Above; m_DropData.rowMarkerControlID = TreeViewController.GetItemControlID(dropRelativeToItem); m_DropData.insertionMarkerYPosition = originalDropPosition == DropPosition.Above ? targetItemRect.y : targetItemRect.yMax; m_DropData.insertRelativeToSibling = dropRelativeToItem; if (didChangeTargetToAncector) { m_DropData.ancestorControlID = TreeViewController.GetItemControlID(dropRelativeToItem); } DragAndDrop.visualMode = mode; } } } Event.current.Use(); return(true); }
virtual public void SetExpanded(TreeViewItem item, bool expand) { SetExpanded(item.id, expand); }
protected float GetDropBetweenHalfHeight(TreeViewItem item, Rect itemRect) { return(m_TreeView.data.CanBeParent(item) ? m_TreeView.gui.halfDropBetweenHeight : itemRect.height * 0.5f); }
internal void HandleSiblingInsertionAtAvailableDepthsAndChangeTargetIfNeeded(ref TreeViewItem targetItem, int targetItemRow, ref DropPosition dropPosition, int cursorDepth, out bool didChangeTargetToAncestor) { if (dropPosition != DropPosition.Above && dropPosition != DropPosition.Below) { throw new ArgumentException("Invalid argument: " + dropPosition); } didChangeTargetToAncestor = false; TreeViewItem prevItem, nextItem; GetPreviousAndNextItemsIgnoringDraggedItems(targetItemRow, dropPosition, out prevItem, out nextItem); if (prevItem == null) { return; // Above first row so keep targetItem } bool hoveringBetweenExpandedParentAndFirstChild = prevItem.hasChildren && m_TreeView.data.IsExpanded(prevItem.id); int minDepth = nextItem != null ? nextItem.depth : 0; int maxDepth = prevItem.depth + (hoveringBetweenExpandedParentAndFirstChild ? 1 : 0); // Change targetItem and dropPosition targetItem = prevItem; dropPosition = DropPosition.Below; if (maxDepth <= minDepth) { if (hoveringBetweenExpandedParentAndFirstChild) { targetItem = prevItem.children[0]; dropPosition = DropPosition.Above; } return; // The nextItem is a descendant of previous item so keep targetItem } if (cursorDepth >= maxDepth) { if (hoveringBetweenExpandedParentAndFirstChild) { targetItem = prevItem.children[0]; dropPosition = DropPosition.Above; } return; // No need to change targetItem if same or higher depth } // Search through parents for a new target that matches the cursor var target = targetItem; while (target.depth > minDepth) { if (target.depth == cursorDepth) { break; } target = target.parent; } didChangeTargetToAncestor = target != targetItem; // Change to new targetItem targetItem = target; }
private void SelectionByKey(TreeViewItem itemSelected) { List <int> newSelection = this.GetNewSelection(itemSelected, false, true); this.NewSelectionFromUserInteraction(newSelection, itemSelected.id); }
public void SelectionClick(TreeViewItem itemClicked, bool keepMultiSelection) { List <int> newSelection = this.GetNewSelection(itemClicked, keepMultiSelection, false); this.NewSelectionFromUserInteraction(newSelection, (itemClicked == null) ? 0 : itemClicked.id); }
// Setup child and parent references based on the depth of the tree view items in 'visibleItems' internal static void SetChildParentReferences(IList <TreeViewItem> visibleItems, TreeViewItem root) { for (int i = 0; i < visibleItems.Count; i++) { visibleItems[i].parent = null; } // Set child and parent references using depth info int rootChildCount = 0; for (int i = 0; i < visibleItems.Count; i++) { SetChildParentReferences(i, visibleItems); if (visibleItems[i].parent == null) { rootChildCount++; } } // Ensure items without a parent gets 'root' as parent if (rootChildCount > 0) { var rootChildren = new List <TreeViewItem>(rootChildCount); for (int i = 0; i < visibleItems.Count; i++) { if (visibleItems[i].parent == null) { rootChildren.Add(visibleItems[i]); visibleItems[i].parent = root; } } root.children = rootChildren; } else { root.children = new List <TreeViewItem>(); } }
private void KeyboardGUI() { if (this.m_KeyboardControlID == GUIUtility.keyboardControl && GUI.enabled) { if (this.keyboardInputCallback != null) { this.keyboardInputCallback(); } if (Event.current.type == EventType.KeyDown) { KeyCode keyCode = Event.current.keyCode; switch (keyCode) { case KeyCode.KeypadEnter: goto IL_1EE; case KeyCode.KeypadEquals: case KeyCode.Insert: case KeyCode.F1: IL_92: if (keyCode != KeyCode.Return) { if (Event.current.keyCode <= KeyCode.A || Event.current.keyCode < KeyCode.Z) { } goto IL_269; } goto IL_1EE; case KeyCode.UpArrow: Event.current.Use(); this.OffsetSelection(-1); goto IL_269; case KeyCode.DownArrow: Event.current.Use(); this.OffsetSelection(1); goto IL_269; case KeyCode.RightArrow: this.ChangeFolding(this.state.selectedIDs.ToArray(), true); Event.current.Use(); goto IL_269; case KeyCode.LeftArrow: this.ChangeFolding(this.state.selectedIDs.ToArray(), false); Event.current.Use(); goto IL_269; case KeyCode.Home: Event.current.Use(); this.OffsetSelection(-1000000); goto IL_269; case KeyCode.End: Event.current.Use(); this.OffsetSelection(1000000); goto IL_269; case KeyCode.PageUp: { Event.current.Use(); TreeViewItem treeViewItem = this.data.FindItem(this.state.lastClickedID); if (treeViewItem != null) { int numRowsOnPageUpDown = this.gui.GetNumRowsOnPageUpDown(treeViewItem, true, this.m_TotalRect.height); this.OffsetSelection(-numRowsOnPageUpDown); } goto IL_269; } case KeyCode.PageDown: { Event.current.Use(); TreeViewItem treeViewItem2 = this.data.FindItem(this.state.lastClickedID); if (treeViewItem2 != null) { int numRowsOnPageUpDown2 = this.gui.GetNumRowsOnPageUpDown(treeViewItem2, true, this.m_TotalRect.height); this.OffsetSelection(numRowsOnPageUpDown2); } goto IL_269; } case KeyCode.F2: if (Application.platform != RuntimePlatform.OSXEditor && this.BeginNameEditing(0f)) { Event.current.Use(); } goto IL_269; } goto IL_92; IL_1EE: if (Application.platform == RuntimePlatform.OSXEditor && this.BeginNameEditing(0f)) { Event.current.Use(); } IL_269 :; } } }
virtual public float GetContentIndent(TreeViewItem item) { return(GetFoldoutIndent(item) + foldoutStyleWidth + lineStyle.margin.left); }
virtual public bool BeginRename(TreeViewItem item, float delay) { return(GetRenameOverlay().BeginRename(item.displayName, item.id, delay)); }
protected virtual void OnAdditionalGUI(Rect rect, int row, TreeViewItem item, bool selected, bool focused) { }
// This method is called from TreeView when a drag is started // Client should setup the drag data public abstract void StartDrag(TreeViewItem draggedItem, List <int> draggedItemIDs);
internal static int GetItemControlID(TreeViewItem item) { return(((item == null) ? 0 : item.id) + 10000000); }
// This method is called from within DragElement when it has determined what is the parent item of the current targetItem // (This depends on if dropPosition is above, below or upon) // Implemented by client code to decide what should happen when the drag is e.g performed (e.g change the backend state of the tree view) // Notes on arguments: // When hovering outside any items: target and parent is null, dropPos is invalid // If parentItem and targetItem is the same then insert as first child of parent, dropPos is invalid // If parentItem and targetItem is different then use dropPos to insert dragged items relative to targetItem // parentItem can be null when root is visible and hovering above or below the root // if targetItem is null then parent can be null if root is visible // if targetitem is null then parent might be valid if root is hidden public abstract DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, DropPosition dropPosition);
public void HandleUnusedMouseEventsForItem(Rect rect, TreeViewItem item, int row) { int itemControlID = TreeViewController.GetItemControlID(item); Event current = Event.current; EventType typeForControl = current.GetTypeForControl(itemControlID); switch (typeForControl) { case EventType.MouseDown: if (rect.Contains(Event.current.mousePosition)) { if (Event.current.button == 0) { GUIUtility.keyboardControl = this.m_KeyboardControlID; this.Repaint(); if (Event.current.clickCount == 2) { if (this.itemDoubleClickedCallback != null) { this.itemDoubleClickedCallback(item.id); } } else { List <int> newSelection = this.GetNewSelection(item, true, false); bool flag = this.dragging != null && newSelection.Count != 0 && this.dragging.CanStartDrag(item, newSelection, Event.current.mousePosition); if (flag) { this.m_DragSelection = newSelection; DragAndDropDelay dragAndDropDelay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), itemControlID); dragAndDropDelay.mouseDownPosition = Event.current.mousePosition; } else { this.m_DragSelection.Clear(); if (this.m_AllowRenameOnMouseUp) { this.m_AllowRenameOnMouseUp = (this.state.selectedIDs.Count == 1 && this.state.selectedIDs[0] == item.id); } this.SelectionClick(item, false); if (this.itemSingleClickedCallback != null) { this.itemSingleClickedCallback(item.id); } } GUIUtility.hotControl = itemControlID; } current.Use(); } else if (Event.current.button == 1) { bool keepMultiSelection = true; this.SelectionClick(item, keepMultiSelection); } } return; case EventType.MouseUp: if (GUIUtility.hotControl == itemControlID) { bool flag2 = this.m_DragSelection.Count > 0; GUIUtility.hotControl = 0; this.m_DragSelection.Clear(); current.Use(); if (rect.Contains(current.mousePosition)) { Rect renameRect = this.gui.GetRenameRect(rect, row, item); List <int> selectedIDs = this.state.selectedIDs; if (this.m_AllowRenameOnMouseUp && selectedIDs != null && selectedIDs.Count == 1 && selectedIDs[0] == item.id && renameRect.Contains(current.mousePosition) && !EditorGUIUtility.HasHolddownKeyModifiers(current)) { this.BeginNameEditing(0.5f); } else if (flag2) { this.SelectionClick(item, false); if (this.itemSingleClickedCallback != null) { this.itemSingleClickedCallback(item.id); } } } } return; case EventType.MouseMove: IL_2C: if (typeForControl == EventType.DragUpdated || typeForControl == EventType.DragPerform) { if (this.dragging != null && this.dragging.DragElement(item, rect, row)) { GUIUtility.hotControl = 0; } return; } if (typeForControl != EventType.ContextClick) { return; } if (rect.Contains(current.mousePosition)) { if (this.contextClickItemCallback != null) { this.contextClickItemCallback(item.id); } } return; case EventType.MouseDrag: if (GUIUtility.hotControl == itemControlID && this.dragging != null && this.m_DragSelection.Count > 0) { DragAndDropDelay dragAndDropDelay2 = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), itemControlID); if (dragAndDropDelay2.CanStartDrag() && this.dragging.CanStartDrag(item, this.m_DragSelection, dragAndDropDelay2.mouseDownPosition)) { this.dragging.StartDrag(item, this.m_DragSelection); GUIUtility.hotControl = 0; } current.Use(); } return; } goto IL_2C; }
void GetPreviousAndNextItemsIgnoringDraggedItems(int targetRow, DropPosition dropPosition, out TreeViewItem previousItem, out TreeViewItem nextItem) { if (dropPosition != DropPosition.Above && dropPosition != DropPosition.Below) { throw new ArgumentException("Invalid argument: " + dropPosition); } previousItem = nextItem = null; int curPrevRow = (dropPosition == DropPosition.Above) ? targetRow - 1 : targetRow; int curNextRow = (dropPosition == DropPosition.Above) ? targetRow : targetRow + 1; while (curPrevRow > 0) { var curPreviousItem = m_TreeView.data.GetItem(curPrevRow); if (!m_TreeView.IsDraggingItem(curPreviousItem)) { previousItem = curPreviousItem; break; } curPrevRow--; } while (curNextRow < m_TreeView.data.rowCount) { var curNextItem = m_TreeView.data.GetItem(curNextRow); if (!m_TreeView.IsDraggingItem(curNextItem)) { nextItem = curNextItem; break; } curNextRow++; } }
public bool IsItemDragSelectedOrSelected(TreeViewItem item) { return((this.m_DragSelection.Count <= 0) ? this.state.selectedIDs.Contains(item.id) : this.m_DragSelection.Contains(item.id)); }
protected bool TryGetDropPosition(TreeViewItem item, Rect itemRect, int row, out DropPosition dropPosition) { Vector2 currentMousePos = Event.current.mousePosition; if (itemRect.Contains(currentMousePos)) { float dropBetweenHalfHeight = GetDropBetweenHalfHeight(item, itemRect); if (currentMousePos.y >= itemRect.yMax - dropBetweenHalfHeight) { dropPosition = DropPosition.Below; } else if (currentMousePos.y <= itemRect.yMin + dropBetweenHalfHeight) { dropPosition = DropPosition.Above; } else { dropPosition = DropPosition.Upon; } return(true); } else { // Check overlap with next item (if any) float nextOverlap = m_TreeView.gui.halfDropBetweenHeight; int nextRow = row + 1; if (nextRow < m_TreeView.data.rowCount) { Rect nextRect = m_TreeView.gui.GetRowRect(nextRow, itemRect.width); bool nextCanBeParent = m_TreeView.data.CanBeParent(m_TreeView.data.GetItem(nextRow)); if (nextCanBeParent) { nextOverlap = m_TreeView.gui.halfDropBetweenHeight; } else { nextOverlap = nextRect.height * 0.5f; } } Rect nextOverlapRect = itemRect; nextOverlapRect.y = itemRect.yMax; nextOverlapRect.height = nextOverlap; if (nextOverlapRect.Contains(currentMousePos)) { dropPosition = DropPosition.Below; return(true); } // Check overlap above first item if (row == 0) { Rect overlapUpwards = itemRect; overlapUpwards.yMin -= m_TreeView.gui.halfDropBetweenHeight; overlapUpwards.height = m_TreeView.gui.halfDropBetweenHeight; if (overlapUpwards.Contains(currentMousePos)) { dropPosition = DropPosition.Above; return(true); } } } dropPosition = DropPosition.Below; return(false); }
public virtual bool DragElement(TreeViewItem targetItem, Rect targetItemRect, bool firstItem) { bool flag = Event.current.type == EventType.DragPerform; bool result; if (targetItem == null) { if (this.m_DropData != null) { this.m_DropData.dropTargetControlID = 0; this.m_DropData.rowMarkerControlID = 0; } DragAndDrop.visualMode = this.DoDrag(null, null, flag, TreeViewDragging.DropPosition.Below); if (DragAndDrop.visualMode != DragAndDropVisualMode.None && flag) { this.FinalizeDragPerformed(true); } result = false; } else { Vector2 mousePosition = Event.current.mousePosition; bool flag2 = this.m_TreeView.data.CanBeParent(targetItem); Rect rect = targetItemRect; float num = (!flag2) ? (targetItemRect.height * 0.5f) : this.m_TreeView.gui.halfDropBetweenHeight; if (firstItem) { rect.yMin -= num; } rect.yMax += num; if (!rect.Contains(mousePosition)) { result = false; } else { TreeViewDragging.DropPosition dropPosition; if (mousePosition.y >= targetItemRect.yMax - num) { dropPosition = TreeViewDragging.DropPosition.Below; } else if (firstItem && mousePosition.y <= targetItemRect.yMin + num) { dropPosition = TreeViewDragging.DropPosition.Above; } else { dropPosition = ((!flag2) ? TreeViewDragging.DropPosition.Above : TreeViewDragging.DropPosition.Upon); } TreeViewItem treeViewItem = null; switch (dropPosition) { case TreeViewDragging.DropPosition.Upon: treeViewItem = targetItem; break; case TreeViewDragging.DropPosition.Below: if (this.m_TreeView.data.IsExpanded(targetItem) && targetItem.hasChildren) { treeViewItem = targetItem; targetItem = targetItem.children[0]; dropPosition = TreeViewDragging.DropPosition.Above; } else { treeViewItem = targetItem.parent; } break; case TreeViewDragging.DropPosition.Above: treeViewItem = targetItem.parent; break; } DragAndDropVisualMode dragAndDropVisualMode = DragAndDropVisualMode.None; if (flag) { if (dropPosition == TreeViewDragging.DropPosition.Upon) { dragAndDropVisualMode = this.DoDrag(targetItem, targetItem, true, dropPosition); } if (dragAndDropVisualMode == DragAndDropVisualMode.None && treeViewItem != null) { dragAndDropVisualMode = this.DoDrag(treeViewItem, targetItem, true, dropPosition); } if (dragAndDropVisualMode != DragAndDropVisualMode.None) { this.FinalizeDragPerformed(false); } else { this.DragCleanup(true); this.m_TreeView.NotifyListenersThatDragEnded(null, false); } } else { if (this.m_DropData == null) { this.m_DropData = new TreeViewDragging.DropData(); } this.m_DropData.dropTargetControlID = 0; this.m_DropData.rowMarkerControlID = 0; int itemControlID = TreeViewController.GetItemControlID(targetItem); this.HandleAutoExpansion(itemControlID, targetItem, targetItemRect, num, mousePosition); if (dropPosition == TreeViewDragging.DropPosition.Upon) { dragAndDropVisualMode = this.DoDrag(targetItem, targetItem, false, dropPosition); } if (dragAndDropVisualMode != DragAndDropVisualMode.None) { this.m_DropData.dropTargetControlID = itemControlID; DragAndDrop.visualMode = dragAndDropVisualMode; } else if (targetItem != null && treeViewItem != null) { dragAndDropVisualMode = this.DoDrag(treeViewItem, targetItem, false, dropPosition); if (dragAndDropVisualMode != DragAndDropVisualMode.None) { this.drawRowMarkerAbove = (dropPosition == TreeViewDragging.DropPosition.Above); this.m_DropData.rowMarkerControlID = itemControlID; DragAndDrop.visualMode = dragAndDropVisualMode; } } } Event.current.Use(); result = true; } } return(result); }
public virtual bool CanStartDrag(TreeViewItem targetItem, List <int> draggedItemIDs, Vector2 mouseDownPosition) { return(true); }
internal static void SetChildParentReferences(IList <TreeViewItem> visibleItems, TreeViewItem root) { for (int i = 0; i < visibleItems.Count; i++) { visibleItems[i].parent = null; } int num = 0; for (int j = 0; j < visibleItems.Count; j++) { TreeViewUtility.SetChildParentReferences(j, visibleItems); if (visibleItems[j].parent == null) { num++; } } if (num > 0) { List <TreeViewItem> list = new List <TreeViewItem>(num); for (int k = 0; k < visibleItems.Count; k++) { if (visibleItems[k].parent == null) { list.Add(visibleItems[k]); visibleItems[k].parent = root; } } root.children = list; } else { root.children = new List <TreeViewItem>(); } }
virtual public bool IsExpanded(TreeViewItem item) { return(IsExpanded(item.id)); }
internal static TreeViewItem FindItem(int id, TreeViewItem searchFromThisItem) { return(TreeViewUtility.FindItemRecursive(id, searchFromThisItem)); }
virtual public bool CanBeParent(TreeViewItem item) { return(true); }
internal static void SetParentAndChildrenForItems(IList <TreeViewItem> rows, TreeViewItem root) { TreeViewUtility.SetChildParentReferences(rows, root); }
public virtual void ReloadData() { m_FakeItem = null; FetchData(); }
protected virtual void DrawItemBackground(Rect rect, int row, TreeViewItem item, bool selected, bool focused) { // override for custom rendering of background behind selection and drop effect rendering }