private bool HandleMouse(Rect area) { Event current = Event.current; bool result = false; bool flag = area.Contains(current.mousePosition); if (current.type == EventType.MouseDown && flag) { result = true; this.dragCount = 0; GUIUtility.keyboardControl = 0; this.singleSelect = this.GetItemAt(area, current.mousePosition); if (this.singleSelect != null && !this.singleSelect.Dummy) { if (current.button == 0 && current.clickCount > 1 && this.singleSelect.Asset != null) { this.singleSelect.Asset.Edit(); } if (current.button < 2) { float num = area.x + (float)((this.singleSelect.Indent - 1) * 18); if (current.mousePosition.x >= num && current.mousePosition.x < num + 16f && this.singleSelect.CanExpand) { this.singleSelect.Expanded = !this.singleSelect.Expanded; this.CallExpandedEvent(this.singleSelect, true); this.singleSelect = null; } else { if (current.control || current.command) { if (current.button == 1) { this.SelectedAdd(this.singleSelect); } else { this.SelectedToggle(this.singleSelect); } this.singleSelect = null; } else { if (current.shift) { this.SelectionFlow(this.singleSelect); this.singleSelect = null; } else { if (!this.IsSelected(this.singleSelect)) { this.SelectedSet(this.singleSelect); this.singleSelect = null; } } } } } } else { if (current.button == 0) { this.SelectedClear(); this.singleSelect = null; } } } else { if ((current.type == EventType.MouseUp || current.type == EventType.ContextClick) && flag) { GUIUtility.keyboardControl = 0; this.singleSelect = this.GetItemAt(area, current.mousePosition); this.dragCount = 0; result = true; if (this.singleSelect != null && !this.singleSelect.Dummy) { if (current.type == EventType.ContextClick) { this.singleSelect = null; if (!this.IsSelectedAsset() && !string.IsNullOrEmpty(this.menuFolder)) { ListControl.s_uniqueIDList[this.uniqueID] = this; EditorUtility.DisplayPopupMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), this.menuFolder, new MenuCommand(null, this.uniqueID)); } else { if (!string.IsNullOrEmpty(this.menuDefault)) { ListControl.s_uniqueIDList[this.uniqueID] = this; EditorUtility.DisplayPopupMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), this.menuDefault, new MenuCommand(null, this.uniqueID)); } } } else { if (current.type != EventType.ContextClick && current.button == 0 && !current.control && !current.command && !current.shift && this.IsSelected(this.singleSelect)) { this.SelectedSet(this.singleSelect); this.singleSelect = null; } } } } } if (current.type == EventType.MouseDrag && flag) { this.dragCount++; if (this.dragCount > 2 && Selection.objects.Length > 0) { DragAndDrop.PrepareStartDrag(); if (this.singleSelect != null) { DragAndDrop.objectReferences = new UnityEngine.Object[] { this.singleSelect.Asset.Load() }; } else { DragAndDrop.objectReferences = Selection.objects; } DragAndDrop.StartDrag("Move"); } } if (current.type == EventType.DragUpdated) { result = true; DragAndDrop.visualMode = DragAndDropVisualMode.Move; this.dragTarget = this.GetItemAt(area, current.mousePosition); if (this.dragTarget != null) { if (this.IsSelected(this.dragTarget)) { this.dragTarget = null; } else { if (this.dragAcceptOnly) { if (!this.dragTarget.CanAccept) { this.dragTarget = null; } } else { bool flag2 = !this.dragTarget.CanAccept || this.dragTarget.PrevOpenVisible != this.dragTarget.Parent; bool flag3 = !this.dragTarget.CanAccept || this.dragTarget.NextOpenVisible != this.dragTarget.FirstChild; float num2 = (!this.dragTarget.CanAccept) ? 8f : 2f; int num3 = (int)((current.mousePosition.y - area.y) / 16f); float num4 = area.y + (float)num3 * 16f; this.dragAdjust = ListControl.SelectDirection.Current; if (flag2 && current.mousePosition.y <= num4 + num2) { this.dragAdjust = ListControl.SelectDirection.Up; } else { if (flag3 && current.mousePosition.y >= num4 + 16f - num2) { this.dragAdjust = ListControl.SelectDirection.Down; } } } } } } if (current.type == EventType.DragPerform && this.dragTarget != null) { ListItem listItem = (this.dragAdjust != ListControl.SelectDirection.Current) ? this.dragTarget.Parent : this.dragTarget; if (this.dragDelegate != null && listItem != null && listItem.CanAccept) { this.dragDelegate(listItem.Change); } this.dragTarget = null; } if (current.type == EventType.DragExited) { this.dragTarget = null; } return(result); }
private void DrawItem(ListItem item, Rect area, float x, float y, bool focus, bool selected) { bool flag = item == this.dragTarget; bool flag2 = selected; if (selected) { Texture2D image = (!focus) ? this.greyTex : this.blueTex; GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), image, ScaleMode.StretchToFill, false); } else { if (flag) { ListControl.SelectDirection selectDirection = this.dragAdjust; if (selectDirection != ListControl.SelectDirection.Up) { if (selectDirection != ListControl.SelectDirection.Down) { if (item.CanAccept) { GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), this.yellowTex, ScaleMode.StretchToFill, false); flag2 = true; } } else { GUI.DrawTexture(new Rect(x, y + 16f - 1f, area.width, 2f), this.yellowTex, ScaleMode.StretchToFill, false); } } else { if (item.PrevOpenVisible != item.Parent) { GUI.DrawTexture(new Rect(x, y - 1f, area.width, 2f), this.yellowTex, ScaleMode.StretchToFill, false); } } } else { if (this.dragTarget != null && item == this.dragTarget.Parent && this.dragAdjust != ListControl.SelectDirection.Current) { GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), this.yellowTex, ScaleMode.StretchToFill, false); flag2 = true; } } } if (item.HasActions) { for (int i = 0; i < item.Actions.Length; i++) { this.calcSizeTmpContent.text = item.Actions[i]; Vector2 vector = GUI.skin.button.CalcSize(this.calcSizeTmpContent); if (GUI.Button(new Rect(x, y, vector.x, 16f), item.Actions[i])) { this.actionDelegate(item, i); } x += vector.x + 4f; } } if (item.CanExpand) { EditorGUI.Foldout(new Rect(x, y, 16f, 16f), item.Expanded, GUIContent.none); } Texture texture = item.Icon; Color color = GUI.color; Color contentColor = GUI.contentColor; if (item.Dummy) { GUI.color = new Color(0.65f, 0.65f, 0.65f); } if (!item.Dummy) { if (texture == null) { texture = InternalEditorUtility.GetIconForFile(item.Name); } Rect rect = new Rect(x + 14f, y, 16f, 16f); if (texture != null) { GUI.DrawTexture(rect, texture); } if (item.Asset != null) { Rect itemRect = rect; itemRect.width += 12f; itemRect.x -= 6f; Overlay.DrawOverlay(item.Asset, itemRect); } } if (flag2) { GUI.contentColor = new Color(3f, 3f, 3f); GUI.Label(new Rect(x + 32f, y, area.width - (x + 32f), 18f), this.DisplayName(item)); } else { GUI.Label(new Rect(x + 32f, y, area.width - (x + 32f), 18f), this.DisplayName(item)); } GUI.contentColor = contentColor; GUI.color = color; }
private bool HandleMouse(Rect area) { Event current = Event.current; bool flag1 = false; bool flag2 = area.Contains(current.mousePosition); if (current.type == EventType.MouseDown && flag2) { flag1 = true; this.dragCount = 0; GUIUtility.keyboardControl = 0; this.singleSelect = this.GetItemAt(area, current.mousePosition); if (this.singleSelect != null && !this.singleSelect.Dummy) { if (current.button == 0 && current.clickCount > 1 && this.singleSelect.Asset != null) this.singleSelect.Asset.Edit(); if (current.button < 2) { float num = area.x + (float) ((this.singleSelect.Indent - 1) * 18); if ((double) current.mousePosition.x >= (double) num && ((double) current.mousePosition.x < (double) num + 16.0 && this.singleSelect.CanExpand)) { this.singleSelect.Expanded = !this.singleSelect.Expanded; this.CallExpandedEvent(this.singleSelect, true); this.singleSelect = (ListItem) null; } else if (current.control || current.command) { if (current.button == 1) this.SelectedAdd(this.singleSelect); else this.SelectedToggle(this.singleSelect); this.singleSelect = (ListItem) null; } else if (current.shift) { this.SelectionFlow(this.singleSelect); this.singleSelect = (ListItem) null; } else if (!this.IsSelected(this.singleSelect)) { this.SelectedSet(this.singleSelect); this.singleSelect = (ListItem) null; } } } else if (current.button == 0) { this.SelectedClear(); this.singleSelect = (ListItem) null; } } else if ((current.type == EventType.MouseUp || current.type == EventType.ContextClick) && flag2) { GUIUtility.keyboardControl = 0; this.singleSelect = this.GetItemAt(area, current.mousePosition); this.dragCount = 0; flag1 = true; if (this.singleSelect != null && !this.singleSelect.Dummy) { if (current.type == EventType.ContextClick) { this.singleSelect = (ListItem) null; if (!this.IsSelectedAsset() && !string.IsNullOrEmpty(this.menuFolder)) { ListControl.s_uniqueIDList[this.uniqueID] = this; EditorUtility.DisplayPopupMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0.0f, 0.0f), this.menuFolder, new MenuCommand((UnityEngine.Object) null, this.uniqueID)); } else if (!string.IsNullOrEmpty(this.menuDefault)) { ListControl.s_uniqueIDList[this.uniqueID] = this; EditorUtility.DisplayPopupMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0.0f, 0.0f), this.menuDefault, new MenuCommand((UnityEngine.Object) null, this.uniqueID)); } } else if (current.type != EventType.ContextClick && current.button == 0 && (!current.control && !current.command) && (!current.shift && this.IsSelected(this.singleSelect))) { this.SelectedSet(this.singleSelect); this.singleSelect = (ListItem) null; } } } if (current.type == EventType.MouseDrag && flag2) { ++this.dragCount; if (this.dragCount > 2 && Selection.objects.Length > 0) { DragAndDrop.PrepareStartDrag(); if (this.singleSelect != null) DragAndDrop.objectReferences = new UnityEngine.Object[1] { this.singleSelect.Asset.Load() }; else DragAndDrop.objectReferences = Selection.objects; DragAndDrop.StartDrag("Move"); } } if (current.type == EventType.DragUpdated) { flag1 = true; DragAndDrop.visualMode = DragAndDropVisualMode.Move; this.dragTarget = this.GetItemAt(area, current.mousePosition); if (this.dragTarget != null) { if (this.IsSelected(this.dragTarget)) this.dragTarget = (ListItem) null; else if (this.dragAcceptOnly) { if (!this.dragTarget.CanAccept) this.dragTarget = (ListItem) null; } else { bool flag3 = !this.dragTarget.CanAccept || this.dragTarget.PrevOpenVisible != this.dragTarget.Parent; bool flag4 = !this.dragTarget.CanAccept || this.dragTarget.NextOpenVisible != this.dragTarget.FirstChild; float num1 = !this.dragTarget.CanAccept ? 8f : 2f; int num2 = (int) (((double) current.mousePosition.y - (double) area.y) / 16.0); float num3 = area.y + (float) num2 * 16f; this.dragAdjust = ListControl.SelectDirection.Current; if (flag3 && (double) current.mousePosition.y <= (double) num3 + (double) num1) this.dragAdjust = ListControl.SelectDirection.Up; else if (flag4 && (double) current.mousePosition.y >= (double) num3 + 16.0 - (double) num1) this.dragAdjust = ListControl.SelectDirection.Down; } } } if (current.type == EventType.DragPerform && this.dragTarget != null) { ListItem listItem = this.dragAdjust != ListControl.SelectDirection.Current ? this.dragTarget.Parent : this.dragTarget; if (this.dragDelegate != null && listItem != null && listItem.CanAccept) this.dragDelegate(listItem.Change); this.dragTarget = (ListItem) null; } if (current.type == EventType.DragExited) this.dragTarget = (ListItem) null; return flag1; }