Commit 29dd92a4 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Polygons can now be transformes at the same time by a single gesture on the root window.

parent 2b5a1a55
......@@ -55,7 +55,6 @@ class Polygon(BoundingBoxArea):
def handle_flick(self, g):
trans = g.get_translation()
print trans.distance_to((0, 0))
if trans.distance_to((0, 0)) > 10:
self.flick_direction = trans
flicks.add(Flick(self.flick_drag, 0.7, 0.4))
......@@ -290,6 +289,31 @@ def on_show(window):
overlay.on_finger_up(handle_up)
root.add_area(overlay)
# Root area rotation leads to rotation of all polygons around the centroid
def move_to_polygons(g):
gx, gy = g.get_position()
for obj in draw_objects:
x, y = obj.get_position()
g.set_position(gx - x, gy - y)
yield obj, g
def rotate_root(g):
for obj, gesture in move_to_polygons(g):
obj.handle_rotate(gesture)
def scale_root(g):
for obj, gesture in move_to_polygons(g):
obj.handle_pinch(gesture)
def drag_root(g):
for obj, gesture in move_to_polygons(g):
obj.handle_drag(gesture)
root.on_rotate(rotate_root)
root.on_pinch(scale_root)
root.on_drag(drag_root)
if __name__ == '__main__':
from parse_arguments import create_parser, parse_args
......
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