Commit 3c6f417f authored by Taddeus Kroes's avatar Taddeus Kroes

Updated some event formats and added 'basic' events.

parent 5ca9a829
class GestureEvent(object):
def __init__(self, gesture):
self.gesture = gesture
class BasicEvent(object):
def __init__(self, point):
self.point = point
def __str__(self):
return '<%s (%s, %s) sid=%d>' % \
(self.__class__.__name__, self.point.x, self.point.y,
self.point.sid)
class TapEvent(GestureEvent):
def __init__(self, x, y, double=False):
super(TapEvent, self).__init__('tap')
def __getattr__(self, name):
"""
Delegate attributes to touch point.
"""
if hasattr(self.point, name):
return getattr(self.point, name)
raise AttributeError
class DownEvent(BasicEvent):
_name = 'down'
class UpEvent(BasicEvent):
_name = 'up'
class MoveEvent(BasicEvent):
_name = 'move'
def __str__(self):
return '<%s (%s, %s) to (%s, %s) sid=%d>' % \
(self.__class__.__name__, self.point.px, self.point.py,
self.point.x, self.point.y, self.point.sid)
class GestureEvent(object):
def __init__(self, x, y):
self.x = x
self.y = y
self.double = double
@property
def xy(self):
return self.x, self.y
def __str__(self):
return '<%s (%s, %s)%s>' % (self.__class__.__name__, self.x, self.y,
' double' if self.double else '')
return '<%s (%s, %s)>' % (self.__class__.__name__, self.x, self.y)
class TapEvent(GestureEvent):
_name = 'tap'
class SingleTapEvent(GestureEvent):
_name = 'single_tap'
class DoubleTapEvent(GestureEvent):
_name = 'double_tap'
class FlickEvent(GestureEvent):
_name = 'flick'
def __init__(self, x, y, velocity):
super(FlickEvent, self).__init__('flick')
self.x = x
self.y = y
super(FlickEvent, self).__init__(x, y)
self.velocity = velocity
def __str__(self):
......@@ -28,10 +72,10 @@ class FlickEvent(GestureEvent):
class RotateEvent(GestureEvent):
_name = 'rotate'
def __init__(self, cx, cy, angle, n):
super(RotateEvent, self).__init__('rotate')
self.cx = cx
self.cy = cy
super(RotateEvent, self).__init__(cx, cy)
self.angle = angle
self.n = n
......@@ -41,10 +85,10 @@ class RotateEvent(GestureEvent):
class PinchEvent(GestureEvent):
_name = 'pinch'
def __init__(self, cx, cy, amount, n):
super(RotateEvent, self).__init__('pinch')
self.cx = cx
self.cy = cy
super(RotateEvent, self).__init__(cx, cy)
self.amount = amount
self.n = n
......@@ -54,14 +98,15 @@ class PinchEvent(GestureEvent):
class PanEvent(GestureEvent):
_name = 'pan'
def __init__(self, x, y, dx, dy, n):
super(RotateEvent, self).__init__('pan')
self.x = x
self.y = y
super(RotateEvent, self).__init__(x, y)
self.dx = dx
self.dy = dy
self.n = n
def __str__(self):
return '<%s (%s, %s) amount=%s n=%d>' % \
(self.__class__.__name__, self.x, self.y, self.amount, self.n)
return '<%s (%s, %s) to (%s, %s) n=%d>' % \
(self.__class__.__name__, self.x, self.y, self.dx, self.dy,
self.amount, self.n)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment