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