private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect) { ImportPackageItem item = pitem.item; if (item != null) { if (((Event.current.type == EventType.MouseDown) && rowRect.Contains(Event.current.mousePosition)) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = pitem.id; } if ((pitem.id == this.showPreviewForID) && (Event.current.type != EventType.Layout)) { this.showPreviewForID = 0; if (!string.IsNullOrEmpty(item.previewPath)) { Texture2D preview = PackageImport.GetPreview(item.previewPath); Rect activatorRect = rowRect; activatorRect.width = EditorGUIUtility.currentViewWidth; PopupLocationHelper.PopupLocation[] locationPriorityOrder = new PopupLocationHelper.PopupLocation[3]; locationPriorityOrder[0] = PopupLocationHelper.PopupLocation.Right; locationPriorityOrder[1] = PopupLocationHelper.PopupLocation.Left; PopupWindowWithoutFocus.Show(activatorRect, new PackageImportTreeView.PreviewPopup(preview), locationPriorityOrder); } } } }
void DoPreviewPopup(PackageImportTreeViewItem pitem, Rect rowRect) { var item = pitem.item; if (item != null) { // Ensure preview is shown when clicking on an already selected item (the preview might have been closed) if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { showPreviewForID = pitem.id; } // Show preview if (pitem.id == showPreviewForID && Event.current.type != EventType.Layout) { showPreviewForID = 0; if (!string.IsNullOrEmpty(item.previewPath)) { Texture2D preview = PackageImport.GetPreview(item.previewPath); Rect buttonRect = rowRect; buttonRect.width = EditorGUIUtility.currentViewWidth; PopupWindowWithoutFocus.Show(buttonRect, new PreviewPopup(preview), new[] { PopupLocationHelper.PopupLocation.Right, PopupLocationHelper.PopupLocation.Left, PopupLocationHelper.PopupLocation.Below }); } } } }
private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect) { ImportPackageItem importPackageItem = pitem.item; if (importPackageItem == null) { return; } if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = pitem.id; } if (pitem.id != this.showPreviewForID || Event.current.type == EventType.Layout) { return; } this.showPreviewForID = 0; if (string.IsNullOrEmpty(importPackageItem.previewPath)) { return; } Texture2D preview = PackageImport.GetPreview(importPackageItem.previewPath); Rect activatorRect = rowRect; activatorRect.width = EditorGUIUtility.currentViewWidth; PopupWindowWithoutFocus.Show(activatorRect, (PopupWindowContent) new PackageImportTreeView.PreviewPopup(preview), new PopupLocationHelper.PopupLocation[3] { PopupLocationHelper.PopupLocation.Right, PopupLocationHelper.PopupLocation.Left, PopupLocationHelper.PopupLocation.Below }); }
private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect) { ImportPackageItem item = pitem.item; if (item != null) { if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = pitem.id; } if (pitem.id == this.showPreviewForID && Event.current.type != EventType.Layout) { this.showPreviewForID = 0; if (!string.IsNullOrEmpty(item.previewPath)) { Texture2D preview = PackageImport.GetPreview(item.previewPath); Rect rect = rowRect; rect.width = EditorGUIUtility.currentViewWidth; Rect arg_AF_0 = rect; PopupWindowContent arg_AF_1 = new PackageImportTreeView.PreviewPopup(preview); PopupLocationHelper.PopupLocation[] expr_A7 = new PopupLocationHelper.PopupLocation[3]; expr_A7[0] = PopupLocationHelper.PopupLocation.Right; expr_A7[1] = PopupLocationHelper.PopupLocation.Left; PopupWindowWithoutFocus.Show(arg_AF_0, arg_AF_1, expr_A7); } } } }
public override Rect OnRowGUI(TreeViewItem node, int row, float rowWidth, bool selected, bool focused) { Rect rect = new Rect(0f, (float)row * this.k_LineHeight, rowWidth, this.k_LineHeight); this.DoNodeGUI(rect, node, selected, focused, false); PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = node as PackageImportTreeView.PackageImportTreeViewItem; if (packageImportTreeViewItem != null) { Rect toggleRect = new Rect(2f, rect.y, rect.height, rect.height); EditorGUI.BeginChangeCheck(); PackageImportTreeView.PackageImportTreeViewGUI.Toggle(packageImportTreeViewItem, toggleRect); if (EditorGUI.EndChangeCheck()) { if (this.m_TreeView.GetSelection().Length <= 1 || !this.m_TreeView.GetSelection().Contains(packageImportTreeViewItem.id)) { this.m_TreeView.SetSelection(new int[] { packageImportTreeViewItem.id }, false); this.m_TreeView.NotifyListenersThatSelectionChanged(); } if (this.itemWasToggled != null) { this.itemWasToggled(packageImportTreeViewItem); } Event.current.Use(); } if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = packageImportTreeViewItem.id; } if (packageImportTreeViewItem.id == this.showPreviewForID && Event.current.type != EventType.Layout) { this.showPreviewForID = 0; if (!string.IsNullOrEmpty(packageImportTreeViewItem.item.previewPath)) { Texture2D preview = PackageImport.GetPreview(packageImportTreeViewItem.item.previewPath); Rect rect2 = rect; rect2.width = EditorGUIUtility.currentViewWidth; Rect arg_190_0 = rect2; PopupWindowContent arg_190_1 = new PackageImportTreeView.PreviewPopup(preview); PopupLocationHelper.PopupLocation[] expr_188 = new PopupLocationHelper.PopupLocation[3]; expr_188[0] = PopupLocationHelper.PopupLocation.Right; expr_188[1] = PopupLocationHelper.PopupLocation.Left; PopupWindowWithoutFocus.Show(arg_190_0, arg_190_1, expr_188); } } if (packageImportTreeViewItem.item.exists == 0) { Texture image = this.constants.badgeNew.image; GUI.DrawTexture(new Rect(rect.xMax - (float)image.width - 6f, rect.y + (rect.height - (float)image.height) / 2f, (float)image.width, (float)image.height), image); } } return(rect); }