コード例 #1
0
ファイル: UiSlider.cs プロジェクト: luizmramos/Hackathon
 void Slider_OnMoved(TouchInfo ti)
 {
     Value = (ti.Position.x - GetAbsoluteX()) / Size.x + 0.5f;
     if (Value < 0)
     {
         Value = 0;
     }
     else if (Value > 1)
     {
         Value = 1;
     }
     OnChangeValue.Fire(Value);
 }
コード例 #2
0
        public virtual bool Consume(TouchInfo touchInfo)
        {
            if (blockInput)
            {
                return(true);
            }

            UIElement toConsume = null;

            if (overlay != null)
            {
                toConsume = overlay.GetConsumedElement(touchInfo);
            }
            else
            {
                toConsume = CurrentPage.GetConsumedElement(touchInfo);
            }

            if (touchInfo.TouchState == TouchState.Released)
            {
                touchInfo.Delta = touchInfo.Position - lastPressPos;
                if (draggedObject != null)
                {
                    toConsume     = draggedObject;
                    draggedObject = null;
                }
            }
            else if (touchInfo.TouchState == TouchState.Pressed)
            {
                if (draggedObject == null)
                {
                    draggedObject = toConsume;
                    lastPressPos.Copy(touchInfo.Position);
                }
            }
            else if (touchInfo.TouchState == TouchState.Moved)
            {
                if (draggedObject != null)
                {
                    toConsume = draggedObject;
                }
                touchInfo.Delta = touchInfo.Position - lastPressPos;
            }

            if (toConsume == null)
            {
                return(overlay != null);
            }
            toConsume.Consume(touchInfo);
            return(true);
        }
コード例 #3
0
        public override UIElement GetConsumedElement(TouchInfo ti)
        {
            if (!Active)
            {
                return(null);
            }

            lastConsumed = base.GetConsumedElement(ti);
            if (lastConsumed != null || holding)
            {
                return(this);
            }
            return(lastConsumed);
        }
コード例 #4
0
        public void ToTouchInfo(TouchLocation tl, ref TouchInfo ti)
        {
            TouchState touchState = TouchState.Moved;

            if (tl.State == TouchLocationState.Pressed)
            {
                touchState = TouchState.Pressed;
            }
            else if (tl.State == TouchLocationState.Released)
            {
                touchState = TouchState.Released;
            }

            ti.id = tl.Id;
            ti.Set(tl.Position.X, tl.Position.Y, touchState);
        }
コード例 #5
0
 public override void Consume(TouchInfo ti)
 {
     if (ti.TouchState == TouchState.Released)
     {
         if (ti.Delta.x > 25f / 480)
         {
             SlidePrev();
         }
         else if (ti.Delta.x < -25f / 480)
         {
             SlideNext();
         }
         else
         {
             if (Math.Abs(maxDelta) < 25f / 480)
             {
                 if (lastConsumed != null)
                 {
                     lastConsumed.Consume(ti);
                 }
             }
         }
         holding  = false;
         maxDelta = 0;
     }
     else if (ti.TouchState == TouchState.Moved)
     {
         if (Math.Abs(ti.Delta.x) > Math.Abs(maxDelta))
         {
             maxDelta = ti.Delta.x;
         }
         slideContainer.Position.x = ti.Delta.x + holdPos;
     }
     else if (ti.TouchState == TouchState.Pressed)
     {
         holding  = true;
         holdPos  = slideContainer.Position.x;
         maxDelta = 0;
     }
     else
     {
         if (lastConsumed != null)
         {
             lastConsumed.Consume(ti);
         }
     }
 }
コード例 #6
0
ファイル: UIButton.cs プロジェクト: luizmramos/Hackathon
        public override UIElement GetConsumedElement(TouchInfo ti)
        {
            if (!Visible)
            {
                return(null);
            }
            if (!Active)
            {
                return(null);
            }

            bool canConsume = CheckBounds(ti);

            mouseOver = canConsume && ti.TouchState != TouchState.Released;
            pressed   = (ti.TouchState == TouchState.Pressed || pressed) && mouseOver;

            if (!canConsume)
            {
                return(null);
            }
            return(this);
        }
コード例 #7
0
 public void Copy(TouchInfo ti)
 {
     id = ti.id;
     Position.Copy(ti.Position);
     TouchState = ti.TouchState;
 }
コード例 #8
0
 protected void FireOnRelease(TouchInfo ti)
 {
     OnRelease.Fire(ti);
 }