Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / athena / home / home_card_gesture_manager.h
blob8749b91d8cb426be204f5b5822c9e46283603e47
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.
5 #ifndef ATHENA_HOME_HOME_CARD_GESTURE_MANAGER_H_
6 #define ATHENA_HOME_HOME_CARD_GESTURE_MANAGER_H_
8 #include "athena/home/public/home_card.h"
9 #include "athena/athena_export.h"
10 #include "ui/gfx/geometry/rect.h"
12 namespace ui {
13 class GestureEvent;
16 namespace athena {
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|.
25 virtual void OnGestureEnded(HomeCard::State final_state) = 0;
27 // Called when the gesture position is updated so that |delegate| should
28 // update the visual. The arguments represent the state of the current
29 // gesture position is switching from |from_state| to |to_state|, and
30 // the level of the progress is at |progress|, which is 0 to 1.
31 // |from_state| and |to_state| could be same. For example, if the user moves
32 // the finger down to the bottom of the screen, both states are MINIMIZED.
33 // In that case |progress| is 0.
34 virtual void OnGestureProgressed(
35 HomeCard::State from_state,
36 HomeCard::State to_state,
37 float progress) = 0;
40 HomeCardGestureManager(Delegate* delegate,
41 const gfx::Rect& screen_bounds);
42 ~HomeCardGestureManager();
44 void ProcessGestureEvent(ui::GestureEvent* event);
46 private:
47 // Get the closest state from the last position.
48 HomeCard::State GetClosestState() const;
50 // Update the current position and emits OnGestureProgressed().
51 void UpdateScrollState(const ui::GestureEvent& event);
53 Delegate* delegate_; // Not owned.
54 HomeCard::State last_state_;
56 // The offset from the top edge of the home card and the initial position of
57 // gesture.
58 int y_offset_;
60 // The estimated height of the home card after the last touch event.
61 int last_estimated_height_;
63 // The bounds of the screen to compute the home card bounds.
64 gfx::Rect screen_bounds_;
66 DISALLOW_COPY_AND_ASSIGN(HomeCardGestureManager);
69 } // namespace athena
71 #endif // ATHENA_HOME_HOME_CARD_GESTURE_MANAGER_H_