| 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 "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" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // Controller for manipulating text selection via touch input. | 35 // Controller for manipulating text selection via touch input. |
| 36 class UI_TOUCH_SELECTION_EXPORT TouchSelectionController | 36 class UI_TOUCH_SELECTION_EXPORT TouchSelectionController |
| 37 : public TouchHandleClient { | 37 : public TouchHandleClient { |
| 38 public: | 38 public: |
| 39 TouchSelectionController(TouchSelectionControllerClient* client, | 39 TouchSelectionController(TouchSelectionControllerClient* client, |
| 40 base::TimeDelta tap_timeout, | 40 base::TimeDelta tap_timeout, |
| 41 float tap_slop, | 41 float tap_slop, |
| 42 bool show_on_tap_for_empty_editable); | 42 bool show_on_tap_for_empty_editable); |
| 43 ~TouchSelectionController() override; | 43 ~TouchSelectionController() override; |
| 44 | 44 |
| 45 // To be called when the selection bounds have changed. | 45 // To be called when the selection bounds info has been updated. |
| 46 // Note that such updates will trigger handle updates only if preceded | 46 // Note that such updates will trigger handle updates only if preceded |
| 47 // by an appropriate call to allow automatic showing. | 47 // by an appropriate call to allow automatic showing. |
| 48 void OnSelectionBoundsChanged(const SelectionBound& start, | 48 // Return value specifies if anything has been updated or not. |
| 49 bool OnSelectionBoundsUpdated(const SelectionBound& start, |
| 49 const SelectionBound& end); | 50 const SelectionBound& end); |
| 50 | 51 |
| 51 // Allows touch-dragging of the handle. | 52 // Allows touch-dragging of the handle. |
| 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(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 75 // To be called when the editability of the focused region changes. | 76 // To be called when the editability of the focused region changes. |
| 76 void OnSelectionEditable(bool editable); | 77 void OnSelectionEditable(bool editable); |
| 77 | 78 |
| 78 // To be called when the contents of the focused region changes. | 79 // To be called when the contents of the focused region changes. |
| 79 void OnSelectionEmpty(bool empty); | 80 void OnSelectionEmpty(bool empty); |
| 80 | 81 |
| 81 // Ticks an active animation, as requested to the client by |SetNeedsAnimate|. | 82 // Ticks an active animation, as requested to the client by |SetNeedsAnimate|. |
| 82 // Returns true if an animation is active and requires further ticking. | 83 // Returns true if an animation is active and requires further ticking. |
| 83 bool Animate(base::TimeTicks animate_time); | 84 bool Animate(base::TimeTicks animate_time); |
| 84 | 85 |
| 86 const SelectionBound& start() const { return start_; } |
| 87 const SelectionBound& end() const { return end_; } |
| 88 |
| 89 bool is_insertion_active() const { return is_insertion_active_; } |
| 90 bool is_selection_active() const { return is_selection_active_; } |
| 91 |
| 85 private: | 92 private: |
| 86 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; | 93 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; |
| 87 | 94 |
| 88 // TouchHandleClient implementation. | 95 // TouchHandleClient implementation. |
| 89 void OnHandleDragBegin(const TouchHandle& handle) override; | 96 void OnHandleDragBegin(const TouchHandle& handle) override; |
| 90 void OnHandleDragUpdate(const TouchHandle& handle, | 97 void OnHandleDragUpdate(const TouchHandle& handle, |
| 91 const gfx::PointF& new_position) override; | 98 const gfx::PointF& new_position) override; |
| 92 void OnHandleDragEnd(const TouchHandle& handle) override; | 99 void OnHandleDragEnd(const TouchHandle& handle) override; |
| 93 void OnHandleTapped(const TouchHandle& handle) override; | 100 void OnHandleTapped(const TouchHandle& handle) override; |
| 94 void SetNeedsAnimate() override; | 101 void SetNeedsAnimate() override; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // Whether a selection handle was dragged during the current 'selection | 158 // Whether a selection handle was dragged during the current 'selection |
| 152 // session' - i.e. since the current selection has been activated. | 159 // session' - i.e. since the current selection has been activated. |
| 153 bool selection_handle_dragged_; | 160 bool selection_handle_dragged_; |
| 154 | 161 |
| 155 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); | 162 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); |
| 156 }; | 163 }; |
| 157 | 164 |
| 158 } // namespace ui | 165 } // namespace ui |
| 159 | 166 |
| 160 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ | 167 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
| OLD | NEW |