Example #1
0
        private DragVisualMode GetVisualMode(Vector3 pointerPosition, ref ListViewDragger.DragPosition dragPosition)
        {
            bool           flag = this.dragAndDropController == null;
            DragVisualMode result;

            if (flag)
            {
                result = DragVisualMode.Rejected;
            }
            else
            {
                this.HandleDragAndScroll(pointerPosition);
                bool flag2 = !this.TryGetDragPosition(pointerPosition, ref dragPosition);
                if (flag2)
                {
                    result = DragVisualMode.Rejected;
                }
                else
                {
                    ListDragAndDropArgs listDragAndDropArgs = this.MakeDragAndDropArgs(dragPosition);
                    result = this.dragAndDropController.HandleDragAndDrop(listDragAndDropArgs);
                }
            }
            return(result);
        }
Example #2
0
 protected override void ClearDragAndDropUI()
 {
     this.m_LastDragPosition = default(ListViewDragger.DragPosition);
     foreach (ListView.RecycledItem current in this.targetListView.Pool)
     {
         current.element.RemoveFromClassList(ListView.itemDragHoverUssClassName);
     }
     this.m_DragHoverBar.style.visibility = Visibility.Hidden;
 }
Example #3
0
        protected override void OnDrop(Vector3 pointerPosition)
        {
            ListViewDragger.DragPosition dragPosition = default(ListViewDragger.DragPosition);
            bool flag = !this.TryGetDragPosition(pointerPosition, ref dragPosition);

            if (!flag)
            {
                ListDragAndDropArgs listDragAndDropArgs = this.MakeDragAndDropArgs(dragPosition);
                bool flag2 = this.dragAndDropController.HandleDragAndDrop(listDragAndDropArgs) != DragVisualMode.Rejected;
                if (flag2)
                {
                    this.dragAndDropController.OnDrop(listDragAndDropArgs);
                }
            }
        }
Example #4
0
        protected void ApplyDragAndDropUI(ListViewDragger.DragPosition dragPosition)
        {
            bool flag = this.m_LastDragPosition.Equals(dragPosition);

            if (!flag)
            {
                this.ClearDragAndDropUI();
                this.m_LastDragPosition = dragPosition;
                switch (dragPosition.dragAndDropPosition)
                {
                case DragAndDropPosition.OverItem:
                    dragPosition.recycledItem.element.AddToClassList(ListView.itemDragHoverUssClassName);
                    break;

                case DragAndDropPosition.BetweenItems:
                {
                    bool flag2 = dragPosition.insertAtIndex == 0;
                    if (flag2)
                    {
                        this.PlaceHoverBarAt(0f);
                    }
                    else
                    {
                        this.PlaceHoverBarAtElement(this.targetListView.GetRecycledItemFromIndex(dragPosition.insertAtIndex - 1).element);
                    }
                    break;
                }

                case DragAndDropPosition.OutsideItems:
                {
                    ListView.RecycledItem recycledItemFromIndex = this.targetListView.GetRecycledItemFromIndex(this.targetListView.itemsSource.Count - 1);
                    bool flag3 = recycledItemFromIndex != null;
                    if (flag3)
                    {
                        this.PlaceHoverBarAtElement(recycledItemFromIndex.element);
                    }
                    else
                    {
                        this.PlaceHoverBarAt(0f);
                    }
                    break;
                }

                default:
                    throw new ArgumentOutOfRangeException("dragAndDropPosition", dragPosition.dragAndDropPosition, "Unsupported dragAndDropPosition value");
                }
            }
        }
Example #5
0
        protected override DragVisualMode UpdateDrag(Vector3 pointerPosition)
        {
            ListViewDragger.DragPosition dragPosition = default(ListViewDragger.DragPosition);
            DragVisualMode visualMode = this.GetVisualMode(pointerPosition, ref dragPosition);
            bool           flag       = visualMode == DragVisualMode.Rejected;

            if (flag)
            {
                this.ClearDragAndDropUI();
            }
            else
            {
                this.ApplyDragAndDropUI(dragPosition);
            }
            return(visualMode);
        }
Example #6
0
        private ListDragAndDropArgs MakeDragAndDropArgs(ListViewDragger.DragPosition dragPosition)
        {
            object target = null;

            ListView.RecycledItem recycledItem = dragPosition.recycledItem;
            bool flag = recycledItem != null;

            if (flag)
            {
                target = this.targetListView.itemsSource[recycledItem.index];
            }
            return(new ListDragAndDropArgs
            {
                target = target,
                insertAtIndex = dragPosition.insertAtIndex,
                dragAndDropPosition = dragPosition.dragAndDropPosition
            });
        }
Example #7
0
        protected bool TryGetDragPosition(Vector2 pointerPosition, ref ListViewDragger.DragPosition dragPosition)
        {
            ListView.RecycledItem recycledItem = this.GetRecycledItem(pointerPosition);
            bool flag = recycledItem != null;
            bool result;

            if (flag)
            {
                bool flag2 = recycledItem.element.worldBound.yMax - pointerPosition.y < 5f;
                if (flag2)
                {
                    dragPosition.insertAtIndex       = recycledItem.index + 1;
                    dragPosition.dragAndDropPosition = DragAndDropPosition.BetweenItems;
                    result = true;
                }
                else
                {
                    bool flag3 = pointerPosition.y - recycledItem.element.worldBound.yMin > 5f;
                    if (flag3)
                    {
                        Vector2 scrollOffset = this.targetScrollView.scrollOffset;
                        this.targetScrollView.ScrollTo(recycledItem.element);
                        bool flag4 = scrollOffset != this.targetScrollView.scrollOffset;
                        if (flag4)
                        {
                            result = this.TryGetDragPosition(pointerPosition, ref dragPosition);
                        }
                        else
                        {
                            dragPosition.recycledItem        = recycledItem;
                            dragPosition.insertAtIndex       = -1;
                            dragPosition.dragAndDropPosition = DragAndDropPosition.OverItem;
                            result = true;
                        }
                    }
                    else
                    {
                        dragPosition.insertAtIndex       = recycledItem.index;
                        dragPosition.dragAndDropPosition = DragAndDropPosition.BetweenItems;
                        result = true;
                    }
                }
            }
            else
            {
                bool flag5 = !this.targetListView.worldBound.Contains(pointerPosition);
                if (flag5)
                {
                    result = false;
                }
                else
                {
                    dragPosition.dragAndDropPosition = DragAndDropPosition.OutsideItems;
                    bool flag6 = pointerPosition.y >= this.targetScrollView.contentContainer.worldBound.yMax;
                    if (flag6)
                    {
                        dragPosition.insertAtIndex = this.targetListView.itemsSource.Count;
                    }
                    else
                    {
                        dragPosition.insertAtIndex = 0;
                    }
                    result = true;
                }
            }
            return(result);
        }