OLD | NEW |
| (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_HOME_HOME_CARD_GESTURE_MANAGER_H_ | |
6 #define ATHENA_HOME_HOME_CARD_GESTURE_MANAGER_H_ | |
7 | |
8 #include "athena/home/public/home_card.h" | |
9 #include "athena/athena_export.h" | |
10 #include "ui/gfx/geometry/rect.h" | |
11 | |
12 namespace ui { | |
13 class GestureEvent; | |
14 } | |
15 | |
16 namespace athena { | |
17 | |
18 // Handles the touch gestures over the home card. | |
19 class ATHENA_EXPORT HomeCardGestureManager { | |
20 public: | |
21 class Delegate { | |
22 public: | |
23 // Called when the gesture has ended. The state of the home card will | |
24 // end up with |final_state|. |is_fling| is true only when the gesture has | |
25 // ended with a fling action. | |
26 virtual void OnGestureEnded(HomeCard::State final_state, | |
27 bool is_fling) = 0; | |
28 | |
29 // Called when the gesture position is updated so that |delegate| updates | |
30 // the visual. The arguments indicate that the gesture is switching between | |
31 // |from_state| and |to_state|, and that the level of progress is at | |
32 // |progress|, which is in the range (0, 1]. The home card was previously | |
33 // at either |from_state| or |to_state|. In particular, the home card may | |
34 // never have been at |from_state|. |from_state| is never equal to | |
35 // |to_state|. | |
36 virtual void OnGestureProgressed( | |
37 HomeCard::State from_state, | |
38 HomeCard::State to_state, | |
39 float progress) = 0; | |
40 }; | |
41 | |
42 HomeCardGestureManager(Delegate* delegate, | |
43 const gfx::Rect& screen_bounds); | |
44 ~HomeCardGestureManager(); | |
45 | |
46 void ProcessGestureEvent(ui::GestureEvent* event); | |
47 | |
48 private: | |
49 // Get the final state from the last position. | |
50 HomeCard::State GetFinalState() const; | |
51 | |
52 // Update the current position and emits OnGestureProgressed(). | |
53 void UpdateScrollState(const ui::GestureEvent& event); | |
54 | |
55 Delegate* delegate_; // Not owned. | |
56 | |
57 // The state when the gesture starts. | |
58 HomeCard::State original_state_; | |
59 | |
60 // The offset from the top edge of the home card and the initial position of | |
61 // gesture. | |
62 int y_offset_; | |
63 | |
64 // The estimated height of the home card after the last touch event. | |
65 int last_estimated_height_; | |
66 | |
67 // The bounds of the screen to compute the home card bounds. | |
68 gfx::Rect screen_bounds_; | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(HomeCardGestureManager); | |
71 }; | |
72 | |
73 } // namespace athena | |
74 | |
75 #endif // ATHENA_HOME_HOME_CARD_GESTURE_MANAGER_H_ | |
OLD | NEW |