public void UpdateGUI() { SplitterGUILayout.BeginHorizontalSplit(this.horSplit, new GUILayoutOption[0]); GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]); GUILayout.Label(this.totalUpdates, this.constants.title, new GUILayoutOption[0]); IEnumerator enumerator = ListViewGUILayout.ListView(this.lv, GUIStyle.none, new GUILayoutOption[0]).GetEnumerator(); try { while (enumerator.MoveNext()) { ListViewElement current = (ListViewElement)enumerator.Current; Rect position = current.position; position.x++; position.y++; if (Event.current.type == EventType.Repaint) { if ((current.row % 2) == 0) { this.constants.entryEven.Draw(position, false, false, false, false); } else { this.constants.entryOdd.Draw(position, false, false, false, false); } } GUILayout.BeginVertical((current.row != this.lv.row) ? this.constants.entryNormal : this.constants.entrySelected, new GUILayoutOption[0]); GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinWidth(50f) }; GUILayout.Label(this.messageFirstLines[current.row], this.constants.serverUpdateLog, options); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.MinWidth(100f) }; GUILayout.Label(this.changesets[current.row].changeset.ToString() + " " + this.changesets[current.row].date, this.constants.serverUpdateInfo, optionArray2); GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width((float)this.maxNickLength) }; GUILayout.Label(this.changesets[current.row].owner, this.constants.serverUpdateInfo, optionArray3); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } if (this.lv.selectionChanged) { this.SetSelectedRevisionLine(this.lv.row); } GUILayout.EndVertical(); SplitterGUILayout.BeginVerticalSplit(this.vertSplit, new GUILayoutOption[0]); GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]); GUILayout.Label("Changeset", this.constants.title, new GUILayoutOption[0]); int num = -1; int file = -1; IEnumerator enumerator2 = ListViewGUILayout.ListView(this.pv.lv, GUIStyle.none, new GUILayoutOption[0]).GetEnumerator(); try { while (enumerator2.MoveNext()) { ChangeFlags changeFlags; ListViewElement element2 = (ListViewElement)enumerator2.Current; if ((num == -1) && !this.pv.IndexToFolderAndFile(element2.row, ref num, ref file)) { return; } ParentViewFolder folder = this.pv.folders[num]; if (ListViewGUILayout.HasMouseDown(element2.position)) { if (Event.current.clickCount == 2) { if (!this.isDirSelected && (this.selectedGUID != string.Empty)) { this.DoShowDiff(false); GUIUtility.ExitGUI(); } } else { this.pv.lv.scrollPos = ListViewShared.ListViewScrollToRow(this.pv.lv.ilvState, element2.row); this.DoSelect(num, file, element2.row); } } else if (ListViewGUILayout.HasMouseDown(element2.position, 1)) { if (this.lv.row != element2.row) { this.DoSelect(num, file, element2.row); } if (!this.isDirSelected && (this.selectedGUID != string.Empty)) { GUIUtility.hotControl = 0; Rect rect2 = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 1f, 1f); EditorUtility.DisplayCustomMenu(rect2, this.dropDownMenuItems, null, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null); Event.current.Use(); } } if ((element2.row == this.pv.lv.row) && (Event.current.type == EventType.Repaint)) { this.constants.entrySelected.Draw(element2.position, false, false, false, false); } if (file != -1) { Texture2D cachedIcon = AssetDatabase.GetCachedIcon(folder.name + "/" + folder.files[file].name) as Texture2D; if (cachedIcon == null) { cachedIcon = InternalEditorUtility.GetIconForFile(folder.files[file].name); } GUILayout.Label(new GUIContent(folder.files[file].name, cachedIcon), this.constants.element, new GUILayoutOption[0]); changeFlags = folder.files[file].changeFlags; } else { GUILayout.Label(folder.name, this.constants.header, new GUILayoutOption[0]); changeFlags = folder.changeFlags; } GUIContent badgeNew = null; if (this.HasFlag(changeFlags, ChangeFlags.Undeleted) || this.HasFlag(changeFlags, ChangeFlags.Created)) { badgeNew = ASMainWindow.constants.badgeNew; } else if (this.HasFlag(changeFlags, ChangeFlags.Deleted)) { badgeNew = ASMainWindow.constants.badgeDelete; } else if (this.HasFlag(changeFlags, ChangeFlags.Renamed) || this.HasFlag(changeFlags, ChangeFlags.Moved)) { badgeNew = ASMainWindow.constants.badgeMove; } if ((badgeNew != null) && (Event.current.type == EventType.Repaint)) { Rect rect3 = new Rect(((element2.position.x + element2.position.width) - badgeNew.image.width) - 5f, (element2.position.y + (element2.position.height / 2f)) - (badgeNew.image.height / 2), (float)badgeNew.image.width, (float)badgeNew.image.height); EditorGUIUtility.SetIconSize(Vector2.zero); GUIStyle.none.Draw(rect3, badgeNew, false, false, false, false); EditorGUIUtility.SetIconSize(this.iconSize); } this.pv.NextFileFolder(ref num, ref file); } } finally { IDisposable disposable2 = enumerator2 as IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } if (this.pv.lv.selectionChanged && (this.selectedGUID != string.Empty)) { if (this.selectedGUID != AssetServer.GetRootGUID()) { AssetServer.SetSelectionFromGUID(this.selectedGUID); } else { AssetServer.SetSelectionFromGUID(string.Empty); } } if ((GUIUtility.keyboardControl == this.pv.lv.ID) && (((Event.current.type == EventType.KeyDown) && (Event.current.keyCode == KeyCode.Return)) && (!this.isDirSelected && (this.selectedGUID != string.Empty)))) { this.DoShowDiff(false); GUIUtility.ExitGUI(); } GUILayout.EndVertical(); GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]); GUILayout.Label("Update Message", this.constants.title, new GUILayoutOption[0]); GUILayout.TextArea((this.lv.row < 0) ? "" : this.changesets[this.lv.row].message, this.constants.wwText, new GUILayoutOption[0]); GUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); SplitterGUILayout.EndHorizontalSplit(); }
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)GUIUtility.GetStateObject(typeof(DragAndDropDelay), this.ilvState.state.ID)).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) && GUIClip.visibleRect.Contains(Event.current.mousePosition)) { if (((DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), this.ilvState.state.ID)).CanStartDrag()) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityEngine.Object[0]; DragAndDrop.paths = (string[])null; if (this.ilvState.wantsReordering) { this.ilvState.state.dropHereRect = new Rect(this.ilvState.rect.x, 0.0f, this.ilvState.rect.width, (float)(this.ilvState.state.rowHeight * 2)); DragAndDrop.StartDrag(this.dragTitle); } else if (this.ilvState.wantsToStartCustomDrag) { DragAndDrop.SetGenericData("CustomDragID", (object)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.height; } } else { if (this.xPos >= 1) { 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 insertion = (GUIStyle)ListViewShared.Constants.insertion; insertion.Draw(insertion.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; switch (Event.current.type) { case EventType.DragUpdated: 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 ((double)state.dropHereRect.y >= (double)(state.rowHeight * state.totalRows)) { state.dropHereRect.y = (float)(state.rowHeight * (state.totalRows - 1)); } state.drawDropHere = true; break; } break; case EventType.DragPerform: if (GUIClip.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; } this.ilvState.state.row = this.ilvState.state.draggedTo <= this.ilvState.state.draggedFrom ? this.ilvState.state.draggedTo : this.ilvState.state.draggedTo - 1; this.ilvState.state.selectionChanged = true; DragAndDrop.AcceptDrag(); Event.current.Use(); this.ilvState.wantsReordering = false; this.ilvState.state.drawDropHere = false; } GUIUtility.hotControl = 0; break; case EventType.DragExited: this.ilvState.wantsReordering = false; this.ilvState.state.drawDropHere = false; GUIUtility.hotControl = 0; break; } } else if (this.ilvState.wantsExternalFiles) { switch (Event.current.type) { case EventType.DragUpdated: if (GUIClip.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 ((double)this.ilvState.state.dropHereRect.y >= (double)(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; break; } break; } break; case EventType.DragPerform: if (GUIClip.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; break; case EventType.DragExited: this.ilvState.wantsExternalFiles = false; this.ilvState.state.drawDropHere = false; GUIUtility.hotControl = 0; break; } } else if (this.ilvState.wantsToAcceptCustomDrag && ListViewShared.dragControlID != this.ilvState.state.ID) { switch (Event.current.type) { case EventType.DragUpdated: if (GUIClip.visibleRect.Contains(Event.current.mousePosition) && DragAndDrop.GetGenericData("CustomDragID") != null) { DragAndDrop.visualMode = !this.ilvState.rect.Contains(Event.current.mousePosition) ? DragAndDropVisualMode.None : DragAndDropVisualMode.Move; Event.current.Use(); break; } break; case EventType.DragPerform: object genericData = DragAndDrop.GetGenericData("CustomDragID"); if (GUIClip.visibleRect.Contains(Event.current.mousePosition) && genericData != null) { this.ilvState.state.customDraggedFromID = (int)genericData; DragAndDrop.AcceptDrag(); Event.current.Use(); } GUIUtility.hotControl = 0; break; case EventType.DragExited: GUIUtility.hotControl = 0; break; } } if (this.ilvState.beganHorizontal) { EditorGUILayout.EndScrollView(); GUILayout.EndHorizontal(); this.ilvState.beganHorizontal = false; } if (this.isLayouted) { GUILayoutUtility.EndLayoutGroup(); EditorGUILayout.EndScrollView(); } this.ilvState.wantsReordering = false; this.ilvState.wantsExternalFiles = false; } else if (this.isLayouted) { if (this.yPos != this.yFrom) { this.ilvStateL.group.ResetCursor(); this.ilvStateL.group.AddY(); } else { this.ilvStateL.group.AddY((float)(this.ilvState.invisibleRows * this.ilvState.state.rowHeight)); } } if (this.isLayouted) { if (!this.quiting) { GUILayout.BeginHorizontal(GUIStyle.none, new GUILayoutOption[0]); } else { GUILayout.EndHorizontal(); } } return(!this.quiting); }
internal static bool SendKey(ListViewShared.InternalListViewState ilvState, KeyCode keyCode, int totalCols) { ListViewState state = ilvState.state; switch (keyCode) { case KeyCode.UpArrow: if (state.row > 0) { --state.row; break; } break; case KeyCode.DownArrow: if (state.row < state.totalRows - 1) { ++state.row; break; } break; case KeyCode.RightArrow: if (state.column < totalCols - 1) { ++state.column; break; } break; case KeyCode.LeftArrow: if (state.column > 0) { --state.column; break; } break; case KeyCode.Home: state.row = 0; break; case KeyCode.End: state.row = state.totalRows - 1; break; case KeyCode.PageUp: if (!ListViewShared.DoLVPageUpDown(ilvState, ref state.row, ref state.scrollPos, true)) { Event.current.Use(); return(false); } break; case KeyCode.PageDown: if (!ListViewShared.DoLVPageUpDown(ilvState, ref state.row, ref state.scrollPos, false)) { Event.current.Use(); return(false); } break; default: return(false); } state.scrollPos = ListViewShared.ListViewScrollToRow(ilvState, state.scrollPos, state.row); Event.current.Use(); return(true); }
internal static Vector2 ListViewScrollToRow(ListViewShared.InternalListViewState ilvState, int row) { return(ListViewShared.ListViewScrollToRow(ilvState, ilvState.state.scrollPos, row)); }
internal static int ListViewScrollToRow(ListViewShared.InternalListViewState ilvState, int currPosY, int row) { return((int)ListViewShared.ListViewScrollToRow(ilvState, new Vector2(0.0f, (float)currPosY), row).y); }
internal static bool MultiSelection(ListViewShared.InternalListViewState ilvState, int prevSelected, int currSelected, ref int initialSelected, ref bool[] selectedItems) { bool shift = Event.current.shift; bool actionKey = EditorGUI.actionKey; bool flag = false; if ((shift || actionKey) && initialSelected == -1) { initialSelected = prevSelected; } if (shift) { int num1 = Math.Min(initialSelected, currSelected); int num2 = Math.Max(initialSelected, currSelected); if (!actionKey) { for (int index = 0; index < num1; ++index) { if (selectedItems[index]) { flag = true; } selectedItems[index] = false; } for (int index = num2 + 1; index < selectedItems.Length; ++index) { if (selectedItems[index]) { flag = true; } selectedItems[index] = false; } } if (num1 < 0) { num1 = num2; } for (int index = num1; index <= num2; ++index) { if (!selectedItems[index]) { flag = true; } selectedItems[index] = true; } } else if (actionKey) { selectedItems[currSelected] = !selectedItems[currSelected]; initialSelected = currSelected; flag = true; } else { if (!selectedItems[currSelected]) { flag = true; } for (int index = 0; index < selectedItems.Length; ++index) { if (selectedItems[index] && currSelected != index) { flag = true; } selectedItems[index] = false; } initialSelected = -1; selectedItems[currSelected] = true; } if (ilvState != null) { ilvState.state.scrollPos = ListViewShared.ListViewScrollToRow(ilvState, currSelected); } return(flag); }
public bool MoveNext() { if (xPos > -1) { if (ListViewShared.HasMouseDown(ilvState, rect)) { var previousRow = ilvState.state.row; ilvState.state.selectionChanged = true; ilvState.state.row = yPos; ilvState.state.column = xPos; ilvState.state.scrollPos = ListViewShared.ListViewScrollToRow(ilvState, yPos); // this is about clicking on a row that is partially visible if (ilvState.wantsRowMultiSelection) { MultiSelection(ilvState, previousRow); } if ((ilvState.wantsReordering || ilvState.wantsToStartCustomDrag) && (GUIUtility.hotControl == ilvState.state.ID)) { DragAndDropDelay delay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), ilvState.state.ID); delay.mouseDownPosition = Event.current.mousePosition; ilvState.dragItem = yPos; dragControlID = ilvState.state.ID; } } // On Mouse drag, start drag & drop if (!ListViewShared.isDragging && (ilvState.wantsReordering || ilvState.wantsToStartCustomDrag) && GUIUtility.hotControl == ilvState.state.ID && Event.current.type == EventType.MouseDrag && GUIClip.visibleRect.Contains(Event.current.mousePosition)) { DragAndDropDelay delay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), ilvState.state.ID); if (delay.CanStartDrag()) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityEngine.Object[] {}; // this IS required for dragging to work DragAndDrop.paths = null; if (ilvState.wantsReordering) { ilvState.state.dropHereRect = new Rect(ilvState.rect.x, 0, ilvState.rect.width, ilvState.state.rowHeight * 2); DragAndDrop.StartDrag(dragTitle); } else if (ilvState.wantsToStartCustomDrag) { DragAndDrop.SetGenericData("CustomDragID", ilvState.state.ID); DragAndDrop.StartDrag(dragTitle); } ListViewShared.isDragging = true; } Event.current.Use(); } } xPos++; if (xPos > xTo) { xPos = 0; yPos++; rect.x = firstRect.x; rect.width = colWidths[0]; if (yPos > yTo) { quiting = true; } else // move vertically { rect.y += rect.height; } } else // move horizontally { if (xPos >= 1) { rect.x += colWidths[xPos - 1]; } rect.width = colWidths[xPos]; } element.row = yPos; element.column = xPos; element.position = rect; if (element.row >= ilvState.state.totalRows) { quiting = true; } if (isLayouted && Event.current.type == EventType.Layout) { // this is just "on layout event enumerate just first row" (so we get height of single row) if (yFrom + 1 == yPos) { quiting = true; } } if (isLayouted && yPos != yFrom) { GUILayout.EndHorizontal(); } if (quiting) { if (ilvState.state.drawDropHere && Event.current.GetTypeForControl(ilvState.state.ID) == EventType.Repaint) { GUIStyle insertion = Constants.insertion; insertion.Draw(insertion.margin.Remove(ilvState.state.dropHereRect), false, false, false, false); } if (ListViewShared.ListViewKeyboard(ilvState, colWidths.Length)) { ilvState.state.selectionChanged = true; } if (Event.current.GetTypeForControl(ilvState.state.ID) == EventType.MouseUp) { GUIUtility.hotControl = 0; } if (ilvState.wantsReordering && (GUIUtility.hotControl == ilvState.state.ID)) { ListViewState lv = ilvState.state; switch (Event.current.type) { case EventType.DragUpdated: { DragAndDrop.visualMode = ilvState.rect.Contains(Event.current.mousePosition) ? DragAndDropVisualMode.Move : DragAndDropVisualMode.None; Event.current.Use(); if (DragAndDrop.visualMode != DragAndDropVisualMode.None) { lv.dropHereRect.y = (Mathf.RoundToInt(Event.current.mousePosition.y / lv.rowHeight) - 1) * lv.rowHeight; if (lv.dropHereRect.y >= lv.rowHeight * lv.totalRows) { lv.dropHereRect.y = lv.rowHeight * (lv.totalRows - 1); } lv.drawDropHere = true; } break; } case EventType.DragPerform: { if (GUIClip.visibleRect.Contains(Event.current.mousePosition)) { ilvState.state.draggedFrom = ilvState.dragItem; ilvState.state.draggedTo = Mathf.RoundToInt(Event.current.mousePosition.y / lv.rowHeight); if (ilvState.state.draggedTo > ilvState.state.totalRows) { ilvState.state.draggedTo = ilvState.state.totalRows; } // the guy handling this would better actually rearrange items... if (ilvState.state.draggedTo > ilvState.state.draggedFrom) { ilvState.state.row = ilvState.state.draggedTo - 1; } else { ilvState.state.row = ilvState.state.draggedTo; } ilvState.state.selectionChanged = true; DragAndDrop.AcceptDrag(); Event.current.Use(); ilvState.wantsReordering = false; ilvState.state.drawDropHere = false; } GUIUtility.hotControl = 0; break; } case EventType.DragExited: { ilvState.wantsReordering = false; ilvState.state.drawDropHere = false; GUIUtility.hotControl = 0; break; } } } else if (ilvState.wantsExternalFiles) { switch (Event.current.type) { case EventType.DragUpdated: { if ((GUIClip.visibleRect.Contains(Event.current.mousePosition)) && (DragAndDrop.paths != null) && (DragAndDrop.paths.Length != 0)) // dragging files from somewhere { DragAndDrop.visualMode = ilvState.rect.Contains(Event.current.mousePosition) ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.None; Event.current.Use(); if (DragAndDrop.visualMode != DragAndDropVisualMode.None) { ilvState.state.dropHereRect = new Rect(ilvState.rect.x, (Mathf.RoundToInt(Event.current.mousePosition.y / ilvState.state.rowHeight) - 1) * ilvState.state.rowHeight, ilvState.rect.width, ilvState.state.rowHeight); if (ilvState.state.dropHereRect.y >= ilvState.state.rowHeight * ilvState.state.totalRows) { ilvState.state.dropHereRect.y = ilvState.state.rowHeight * (ilvState.state.totalRows - 1); } ilvState.state.drawDropHere = true; } } break; } case EventType.DragPerform: { if (GUIClip.visibleRect.Contains(Event.current.mousePosition)) { ilvState.state.fileNames = DragAndDrop.paths; DragAndDrop.AcceptDrag(); Event.current.Use(); ilvState.wantsExternalFiles = false; ilvState.state.drawDropHere = false; ilvState.state.draggedTo = Mathf.RoundToInt(Event.current.mousePosition.y / ilvState.state.rowHeight); if (ilvState.state.draggedTo > ilvState.state.totalRows) { ilvState.state.draggedTo = ilvState.state.totalRows; } ilvState.state.row = ilvState.state.draggedTo; } GUIUtility.hotControl = 0; break; } case EventType.DragExited: { ilvState.wantsExternalFiles = false; ilvState.state.drawDropHere = false; GUIUtility.hotControl = 0; break; } } } else if (ilvState.wantsToAcceptCustomDrag && (dragControlID != ilvState.state.ID)) { switch (Event.current.type) { case EventType.DragUpdated: { object data = DragAndDrop.GetGenericData("CustomDragID"); if (GUIClip.visibleRect.Contains(Event.current.mousePosition) && data != null) { DragAndDrop.visualMode = ilvState.rect.Contains(Event.current.mousePosition) ? DragAndDropVisualMode.Move : DragAndDropVisualMode.None; Event.current.Use(); } break; } case EventType.DragPerform: { object data = DragAndDrop.GetGenericData("CustomDragID"); if (GUIClip.visibleRect.Contains(Event.current.mousePosition) && data != null) { ilvState.state.customDraggedFromID = (int)data; DragAndDrop.AcceptDrag(); Event.current.Use(); } GUIUtility.hotControl = 0; break; } case EventType.DragExited: { GUIUtility.hotControl = 0; break; } } } if (ilvState.beganHorizontal) { EditorGUILayout.EndScrollView(); GUILayout.EndHorizontal(); ilvState.beganHorizontal = false; } if (isLayouted) { GUILayoutUtility.EndLayoutGroup(); EditorGUILayout.EndScrollView(); } ilvState.wantsReordering = false; ilvState.wantsExternalFiles = false; } else if (isLayouted) { if (yPos != yFrom) { ilvStateL.group.ResetCursor(); ilvStateL.group.AddY(); } else { ilvStateL.group.AddY(ilvState.invisibleRows * ilvState.state.rowHeight); } } if (isLayouted) { if (!quiting) { GUILayout.BeginHorizontal(GUIStyle.none); // for each row } else { GUILayout.EndHorizontal(); // the one used for drawing LVs background } } return(!quiting); }
internal static bool MultiSelection(ListViewShared.InternalListViewState ilvState, int prevSelected, int currSelected, ref int initialSelected, ref bool[] selectedItems) { bool shift = Event.current.shift; bool actionKey = EditorGUI.actionKey; bool result = false; if ((shift || actionKey) && initialSelected == -1) { initialSelected = prevSelected; } if (shift) { int num = Math.Min(initialSelected, currSelected); int num2 = Math.Max(initialSelected, currSelected); if (!actionKey) { for (int i = 0; i < num; i++) { if (selectedItems[i]) { result = true; } selectedItems[i] = false; } for (int j = num2 + 1; j < selectedItems.Length; j++) { if (selectedItems[j]) { result = true; } selectedItems[j] = false; } } if (num < 0) { num = num2; } for (int k = num; k <= num2; k++) { if (!selectedItems[k]) { result = true; } selectedItems[k] = true; } } else if (actionKey) { selectedItems[currSelected] = !selectedItems[currSelected]; initialSelected = currSelected; result = true; } else { if (!selectedItems[currSelected]) { result = true; } for (int l = 0; l < selectedItems.Length; l++) { if (selectedItems[l] && currSelected != l) { result = true; } selectedItems[l] = false; } initialSelected = -1; selectedItems[currSelected] = true; } if (ilvState != null) { ilvState.state.scrollPos = ListViewShared.ListViewScrollToRow(ilvState, currSelected); } return(result); }
internal static bool SendKey(ListViewShared.InternalListViewState ilvState, KeyCode keyCode, int totalCols) { ListViewState state = ilvState.state; bool result; switch (keyCode) { case KeyCode.UpArrow: if (state.row > 0) { state.row--; } goto IL_14C; case KeyCode.DownArrow: if (state.row < state.totalRows - 1) { state.row++; } goto IL_14C; case KeyCode.RightArrow: if (state.column < totalCols - 1) { state.column++; } goto IL_14C; case KeyCode.LeftArrow: if (state.column > 0) { state.column--; } goto IL_14C; case KeyCode.Home: state.row = 0; goto IL_14C; case KeyCode.End: state.row = state.totalRows - 1; goto IL_14C; case KeyCode.PageUp: if (!ListViewShared.DoLVPageUpDown(ilvState, ref state.row, ref state.scrollPos, true)) { Event.current.Use(); result = false; return(result); } goto IL_14C; case KeyCode.PageDown: if (!ListViewShared.DoLVPageUpDown(ilvState, ref state.row, ref state.scrollPos, false)) { Event.current.Use(); result = false; return(result); } goto IL_14C; } result = false; return(result); IL_14C: state.scrollPos = ListViewShared.ListViewScrollToRow(ilvState, state.scrollPos, state.row); Event.current.Use(); result = true; return(result); }
public void UpdateGUI() { SplitterGUILayout.BeginHorizontalSplit(this.horSplit); GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]); GUILayout.Label(this.totalUpdates, this.constants.title, new GUILayoutOption[0]); foreach (ListViewElement listViewElement in ListViewGUILayout.ListView(this.lv, GUIStyle.none)) { Rect position = listViewElement.position; ++position.x; ++position.y; if (Event.current.type == EventType.Repaint) { if (listViewElement.row % 2 == 0) { this.constants.entryEven.Draw(position, false, false, false, false); } else { this.constants.entryOdd.Draw(position, false, false, false, false); } } GUILayout.BeginVertical(listViewElement.row != this.lv.row ? this.constants.entryNormal : this.constants.entrySelected, new GUILayoutOption[0]); GUILayout.Label(this.messageFirstLines[listViewElement.row], this.constants.serverUpdateLog, new GUILayoutOption[1] { GUILayout.MinWidth(50f) }); GUILayout.BeginHorizontal(); GUILayout.Label(this.changesets[listViewElement.row].changeset.ToString() + " " + this.changesets[listViewElement.row].date, this.constants.serverUpdateInfo, new GUILayoutOption[1] { GUILayout.MinWidth(100f) }); GUILayout.Label(this.changesets[listViewElement.row].owner, this.constants.serverUpdateInfo, new GUILayoutOption[1] { GUILayout.Width((float)this.maxNickLength) }); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } if (this.lv.selectionChanged) { this.SetSelectedRevisionLine(this.lv.row); } GUILayout.EndVertical(); SplitterGUILayout.BeginVerticalSplit(this.vertSplit); GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]); GUILayout.Label("Changeset", this.constants.title, new GUILayoutOption[0]); int folder1 = -1; int file = -1; foreach (ListViewElement listViewElement in ListViewGUILayout.ListView(this.pv.lv, GUIStyle.none)) { if (folder1 == -1 && !this.pv.IndexToFolderAndFile(listViewElement.row, ref folder1, ref file)) { return; } ParentViewFolder folder2 = this.pv.folders[folder1]; if (ListViewGUILayout.HasMouseDown(listViewElement.position)) { if (Event.current.clickCount == 2) { if (!this.isDirSelected && this.selectedGUID != string.Empty) { this.DoShowDiff(false); GUIUtility.ExitGUI(); } } else { this.pv.lv.scrollPos = ListViewShared.ListViewScrollToRow((ListViewShared.InternalListViewState) this.pv.lv.ilvState, listViewElement.row); this.DoSelect(folder1, file, listViewElement.row); } } else if (ListViewGUILayout.HasMouseDown(listViewElement.position, 1)) { if (this.lv.row != listViewElement.row) { this.DoSelect(folder1, file, listViewElement.row); } if (!this.isDirSelected && this.selectedGUID != string.Empty) { GUIUtility.hotControl = 0; EditorUtility.DisplayCustomMenu(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 1f, 1f), this.dropDownMenuItems, (int[])null, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), (object)null); Event.current.Use(); } } if (listViewElement.row == this.pv.lv.row && Event.current.type == EventType.Repaint) { this.constants.entrySelected.Draw(listViewElement.position, false, false, false, false); } ChangeFlags changeFlags; if (file != -1) { Texture2D texture2D = AssetDatabase.GetCachedIcon(folder2.name + "/" + folder2.files[file].name) as Texture2D; if ((UnityEngine.Object)texture2D == (UnityEngine.Object)null) { texture2D = InternalEditorUtility.GetIconForFile(folder2.files[file].name); } GUILayout.Label(new GUIContent(folder2.files[file].name, (Texture)texture2D), this.constants.element, new GUILayoutOption[0]); changeFlags = folder2.files[file].changeFlags; } else { GUILayout.Label(folder2.name, this.constants.header, new GUILayoutOption[0]); changeFlags = folder2.changeFlags; } GUIContent content = (GUIContent)null; if (this.HasFlag(changeFlags, ChangeFlags.Undeleted) || this.HasFlag(changeFlags, ChangeFlags.Created)) { content = ASMainWindow.constants.badgeNew; } else if (this.HasFlag(changeFlags, ChangeFlags.Deleted)) { content = ASMainWindow.constants.badgeDelete; } else if (this.HasFlag(changeFlags, ChangeFlags.Renamed) || this.HasFlag(changeFlags, ChangeFlags.Moved)) { content = ASMainWindow.constants.badgeMove; } if (content != null && Event.current.type == EventType.Repaint) { Rect position = new Rect((float)((double)listViewElement.position.x + (double)listViewElement.position.width - (double)content.image.width - 5.0), listViewElement.position.y + listViewElement.position.height / 2f - (float)(content.image.height / 2), (float)content.image.width, (float)content.image.height); EditorGUIUtility.SetIconSize(Vector2.zero); GUIStyle.none.Draw(position, content, false, false, false, false); EditorGUIUtility.SetIconSize(this.iconSize); } this.pv.NextFileFolder(ref folder1, ref file); } if (this.pv.lv.selectionChanged && this.selectedGUID != string.Empty) { if (this.selectedGUID != AssetServer.GetRootGUID()) { AssetServer.SetSelectionFromGUID(this.selectedGUID); } else { AssetServer.SetSelectionFromGUID(string.Empty); } } if (GUIUtility.keyboardControl == this.pv.lv.ID && Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.Return && !this.isDirSelected) && this.selectedGUID != string.Empty) { this.DoShowDiff(false); GUIUtility.ExitGUI(); } GUILayout.EndVertical(); GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]); GUILayout.Label("Update Message", this.constants.title, new GUILayoutOption[0]); GUILayout.TextArea(this.lv.row < 0 ? string.Empty : this.changesets[this.lv.row].message, this.constants.wwText, new GUILayoutOption[0]); GUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); SplitterGUILayout.EndHorizontalSplit(); }