Exemplo n.º 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);
        }
Exemplo n.º 2
0
 void _fireDragEnded(ItemType item, IntVector2 position)
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke(item, position);
     }
 }
Exemplo n.º 3
0
 private void EndDrag()
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke();
     }
 }
Exemplo n.º 4
0
 public void OnEndDrag(PointerEventData eventData)
 {
     if (IsWithItem)
     {
         DragEnded?.Invoke(this, eventData.position);
     }
 }
Exemplo n.º 5
0
 public override void dragEnded(IntVector2 position)
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke(this, position);
     }
 }
Exemplo n.º 6
0
 internal override void _fireDragEnded(DragAndDropItem item, IntVector2 position)
 {
     if (DragEnded != null)
     {
         DragEnded.Invoke((ItemType)item, position);
     }
 }
Exemplo n.º 7
0
 private void TryEndDrag()
 {
     if (!isDragActive)
     {
         return;
     }
     isDragActive = false;
     DragEnded?.Invoke();
     RunThumbAnimation("Normal");
 }
Exemplo n.º 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;
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 13
0
        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);
                }
            }
        }
Exemplo n.º 14
0
 public void InvokeDragEnded(int startIndex, int endIndex)
 {
     DragEnded?.Invoke(this, new DragAndDropEventArgs(startIndex, endIndex));
 }
Exemplo n.º 15
0
 private void RaiseDragEnded()
 {
     DragEnded?.Invoke();
 }
Exemplo n.º 16
0
 protected virtual void OnDragEnded(Dock position, double delta)
 {
     DragEnded?.Invoke(this, position, delta);
 }
Exemplo n.º 17
0
 protected virtual void OnDragEnded()
 {
     DragEnded?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 18
0
 public void OnEndDrag(PointerEventData eventData)
 {
     DragEnded?.Invoke(eventData, gameObject);
 }
Exemplo n.º 19
0
 private void OnDragEnded()
 {
     DragEnded?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 20
0
 protected void RaiseDragEnded() => DragEnded?.Invoke();
Exemplo n.º 21
0
 public virtual void EndDrag(Vector3 mousePosition) => DragEnded?.Invoke(this, mousePosition);
Exemplo n.º 22
0
 private void Command_MouseUp(object sender, MouseEventArgs e)
 {
     DragEnded?.Invoke(this);
 }
Exemplo n.º 23
0
 private void OnDragEnded(InventorySlot inventorySlot, Vector2 pointerPosition)
 {
     DraggingInventorySlot.GetComponent <InventorySlot>().SetMainSprite(null);
     DraggingInventorySlot.SetActive(false);
     DragEnded?.Invoke(inventorySlot, pointerPosition);
 }
Exemplo n.º 24
0
 void SetupSliderDragHandlers(Slider slider)
 {
     slider.DragStarted += () => DragStarted?.Invoke();
     slider.DragEnded   += () => DragEnded?.Invoke();
     slider.Changed     += () => Changed?.Invoke();
 }