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