示例#1
0
        /// <summary>
        /// Handler for drag event.
        /// </summary>
        /// <param name="eventData">Pointer data.</param>
        public void OnDrag(PointerEventData eventData)
        {
            DebugEx.VeryVerboseFormat("DockingTabButton.OnDrag(eventData = {0})", eventData);

            DragInfoHolder.minimum       = float.MaxValue;
            DragInfoHolder.dockingArea   = null;
            DragInfoHolder.mouseLocation = DragInfoHolder.MouseLocation.Outside;

            RaycastResult     raycastResult  = eventData.pointerCurrentRaycast;
            DockingAreaScript hitDockingArea = null;

            if (raycastResult.gameObject != null)
            {
                hitDockingArea = Utils.FindInParents <DockingAreaScript>(raycastResult.gameObject);
            }

            if (hitDockingArea != null && hitDockingArea.HasDragInfo())
            {
                hitDockingArea.PreprocessDockWidgetDrag(eventData);
            }
            else
            {
                for (int i = mDockingAreas.Count - 1; i >= 0; --i)
                {
                    mDockingAreas[i].PreprocessDockWidgetDrag(eventData);
                }
            }

            if (DragInfoHolder.dockingArea != null)
            {
                DragInfoHolder.dockingArea.ProcessDockWidgetDrag(eventData);
            }

            if (DragInfoHolder.dockingArea != null)
            {
                DragData.HideImage();
            }
            else
            {
                DummyDockWidgetScript.DestroyInstance();

                DragData.ShowImage();
                DragData.Drag();
            }
        }
示例#2
0
        /// <summary>
        /// Handler for end drag event.
        /// </summary>
        /// <param name="eventData">Pointer data.</param>
        public void OnEndDrag(PointerEventData eventData)
        {
            DebugEx.VerboseFormat("DockingTabButton.OnEndDrag(eventData = {0})", eventData);

            foreach (DockingAreaScript dockingArea in mDockingAreas)
            {
                dockingArea.ClearDragInfo();
            }

            mDockingAreas = null;

            if (DummyDockWidgetScript.instance != null)
            {
                int index = DummyDockWidgetScript.instance.parent.children.IndexOf(DummyDockWidgetScript.instance);

                if (index >= 0)
                {
                    DummyDockWidgetScript.instance.parent.InsertDockWidget(DragInfoHolder.dockWidget, index);
                    DummyDockWidgetScript.instance.parent.selectedIndex = index;
                }
                else
                {
                    DebugEx.Fatal("Unexpected behaviour in DockingTabButton.OnEndDrag()");
                }

                DummyDockWidgetScript.DestroyInstance();
            }
            else
            if (DragInfoHolder.dockingArea == null)
            {
                WindowScript parentWindow = Utils.FindInParents <WindowScript>(gameObject);

                if (parentWindow != null)
                {
                    //***************************************************************************
                    // DockingWindow GameObject
                    //***************************************************************************
                    #region DockingWindow GameObject
                    GameObject dockingWindow = new GameObject("DockingWindow");
                    Utils.InitUIObject(dockingWindow, parentWindow.transform.parent);

                    //===========================================================================
                    // DockingWindowScript Component
                    //===========================================================================
                    #region DockingWindowScript Component
                    DockingWindowScript dockingWindowScript = dockingWindow.AddComponent <DockingWindowScript>();

                    dockingWindowScript.dockWidget = DragInfoHolder.dockWidget;

                    dockingWindowScript.x      = DragData.x - 8f;
                    dockingWindowScript.y      = DragData.y - 15f;      // - 8f      - 7f
                    dockingWindowScript.width  = DragData.width + 16f;  // + 8f + 8f
                    dockingWindowScript.height = DragData.height + 23f; // + 8f + 8f + 7f

                    dockingWindowScript.Show();
                    #endregion
                    #endregion
                }
                else
                {
                    DebugEx.Fatal("Unexpected behaviour in DockingTabButton.OnEndDrag()");
                }
            }

            DragInfoHolder.dockWidget    = null;
            DragInfoHolder.minimum       = float.MaxValue;
            DragInfoHolder.dockingArea   = null;
            DragInfoHolder.mouseLocation = DragInfoHolder.MouseLocation.Outside;

            DragData.EndDrag();
        }