| 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/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "ui/base/touch/selection_bound.h" | 10 #include "ui/base/touch/selection_bound.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 public: | 26 public: |
| 27 virtual ~TouchSelectionControllerClient() {} | 27 virtual ~TouchSelectionControllerClient() {} |
| 28 | 28 |
| 29 virtual bool SupportsAnimation() const = 0; | 29 virtual bool SupportsAnimation() const = 0; |
| 30 virtual void SetNeedsAnimate() = 0; | 30 virtual void SetNeedsAnimate() = 0; |
| 31 virtual void MoveCaret(const gfx::PointF& position) = 0; | 31 virtual void MoveCaret(const gfx::PointF& position) = 0; |
| 32 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) = 0; | 32 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) = 0; |
| 33 virtual void SelectBetweenCoordinates(const gfx::PointF& base, | 33 virtual void SelectBetweenCoordinates(const gfx::PointF& base, |
| 34 const gfx::PointF& extent) = 0; | 34 const gfx::PointF& extent) = 0; |
| 35 virtual void OnSelectionEvent(SelectionEventType event) = 0; | 35 virtual void OnSelectionEvent(SelectionEventType event) = 0; |
| 36 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0; | 36 virtual std::unique_ptr<TouchHandleDrawable> CreateDrawable() = 0; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 // Controller for manipulating text selection via touch input. | 39 // Controller for manipulating text selection via touch input. |
| 40 class UI_TOUCH_SELECTION_EXPORT TouchSelectionController | 40 class UI_TOUCH_SELECTION_EXPORT TouchSelectionController |
| 41 : public TouchHandleClient, | 41 : public TouchHandleClient, |
| 42 public LongPressDragSelectorClient { | 42 public LongPressDragSelectorClient { |
| 43 public: | 43 public: |
| 44 enum ActiveStatus { | 44 enum ActiveStatus { |
| 45 INACTIVE, | 45 INACTIVE, |
| 46 INSERTION_ACTIVE, | 46 INSERTION_ACTIVE, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 // TouchHandleClient implementation. | 155 // TouchHandleClient implementation. |
| 156 void OnDragBegin(const TouchSelectionDraggable& draggable, | 156 void OnDragBegin(const TouchSelectionDraggable& draggable, |
| 157 const gfx::PointF& drag_position) override; | 157 const gfx::PointF& drag_position) override; |
| 158 void OnDragUpdate(const TouchSelectionDraggable& draggable, | 158 void OnDragUpdate(const TouchSelectionDraggable& draggable, |
| 159 const gfx::PointF& drag_position) override; | 159 const gfx::PointF& drag_position) override; |
| 160 void OnDragEnd(const TouchSelectionDraggable& draggable) override; | 160 void OnDragEnd(const TouchSelectionDraggable& draggable) override; |
| 161 bool IsWithinTapSlop(const gfx::Vector2dF& delta) const override; | 161 bool IsWithinTapSlop(const gfx::Vector2dF& delta) const override; |
| 162 void OnHandleTapped(const TouchHandle& handle) override; | 162 void OnHandleTapped(const TouchHandle& handle) override; |
| 163 void SetNeedsAnimate() override; | 163 void SetNeedsAnimate() override; |
| 164 scoped_ptr<TouchHandleDrawable> CreateDrawable() override; | 164 std::unique_ptr<TouchHandleDrawable> CreateDrawable() override; |
| 165 base::TimeDelta GetMaxTapDuration() const override; | 165 base::TimeDelta GetMaxTapDuration() const override; |
| 166 bool IsAdaptiveHandleOrientationEnabled() const override; | 166 bool IsAdaptiveHandleOrientationEnabled() const override; |
| 167 | 167 |
| 168 // LongPressDragSelectorClient implementation. | 168 // LongPressDragSelectorClient implementation. |
| 169 void OnLongPressDragActiveStateChanged() override; | 169 void OnLongPressDragActiveStateChanged() override; |
| 170 gfx::PointF GetSelectionStart() const override; | 170 gfx::PointF GetSelectionStart() const override; |
| 171 gfx::PointF GetSelectionEnd() const override; | 171 gfx::PointF GetSelectionEnd() const override; |
| 172 | 172 |
| 173 void ShowInsertionHandleAutomatically(); | 173 void ShowInsertionHandleAutomatically(); |
| 174 void ShowSelectionHandlesAutomatically(); | 174 void ShowSelectionHandlesAutomatically(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 InputEventType response_pending_input_event_; | 208 InputEventType response_pending_input_event_; |
| 209 | 209 |
| 210 SelectionBound start_; | 210 SelectionBound start_; |
| 211 SelectionBound end_; | 211 SelectionBound end_; |
| 212 TouchHandleOrientation start_orientation_; | 212 TouchHandleOrientation start_orientation_; |
| 213 TouchHandleOrientation end_orientation_; | 213 TouchHandleOrientation end_orientation_; |
| 214 | 214 |
| 215 ActiveStatus active_status_; | 215 ActiveStatus active_status_; |
| 216 | 216 |
| 217 scoped_ptr<TouchHandle> insertion_handle_; | 217 std::unique_ptr<TouchHandle> insertion_handle_; |
| 218 bool activate_insertion_automatically_; | 218 bool activate_insertion_automatically_; |
| 219 | 219 |
| 220 scoped_ptr<TouchHandle> start_selection_handle_; | 220 std::unique_ptr<TouchHandle> start_selection_handle_; |
| 221 scoped_ptr<TouchHandle> end_selection_handle_; | 221 std::unique_ptr<TouchHandle> end_selection_handle_; |
| 222 bool activate_selection_automatically_; | 222 bool activate_selection_automatically_; |
| 223 | 223 |
| 224 bool selection_empty_; | 224 bool selection_empty_; |
| 225 bool selection_editable_; | 225 bool selection_editable_; |
| 226 | 226 |
| 227 bool temporarily_hidden_; | 227 bool temporarily_hidden_; |
| 228 | 228 |
| 229 // Whether to use the start bound (if false, the end bound) for computing the | 229 // Whether to use the start bound (if false, the end bound) for computing the |
| 230 // appropriate text line offset when performing a selection drag. This helps | 230 // appropriate text line offset when performing a selection drag. This helps |
| 231 // ensure that the initial selection induced by the drag doesn't "jump" | 231 // ensure that the initial selection induced by the drag doesn't "jump" |
| 232 // between lines. | 232 // between lines. |
| 233 bool anchor_drag_to_selection_start_; | 233 bool anchor_drag_to_selection_start_; |
| 234 | 234 |
| 235 // Longpress drag allows direct manipulation of longpress-initiated selection. | 235 // Longpress drag allows direct manipulation of longpress-initiated selection. |
| 236 LongPressDragSelector longpress_drag_selector_; | 236 LongPressDragSelector longpress_drag_selector_; |
| 237 | 237 |
| 238 gfx::RectF viewport_rect_; | 238 gfx::RectF viewport_rect_; |
| 239 | 239 |
| 240 base::TimeTicks selection_start_time_; | 240 base::TimeTicks selection_start_time_; |
| 241 // Whether a selection handle was dragged during the current 'selection | 241 // Whether a selection handle was dragged during the current 'selection |
| 242 // session' - i.e. since the current selection has been activated. | 242 // session' - i.e. since the current selection has been activated. |
| 243 bool selection_handle_dragged_; | 243 bool selection_handle_dragged_; |
| 244 | 244 |
| 245 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); | 245 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 } // namespace ui | 248 } // namespace ui |
| 249 | 249 |
| 250 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ | 250 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
| OLD | NEW |