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