Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: ui/touch_selection/touch_selection_controller.h

Issue 1087893003: Support longpress drag selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ui/base/touch/selection_bound.h" 8 #include "ui/base/touch/selection_bound.h"
9 #include "ui/gfx/geometry/point_f.h" 9 #include "ui/gfx/geometry/point_f.h"
10 #include "ui/gfx/geometry/rect_f.h" 10 #include "ui/gfx/geometry/rect_f.h"
11 #include "ui/gfx/geometry/vector2d_f.h"
11 #include "ui/touch_selection/selection_event_type.h" 12 #include "ui/touch_selection/selection_event_type.h"
12 #include "ui/touch_selection/touch_handle.h" 13 #include "ui/touch_selection/touch_handle.h"
13 #include "ui/touch_selection/touch_handle_orientation.h" 14 #include "ui/touch_selection/touch_handle_orientation.h"
14 #include "ui/touch_selection/ui_touch_selection_export.h" 15 #include "ui/touch_selection/ui_touch_selection_export.h"
15 16
16 namespace ui { 17 namespace ui {
17 class MotionEvent; 18 class MotionEvent;
18 19
19 // Interface through which |TouchSelectionController| issues selection-related 20 // Interface through which |TouchSelectionController| issues selection-related
20 // commands, notifications and requests. 21 // commands, notifications and requests.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // Returns true iff the event was consumed, in which case the caller should 53 // Returns true iff the event was consumed, in which case the caller should
53 // cease further handling of the event. 54 // cease further handling of the event.
54 bool WillHandleTouchEvent(const MotionEvent& event); 55 bool WillHandleTouchEvent(const MotionEvent& event);
55 56
56 // To be called before forwarding a tap event. This allows automatically 57 // To be called before forwarding a tap event. This allows automatically
57 // showing the insertion handle from subsequent bounds changes. 58 // showing the insertion handle from subsequent bounds changes.
58 void OnTapEvent(); 59 void OnTapEvent();
59 60
60 // To be called before forwarding a longpress event. This allows automatically 61 // To be called before forwarding a longpress event. This allows automatically
61 // showing the selection or insertion handles from subsequent bounds changes. 62 // showing the selection or insertion handles from subsequent bounds changes.
62 void OnLongPressEvent(); 63 void OnLongPressEvent(const gfx::PointF& location);
63 64
64 // Allow showing the selection handles from the most recent selection bounds 65 // Allow showing the selection handles from the most recent selection bounds
65 // update (if valid), or a future valid bounds update. 66 // update (if valid), or a future valid bounds update.
66 void AllowShowingFromCurrentSelection(); 67 void AllowShowingFromCurrentSelection();
67 68
68 // Hide the handles and suppress bounds updates until the next explicit 69 // Hide the handles and suppress bounds updates until the next explicit
69 // showing allowance. 70 // showing allowance.
70 void HideAndDisallowShowingAutomatically(); 71 void HideAndDisallowShowingAutomatically();
71 72
72 // Override the handle visibility according to |hidden|. 73 // Override the handle visibility according to |hidden|.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 117
117 void OnInsertionChanged(); 118 void OnInsertionChanged();
118 void OnSelectionChanged(); 119 void OnSelectionChanged();
119 120
120 void ActivateInsertion(); 121 void ActivateInsertion();
121 void DeactivateInsertion(); 122 void DeactivateInsertion();
122 void ActivateSelection(); 123 void ActivateSelection();
123 void DeactivateSelection(); 124 void DeactivateSelection();
124 void ResetCachedValuesIfInactive(); 125 void ResetCachedValuesIfInactive();
125 126
127 bool WillHandleTouchEventForLongPressDrag(const MotionEvent& event);
128 void SetTemporarilyHiddenForLongPressDrag(bool hidden);
129 void OnHandleVisibilityOverrideChanged();
130
126 gfx::Vector2dF GetStartLineOffset() const; 131 gfx::Vector2dF GetStartLineOffset() const;
127 gfx::Vector2dF GetEndLineOffset() const; 132 gfx::Vector2dF GetEndLineOffset() const;
128 bool GetStartVisible() const; 133 bool GetStartVisible() const;
129 bool GetEndVisible() const; 134 bool GetEndVisible() const;
130 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; 135 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const;
131 136
132 void LogSelectionEnd(); 137 void LogSelectionEnd();
133 138
134 TouchSelectionControllerClient* const client_; 139 TouchSelectionControllerClient* const client_;
135 const base::TimeDelta tap_timeout_; 140 const base::TimeDelta tap_timeout_;
(...skipping 17 matching lines...) Expand all
153 scoped_ptr<TouchHandle> start_selection_handle_; 158 scoped_ptr<TouchHandle> start_selection_handle_;
154 scoped_ptr<TouchHandle> end_selection_handle_; 159 scoped_ptr<TouchHandle> end_selection_handle_;
155 bool is_selection_active_; 160 bool is_selection_active_;
156 bool activate_selection_automatically_; 161 bool activate_selection_automatically_;
157 162
158 bool selection_empty_; 163 bool selection_empty_;
159 bool selection_editable_; 164 bool selection_editable_;
160 165
161 bool temporarily_hidden_; 166 bool temporarily_hidden_;
162 167
168 // Longpress drag allows direct manipulation of longpress-initiated selection.
169 // TODO(jdduke): Factor out longpress drag-specific logic into a more isolated
mfomitchev 2015/04/18 16:09:08 I wonder if we can reuse some of the TouchHandle c
jdduke (slow) 2015/04/21 19:25:57 I think this is very reasonable. I'd been planning
mfomitchev 2015/04/21 21:08:57 Do you mean StylusTextSelector?
170 // logic unit.
171 bool temporarily_hidden_for_longpress_drag_;
mfomitchev 2015/04/18 16:09:08 handles_hidden_for_longpress_drag_? Otherwise it's
jdduke (slow) 2015/04/21 19:25:57 Hmm, well this is a parallel of the existing |temp
172 bool consume_remaining_motion_for_longpress_drag_;
173 bool has_begun_longpress_drag_;
174 gfx::PointF longpress_drag_initial_position_;
175 gfx::Vector2dF longpress_drag_selection_offset_;
176
177 bool has_active_touch_sequence_;
178 gfx::PointF touch_sequence_start_position_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698