protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            var render = AssetTreeManager.mIns.GetGuiRender(EditorContexts.mIns.Mode);

            if (render != null)
            {
                AssetDragAndDropArgs copyArgs = new AssetDragAndDropArgs();
                copyArgs.dragAndDropPosition = (AssetDragAndDropArgs.DragAndDropPosition)((int)args.dragAndDropPosition);
                copyArgs.insertAtIndex       = args.insertAtIndex;
                copyArgs.parentItem          = args.parentItem;
                copyArgs.performDrop         = args.performDrop;
                DragAndDropVisualMode result = DragAndDropVisualMode.Move;
                foreach (var subrender in render)
                {
                    if (subrender.TypeMode == _viewMode)
                    {
                        IGuiTree treeRender = subrender as IGuiTree;
                        if (treeRender != null)
                        {
                            treeRender.Drag(ref copyArgs, ref result);
                        }
                    }
                }
                return(result);
            }

            return(base.HandleDragAndDrop(args));
        }
        public void Drag(ref AssetDragAndDropArgs dragargs, ref DragAndDropVisualMode dragmd)
        {
            var draggedRows = DragAndDrop.GetGenericData("AssetTreeViewDragging") as List <TreeViewItem>;

            if (draggedRows != null)
            {
                switch (dragargs.dragAndDropPosition)
                {
                case AssetDragAndDropArgs.DragAndDropPosition.UponItem:
                case AssetDragAndDropArgs.DragAndDropPosition.BetweenItems:
                {
                    bool validDrag = dragargs.parentItem.depth != 0;
                    if (dragargs.performDrop && validDrag)
                    {
                        if (dragargs.parentItem.parent != null)
                        {
                            AssetTreeItem <SpriteTrackData> itemdata = dragargs.parentItem as AssetTreeItem <SpriteTrackData>;
                            if (itemdata != null && itemdata.GetData().ShowMode == SpriteShowMode.Atlas && itemdata.depth == 1)
                            {
                                OnDropDraggedElements(draggedRows, itemdata);
                            }
                        }
                    }

                    dragmd = validDrag ? DragAndDropVisualMode.Move : DragAndDropVisualMode.None;
                    break;
                }

                case AssetDragAndDropArgs.DragAndDropPosition.OutsideItems:
                {
                    dragmd = DragAndDropVisualMode.Move;
                    break;
                }

                default:
                    Debug.LogError("Unhandled enum " + dragargs.dragAndDropPosition);
                    dragmd = DragAndDropVisualMode.None;
                    break;
                }
            }
            else
            {
                dragmd = DragAndDropVisualMode.None;
            }
        }
Example #3
0
 public void Drag(ref AssetDragAndDropArgs dragargs, ref DragAndDropVisualMode dragmd)
 {
 }
Example #4
0
        public void Drag(ref AssetDragAndDropArgs dragargs, ref DragAndDropVisualMode dragmd)
        {
            var draggedRows = DragAndDrop.GetGenericData("AssetTreeViewDragging") as List <TreeViewItem>;

            if (draggedRows != null)
            {
                switch (dragargs.dragAndDropPosition)
                {
                case AssetDragAndDropArgs.DragAndDropPosition.UponItem:
                case AssetDragAndDropArgs.DragAndDropPosition.BetweenItems:
                {
                    bool validDrag = dragargs.parentItem.depth != 0;
                    if (dragargs.performDrop && validDrag)
                    {
                        if (dragargs.parentItem.parent != null)
                        {
                            AssetTreeItem <AssetTreeData> itemdata = dragargs.parentItem.parent as AssetTreeItem <AssetTreeData>;
                            if (itemdata != null)
                            {
                                OnDropDraggedElements(draggedRows, itemdata);
                            }
                        }
                    }

                    dragmd = validDrag ? DragAndDropVisualMode.Move : DragAndDropVisualMode.None;
                    break;
                }

                case AssetDragAndDropArgs.DragAndDropPosition.OutsideItems:
                {
                    //if (dragargs.performDrop)
                    //{
                    //    int index = dragargs.insertAtIndex == -1 ? 0 : dragargs.insertAtIndex;
                    //    var rows = dragargs.parentItem.children;

                    //    if (index < rows.Count)
                    //    {
                    //        AssetTreeItem<AssetTreeData> itemdata = rows[index] as AssetTreeItem<AssetTreeData>;
                    //        if (itemdata != null)
                    //            OnDropDraggedElements(draggedRows, itemdata);
                    //    }
                    //    else
                    //    {
                    //        Debug.LogError("drag index error");
                    //    }
                    //}

                    dragmd = DragAndDropVisualMode.Move;
                    break;
                }

                default:
                    Debug.LogError("Unhandled enum " + dragargs.dragAndDropPosition);
                    dragmd = DragAndDropVisualMode.None;
                    break;
                }
            }
            else
            {
                dragmd = DragAndDropVisualMode.None;
            }
        }