public bool MoveNext() { if (this.xPos > -1) { if (ListViewShared.HasMouseDown(this.ilvState, this.rect)) { this.ilvState.state.selectionChanged = true; this.ilvState.state.row = this.yPos; this.ilvState.state.column = this.xPos; this.ilvState.state.scrollPos = ListViewShared.ListViewScrollToRow(this.ilvState, this.yPos); if ((this.ilvState.wantsReordering || this.ilvState.wantsToStartCustomDrag) && GUIUtility.hotControl == this.ilvState.state.ID) { DragAndDropDelay dragAndDropDelay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), this.ilvState.state.ID); dragAndDropDelay.mouseDownPosition = Event.current.mousePosition; this.ilvState.dragItem = this.yPos; ListViewShared.dragControlID = this.ilvState.state.ID; } } if ((this.ilvState.wantsReordering || this.ilvState.wantsToStartCustomDrag) && GUIUtility.hotControl == this.ilvState.state.ID && Event.current.type == EventType.MouseDrag && GUIClipHelper.visibleRect.Contains(Event.current.mousePosition)) { DragAndDropDelay dragAndDropDelay2 = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), this.ilvState.state.ID); if (dragAndDropDelay2.CanStartDrag()) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityEngine.Object[0]; DragAndDrop.paths = null; if (this.ilvState.wantsReordering) { this.ilvState.state.dropHereRect = new Rect(this.ilvState.rect.x, 0f, this.ilvState.rect.width, (float)(this.ilvState.state.rowHeight * 2)); DragAndDrop.StartDrag(this.dragTitle); } else { if (this.ilvState.wantsToStartCustomDrag) { DragAndDrop.SetGenericData("CustomDragID", this.ilvState.state.ID); DragAndDrop.StartDrag(this.dragTitle); } } } Event.current.Use(); } } this.xPos++; if (this.xPos > this.xTo) { this.xPos = 0; this.yPos++; this.rect.x = this.firstRect.x; this.rect.width = (float)this.colWidths[0]; if (this.yPos > this.yTo) { this.quiting = true; } else { this.rect.y = this.rect.y + this.rect.height; } } else { if (this.xPos >= 1) { this.rect.x = this.rect.x + (float)this.colWidths[this.xPos - 1]; } this.rect.width = (float)this.colWidths[this.xPos]; } this.element.row = this.yPos; this.element.column = this.xPos; this.element.position = this.rect; if (this.element.row >= this.ilvState.state.totalRows) { this.quiting = true; } if (this.isLayouted && Event.current.type == EventType.Layout && this.yFrom + 1 == this.yPos) { this.quiting = true; } if (this.isLayouted && this.yPos != this.yFrom) { GUILayout.EndHorizontal(); } if (this.quiting) { if (this.ilvState.state.drawDropHere && Event.current.GetTypeForControl(this.ilvState.state.ID) == EventType.Repaint) { GUIStyle gUIStyle = ListViewShared.Constants.insertion; gUIStyle.Draw(gUIStyle.margin.Remove(this.ilvState.state.dropHereRect), false, false, false, false); } if (ListViewShared.ListViewKeyboard(this.ilvState, this.colWidths.Length)) { this.ilvState.state.selectionChanged = true; } if (Event.current.GetTypeForControl(this.ilvState.state.ID) == EventType.MouseUp) { GUIUtility.hotControl = 0; } if (this.ilvState.wantsReordering && GUIUtility.hotControl == this.ilvState.state.ID) { ListViewState state = this.ilvState.state; EventType type = Event.current.type; if (type != EventType.DragUpdated) { if (type != EventType.DragPerform) { if (type == EventType.DragExited) { this.ilvState.wantsReordering = false; this.ilvState.state.drawDropHere = false; GUIUtility.hotControl = 0; } } else { if (GUIClipHelper.visibleRect.Contains(Event.current.mousePosition)) { this.ilvState.state.draggedFrom = this.ilvState.dragItem; this.ilvState.state.draggedTo = Mathf.RoundToInt(Event.current.mousePosition.y / (float)state.rowHeight); if (this.ilvState.state.draggedTo > this.ilvState.state.totalRows) { this.ilvState.state.draggedTo = this.ilvState.state.totalRows; } if (this.ilvState.state.draggedTo > this.ilvState.state.draggedFrom) { this.ilvState.state.row = this.ilvState.state.draggedTo - 1; } else { this.ilvState.state.row = this.ilvState.state.draggedTo; } this.ilvState.state.selectionChanged = true; DragAndDrop.AcceptDrag(); Event.current.Use(); this.ilvState.wantsReordering = false; this.ilvState.state.drawDropHere = false; } GUIUtility.hotControl = 0; } } else { DragAndDrop.visualMode = ((!this.ilvState.rect.Contains(Event.current.mousePosition)) ? DragAndDropVisualMode.None : DragAndDropVisualMode.Move); Event.current.Use(); if (DragAndDrop.visualMode != DragAndDropVisualMode.None) { state.dropHereRect.y = (float)((Mathf.RoundToInt(Event.current.mousePosition.y / (float)state.rowHeight) - 1) * state.rowHeight); if (state.dropHereRect.y >= (float)(state.rowHeight * state.totalRows)) { state.dropHereRect.y = (float)(state.rowHeight * (state.totalRows - 1)); } state.drawDropHere = true; } } } else { if (this.ilvState.wantsExternalFiles) { EventType type = Event.current.type; if (type != EventType.DragUpdated) { if (type != EventType.DragPerform) { if (type == EventType.DragExited) { this.ilvState.wantsExternalFiles = false; this.ilvState.state.drawDropHere = false; GUIUtility.hotControl = 0; } } else { if (GUIClipHelper.visibleRect.Contains(Event.current.mousePosition)) { this.ilvState.state.fileNames = DragAndDrop.paths; DragAndDrop.AcceptDrag(); Event.current.Use(); this.ilvState.wantsExternalFiles = false; this.ilvState.state.drawDropHere = false; this.ilvState.state.draggedTo = Mathf.RoundToInt(Event.current.mousePosition.y / (float)this.ilvState.state.rowHeight); if (this.ilvState.state.draggedTo > this.ilvState.state.totalRows) { this.ilvState.state.draggedTo = this.ilvState.state.totalRows; } this.ilvState.state.row = this.ilvState.state.draggedTo; } GUIUtility.hotControl = 0; } } else { if (GUIClipHelper.visibleRect.Contains(Event.current.mousePosition) && DragAndDrop.paths != null && DragAndDrop.paths.Length != 0) { DragAndDrop.visualMode = ((!this.ilvState.rect.Contains(Event.current.mousePosition)) ? DragAndDropVisualMode.None : DragAndDropVisualMode.Copy); Event.current.Use(); if (DragAndDrop.visualMode != DragAndDropVisualMode.None) { this.ilvState.state.dropHereRect = new Rect(this.ilvState.rect.x, (float)((Mathf.RoundToInt(Event.current.mousePosition.y / (float)this.ilvState.state.rowHeight) - 1) * this.ilvState.state.rowHeight), this.ilvState.rect.width, (float)this.ilvState.state.rowHeight); if (this.ilvState.state.dropHereRect.y >= (float)(this.ilvState.state.rowHeight * this.ilvState.state.totalRows)) { this.ilvState.state.dropHereRect.y = (float)(this.ilvState.state.rowHeight * (this.ilvState.state.totalRows - 1)); } this.ilvState.state.drawDropHere = true; } } } } else { if (this.ilvState.wantsToAcceptCustomDrag && ListViewShared.dragControlID != this.ilvState.state.ID) { EventType type = Event.current.type; if (type != EventType.DragUpdated) { if (type != EventType.DragPerform) { if (type == EventType.DragExited) { GUIUtility.hotControl = 0; } } else { object genericData = DragAndDrop.GetGenericData("CustomDragID"); if (GUIClipHelper.visibleRect.Contains(Event.current.mousePosition) && genericData != null) { this.ilvState.state.customDraggedFromID = (int)genericData; DragAndDrop.AcceptDrag(); Event.current.Use(); } GUIUtility.hotControl = 0; } } else { object genericData2 = DragAndDrop.GetGenericData("CustomDragID"); if (GUIClipHelper.visibleRect.Contains(Event.current.mousePosition) && genericData2 != null) { DragAndDrop.visualMode = ((!this.ilvState.rect.Contains(Event.current.mousePosition)) ? DragAndDropVisualMode.None : DragAndDropVisualMode.Move); Event.current.Use(); } } } } } if (this.ilvState.beganHorizontal) { EditorGUILayout.EndScrollView(); GUILayout.EndHorizontal(); this.ilvState.beganHorizontal = false; } if (this.isLayouted) { } this.ilvState.wantsReordering = false; this.ilvState.wantsExternalFiles = false; } else { if (this.isLayouted) { } } if (this.isLayouted) { if (!this.quiting) { GUILayout.BeginHorizontal(GUIStyle.none, new GUILayoutOption[0]); } else { GUILayout.EndHorizontal(); } } return(!this.quiting); }
public static bool HasMouseDown(Rect r, int button) { return(ListViewShared.HasMouseDown(ListViewGUI.ilvState, r, button)); }
internal static bool HasMouseDown(ListViewShared.InternalListViewState ilvState, Rect r) { return(ListViewShared.HasMouseDown(ilvState, r, 0)); }
public static bool HasMouseDown(Rect r) { return(ListViewShared.HasMouseDown(ListViewGUI.ilvState, r, 0)); }