diff options
author | Simon Schampijer <simon@laptop.org> | 2012-10-09 18:48:26 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@laptop.org> | 2012-10-09 19:09:36 (GMT) |
commit | 536204c2a3f742a3d62c0c94e975c3a47ce6c12f (patch) | |
tree | 12f5ef5abd494913475ef495217d56c3383838e5 | |
parent | 26eab6ccb5b90128553ee1ec5de2bf4e54238388 (diff) |
Frame gesture: only make the top area recognizing the gesture
After testing and running into several trickier cases with
the Activity canvas (SL #3994) we agreed on using only the
area at the top to trigger the Frame. The same gesture is
used to show/hide the Frame as we discovered that swiping
towards the bezel is not as pleasant.
Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Manuel QuiƱones <manuq@laptop.org>
-rw-r--r-- | src/jarabe/view/gesturehandler.py | 118 |
1 files changed, 22 insertions, 96 deletions
diff --git a/src/jarabe/view/gesturehandler.py b/src/jarabe/view/gesturehandler.py index 06fa044..47b9f8f 100644 --- a/src/jarabe/view/gesturehandler.py +++ b/src/jarabe/view/gesturehandler.py @@ -28,15 +28,12 @@ class GestureHandler(object): '''Handling gestures to show/hide the frame We use SugarExt.GestureGrabber to listen for - gestures on the root window. Swiping from - the frame area towards the center does reveal - the Frame. Swiping towards one of the edges - does hide the Frame. + gestures on the root window. We use a toggle + gesture to either hide or show the frame: Swiping + from the frame area at the top towards the center + does reveal the Frame or hide it. ''' - _HIDE = 0 - _SHOW = 1 - def __init__(self, frame): self._frame = frame @@ -55,97 +52,26 @@ class GestureHandler(object): for controller in self._controller: self._gesture_grabber.remove(controller) - rectangle = self._create_rectangle(0, 0, Gdk.Screen.width(), - style.GRID_CELL_SIZE) - swipe = SugarGestures.SwipeController( \ - directions=SugarGestures.SwipeDirectionFlags.DOWN) - swipe.connect('swipe-ended', self.__top_show_cb) - self._gesture_grabber.add(swipe, rectangle) - - rectangle = self._create_rectangle(0, 0, Gdk.Screen.width(), - style.GRID_CELL_SIZE * 2) - swipe = SugarGestures.SwipeController( \ - directions=SugarGestures.SwipeDirectionFlags.UP) - swipe.connect('swipe-ended', self.__top_hide_cb) - self._gesture_grabber.add(swipe, rectangle) - - rectangle = self._create_rectangle( \ - 0, Gdk.Screen.height() - style.GRID_CELL_SIZE, - Gdk.Screen.width(), style.GRID_CELL_SIZE) - swipe = SugarGestures.SwipeController( \ - directions=SugarGestures.SwipeDirectionFlags.UP) - swipe.connect('swipe-ended', self.__bottom_show_cb) - self._gesture_grabber.add(swipe, rectangle) - - rectangle = self._create_rectangle( \ - 0, Gdk.Screen.height() - style.GRID_CELL_SIZE * 2, - Gdk.Screen.width(), style.GRID_CELL_SIZE * 2) - swipe = SugarGestures.SwipeController( \ - directions=SugarGestures.SwipeDirectionFlags.DOWN) - swipe.connect('swipe-ended', self.__bottom_hide_cb) - self._gesture_grabber.add(swipe, rectangle) - - rectangle = self._create_rectangle( \ - 0, 0, style.GRID_CELL_SIZE, Gdk.Screen.height()) - swipe = SugarGestures.SwipeController( \ - directions=SugarGestures.SwipeDirectionFlags.RIGHT) - swipe.connect('swipe-ended', self.__left_show_cb) + self._track_gesture_for_area(SugarGestures.SwipeDirectionFlags.DOWN, + 0, 0, Gdk.Screen.width(), + style.GRID_CELL_SIZE) + + def _track_gesture_for_area(self, directions, x, y, width, height): + rectangle = Gdk.Rectangle() + rectangle.x = x + rectangle.y = y + rectangle.width = width + rectangle.height = height + swipe = SugarGestures.SwipeController(directions=directions) + swipe.connect('swipe-ended', self.__swipe_ended_cb) self._gesture_grabber.add(swipe, rectangle) + self._controller.append(swipe) - rectangle = self._create_rectangle( \ - 0, 0, style.GRID_CELL_SIZE * 2, Gdk.Screen.height()) - swipe = SugarGestures.SwipeController( \ - directions=SugarGestures.SwipeDirectionFlags.LEFT) - swipe.connect('swipe-ended', self.__left_hide_cb) - self._gesture_grabber.add(swipe, rectangle) - - rectangle = self._create_rectangle( \ - Gdk.Screen.width() - style.GRID_CELL_SIZE, 0, - style.GRID_CELL_SIZE, Gdk.Screen.height()) - swipe = SugarGestures.SwipeController( \ - directions=SugarGestures.SwipeDirectionFlags.LEFT) - swipe.connect('swipe-ended', self.__right_show_cb) - self._gesture_grabber.add(swipe, rectangle) - - rectangle = self._create_rectangle( \ - Gdk.Screen.width() - style.GRID_CELL_SIZE * 2, 0, - style.GRID_CELL_SIZE * 2, Gdk.Screen.height()) - swipe = SugarGestures.SwipeController( \ - directions=SugarGestures.SwipeDirectionFlags.RIGHT) - swipe.connect('swipe-ended', self.__right_hide_cb) - self._gesture_grabber.add(swipe, rectangle) - - def _create_rectangle(self, x, y, width, height): - rect = Gdk.Rectangle() - rect.x = x - rect.y = y - rect.width = width - rect.height = height - return rect - - def __top_show_cb(self, controller, event_direction): - self._frame.show() - - def __top_hide_cb(self, controller, event_direction): - self._frame.hide() - - def __bottom_show_cb(self, controller, event_direction): - self._frame.show() - - def __bottom_hide_cb(self, controller, event_direction): - self._frame.hide() - - def __left_show_cb(self, controller, event_direction): - self._frame.show() - - def __left_hide_cb(self, controller, event_direction): - self._frame.hide() - - def __right_show_cb(self, controller, event_direction): - self._frame.show() - - def __right_hide_cb(self, controller, event_direction): - self._frame.hide() + def __swipe_ended_cb(self, controller, event_direction): + if self._frame.is_visible(): + self._frame.hide() + else: + self._frame.show() def setup(frame): |