Exemple #1
0
 public override void dragEnded(IntVector2 position)
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke(this, position);
     }
 }
Exemple #2
0
        public ColorPickerPanel()
        {
            var colorProperty = new Property <ColorHSVA>(() => colorHSVA, c => colorHSVA = c);

            spectrum              = new Spectrum(colorProperty);
            spectrum.DragStarted += () => DragStarted?.Invoke();
            spectrum.Changed     += () => Changed?.Invoke();
            spectrum.DragEnded   += () => DragEnded?.Invoke();
            valueSlider           = new ValueSlider(colorProperty);
            alphaSlider           = new AlphaSlider(colorProperty);
            SetupSliderDragHandlers(valueSlider.Widget);
            SetupSliderDragHandlers(alphaSlider.Widget);
            Widget = new Widget
            {
                Padding = new Thickness(8),
                Layout  = new VBoxLayout {
                    Spacing = 8
                },
                Nodes =
                {
                    new Widget {
                        LayoutCell = new LayoutCell(Alignment.Center),
                        Layout     = new StackLayout(),
                        Nodes      =
                        {
                            spectrum.Widget
                        }
                    },
                    valueSlider.Widget,
                    alphaSlider.Widget,
                }
            };
            Widget.FocusScope = new KeyboardFocusScope(Widget);
        }
 internal override void _fireDragEnded(DragAndDropItem item, IntVector2 position)
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke((ItemType)item, position);
     }
 }
Exemple #4
0
 private void EndDrag()
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke();
     }
 }
Exemple #5
0
 public void OnEndDrag(PointerEventData eventData)
 {
     if (IsWithItem)
     {
         DragEnded?.Invoke(this, eventData.position);
     }
 }
Exemple #6
0
 void _fireDragEnded(ItemType item, IntVector2 position)
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke(item, position);
     }
 }
Exemple #7
0
        private async Task OnDroppedCanceled()
        {
            dragging = false;

            await DragEnded.InvokeAsync(Item);

            await InvokeAsync(StateHasChanged);
        }
Exemple #8
0
 private void TryEndDrag()
 {
     if (!isDragActive)
     {
         return;
     }
     isDragActive = false;
     DragEnded?.Invoke();
     RunThumbAnimation("Normal");
 }
Exemple #9
0
        private async Task OnDragEndHandler(DragEventArgs e)
        {
            if (dragging)
            {
                dragging = false;

                await ParentContainer?.CancelTransaction();
            }
            else
            {
                await DragEnded.InvokeAsync(Item);
            }
        }
Exemple #10
0
        protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
        {
            base.OnPreviewMouseUp(e);

            if (isDragInProgress)
            {
                isDragInProgress = false;
                DragEnded?.Invoke(ElementBeingDragged.Element, new EventArgs());
            }

            ElementBeingDragged = null;
            elementsInDragGroup = null;
        }
Exemple #11
0
 IEnumerator <object> SelectTask()
 {
     while (true)
     {
         if (Widget.Input.WasMousePressed())
         {
             var pick = Pick(
                 Widget.Input.MousePosition.X - Widget.GlobalPosition.X,
                 Widget.Input.MousePosition.Y - Widget.GlobalPosition.Y);
             if (pick.Area != Area.Outside)
             {
                 DragStarted?.Invoke();
                 while (Widget.Input.IsMousePressed())
                 {
                     float nx, ny;
                     ShiftedCoordinates(
                         Widget.Input.MousePosition.X - Widget.GlobalPosition.X,
                         Widget.Input.MousePosition.Y - Widget.GlobalPosition.Y,
                         out nx, out ny);
                     if (pick.Area == Area.Triangle)
                     {
                         var newPick = PositionToSV(nx, ny, ignoreBounds: true);
                         color.Value = new ColorHSVA {
                             H = color.Value.H,
                             S = Mathf.Min(Mathf.Max(newPick.S.Value, 0), 1),
                             V = Mathf.Min(Mathf.Max(newPick.V.Value, 0), 1),
                             A = color.Value.A
                         };
                     }
                     else
                     {
                         var newPick = PositionToHue(nx, ny);
                         color.Value = new ColorHSVA {
                             H = Mathf.Min(Mathf.Max(newPick.H.Value, 0), 360),
                             S = color.Value.S,
                             V = color.Value.V,
                             A = color.Value.A
                         };
                     }
                     Window.Current.Invalidate();
                     Changed?.Invoke();
                     yield return(null);
                 }
                 DragEnded?.Invoke();
             }
         }
         yield return(null);
     }
 }
Exemple #12
0
        private void LongPressGestureUpdated(DigitalRubyShared.GestureRecognizer r)
        {
            Camera camera;

            FingersScript.StartOrResetGesture(r, BringToFront, Cameras, gameObject, spriteRenderer, GestureRecognizerComponentScriptBase.GestureObjectMode.RequireIntersectWithGameObject, out camera);
            if (r.State == GestureRecognizerState.Began)
            {
                transform.localScale *= DragScale;
                panZ      = camera.WorldToScreenPoint(transform.position).z;
                panOffset = transform.position - ScreenToWorldPoint(camera, r.FocusX, r.FocusY, panZ);
                if (DragStarted != null)
                {
                    DragStarted.Invoke(this, System.EventArgs.Empty);
                }
            }
            else if (r.State == GestureRecognizerState.Executing)
            {
                Vector3 gestureScreenPoint = new Vector3(r.FocusX, r.FocusY, panZ);
                Vector3 gestureWorldPoint  = ScreenToWorldPoint(camera, gestureScreenPoint.x, gestureScreenPoint.y, gestureScreenPoint.z) + panOffset;
                if (rigidBody != null)
                {
                    rigidBody.MovePosition(gestureWorldPoint);
                }
                else if (rigidBody2D != null)
                {
                    rigidBody2D.MovePosition(gestureWorldPoint);
                }
                else
                {
                    transform.position = gestureWorldPoint;
                }
                if (DragUpdated != null)
                {
                    DragUpdated.Invoke(this, System.EventArgs.Empty);
                }
            }
            else if (r.State == GestureRecognizerState.Ended)
            {
                transform.localScale /= DragScale;
                if (spriteRenderer != null && BringToFront)
                {
                    spriteRenderer.sortingOrder = startSortOrder;
                }
                if (DragEnded != null)
                {
                    DragEnded.Invoke(this, System.EventArgs.Empty);
                }
            }
        }
Exemple #13
0
 private void LongPressGestureUpdated(GestureRecognizer r)
 {
     FingersPanRotateScaleComponentScript.StartOrResetGesture(r, BringToFront, Camera, gameObject, spriteRenderer, GestureRecognizerComponentScriptBase.GestureObjectMode.RequireIntersectWithGameObject);
     if (r.State == GestureRecognizerState.Began)
     {
         panZ      = Camera.WorldToScreenPoint(transform.position).z;
         panOffset = transform.position - Camera.ScreenToWorldPoint(new Vector3(r.FocusX, r.FocusY, panZ));
         if (DragStarted != null)
         {
             DragStarted.Invoke(this, System.EventArgs.Empty);
         }
     }
     if (r.State == GestureRecognizerState.Executing)
     {
         Vector3 gestureScreenPoint = new Vector3(r.FocusX, r.FocusY, panZ);
         Vector3 gestureWorldPoint  = Camera.ScreenToWorldPoint(gestureScreenPoint) + panOffset;
         if (rigidBody == null)
         {
             transform.position = gestureWorldPoint;
         }
         else
         {
             rigidBody.MovePosition(gestureWorldPoint);
         }
         if (DragUpdated != null)
         {
             DragUpdated.Invoke(this, System.EventArgs.Empty);
         }
     }
     else if (r.State == GestureRecognizerState.Ended)
     {
         if (spriteRenderer != null && BringToFront)
         {
             spriteRenderer.sortingOrder = startSortOrder;
         }
         if (DragEnded != null)
         {
             DragEnded.Invoke(this, System.EventArgs.Empty);
         }
     }
 }
Exemple #14
0
 IEnumerator <object> SelectTask()
 {
     while (true)
     {
         if (Widget.Input.WasMousePressed() && HitTest(Widget.Input.MousePosition))
         {
             DragStarted?.Invoke();
             while (Widget.Input.IsMousePressed())
             {
                 var c = color.Value;
                 PositionToHueSaturation(Widget.Input.MousePosition - Widget.GlobalCenter, out c.H, out c.S);
                 color.Value = c;
                 Window.Current.Invalidate();
                 Changed?.Invoke();
                 yield return(null);
             }
             DragEnded?.Invoke();
         }
         yield return(null);
     }
 }
        private void Update()
        {
            if (_mouseDown)
            {
                // Check for drag release
                if (Input.GetMouseButtonUp(0))
                {
                    // Touch ended; cancel tracking
                    _mouseDown    = false;
                    _lastPosition = Vector3.zero;
                    if (DragEnded != null)
                    {
                        DragEnded.Invoke(Input.mousePosition);
                    }
                }
                else if (_lastPosition != Input.mousePosition)
                {
                    // Touch still occuring and moved
                    if (DragMoved != null)
                    {
                        DragMoved.Invoke(_lastPosition - Input.mousePosition);
                    }

                    _lastPosition = Input.mousePosition;
                }
            }
            else if (Input.GetMouseButtonDown(0))
            {
                // Otherwise, start tracking the first touch to begin
                _lastPosition = Input.mousePosition;
                _mouseDown    = true;

                if (DragBegan != null)
                {
                    DragBegan.Invoke(_lastPosition);
                }
            }
        }
Exemple #16
0
 private void RaiseDragEnded()
 {
     DragEnded?.Invoke();
 }
 public void InvokeDragEnded(int startIndex, int endIndex)
 {
     DragEnded?.Invoke(this, new DragAndDropEventArgs(startIndex, endIndex));
 }
        private void OnDragEvent(object sender, EventArgs arguments)
        {
            //Debug.LogError ("Entered the efvent");
            DragEnded drag = (DragEnded)arguments;

            isDragEnded = drag.value;
            switch (drag.action)
            {
            case Action.NONE:
            {
                shouldCueRotate = false;
                break;
            }

            case Action.MSG_MOUSE_DOWN_TABLE:
            {
                Debug.LogError(" MOUSE IS DOWN ON THE TABLE ");
                shouldCueRotate = true;
                break;
            }

            case Action.MSG_MOUSE_UP_TABLE:
            {
                Debug.LogError("MOUSE IS UP FROM THE TABLE ");
                shouldCueRotate = false;
                break;
            }

            //Canvas Events......


            case Action.MSG_MOUSE_CANVAS_DOWN:
            {
                isCanvasTouched = true;
                break;
            }

            case Action.MSG_MOUSE_CANVAS_STAY:
            {
                isCanvasTouched = true;
                break;
            }

            case Action.MSG_MOUSE_CANVAS_UP:
            {
                isCanvasTouched = false;
                break;
            }

            //Image Events

            case Action.MSG_MOUSE_UP_IMAGE:
            {
                isImageTouched = false;
                break;
            }

            case Action.MSG_MOUSE_DOWN_IMAGE:
            {
                isImageTouched = true;
                break;
            }

            // Cue Ball Canvas Events
            case Action.MSG_MOUSE_CUE_BALL_CANVAS_DOWN:
            {
                isCueBallCanvasTouched = true;
                break;
            }

            case Action.MSG_MOUSE_CUE_BALL_CANVAS_UP:
            {
                isCueBallCanvasTouched = false;
                break;
            }

            // Region Script Events
            case Action.MSG_MOUSE_INSIDE_REGION:
            {
                isCueBallInRegion = true;
                break;
            }

            case Action.MSG_MOUSE_OUTSIDE_REGION:
            {
                isCueBallInRegion = false;
                break;
            }

            case Action.MSG_MOUSE_DOWN_CANVAS:
            {
                Debug.LogError("event happened MOUSE IS DOWN ON CANVAS");
                break;
            }

            case Action.MSG_MOUSE_UP_CANVAS:
            {
                Debug.LogError("event happened MOUSE IS UP ON CANVAS");
                break;
            }
            }


            if (isImageTouched == false && isCueBallCanvasTouched == false)
            {
                cueBall.GetComponent <Rigidbody> ().WakeUp();
                float   factor = PlayerPrefs.GetFloat("factor");
                Vector3 __rotationDirection = Vector3.zero;
                var     x           = 0.0f;
                var     __prevAngle = 0.0;
                                #if UNITY_EDITOR
                if (Input.GetMouseButton(0))
                {
                                #else
                if (Input.touches.Length > 0)
                {
                                #endif
                    if (isFirstTouch == false)
                    {
                        isFirstTouch = true;
                                                #if UNITY_EDITOR
                        firstInputPosition = Input.mousePosition;
                                                #else
                        firstInputPosition = (Vector3)Input.GetTouch(0).position;
                                                #endif
                    }

                    Vector3 currentInputPosition;
                                        #if UNITY_EDITOR
                    currentInputPosition = Input.mousePosition;
                                        #else
                    currentInputPosition = (Vector3)Input.GetTouch(0).position;
                                        #endif

                    Vector3 cuePosition = Camera.main.WorldToScreenPoint(cueBall.transform.position);
                    float   __angle     = Vector3.Angle((firstInputPosition - cuePosition), (currentInputPosition - cuePosition));
                    Vector3 __cross     = Vector3.Cross((firstInputPosition - cuePosition), (currentInputPosition - cuePosition));
                    Vector3 __direction = __cross.z > 0 ? Vector3.down : Vector3.up;

                    x = __angle;
                    __rotationDirection = __direction;
                                        #if UNITY_EDITOR
                    firstInputPosition = Input.mousePosition;
                                        #else
                    firstInputPosition = (Vector3)Input.GetTouch(0).position;
                                        #endif
                    __prevAngle = __angle;


                    if (x != 0 && isDragEnded == true)
                    {
                        var angle = x;                        //x=2 for touch and 75 for pc
                        gameController.strikeDirection = Quaternion.AngleAxis(angle, __rotationDirection) * gameController.strikeDirection;

                        //						/cue.transform.position = cueBall.transform.position + gameController.strikeDirection * (-1) * PoolGameController.MIN_DISTANCE;
                        //	cue.transform.position = new Vector3 (cue.transform.position.x, 9f, cue.transform.position.z);

                        cue.transform.RotateAround(cueBall.transform.position, __rotationDirection, angle);
                    }

                    Debug.DrawLine(cueBall.transform.position, cueBall.transform.position + gameController.strikeDirection * 10);
                    if (isDragEnded == true && factor != 0)
                    {
                    }
                    if (Input.GetMouseButtonUp(0))
                    {
                        isFirstTouch = false;
                    }
                }
            }
            if (Input.GetMouseButtonUp(0))
            {
                isFirstTouch = false;
            }
        }
Exemple #19
0
 protected virtual void OnDragEnded(Dock position, double delta)
 {
     DragEnded?.Invoke(this, position, delta);
 }
 public void OnEndDrag(PointerEventData eventData)
 {
     DragEnded?.Invoke(eventData, gameObject);
 }
Exemple #21
0
 protected virtual void OnDragEnded()
 {
     DragEnded?.Invoke(this, EventArgs.Empty);
 }
Exemple #22
0
 public virtual void EndDrag(Vector3 mousePosition) => DragEnded?.Invoke(this, mousePosition);
Exemple #23
0
 private void OnDragEnded(InventorySlot inventorySlot, Vector2 pointerPosition)
 {
     DraggingInventorySlot.GetComponent <InventorySlot>().SetMainSprite(null);
     DraggingInventorySlot.SetActive(false);
     DragEnded?.Invoke(inventorySlot, pointerPosition);
 }
Exemple #24
0
 void SetupSliderDragHandlers(Slider slider)
 {
     slider.DragStarted += () => DragStarted?.Invoke();
     slider.DragEnded   += () => DragEnded?.Invoke();
     slider.Changed     += () => Changed?.Invoke();
 }
Exemple #25
0
 private void Command_MouseUp(object sender, MouseEventArgs e)
 {
     DragEnded?.Invoke(this);
 }
Exemple #26
0
        private void OnDragEvent(object sender, EventArgs arguments)
        {
            //Debug.LogError ("Entered the efvent");
            DragEnded drag = (DragEnded)arguments;

            isDragEnded = drag.value;
            switch (drag.action)
            {
            case Action.NONE:
            {
                shouldCueRotate = false;
                break;
            }

            case Action.MSG_MOUSE_DOWN_TABLE:
            {
                Debug.LogError(" MOUSE IS DOWN ON THE TABLE ");
                shouldCueRotate = true;
                break;
            }

            case Action.MSG_MOUSE_UP_TABLE:
            {
                Debug.LogError("MOUSE IS UP FROM THE TABLE ");
                shouldCueRotate = false;
                break;
            }

            //Canvas Events......


            case Action.MSG_MOUSE_CANVAS_DOWN:
            {
                isCanvasTouched = true;
                break;
            }

            case Action.MSG_MOUSE_CANVAS_STAY:
            {
                isCanvasTouched = true;
                break;
            }

            case Action.MSG_MOUSE_CANVAS_UP:
            {
                isCanvasTouched = false;
                break;
            }

            //Image Events

            case Action.MSG_MOUSE_UP_IMAGE:
            {
                isImageTouched = false;
                break;
            }

            case Action.MSG_MOUSE_DOWN_IMAGE:
            {
                isImageTouched = true;
                break;
            }

            // Cue Ball Canvas Events
            case Action.MSG_MOUSE_CUE_BALL_CANVAS_DOWN:
            {
                isCueBallCanvasTouched = true;
                break;
            }

            case Action.MSG_MOUSE_CUE_BALL_CANVAS_UP:
            {
                isCueBallCanvasTouched = false;
                break;
            }

            // Region Script Events
            case Action.MSG_MOUSE_INSIDE_REGION:
            {
                isCueBallInRegion = true;
                break;
            }

            case Action.MSG_MOUSE_OUTSIDE_REGION:
            {
                isCueBallInRegion = false;
                break;
            }
            }
        }
 private void OnDragEnded()
 {
     DragEnded?.Invoke(this, EventArgs.Empty);
 }
Exemple #28
0
 protected void RaiseDragEnded() => DragEnded?.Invoke();