Пример #1
0
        protected internal virtual void UpdateStateByEvent(MotionEvent curr)
        {
            MotionEvent prev = mPrevEvent;

            // Reset mCurrEvent
            if (mCurrEvent != null)
            {
                mCurrEvent.Recycle();
                mCurrEvent = null;
            }
            mCurrEvent = MotionEvent.Obtain(curr);
            // Delta time
            mTimeDelta = curr.EventTime - prev.EventTime;
            // Pressure
            mCurrPressure = curr.GetPressure(curr.ActionIndex);
            mPrevPressure = prev.GetPressure(prev.ActionIndex);
        }
Пример #2
0
        /// <summary>
        /// Updates the current state with the given event.
        /// </summary>
        /// <param name="curr">The current event.</param>
        protected virtual void UpdateStateByEvent(MotionEvent curr)
        {
            MotionEvent prev = _previousEvent;

            // Reset _currentEvent.
            if (_currentEvent != null)
            {
                _currentEvent.Recycle();
                _currentEvent = null;
            }
            _currentEvent = MotionEvent.Obtain(curr);

            // Delta time.
            _timeDelta = 0;
            if (prev != null)
            {
                _timeDelta = curr.EventTime - prev.EventTime;

                // Pressure.
                _previousPressure = prev.GetPressure(prev.ActionIndex);
            }
            _currentPressure = curr.GetPressure(curr.ActionIndex);
        }
Пример #3
0
		/// <summary>
		/// Updates the current state with the given event.
		/// </summary>
		/// <param name="curr">The current event.</param>
		protected virtual void UpdateStateByEvent(MotionEvent curr) {
			MotionEvent prev = _previousEvent;

			// Reset _currentEvent.
			if (_currentEvent != null) {
				_currentEvent.Recycle ();
				_currentEvent = null;
			}
			_currentEvent = MotionEvent.Obtain (curr);

			// Delta time.
			_timeDelta = 0;
			if (prev != null) {
				_timeDelta = curr.EventTime - prev.EventTime;

				// Pressure.
				_previousPressure = prev.GetPressure (prev.ActionIndex);
			}
			_currentPressure = curr.GetPressure (curr.ActionIndex);
		}
		protected internal virtual void UpdateStateByEvent(MotionEvent curr)
		{
			MotionEvent prev = mPrevEvent;
			// Reset mCurrEvent
			if (mCurrEvent != null)
			{
				mCurrEvent.Recycle();
				mCurrEvent = null;
			}
			mCurrEvent = MotionEvent.Obtain(curr);
			// Delta time
			mTimeDelta = curr.EventTime - prev.EventTime;
			// Pressure
			mCurrPressure = curr.GetPressure(curr.ActionIndex);
			mPrevPressure = prev.GetPressure(prev.ActionIndex);
		}
Пример #5
0
			bool OnTouchOrHoverEvent (MotionEvent e, bool isTouch)
			{
				MotionEventButtonState buttonState = e.ButtonState;
				MotionEventButtonState pressedButtons = buttonState & ~mOldButtonState;
				mOldButtonState = buttonState;

				if ((pressedButtons & MotionEventButtonState.Secondary) != 0) {
					// Advance color when the right mouse button or first stylus button
					// is pressed.
					AdvanceColor ();
				}

				PaintMode mode;
				if ((buttonState & MotionEventButtonState.Tertiary) != 0) {
					// Splat paint when the middle mouse button or second stylus button is pressed.
					mode = PaintMode.Splat;
				} else if (isTouch || (buttonState & MotionEventButtonState.Primary) != 0) {
					// Draw paint when touching or if the primary button is pressed.
					mode = PaintMode.Draw;
				} else {
					// Otherwise, do not paint anything.
					return false;
				}

				MotionEventActions action = e.ActionMasked;
				if (action ==  MotionEventActions.Down || action == MotionEventActions.Move
					|| action == MotionEventActions.HoverMove) {
					int N = e.HistorySize;
					int P = e.PointerCount;
					for (int i = 0; i < N; i++) {
						for (int j = 0; j < P; j++) {
							Paint (GetPaintModeForTool (e.GetToolType (j), mode),
								e.GetHistoricalX (j, i),
								e.GetHistoricalY(j, i),
								e.GetHistoricalPressure (j, i),
								e.GetHistoricalTouchMajor (j, i),
								e.GetHistoricalTouchMinor (j, i),
								e.GetHistoricalOrientation (j, i),
								e.GetHistoricalAxisValue (Axis.Distance, j, i),
								e.GetHistoricalAxisValue (Axis.Tilt, j, i));
						}
					}
					for (int j = 0; j < P; j++) {
						Paint (GetPaintModeForTool (e.GetToolType (j), mode),
							e.GetX (j),
							e.GetY (j),
							e.GetPressure (j),
							e.GetTouchMajor (j),
							e.GetTouchMinor (j),
							e.GetOrientation (j),
							e.GetAxisValue (Axis.Distance, j),
							e.GetAxisValue (Axis.Tilt, j));
					}
					mCurX = e.GetX ();
					mCurY = e.GetY ();
				}
				return true;
			}
Пример #6
0
		void SetContext (MotionEvent curr)
		{
			if (mCurrEvent != null) {
				mCurrEvent.Recycle();
			}
			mCurrEvent = MotionEvent.Obtain(curr);

			mCurrLen = -1;
			mPrevLen = -1;
			mScaleFactor = -1;

			MotionEvent prev = mPrevEvent;

			int prevIndex0 = prev.FindPointerIndex(mActiveId0);
			int prevIndex1 = prev.FindPointerIndex(mActiveId1);
			int currIndex0 = curr.FindPointerIndex(mActiveId0);
			int currIndex1 = curr.FindPointerIndex(mActiveId1);

			if (prevIndex0 < 0 || prevIndex1 < 0 || currIndex0 < 0 || currIndex1 < 0) {
				mInvalidGesture = true;
				if (mGestureInProgress) {
					mListener.OnScaleEnd(this);
				}
				return;
			}

			float px0 = prev.GetX(prevIndex0);
			float py0 = prev.GetY(prevIndex0);
			float px1 = prev.GetX(prevIndex1);
			float py1 = prev.GetY(prevIndex1);
			float cx0 = curr.GetX(currIndex0);
			float cy0 = curr.GetY(currIndex0);
			float cx1 = curr.GetX(currIndex1);
			float cy1 = curr.GetY(currIndex1);

			float pvx = px1 - px0;
			float pvy = py1 - py0;
			float cvx = cx1 - cx0;
			float cvy = cy1 - cy0;
			mPrevFingerDiffX = pvx;
			mPrevFingerDiffY = pvy;
			mCurrFingerDiffX = cvx;
			mCurrFingerDiffY = cvy;

			mFocusX = cx0 + cvx * 0.5f;
			mFocusY = cy0 + cvy * 0.5f;
			mTimeDelta = curr.EventTime - prev.EventTime;
			mCurrPressure = curr.GetPressure(currIndex0) + curr.GetPressure(currIndex1);
			mPrevPressure = prev.GetPressure(prevIndex0) + prev.GetPressure(prevIndex1);
		}