1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_WM_GESTURES_BORDER_GESTURE_HANDLER_H_
6 #define ASH_WM_GESTURES_BORDER_GESTURE_HANDLER_H_
10 #include "ash/shelf/shelf_types.h"
11 #include "ash/wm/gestures/shelf_gesture_handler.h"
12 #include "base/basictypes.h"
30 enum BorderScrollOrientation
{
31 BORDER_SCROLL_ORIENTATION_UNSET
= 0,
32 BORDER_SCROLL_ORIENTATION_HORIZONTAL
,
33 BORDER_SCROLL_ORIENTATION_VERTICAL
36 // Bit positions of border location flags
38 BORDER_LOCATION_BOTTOM
= 0,
39 BORDER_LOCATION_LEFT
= 1,
40 BORDER_LOCATION_TOP
= 2,
41 BORDER_LOCATION_RIGHT
= 3,
45 typedef std::bitset
<NUM_BORDER_LOCATIONS
> BorderFlags
;
47 // Handles touch gestures that occur around the border of the display area that
48 // might have actions associated with them. It handles both gestures that
49 // require a bezel sensor (bezel gestures) and those that do not (edge
51 class BorderGestureHandler
{
53 BorderGestureHandler();
54 ~BorderGestureHandler();
56 // Returns true of the gesture has been handled and it should not be processed
57 // any farther, false otherwise.
58 bool ProcessGestureEvent(aura::Window
* target
, const ui::GestureEvent
& event
);
61 // Handle events meant for showing the launcher. Returns true when no further
62 // events from this gesture should be sent.
63 bool HandleLauncherControl(const ui::GestureEvent
& event
);
65 bool HandleBorderGestureStart(aura::Window
* target
,
66 const ui::GestureEvent
& event
);
68 // Handles a gesture update once the orientation has been found.
69 bool HandleBorderGestureUpdate(aura::Window
* target
,
70 const ui::GestureEvent
& event
);
72 bool HandleBorderGestureEnd(aura::Window
* target
,
73 const ui::GestureEvent
& event
);
75 // Check that gesture starts on a bezel or in the edge region of the
76 // screen. If so, set bits in |start_location_|.
77 void GestureStartInTargetArea(const gfx::Rect
& screen
,
78 const ui::GestureEvent
& event
);
80 // Determine the gesture orientation (if not yet done).
81 // Returns true when the orientation has been successfully determined.
82 bool DetermineGestureOrientation(const ui::GestureEvent
& event
);
84 // Test if the gesture orientation makes sense to be dragging in or out the
86 bool IsGestureInLauncherOrientation(const ui::GestureEvent
& event
);
88 // Which bezel/edges the gesture started in. In the case that a gesture begins
89 // in a corner of the screen more then one flag may be set and the orientation
90 // of the gesture will be needed to disambiguate.
91 BorderFlags start_location_
;
93 // Orientation relative to the screen that the gesture is moving in
94 BorderScrollOrientation orientation_
;
96 ShelfGestureHandler shelf_handler_
;
98 DISALLOW_COPY_AND_ASSIGN(BorderGestureHandler
);
101 } // namespace internal
103 #endif // ASH_WM_GESTURES_BORDER_GESTURE_HANDLER_H_