|
|
@@ -2,6 +2,7 @@ from __future__ import division
|
|
|
from time import sleep
|
|
|
from threading import Thread
|
|
|
from numpy import array, diag, dot, cos, sin, asarray, column_stack, c_
|
|
|
+from gtk import Window
|
|
|
|
|
|
from src import RectangularArea
|
|
|
|
|
|
@@ -36,11 +37,16 @@ class BoundingBoxArea(RectangularArea):
|
|
|
def update_bounds(self):
|
|
|
min_x, min_y = self.points.min(1)
|
|
|
max_x, max_y = self.points.max(1)
|
|
|
- self.set_size(max_x - min_x, max_y - min_y)
|
|
|
+ width = max_x - min_x
|
|
|
+ height = max_y - min_y
|
|
|
|
|
|
if min_x or min_y:
|
|
|
- self.translate(min_x, min_y)
|
|
|
+ self.width = width
|
|
|
+ self.height = height
|
|
|
self.translate_points(-min_x, -min_y)
|
|
|
+ self.translate(min_x, min_y)
|
|
|
+ elif width != self.width or height != self.height:
|
|
|
+ self.set_size(width, height)
|
|
|
|
|
|
|
|
|
FLICK_UPDATE_RATE = 30
|
|
|
@@ -114,3 +120,22 @@ def inside_shape(p, verts):
|
|
|
inside = not inside
|
|
|
|
|
|
return inside
|
|
|
+
|
|
|
+
|
|
|
+class GtkEventWindow(Window):
|
|
|
+ def __init__(self, width=0, height=0):
|
|
|
+ Window.__init__(self)
|
|
|
+ self.area = RectangularArea(0, 0, width, height)
|
|
|
+ self.connect('configure-event', self.sync_area)
|
|
|
+
|
|
|
+ def get_area(self):
|
|
|
+ return self.area
|
|
|
+
|
|
|
+ def on_update(self, handler):
|
|
|
+ self.area.on_update(handler)
|
|
|
+
|
|
|
+ def sync_area(self, win, event):
|
|
|
+ """Synchronize root multi-touch area with GTK window."""
|
|
|
+ self.area.width = event.width
|
|
|
+ self.area.height = event.height
|
|
|
+ self.area.set_position(*event.get_coords())
|