OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ | 5 #ifndef UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
6 #define UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ | 6 #define UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
7 | 7 |
| 8 #include "base/time/time.h" |
8 #include "ui/base/touch/selection_bound.h" | 9 #include "ui/base/touch/selection_bound.h" |
9 #include "ui/gfx/geometry/point_f.h" | 10 #include "ui/gfx/geometry/point_f.h" |
10 #include "ui/gfx/geometry/rect_f.h" | 11 #include "ui/gfx/geometry/rect_f.h" |
| 12 #include "ui/gfx/geometry/vector2d_f.h" |
| 13 #include "ui/touch_selection/longpress_drag_selector.h" |
11 #include "ui/touch_selection/selection_event_type.h" | 14 #include "ui/touch_selection/selection_event_type.h" |
12 #include "ui/touch_selection/touch_handle.h" | 15 #include "ui/touch_selection/touch_handle.h" |
13 #include "ui/touch_selection/touch_handle_orientation.h" | 16 #include "ui/touch_selection/touch_handle_orientation.h" |
14 #include "ui/touch_selection/ui_touch_selection_export.h" | 17 #include "ui/touch_selection/ui_touch_selection_export.h" |
15 | 18 |
16 namespace ui { | 19 namespace ui { |
17 class MotionEvent; | 20 class MotionEvent; |
18 | 21 |
19 // Interface through which |TouchSelectionController| issues selection-related | 22 // Interface through which |TouchSelectionController| issues selection-related |
20 // commands, notifications and requests. | 23 // commands, notifications and requests. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // Returns true iff the event was consumed, in which case the caller should | 55 // Returns true iff the event was consumed, in which case the caller should |
53 // cease further handling of the event. | 56 // cease further handling of the event. |
54 bool WillHandleTouchEvent(const MotionEvent& event); | 57 bool WillHandleTouchEvent(const MotionEvent& event); |
55 | 58 |
56 // To be called before forwarding a tap event. This allows automatically | 59 // To be called before forwarding a tap event. This allows automatically |
57 // showing the insertion handle from subsequent bounds changes. | 60 // showing the insertion handle from subsequent bounds changes. |
58 void OnTapEvent(); | 61 void OnTapEvent(); |
59 | 62 |
60 // To be called before forwarding a longpress event. This allows automatically | 63 // To be called before forwarding a longpress event. This allows automatically |
61 // showing the selection or insertion handles from subsequent bounds changes. | 64 // showing the selection or insertion handles from subsequent bounds changes. |
62 void OnLongPressEvent(); | 65 void OnLongPressEvent(base::TimeTicks event_time, |
| 66 const gfx::PointF& location); |
63 | 67 |
64 // Allow showing the selection handles from the most recent selection bounds | 68 // Allow showing the selection handles from the most recent selection bounds |
65 // update (if valid), or a future valid bounds update. | 69 // update (if valid), or a future valid bounds update. |
66 void AllowShowingFromCurrentSelection(); | 70 void AllowShowingFromCurrentSelection(); |
67 | 71 |
68 // Hide the handles and suppress bounds updates until the next explicit | 72 // Hide the handles and suppress bounds updates until the next explicit |
69 // showing allowance. | 73 // showing allowance. |
70 void HideAndDisallowShowingAutomatically(); | 74 void HideAndDisallowShowingAutomatically(); |
71 | 75 |
72 // Override the handle visibility according to |hidden|. | 76 // Override the handle visibility according to |hidden|. |
(...skipping 21 matching lines...) Expand all Loading... |
94 | 98 |
95 // Returns the focal point of the start and end bounds, as defined by | 99 // Returns the focal point of the start and end bounds, as defined by |
96 // their bottom coordinate. | 100 // their bottom coordinate. |
97 const gfx::PointF& GetStartPosition() const; | 101 const gfx::PointF& GetStartPosition() const; |
98 const gfx::PointF& GetEndPosition() const; | 102 const gfx::PointF& GetEndPosition() const; |
99 | 103 |
100 private: | 104 private: |
101 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; | 105 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; |
102 | 106 |
103 // TouchHandleClient implementation. | 107 // TouchHandleClient implementation. |
104 void OnHandleDragBegin(const TouchHandle& handle) override; | 108 void OnDragBegin(const TouchSelectionDraggable& draggable, |
105 void OnHandleDragUpdate(const TouchHandle& handle, | 109 const gfx::PointF& drag_position) override; |
106 const gfx::PointF& new_position) override; | 110 void OnDragUpdate(const TouchSelectionDraggable& draggable, |
107 void OnHandleDragEnd(const TouchHandle& handle) override; | 111 const gfx::PointF& drag_position) override; |
| 112 void OnDragEnd(const TouchSelectionDraggable& draggable) override; |
108 void OnHandleTapped(const TouchHandle& handle) override; | 113 void OnHandleTapped(const TouchHandle& handle) override; |
109 void SetNeedsAnimate() override; | 114 void SetNeedsAnimate() override; |
110 scoped_ptr<TouchHandleDrawable> CreateDrawable() override; | 115 scoped_ptr<TouchHandleDrawable> CreateDrawable() override; |
111 base::TimeDelta GetTapTimeout() const override; | 116 base::TimeDelta GetTapTimeout() const override; |
112 float GetTapSlop() const override; | 117 float GetTapSlop() const override; |
113 | 118 |
114 void ShowInsertionHandleAutomatically(); | 119 void ShowInsertionHandleAutomatically(); |
115 void ShowSelectionHandlesAutomatically(); | 120 void ShowSelectionHandlesAutomatically(); |
116 | 121 |
117 void OnInsertionChanged(); | 122 void OnInsertionChanged(); |
118 void OnSelectionChanged(); | 123 void OnSelectionChanged(); |
119 | 124 |
120 void ActivateInsertion(); | 125 void ActivateInsertion(); |
121 void DeactivateInsertion(); | 126 void DeactivateInsertion(); |
122 void ActivateSelection(); | 127 void ActivateSelection(); |
123 void DeactivateSelection(); | 128 void DeactivateSelection(); |
124 void ResetCachedValuesIfInactive(); | 129 void ResetCachedValuesIfInactive(); |
125 | 130 |
| 131 bool WillHandleTouchEventForLongPressDrag(const MotionEvent& event); |
| 132 void SetTemporarilyHiddenForLongPressDrag(bool hidden); |
| 133 void OnHandleVisibilityOverrideMaybeChanged(); |
| 134 |
126 gfx::Vector2dF GetStartLineOffset() const; | 135 gfx::Vector2dF GetStartLineOffset() const; |
127 gfx::Vector2dF GetEndLineOffset() const; | 136 gfx::Vector2dF GetEndLineOffset() const; |
128 bool GetStartVisible() const; | 137 bool GetStartVisible() const; |
129 bool GetEndVisible() const; | 138 bool GetEndVisible() const; |
130 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; | 139 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; |
131 | 140 |
132 void LogSelectionEnd(); | 141 void LogSelectionEnd(); |
133 | 142 |
134 TouchSelectionControllerClient* const client_; | 143 TouchSelectionControllerClient* const client_; |
135 const base::TimeDelta tap_timeout_; | 144 const base::TimeDelta tap_timeout_; |
(...skipping 17 matching lines...) Expand all Loading... |
153 scoped_ptr<TouchHandle> start_selection_handle_; | 162 scoped_ptr<TouchHandle> start_selection_handle_; |
154 scoped_ptr<TouchHandle> end_selection_handle_; | 163 scoped_ptr<TouchHandle> end_selection_handle_; |
155 bool is_selection_active_; | 164 bool is_selection_active_; |
156 bool activate_selection_automatically_; | 165 bool activate_selection_automatically_; |
157 | 166 |
158 bool selection_empty_; | 167 bool selection_empty_; |
159 bool selection_editable_; | 168 bool selection_editable_; |
160 | 169 |
161 bool temporarily_hidden_; | 170 bool temporarily_hidden_; |
162 | 171 |
| 172 // Offset from the start of a drag sequence to a reasonable position on the |
| 173 // corresponding line of text. This helps ensure that the initial selection |
| 174 // induced by the drag doesn't "jump" between lines. |
| 175 gfx::Vector2dF drag_line_offset_; |
| 176 |
| 177 // Longpress drag allows direct manipulation of longpress-initiated selection. |
| 178 LongPressDragSelector longpress_drag_selector_; |
| 179 |
163 base::TimeTicks selection_start_time_; | 180 base::TimeTicks selection_start_time_; |
164 // Whether a selection handle was dragged during the current 'selection | 181 // Whether a selection handle was dragged during the current 'selection |
165 // session' - i.e. since the current selection has been activated. | 182 // session' - i.e. since the current selection has been activated. |
166 bool selection_handle_dragged_; | 183 bool selection_handle_dragged_; |
167 | 184 |
168 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); | 185 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); |
169 }; | 186 }; |
170 | 187 |
171 } // namespace ui | 188 } // namespace ui |
172 | 189 |
173 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ | 190 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
OLD | NEW |