From 290189d892861a30fb97cefe9197cd2194e89594 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 29 Oct 2012 20:13:15 +0000 Subject: Zoom Gesture zooms through the gesture's center When two fingers are used to zoom in/out the image, the center of the gesture is used to zoom the image through it. Signed-off-by: Manuel Kaufmann Signed-off-by: Agustin Zubiaga --- (limited to 'ImageViewerActivity.py') diff --git a/ImageViewerActivity.py b/ImageViewerActivity.py index 0c51699..4850116 100644 --- a/ImageViewerActivity.py +++ b/ImageViewerActivity.py @@ -123,6 +123,8 @@ class ImageViewerActivity(activity.Activity): zoom_controller = SugarGestures.ZoomController() zoom_controller.connect('scale-changed', self.__scale_changed_cb) + zoom_controller.connect('began', + self.__scale_began_cb) zoom_controller.attach(self, SugarGestures.EventControllerFlags.NONE) @@ -208,12 +210,16 @@ class ImageViewerActivity(activity.Activity): # Wait for a successful join before trying to get the document self.connect("joined", self._joined_cb) + def __scale_began_cb(self, controller): + self.view._zoom_ori = self.view.zoom + def __scale_changed_cb(self, controller, scale): if scale != self._last_scale: self._last_scale = scale logging.error('Scale changed %f', scale) self.view._is_touching = True + self.view._touch_center = controller.get_center() self.view.set_zoom_relative(scale) def handle_view_source(self): -- cgit v0.9.1