Commit 878291b4 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Did some debugging in trackers.

parent 0a2aed47
......@@ -52,6 +52,9 @@ class Positionable(object):
ox, oy = other
return ((ox - self.x) ** 2 + (oy - self.y) ** 2) ** .5
def translate(self, x, y):
self.set_position(self.x + x, self.y + y)
class MovingPositionable(Positionable):
"""
......
......@@ -36,8 +36,8 @@ class TapTracker(GestureTracker):
configurable = ['tap_distance', 'tap_time', 'double_tap_time',
'double_tap_distance', 'update_rate', 'propagate_up_event']
def __init__(self, window=None):
super(TapTracker, self).__init__(window)
def __init__(self, widget):
super(TapTracker, self).__init__(widget)
# Map of touch object id to tuple (timestamp, position) of point down
self.reg = {}
......
......@@ -59,6 +59,9 @@ class DragGesture(Gesture, Positionable):
return '<DragGesture at (%s, %s) translation=(%s, %s)>' \
% (self.get_position() + self.translation.get_position())
def get_translation(self):
return self.translation
class TransformationTracker(GestureTracker):
"""
......@@ -67,7 +70,7 @@ class TransformationTracker(GestureTracker):
"""
supported_gestures = [RotationGesture, PinchGesture, DragGesture]
def __init__(self, widget=None):
def __init__(self, widget):
super(TransformationTracker, self).__init__(widget)
# All touch points performing the transformation
......@@ -116,13 +119,17 @@ class TransformationTracker(GestureTracker):
scale = dist / prev
self.trigger(PinchGesture(event, self.centroid, scale))
# Movement using multiple touch points
self.trigger(DragGesture(event, self.centroid,
self.centroid.translation()))
else:
# Movement using one touch point
self.trigger(DragGesture(event, event.point,
event.point.translation()))
# Update centroid before movement can be detected
self.update_centroid()
# Movement
self.trigger(DragGesture(event, self.centroid,
self.centroid.translation()))
def on_point_up(self, event):
self.points.remove(event.point)
self.update_centroid()
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