Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(744)

Side by Side Diff: athena/wm/bezel_controller.h

Issue 394833004: Split View Mode: Support for the 2-finger bezel scroll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing accidental edit. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 #ifndef ATHENA_WM_BEZEL_CONTROLLER_H_
6 #define ATHENA_WM_BEZEL_CONTROLLER_H_
7
8 #include "ui/events/event_handler.h"
9
10 namespace aura {
11 class Window;
12 }
13
14 namespace gfx {
15 class PointF;
16 }
17
18 namespace athena {
19
20 // Responsible for detecting bezel gestures and notifying the delegate(s)
21 // subscribed to them.
22 class BezelController : public ui::EventHandler {
23 public:
24 enum Bezel {
25 BEZEL_NONE,
26 BEZEL_LEFT,
27 BEZEL_RIGHT,
28 // BEZEL_TOP,
29 // BEZEL_BOTTOM
Jun Mukai 2014/07/21 17:18:52 Uncomment-out them (it's okay unused at all), or j
mfomitchev 2014/07/21 17:31:47 Done.
30 };
31
32 // Responsible for handling scroll gestures initiated from the bezel.
33 // Two touch points are need to perform the bezel scroll gesture from
34 // the left and right bezel.
35 class ScrollDelegate {
36 public:
37 virtual ~ScrollDelegate() {}
38
39 // Beginning of a bezel scroll gesture started from the |bezel|.
40 virtual void ScrollBegin(Bezel bezel, float delta) = 0;
41
42 // End of the current bezel scroll
43 virtual void ScrollEnd() = 0;
44
45 // Update of the scroll position for the currently active bezel scroll.
46 virtual void ScrollUpdate(float delta) = 0;
47
48 // Should return false if the delegate isn't going to react to the scroll
49 // events.
50 virtual bool CanScroll() = 0;
51 };
52
53 BezelController(aura::Window* container);
54 virtual ~BezelController() {}
55
56 // Set the delegate to handle the gestures from left and right bezels.
57 // Two touch points are need to perform the bezel scroll gesture from
58 // the left and right bezel.
59 void set_left_right_delegate(ScrollDelegate* delegate) {
60 left_right_delegate_ = delegate;
61 }
62
63 private:
64 enum State {
65 NO_FINGERS_DOWN,
66 IGNORE,
67 BEZEL_GESTURE_STARTED,
68 BEZEL_SCROLLING_ONE_FINGER,
69 BEZEL_SCROLLING_TWO_FINGERS,
70 };
71
72 // Defines the effective bezel width.
73 static const float kBezelWidth;
74
75 static const gfx::PointF& kScrollPositionNone;
76
77 // Calculates the distance from |position| to the |bezel|.
78 float GetDistance(const gfx::PointF& position, Bezel bezel);
79
80 // |scroll_position| only needs to be passed in the scrolling state
81 void SetState(State state, const gfx::PointF& scroll_position);
82
83 // Returns the bezel corresponding to the |location| or BEZEL_NONE if the
84 // location is outside of the bezel area.
85 Bezel GetBezel(const gfx::PointF& location);
86
87 bool ShouldProcessGesture(ui::EventType event_type);
88
89 // ui::EventHandler overrides
90 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
91 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
92
93 aura::Window* container_;
94
95 int num_fingers_down_;
96 State state_;
97
98 // The bezel where the current bezel scroll was started.
99 Bezel scroll_bezel_;
100
101 // Responsible for handling gestures started from the left and right bezels.
102 ScrollDelegate* left_right_delegate_;
103 };
104
105 } // namespace athena
106
107 #endif // ATHENA_WM_BEZEL_CONTROLLER_H_
OLDNEW
« no previous file with comments | « athena/athena.gyp ('k') | athena/wm/bezel_controller.cc » ('j') | athena/wm/bezel_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698