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

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

Issue 481683003: Support for Adaptive Handle Orientation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 5 years, 2 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 "base/time/time.h" 8 #include "base/time/time.h"
9 #include "ui/base/touch/selection_bound.h" 9 #include "ui/base/touch/selection_bound.h"
10 #include "ui/gfx/geometry/point_f.h" 10 #include "ui/gfx/geometry/point_f.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 struct UI_TOUCH_SELECTION_EXPORT Config { 49 struct UI_TOUCH_SELECTION_EXPORT Config {
50 Config(); 50 Config();
51 ~Config(); 51 ~Config();
52 52
53 // Maximum allowed time for handle tap detection. Defaults to 300 ms. 53 // Maximum allowed time for handle tap detection. Defaults to 300 ms.
54 base::TimeDelta max_tap_duration; 54 base::TimeDelta max_tap_duration;
55 55
56 // Defaults to 8 DIPs. 56 // Defaults to 8 DIPs.
57 float tap_slop; 57 float tap_slop;
58 58
59 // Controls whether adaptive orientation for selection handles is enabled.
60 // Defaults to false.
61 bool enable_adaptive_handle_orientation;
62
59 // Controls whether drag selection after a longpress is enabled. 63 // Controls whether drag selection after a longpress is enabled.
60 // Defaults to false. 64 // Defaults to false.
61 bool enable_longpress_drag_selection; 65 bool enable_longpress_drag_selection;
62 66
63 // Controls whether an insertion handle is shown on a tap for an empty 67 // Controls whether an insertion handle is shown on a tap for an empty
64 // editable text. Defauls to false. 68 // editable text. Defauls to false.
65 bool show_on_tap_for_empty_editable; 69 bool show_on_tap_for_empty_editable;
66 }; 70 };
67 71
68 TouchSelectionController(TouchSelectionControllerClient* client, 72 TouchSelectionController(TouchSelectionControllerClient* client,
69 const Config& config); 73 const Config& config);
70 ~TouchSelectionController() override; 74 ~TouchSelectionController() override;
71 75
72 // To be called when the selection bounds have changed. 76 // To be called when the selection bounds have changed.
73 // Note that such updates will trigger handle updates only if preceded 77 // Note that such updates will trigger handle updates only if preceded
74 // by an appropriate call to allow automatic showing. 78 // by an appropriate call to allow automatic showing.
75 void OnSelectionBoundsChanged(const SelectionBound& start, 79 void OnSelectionBoundsChanged(const SelectionBound& start,
76 const SelectionBound& end); 80 const SelectionBound& end);
77 81
82 // To be called when the viewport rect has been changed. This is used for
83 // setting the state of the handles.
84 void OnViewportChanged(const gfx::RectF viewport_rect);
85
78 // Allows touch-dragging of the handle. 86 // Allows touch-dragging of the handle.
79 // Returns true iff the event was consumed, in which case the caller should 87 // Returns true iff the event was consumed, in which case the caller should
80 // cease further handling of the event. 88 // cease further handling of the event.
81 bool WillHandleTouchEvent(const MotionEvent& event); 89 bool WillHandleTouchEvent(const MotionEvent& event);
82 90
83 // To be called before forwarding a tap event. This allows automatically 91 // To be called before forwarding a tap event. This allows automatically
84 // showing the insertion handle from subsequent bounds changes. 92 // showing the insertion handle from subsequent bounds changes.
85 // |tap_count| is tap index in a repeated sequence, i.e., 1 for the first 93 // |tap_count| is tap index in a repeated sequence, i.e., 1 for the first
86 // tap, 2 for the second tap, etc... 94 // tap, 2 for the second tap, etc...
87 bool WillHandleTapEvent(const gfx::PointF& location, int tap_count); 95 bool WillHandleTapEvent(const gfx::PointF& location, int tap_count);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 void OnDragBegin(const TouchSelectionDraggable& draggable, 149 void OnDragBegin(const TouchSelectionDraggable& draggable,
142 const gfx::PointF& drag_position) override; 150 const gfx::PointF& drag_position) override;
143 void OnDragUpdate(const TouchSelectionDraggable& draggable, 151 void OnDragUpdate(const TouchSelectionDraggable& draggable,
144 const gfx::PointF& drag_position) override; 152 const gfx::PointF& drag_position) override;
145 void OnDragEnd(const TouchSelectionDraggable& draggable) override; 153 void OnDragEnd(const TouchSelectionDraggable& draggable) override;
146 bool IsWithinTapSlop(const gfx::Vector2dF& delta) const override; 154 bool IsWithinTapSlop(const gfx::Vector2dF& delta) const override;
147 void OnHandleTapped(const TouchHandle& handle) override; 155 void OnHandleTapped(const TouchHandle& handle) override;
148 void SetNeedsAnimate() override; 156 void SetNeedsAnimate() override;
149 scoped_ptr<TouchHandleDrawable> CreateDrawable() override; 157 scoped_ptr<TouchHandleDrawable> CreateDrawable() override;
150 base::TimeDelta GetMaxTapDuration() const override; 158 base::TimeDelta GetMaxTapDuration() const override;
159 bool IsAdaptiveHandleOrientationEnabled() const override;
151 160
152 // LongPressDragSelectorClient implementation. 161 // LongPressDragSelectorClient implementation.
153 void OnLongPressDragActiveStateChanged() override; 162 void OnLongPressDragActiveStateChanged() override;
154 gfx::PointF GetSelectionStart() const override; 163 gfx::PointF GetSelectionStart() const override;
155 gfx::PointF GetSelectionEnd() const override; 164 gfx::PointF GetSelectionEnd() const override;
156 165
157 void ShowInsertionHandleAutomatically(); 166 void ShowInsertionHandleAutomatically();
158 void ShowSelectionHandlesAutomatically(); 167 void ShowSelectionHandlesAutomatically();
159 bool WillHandleTapOrLongPress(const gfx::PointF& location); 168 bool WillHandleTapOrLongPress(const gfx::PointF& location);
160 169
161 void OnInsertionChanged(); 170 void OnInsertionChanged();
162 void OnSelectionChanged(); 171 void OnSelectionChanged();
163 172
164 // Returns true if insertion mode was newly (re)activated. 173 // Returns true if insertion mode was newly (re)activated.
165 bool ActivateInsertionIfNecessary(); 174 bool ActivateInsertionIfNecessary();
166 void DeactivateInsertion(); 175 void DeactivateInsertion();
167 // Returns true if selection mode was newly (re)activated. 176 // Returns true if selection mode was newly (re)activated.
168 bool ActivateSelectionIfNecessary(); 177 bool ActivateSelectionIfNecessary();
169 void DeactivateSelection(); 178 void DeactivateSelection();
170 void ForceNextUpdateIfInactive(); 179 void ForceNextUpdateIfInactive();
180 void UpdateHandleLayoutIfNecessary();
171 181
172 bool WillHandleTouchEventForLongPressDrag(const MotionEvent& event); 182 bool WillHandleTouchEventForLongPressDrag(const MotionEvent& event);
173 void SetTemporarilyHiddenForLongPressDrag(bool hidden); 183 void SetTemporarilyHiddenForLongPressDrag(bool hidden);
174 void RefreshHandleVisibility(); 184 void RefreshHandleVisibility();
175 185
176 gfx::Vector2dF GetStartLineOffset() const; 186 gfx::Vector2dF GetStartLineOffset() const;
177 gfx::Vector2dF GetEndLineOffset() const; 187 gfx::Vector2dF GetEndLineOffset() const;
178 bool GetStartVisible() const; 188 bool GetStartVisible() const;
179 bool GetEndVisible() const; 189 bool GetEndVisible() const;
180 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; 190 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const;
(...skipping 30 matching lines...) Expand all
211 221
212 // Whether to use the start bound (if false, the end bound) for computing the 222 // Whether to use the start bound (if false, the end bound) for computing the
213 // appropriate text line offset when performing a selection drag. This helps 223 // appropriate text line offset when performing a selection drag. This helps
214 // ensure that the initial selection induced by the drag doesn't "jump" 224 // ensure that the initial selection induced by the drag doesn't "jump"
215 // between lines. 225 // between lines.
216 bool anchor_drag_to_selection_start_; 226 bool anchor_drag_to_selection_start_;
217 227
218 // Longpress drag allows direct manipulation of longpress-initiated selection. 228 // Longpress drag allows direct manipulation of longpress-initiated selection.
219 LongPressDragSelector longpress_drag_selector_; 229 LongPressDragSelector longpress_drag_selector_;
220 230
231 gfx::RectF viewport_rect_;
232
221 base::TimeTicks selection_start_time_; 233 base::TimeTicks selection_start_time_;
222 // Whether a selection handle was dragged during the current 'selection 234 // Whether a selection handle was dragged during the current 'selection
223 // session' - i.e. since the current selection has been activated. 235 // session' - i.e. since the current selection has been activated.
224 bool selection_handle_dragged_; 236 bool selection_handle_dragged_;
225 237
226 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); 238 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController);
227 }; 239 };
228 240
229 } // namespace ui 241 } // namespace ui
230 242
231 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ 243 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ui/touch_selection/touch_handle_unittest.cc ('k') | ui/touch_selection/touch_selection_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698