Commit 12b9390b authored by UVA Multi-touch's avatar UVA Multi-touch

Hacked in a sort of point_leave event.

parent 3c8c49a4
......@@ -209,17 +209,20 @@ class Area(Positionable, Logger):
child.delegate_event(event)
return
for tracker in self.trackers:
tracker.handle_event(event)
if event.is_immediate_propagation_stopped():
return
self.handle_event(event)
if self.parent and not event.is_propagation_stopped():
event.add_offset(-self.x, -self.y)
#print 'propagated to %s: %s' % (self.parent, event)
self.parent.propagate_event(event)
def handle_event(self, event):
for tracker in self.trackers:
tracker.handle_event(event)
if event.is_immediate_propagation_stopped():
return
def handle_gesture(self, gesture):
"""
Handle a gesture that is triggered by a gesture tracker. First, all
......
from area import Area
from screen import screen_size
from events import PointMoveEvent, PointUpEvent
__all__ = ['RectangularArea', 'CircularArea', 'FullscreenArea']
......@@ -25,10 +26,26 @@ class RectangularArea(Area):
def get_size(self):
return self.width, self.height
def contains(self, x, y):
return self.x <= x <= self.x + self.width \
and self.y <= y <= self.y + self.height
def contains_event(self, event):
ex, ey = event.get_position()
return self.x <= ex <= self.x + self.width \
and self.y <= ey <= self.y + self.height
if self.contains(*event.get_position()):
return True
if isinstance(event, PointMoveEvent):
px, py = event.point.get_previous_position()
if self.parent:
x, y = self.parent.get_screen_offset()
else:
x = y = 0
if self.contains(px - x, py - y):
self.handle_event(PointUpEvent(event.point))
return False
class CircularArea(Area):
......
......@@ -21,7 +21,7 @@ class Rectangle(mt.RectangularArea):
self.on_drag(self.move)
self.on_pinch(self.resize)
self.on_rotate(self.rotate)
#self.on_rotate(self.rotate)
def move(self, g):
print 'move:', g
......@@ -38,6 +38,8 @@ class Rectangle(mt.RectangularArea):
self.tscale(scale)
self.ttrans(-x, -y)
self.translate(x - x * scale, y - y * scale)
self.width *= scale
self.height *= scale
......@@ -57,7 +59,6 @@ class Rectangle(mt.RectangularArea):
t = cairo.Matrix()
t.translate(tx, ty)
self.t = t * self.t
#self.t = self.t * t
def tscale(self, s):
t = cairo.Matrix()
......
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