OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 UI_TOUCH_SELECTION_LONGPRESS_DRAG_SELECTOR_H_ | |
6 #define UI_TOUCH_SELECTION_LONGPRESS_DRAG_SELECTOR_H_ | |
7 | |
8 #include "base/time/time.h" | |
9 #include "ui/gfx/geometry/point_f.h" | |
10 #include "ui/gfx/geometry/vector2d_f.h" | |
11 #include "ui/touch_selection/touch_selection_draggable.h" | |
12 #include "ui/touch_selection/ui_touch_selection_export.h" | |
13 | |
14 namespace ui { | |
15 | |
16 class MotionEvent; | |
17 | |
18 class UI_TOUCH_SELECTION_EXPORT LongPressDragSelectorClient | |
19 : public TouchSelectionDraggableClient { | |
20 public: | |
21 ~LongPressDragSelectorClient() override {} | |
22 virtual void OnLongPressDragActiveStateChanged() = 0; | |
23 virtual gfx::PointF GetSelectionStart() const = 0; | |
24 virtual gfx::PointF GetSelectionEnd() const = 0; | |
25 }; | |
26 | |
27 // Supports text selection via touch dragging after a longpress-initiated | |
28 // selection. | |
29 class UI_TOUCH_SELECTION_EXPORT LongPressDragSelector | |
30 : public TouchSelectionDraggable { | |
31 public: | |
32 explicit LongPressDragSelector(LongPressDragSelectorClient* client); | |
33 ~LongPressDragSelector() override; | |
34 | |
35 // TouchSelectionDraggable implementation. | |
36 bool WillHandleTouchEvent(const MotionEvent& event) override; | |
37 bool IsActive() const override; | |
38 | |
39 // Called just prior to a longpress event being handled. | |
40 void OnLongPressEvent(base::TimeTicks event_time, | |
41 const gfx::PointF& position); | |
42 | |
43 // Called when the active selection changes. | |
44 void OnSelectionActivated(); | |
45 void OnSelectionDeactivated(); | |
46 | |
47 // Whether drag detection following a longpress-triggered selection is active. | |
48 // This includes both the actual drag motion, and the time when the touch | |
49 // sequence is still active after the longpress triggers a selection. | |
50 bool IsDetectingDrag() const; | |
mfomitchev
2015/04/29 00:34:28
This should be removed
jdduke (slow)
2015/04/29 16:39:15
Done.
| |
51 | |
52 private: | |
53 enum SelectionState { | |
54 INACTIVE, | |
55 LONGPRESS_PENDING, | |
56 SELECTION_PENDING, | |
57 DRAG_PENDING, | |
58 DRAGGING | |
59 }; | |
60 | |
61 void SetState(SelectionState state); | |
62 | |
63 LongPressDragSelectorClient* const client_; | |
64 | |
65 SelectionState state_; | |
66 | |
67 gfx::PointF longpress_drag_start_position_; | |
68 gfx::Vector2dF longpress_drag_selection_offset_; | |
69 | |
70 base::TimeTicks touch_down_time_; | |
71 gfx::PointF touch_down_position_; | |
72 }; | |
73 | |
74 } // namespace ui | |
75 | |
76 #endif // UI_TOUCH_SELECTION_LONGPRESS_DRAG_SELECTOR_H_ | |
OLD | NEW |