예제 #1
0
        /**
         *  Initiates a drag and drop operation.
         *
         *  Param: dragInitiator IUIComponent that specifies the component initiating
         *  the drag.
         *
         *  Param: dragSource DragSource object that contains the data
         *  being dragged.
         *
         *  Param: mouseEvent The MouseEvent that contains the mouse information
         *  for the start of the drag.
         *
         *  Param: dragImage The image to drag. This argument is optional.
         *  If omitted, a standard drag rectangle is used during the drag and
         *  drop operation. If you specify an image, you must explicitly set a
         *  height and width of the image or else it will not appear.
         *
         *  Param: xOffset Number that specifies the x offset, in pixels, for the
         *  <code>dragImage</code>. This argument is optional. If omitted, the drag proxy
         *  is shown at the upper-left corner of the drag initiator. The offset is expressed
         *  in pixels from the left edge of the drag proxy to the left edge of the drag
         *  initiator, and is usually a negative number.
         *
         *  Param: yOffset Number that specifies the y offset, in pixels, for the
         *  <code>dragImage</code>. This argument is optional. If omitted, the drag proxy
         *  is shown at the upper-left corner of the drag initiator. The offset is expressed
         *  in pixels from the top edge of the drag proxy to the top edge of the drag
         *  initiator, and is usually a negative number.
         *
         *  Param: imageAlpha Number that specifies the alpha value used for the
         *  drag image. This argument is optional. If omitted, the default alpha
         *  value is 0.5. A value of 0.0 indicates that the image is transparent;
         *  a value of 1.0 indicates it is fully opaque.
         *
         *  Param: allowMove Indicates if a drop target is allowed to move the dragged data.
         *
         */

        /// <summary>
        /// Starts a drag and drop operation
        /// </summary>
        /// <param name="dragInitiator"></param>
        /// <param name="dragSource"></param>
        /// <param name="mouseEvent"></param>
        /// <param name="dragImage"></param>
        /// <param name="xOffset"></param>
        /// <param name="yOffset"></param>
        /// <param name="imageAlpha"></param>
        /// <param name="allowMove"></param>
        /// <param name="options"></param>
        public static void DoDrag(Component dragInitiator, DragSource dragSource, MouseEvent mouseEvent, Component dragImage, float xOffset, float yOffset, float imageAlpha, bool allowMove, params DragOption[] options)
        {
#if DEBUG
            if (DebugMode)
            {
                Debug.Log("DragDropManager.DoDrag: " + dragInitiator);
            }
#endif
            _dragInitiator = dragInitiator;
            _dragSource    = dragSource;
            _mouseEvent    = mouseEvent;
            _dragImage     = dragImage;
            _imageAlpha    = imageAlpha;
            _allowMove     = allowMove;

            ApplyOptions(options);

            /**
             * 20130307
             * Found some glitches regarding the starting the new drag operation while the previous one hasn't been finished yet
             * Since I was dealing with a single proxy instance since, some of the old (custom) proxies were stale, e.g. never removed when the tween finished
             * Now I added the line to a tween callback which destroys the animation target
             * */
            _proxy = dragImage ?? new DragProxy();

            DragProxy.Proxify(_proxy);

            _xOffset = xOffset;
            _yOffset = yOffset;

            DragDropStage.Instance.AddChild(_proxy); // TODO: cleanup after the drag operaion

            var dragInitiatorGlobalBounds = dragInitiator.Parent.LocalToGlobal(dragInitiator.Position);

            _proxy.X = dragInitiatorGlobalBounds.X;
            _proxy.Y = dragInitiatorGlobalBounds.Y;
            //_proxy.Bounds = (Rectangle)dragInitiator.Transform.GlobalBounds.Clone();
            _proxy.Visible = _proxyShouldBeVisible;
            _proxy.Alpha   = imageAlpha;

            Offset = dragInitiatorGlobalBounds.Subtract(mouseEvent.GlobalPosition);

            if (_feedbackShouldBeVisible)
            {
                ChangeCursorTo(CursorType.RejectDrop);
            }

            /**
             * Subscribe to drag and mouse up events on system manager
             * */
            SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_DRAG, OnMouseDrag);
            SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_UP, OnMouseUp);

            //DragEvent dragStartEvent = BuildEvent(DragEvent.DRAG_START);
            //_dragInitiator.DispatchEvent(dragStartEvent);
        }
예제 #2
0
        /**
	     *  Initiates a drag and drop operation.
	     *
	     *  Param: dragInitiator IUIComponent that specifies the component initiating
	     *  the drag.
	     *
	     *  Param: dragSource DragSource object that contains the data
	     *  being dragged.
	     *
	     *  Param: mouseEvent The MouseEvent that contains the mouse information
	     *  for the start of the drag.
	     *
	     *  Param: dragImage The image to drag. This argument is optional.
	     *  If omitted, a standard drag rectangle is used during the drag and
	     *  drop operation. If you specify an image, you must explicitly set a 
	     *  height and width of the image or else it will not appear.
	     *
	     *  Param: xOffset Number that specifies the x offset, in pixels, for the
	     *  <code>dragImage</code>. This argument is optional. If omitted, the drag proxy
	     *  is shown at the upper-left corner of the drag initiator. The offset is expressed
	     *  in pixels from the left edge of the drag proxy to the left edge of the drag
	     *  initiator, and is usually a negative number.
	     *
	     *  Param: yOffset Number that specifies the y offset, in pixels, for the
	     *  <code>dragImage</code>. This argument is optional. If omitted, the drag proxy
	     *  is shown at the upper-left corner of the drag initiator. The offset is expressed
	     *  in pixels from the top edge of the drag proxy to the top edge of the drag
	     *  initiator, and is usually a negative number.
	     *
	     *  Param: imageAlpha Number that specifies the alpha value used for the
	     *  drag image. This argument is optional. If omitted, the default alpha
	     *  value is 0.5. A value of 0.0 indicates that the image is transparent;
	     *  a value of 1.0 indicates it is fully opaque. 
             *
             *  Param: allowMove Indicates if a drop target is allowed to move the dragged data.
	     *  
	     */
        
        /// <summary>
        /// Starts a drag and drop operation
        /// </summary>
        /// <param name="dragInitiator"></param>
        /// <param name="dragSource"></param>
        /// <param name="mouseEvent"></param>
        /// <param name="dragImage"></param>
        /// <param name="xOffset"></param>
        /// <param name="yOffset"></param>
        /// <param name="imageAlpha"></param>
        /// <param name="allowMove"></param>
        /// <param name="options"></param>
        public static void DoDrag(Component dragInitiator, DragSource dragSource, MouseEvent mouseEvent, Component dragImage, float xOffset, float yOffset, float imageAlpha, bool allowMove, params DragOption[] options)
        {
#if DEBUG
            if (DebugMode)
                Debug.Log("DragDropManager.DoDrag: " + dragInitiator);
#endif
            _dragInitiator = dragInitiator;
            _dragSource = dragSource;
            _mouseEvent = mouseEvent;
            _dragImage = dragImage;
            _imageAlpha = imageAlpha;
            _allowMove = allowMove;

            ApplyOptions(options);

            /**
             * 20130307
             * Found some glitches regarding the starting the new drag operation while the previous one hasn't been finished yet
             * Since I was dealing with a single proxy instance since, some of the old (custom) proxies were stale, e.g. never removed when the tween finished
             * Now I added the line to a tween callback which destroys the animation target
             * */
            _proxy = dragImage ?? new DragProxy();

            DragProxy.Proxify(_proxy);

            _xOffset = xOffset;
            _yOffset = yOffset;
            
            DragDropStage.Instance.AddChild(_proxy); // TODO: cleanup after the drag operaion

            var dragInitiatorGlobalBounds = dragInitiator.Parent.LocalToGlobal(dragInitiator.Position);

            _proxy.X = dragInitiatorGlobalBounds.X;
            _proxy.Y = dragInitiatorGlobalBounds.Y;
            //_proxy.Bounds = (Rectangle)dragInitiator.Transform.GlobalBounds.Clone();
            _proxy.Visible = _proxyShouldBeVisible;
            _proxy.Alpha = imageAlpha;

            Offset = dragInitiatorGlobalBounds.Subtract(mouseEvent.GlobalPosition);
            
            if (_feedbackShouldBeVisible)
                ChangeCursorTo(CursorType.RejectDrop);

            /**
             * Subscribe to drag and mouse up events on system manager
             * */
            SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_DRAG, OnMouseDrag);
            SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_UP, OnMouseUp);

            //DragEvent dragStartEvent = BuildEvent(DragEvent.DRAG_START);
            //_dragInitiator.DispatchEvent(dragStartEvent);
        }
예제 #3
0
파일: List.cs 프로젝트: groov0v/edriven-gui
 ///<summary>
 ///</summary>
 ///<param name="dragSource"></param>
 public void AddDragData(DragSource dragSource)
 {
     
 }
예제 #4
0
    private void OnMouseDown(Event e)
    {
        Image comp = e.Target as Image;

        if (null == comp)
            return;

        // check if dragged item is child of _pnlSource or _pnlDest
        if (_pnlSource.ContentContains(comp) || _pnlDest.ContentContains(comp))
        {
            DragSource dataSource = new DragSource();
            //dataSource.AddData(comp.Text, "text"); // add text for COPY_TEXT mode
            //dataSource.AddData(comp.StyleName, "style"); // add text for COPY_STYLE mode
            //dataSource.AddData(comp, "control"); // add reference to control for Move mode

            Image proxy = new Image
                              {
                                  Texture = comp.Texture, // reference the same texture
                                  ScaleMode = ImageScaleMode.ScaleToFit
                                  //// TEMP: handles the DragDropManager missing bounds clonning
                                  //Bounds = (Rectangle) comp.GlobalBounds.Clone(),

                                  //// TEMP: handles the DragDropManager missing MouseEnabled enabled turning off on the proxy
                                  //MouseEnabled = false
                              };

            DragDropManager.DoDrag(comp, dataSource, (MouseEvent)e, proxy, 0, 0, 0.5f, false);
            /*new DragOption(DragOptionType.ProxyVisible, false),
            new DragOption(DragOptionType.FeedbackVisible, false)*/
        }
    }