protected override void DoItemGUI(Rect rect, int row, TreeViewItem item, bool selected, bool focused, bool useBoldFont) { EditorGUIUtility.SetIconSize(new Vector2(k_IconWidth, k_IconWidth)); float foldoutIndent = GetFoldoutIndent(item); int itemControlId = TreeView.GetItemControlID(item, m_TreeView); bool flag1 = false; if (m_TreeView.dragging != null) { flag1 = m_TreeView.dragging.GetDropTargetControlID() == itemControlId && m_TreeView.data.CanBeParent(item); } bool flag2 = IsRenaming(item.id); bool flag3 = m_TreeView.data.IsExpandable(item) && !m_TreeView.isSearching; if (flag2 && Event.current.type == EventType.Repaint) { float num2 = (float)(foldoutIndent + iconTotalPadding - 1.0) + 12f; GetRenameOverlay().editFieldRect = new Rect(rect.x + num2, rect.y, rect.width - num2, rect.height); } if (Event.current.type == EventType.Repaint) { string label = item.displayName; if (flag2) { selected = false; label = string.Empty; } if (selected) { s_Styles.selectionStyle.Draw(rect, false, false, true, focused); } if (flag1) { s_Styles.lineStyle.Draw(rect, GUIContent.none, true, true, false, false); } DrawIconAndLabel(rect, item, label, selected, focused, useBoldFont, false); if (m_TreeView.dragging != null && m_TreeView.dragging.GetRowMarkerControlID() == itemControlId) { float contentIndent = GetContentIndent(item); var paddingLeft = k_IconWidth + iconTotalPadding + k_SpaceBetweenIconAndText; m_DraggingInsertionMarkerRect = new Rect(rect.x + contentIndent - 5 + paddingLeft, rect.y, rect.width - contentIndent + 5, rect.height); } } if (flag3) { DoFoldout(rect, item, row); } EditorGUIUtility.SetIconSize(Vector2.zero); }
public override bool DragElement(TreeViewItem targetItem, Rect targetItemRect, bool firstItem) { if (targetItem == null) { if (m_DropData != null) { m_DropData.dropTargetControlID = 0; m_DropData.rowMarkerControlID = 0; } bool perform = Event.current.type == EventType.DragPerform; DragAndDrop.visualMode = DoDrag(null, null, perform, TreeViewDragging.DropPosition.Below); if (DragAndDrop.visualMode != DragAndDropVisualMode.None && perform) { FinalizeDragPerformed(true); } return(false); } Vector2 mousePosition = Event.current.mousePosition; bool flag = m_TreeView.data.CanBeParent(targetItem); Rect rect = targetItemRect; float betweenHalfHeight = !flag ? targetItemRect.height * 0.5f : m_TreeView.gui.halfDropBetweenHeight; if (firstItem) { rect.yMin -= betweenHalfHeight; } rect.yMax += betweenHalfHeight; if (!rect.Contains(mousePosition)) { return(false); } TreeViewDragging.DropPosition dropPosition = mousePosition.y < targetItemRect.yMax - betweenHalfHeight ? (!firstItem || mousePosition.y > targetItemRect.yMin + betweenHalfHeight ? (!flag ? TreeViewDragging.DropPosition.Above : TreeViewDragging.DropPosition.Upon) : TreeViewDragging.DropPosition.Above) : TreeViewDragging.DropPosition.Below; TreeViewItem parentItem = !m_TreeView.data.IsExpanded(targetItem) || !targetItem.hasChildren ? targetItem.parent : targetItem; DragAndDropVisualMode andDropVisualMode1 = DragAndDropVisualMode.None; if (Event.current.type == EventType.DragPerform) { if (dropPosition == TreeViewDragging.DropPosition.Upon) { andDropVisualMode1 = DoDrag(targetItem, targetItem, true, dropPosition); } if (andDropVisualMode1 == DragAndDropVisualMode.None && parentItem != null) { andDropVisualMode1 = DoDrag(parentItem, targetItem, true, dropPosition); } if (andDropVisualMode1 != DragAndDropVisualMode.None) { FinalizeDragPerformed(false); } else { DragCleanup(true); m_TreeView.NotifyListenersThatDragEnded(null, false); } } else { if (m_DropData == null) { m_DropData = new TreeViewDragging.DropData(); } m_DropData.dropTargetControlID = 0; m_DropData.rowMarkerControlID = 0; int itemControlId = TreeView.GetItemControlID(targetItem, m_TreeView); HandleAutoExpansion(itemControlId, targetItem, targetItemRect, betweenHalfHeight, mousePosition); if (dropPosition == TreeViewDragging.DropPosition.Upon) { andDropVisualMode1 = DoDrag(targetItem, targetItem, false, dropPosition); } if (andDropVisualMode1 != DragAndDropVisualMode.None) { m_DropData.dropTargetControlID = itemControlId; DragAndDrop.visualMode = andDropVisualMode1; } else if (parentItem != null) { DragAndDropVisualMode andDropVisualMode2 = DoDrag(parentItem, targetItem, false, dropPosition); if (andDropVisualMode2 != DragAndDropVisualMode.None) { drawRowMarkerAbove = dropPosition == TreeViewDragging.DropPosition.Above; m_DropData.rowMarkerControlID = itemControlId; //m_DropData.dropTargetControlID = !drawRowMarkerAbove ? TreeView.GetItemControlID(parentItem) : 0; DragAndDrop.visualMode = andDropVisualMode2; } } } Event.current.Use(); return(true); }