Commit 9c260769 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Flick should be fixed now (TEST ON TABLE\!).

parent 55dbb2eb
...@@ -111,8 +111,9 @@ class TransformationTracker(GestureTracker): ...@@ -111,8 +111,9 @@ class TransformationTracker(GestureTracker):
def update_centroid(self): def update_centroid(self):
if not self.points: if not self.points:
prev = self.centroid
self.centroid = None self.centroid = None
return return prev
# Calculate average touch point coordinates # Calculate average touch point coordinates
l = len(self.points) l = len(self.points)
...@@ -124,6 +125,7 @@ class TransformationTracker(GestureTracker): ...@@ -124,6 +125,7 @@ class TransformationTracker(GestureTracker):
# Update centroid positionable # Update centroid positionable
if self.centroid: if self.centroid:
self.centroid.set_position(x, y) self.centroid.set_position(x, y)
return self.centroid.prev
else: else:
self.centroid = MovingPositionable(x, y) self.centroid = MovingPositionable(x, y)
...@@ -176,13 +178,14 @@ class TransformationTracker(GestureTracker): ...@@ -176,13 +178,14 @@ class TransformationTracker(GestureTracker):
self.centroid.translation(), l)) self.centroid.translation(), l))
def on_point_up(self, event): def on_point_up(self, event):
if event.point in self.points: point = event.get_touch_object()
self.points.remove(event.point)
if point in self.points:
self.points.remove(point)
prev = self.update_centroid()
if not self.points: if not self.points:
self.trigger(FlickGesture(event, self.centroid, self.trigger(FlickGesture(event, point, point - prev))
self.centroid.translation()))
self.update_centroid()
if not self.propagate_events: if not self.propagate_events:
event.stop_propagation() event.stop_propagation()
......
...@@ -63,9 +63,14 @@ class Polygon(BoundingBoxArea): ...@@ -63,9 +63,14 @@ class Polygon(BoundingBoxArea):
self.flick_direction = trans self.flick_direction = trans
flicks.add(Flick(self.flick_drag, 0.7, 0.4)) flicks.add(Flick(self.flick_drag, 0.7, 0.4))
def margin_contains(self, x, y):
m = self.margin
return self.x - m <= x < self.x + self.width + m \
and self.y - m <= y < self.y + self.height + m
def contains(self, x, y): def contains(self, x, y):
if draw_bounding_boxes: if draw_bounding_boxes:
return mt.RectangularArea.contains(self, x, y) return self.margin_contains(self, x, y)
return BoundingBoxArea.contains(self, x, y) return BoundingBoxArea.contains(self, x, y)
...@@ -86,11 +91,6 @@ class Polygon(BoundingBoxArea): ...@@ -86,11 +91,6 @@ class Polygon(BoundingBoxArea):
self.update_bounds() self.update_bounds()
refresh() refresh()
#def contains(self, x, y):
# m = self.margin
# return self.x - m <= x < self.x + self.width + m \
# and self.y - m <= y < self.y + self.height + m
def draw(self, cr): def draw(self, cr):
# Draw bounding box # Draw bounding box
if draw_bounding_boxes: if draw_bounding_boxes:
......
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