Skip to content
Snippets Groups Projects
Commit b0639f93 authored by Taddeüs Kroes's avatar Taddeüs Kroes
Browse files

Made test app more fancy.

parent 8280ae9b
No related branches found
No related tags found
No related merge requests found
...@@ -4,4 +4,3 @@ Code: ...@@ -4,4 +4,3 @@ Code:
Report/appendix reference gesture detection: Report/appendix reference gesture detection:
- Point_leave(+point_enter) kan niet -> flaw v/h systeem/driver? - Point_leave(+point_enter) kan niet -> flaw v/h systeem/driver?
- "gesture detection component" -> "gesture tracker"
...@@ -46,10 +46,11 @@ class Polygon(BoundingBoxArea): ...@@ -46,10 +46,11 @@ class Polygon(BoundingBoxArea):
self.on_pinch(self.handle_pinch) self.on_pinch(self.handle_pinch)
self.on_rotate(self.handle_rotate) self.on_rotate(self.handle_rotate)
self.on_flick(self.handle_flick) self.on_flick(self.handle_flick)
self.on_double_tap(self.circulate_color) self.on_tap(self.circulate_color)
def circulate_color(self, g): def circulate_color(self, g):
self.color = self.color[2:] + self.color[:2] self.color = self.color[2:] + self.color[:2]
refresh()
def flick_drag(self, amt): def flick_drag(self, amt):
tx, ty = self.flick_direction tx, ty = self.flick_direction
...@@ -119,6 +120,13 @@ draw_touch_objects = True ...@@ -119,6 +120,13 @@ draw_touch_objects = True
W, H = mt.screen.screen_size W, H = mt.screen.screen_size
def toggle_fullscreen():
global fullscreen
(window.unfullscreen if fullscreen else window.fullscreen)()
fullscreen = not fullscreen
refresh()
def create_context_window(w, h, callback): def create_context_window(w, h, callback):
def create_context(area, event): def create_context(area, event):
"""Add Cairo context to GTK window and draw state.""" """Add Cairo context to GTK window and draw state."""
...@@ -135,9 +143,7 @@ def create_context_window(w, h, callback): ...@@ -135,9 +143,7 @@ def create_context_window(w, h, callback):
key = chr(event.keyval) key = chr(event.keyval)
if key == 'f': if key == 'f':
global fullscreen toggle_fullscreen()
(win.unfullscreen if fullscreen else win.fullscreen)()
fullscreen = not fullscreen
elif key == 'b': elif key == 'b':
global draw_bounding_boxes global draw_bounding_boxes
draw_bounding_boxes = not draw_bounding_boxes draw_bounding_boxes = not draw_bounding_boxes
...@@ -149,7 +155,7 @@ def create_context_window(w, h, callback): ...@@ -149,7 +155,7 @@ def create_context_window(w, h, callback):
elif key == 'q': elif key == 'q':
quit() quit()
def update_window(): def redraw_updated_window():
refresh() refresh()
return True return True
...@@ -160,7 +166,7 @@ def create_context_window(w, h, callback): ...@@ -160,7 +166,7 @@ def create_context_window(w, h, callback):
window.connect('destroy', quit) window.connect('destroy', quit)
window.connect('key-press-event', handle_key) window.connect('key-press-event', handle_key)
window.connect('show', callback) window.connect('show', callback)
window.on_update(update_window) window.on_update(redraw_updated_window)
root = window.get_area() root = window.get_area()
if fullscreen: if fullscreen:
...@@ -196,7 +202,13 @@ def draw(): ...@@ -196,7 +202,13 @@ def draw():
cr.set_source_rgb(*WHITE) cr.set_source_rgb(*WHITE)
for hand in touch_hands: for hand in touch_hands:
cx, cy = hand.get_centroid() centroid = hand.get_centroid()
# Check if all fingers have not been removed already
if not centroid:
continue
cx, cy = centroid
# Filled centroid circle # Filled centroid circle
if len(hand) > 1: if len(hand) > 1:
...@@ -247,8 +259,8 @@ def triangle_height(width): ...@@ -247,8 +259,8 @@ def triangle_height(width):
def on_show(window): def on_show(window):
def root_dtap(g): print 'double tapped on root' # Toggle fullscreen on double tap
root.on_double_tap(root_dtap) root.on_double_tap(lambda g: toggle_fullscreen())
# Create blue rectangle # Create blue rectangle
x, y, w, h = 0, 0, 250, 150 x, y, w, h = 0, 0, 250, 150
...@@ -256,9 +268,6 @@ def on_show(window): ...@@ -256,9 +268,6 @@ def on_show(window):
draw_objects.append(rect) draw_objects.append(rect)
root.add_area(rect) root.add_area(rect)
def rect_tap(g): print 'tapped on rectangle'
rect.on_tap(rect_tap, propagate_up_event=False)
# Create green triangle # Create green triangle
x, y, w = 400, 400, 200 x, y, w = 400, 400, 200
h = triangle_height(w) h = triangle_height(w)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment