Property definitions

android $ AndroidMotionEvent :: defaultinit
# A motion event concerning a single or more `pointers`
class AndroidMotionEvent
	super AndroidInputEvent
	super MotionEvent

	private var native: NativeAndroidMotionEvent

	# Pointers (or fingers) composing this motion event
	var pointers: Array[AndroidPointerEvent] is lazy do
		return [for i in native.pointers_count.times do new AndroidPointerEvent(self, i)]
	end

	# The pointer (or finger) causing this event
	var acting_pointer: AndroidPointerEvent is lazy do
		var action = native.action
		var index = 0

		if action.is_pointer_down or action.is_pointer_up then
			index = native.action.pointer_index
		end

		return new AndroidPointerEvent(self, index)
	end

	redef fun just_went_down do return native.action.is_down or native.action.is_pointer_down

	# Was the top edge of the screen intersected by this event?
	fun touch_to_edge: Bool do return native.edge == 1

	# Was the bottom edge of the screen intersected by this event?
	fun touch_bottom_edge: Bool do return native.edge == 2

	# Was the left edge of the screen intersected by this event?
	fun touch_left_edge: Bool do return native.edge == 4

	# Was the right edge of the screen intersected by this event?
	fun touch_right_edge: Bool do return native.edge == 8

	redef fun down_pointer: nullable AndroidPointerEvent
	do
		if just_went_down then
			# The primary pointer went down
			return pointers[0]
		end

		var i = native.index_down_pointer
		if i > 0 then
			# A secondary pointer went down
			return pointers[i]
		else
			return null
		end
	end

	# Time when the user originally pressed down to start a stream of position events
	#
	# The return value is in the `java.lang.System.nanoTime()` time base.
	fun down_time: Int do return native.native_down_time
end
lib/android/input_events.nit:101,1--159,3