Beispiel #1
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);
        }
Beispiel #2
0
 void _fireDragEnded(ItemType item, IntVector2 position)
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke(item, position);
     }
 }
Beispiel #3
0
 private void EndDrag()
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke();
     }
 }
Beispiel #4
0
 public void OnEndDrag(PointerEventData eventData)
 {
     if (IsWithItem)
     {
         DragEnded?.Invoke(this, eventData.position);
     }
 }
Beispiel #5
0
 public override void dragEnded(IntVector2 position)
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke(this, position);
     }
 }
 internal override void _fireDragEnded(DragAndDropItem item, IntVector2 position)
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke((ItemType)item, position);
     }
 }
Beispiel #7
0
 private void TryEndDrag()
 {
     if (!isDragActive)
     {
         return;
     }
     isDragActive = false;
     DragEnded?.Invoke();
     RunThumbAnimation("Normal");
 }
Beispiel #8
0
        protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
        {
            base.OnPreviewMouseUp(e);

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

            ElementBeingDragged = null;
            elementsInDragGroup = null;
        }
Beispiel #9
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);
     }
 }
Beispiel #10
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);
                }
            }
        }
Beispiel #11
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);
         }
     }
 }
Beispiel #12
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);
                }
            }
        }
Beispiel #14
0
 public void InvokeDragEnded(int startIndex, int endIndex)
 {
     DragEnded?.Invoke(this, new DragAndDropEventArgs(startIndex, endIndex));
 }
Beispiel #15
0
 private void RaiseDragEnded()
 {
     DragEnded?.Invoke();
 }
Beispiel #16
0
 protected virtual void OnDragEnded(Dock position, double delta)
 {
     DragEnded?.Invoke(this, position, delta);
 }
Beispiel #17
0
 protected virtual void OnDragEnded()
 {
     DragEnded?.Invoke(this, EventArgs.Empty);
 }
 public void OnEndDrag(PointerEventData eventData)
 {
     DragEnded?.Invoke(eventData, gameObject);
 }
 private void OnDragEnded()
 {
     DragEnded?.Invoke(this, EventArgs.Empty);
 }
Beispiel #20
0
 protected void RaiseDragEnded() => DragEnded?.Invoke();
Beispiel #21
0
 public virtual void EndDrag(Vector3 mousePosition) => DragEnded?.Invoke(this, mousePosition);
Beispiel #22
0
 private void Command_MouseUp(object sender, MouseEventArgs e)
 {
     DragEnded?.Invoke(this);
 }
Beispiel #23
0
 private void OnDragEnded(InventorySlot inventorySlot, Vector2 pointerPosition)
 {
     DraggingInventorySlot.GetComponent <InventorySlot>().SetMainSprite(null);
     DraggingInventorySlot.SetActive(false);
     DragEnded?.Invoke(inventorySlot, pointerPosition);
 }
Beispiel #24
0
 void SetupSliderDragHandlers(Slider slider)
 {
     slider.DragStarted += () => DragStarted?.Invoke();
     slider.DragEnded   += () => DragEnded?.Invoke();
     slider.Changed     += () => Changed?.Invoke();
 }