| 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 18 matching lines...) Expand all Loading... |
| 29 virtual void SelectBetweenCoordinates(const gfx::PointF& base, | 29 virtual void SelectBetweenCoordinates(const gfx::PointF& base, |
| 30 const gfx::PointF& extent) = 0; | 30 const gfx::PointF& extent) = 0; |
| 31 virtual void OnSelectionEvent(SelectionEventType event) = 0; | 31 virtual void OnSelectionEvent(SelectionEventType event) = 0; |
| 32 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0; | 32 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0; |
| 33 }; | 33 }; |
| 34 | 34 |
| 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 enum ActiveStatus { |
| 40 INACTIVE, |
| 41 INSERTION_ACTIVE, |
| 42 SELECTION_ACTIVE, |
| 43 }; |
| 44 |
| 39 TouchSelectionController(TouchSelectionControllerClient* client, | 45 TouchSelectionController(TouchSelectionControllerClient* client, |
| 40 base::TimeDelta tap_timeout, | 46 base::TimeDelta tap_timeout, |
| 41 float tap_slop, | 47 float tap_slop, |
| 42 bool show_on_tap_for_empty_editable); | 48 bool show_on_tap_for_empty_editable); |
| 43 ~TouchSelectionController() override; | 49 ~TouchSelectionController() override; |
| 44 | 50 |
| 45 // To be called when the selection bounds have changed. | 51 // To be called when the selection bounds have changed. |
| 46 // Note that such updates will trigger handle updates only if preceded | 52 // Note that such updates will trigger handle updates only if preceded |
| 47 // by an appropriate call to allow automatic showing. | 53 // by an appropriate call to allow automatic showing. |
| 48 void OnSelectionBoundsChanged(const SelectionBound& start, | 54 void OnSelectionBoundsChanged(const SelectionBound& start, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // Returns the visible rect of specified touch handle. For an active insertion | 96 // Returns the visible rect of specified touch handle. For an active insertion |
| 91 // these values will be identical. | 97 // these values will be identical. |
| 92 gfx::RectF GetStartHandleRect() const; | 98 gfx::RectF GetStartHandleRect() const; |
| 93 gfx::RectF GetEndHandleRect() const; | 99 gfx::RectF GetEndHandleRect() const; |
| 94 | 100 |
| 95 // Returns the focal point of the start and end bounds, as defined by | 101 // Returns the focal point of the start and end bounds, as defined by |
| 96 // their bottom coordinate. | 102 // their bottom coordinate. |
| 97 const gfx::PointF& GetStartPosition() const; | 103 const gfx::PointF& GetStartPosition() const; |
| 98 const gfx::PointF& GetEndPosition() const; | 104 const gfx::PointF& GetEndPosition() const; |
| 99 | 105 |
| 106 const SelectionBound& start() const { return start_; } |
| 107 const SelectionBound& end() const { return end_; } |
| 108 |
| 109 ActiveStatus active_status() const { return active_status_; } |
| 110 |
| 100 private: | 111 private: |
| 101 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; | 112 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; |
| 102 | 113 |
| 103 // TouchHandleClient implementation. | 114 // TouchHandleClient implementation. |
| 104 void OnHandleDragBegin(const TouchHandle& handle) override; | 115 void OnHandleDragBegin(const TouchHandle& handle) override; |
| 105 void OnHandleDragUpdate(const TouchHandle& handle, | 116 void OnHandleDragUpdate(const TouchHandle& handle, |
| 106 const gfx::PointF& new_position) override; | 117 const gfx::PointF& new_position) override; |
| 107 void OnHandleDragEnd(const TouchHandle& handle) override; | 118 void OnHandleDragEnd(const TouchHandle& handle) override; |
| 108 void OnHandleTapped(const TouchHandle& handle) override; | 119 void OnHandleTapped(const TouchHandle& handle) override; |
| 109 void SetNeedsAnimate() override; | 120 void SetNeedsAnimate() override; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 139 // editable text. | 150 // editable text. |
| 140 bool show_on_tap_for_empty_editable_; | 151 bool show_on_tap_for_empty_editable_; |
| 141 | 152 |
| 142 InputEventType response_pending_input_event_; | 153 InputEventType response_pending_input_event_; |
| 143 | 154 |
| 144 SelectionBound start_; | 155 SelectionBound start_; |
| 145 SelectionBound end_; | 156 SelectionBound end_; |
| 146 TouchHandleOrientation start_orientation_; | 157 TouchHandleOrientation start_orientation_; |
| 147 TouchHandleOrientation end_orientation_; | 158 TouchHandleOrientation end_orientation_; |
| 148 | 159 |
| 160 ActiveStatus active_status_; |
| 161 |
| 149 scoped_ptr<TouchHandle> insertion_handle_; | 162 scoped_ptr<TouchHandle> insertion_handle_; |
| 150 bool is_insertion_active_; | |
| 151 bool activate_insertion_automatically_; | 163 bool activate_insertion_automatically_; |
| 152 | 164 |
| 153 scoped_ptr<TouchHandle> start_selection_handle_; | 165 scoped_ptr<TouchHandle> start_selection_handle_; |
| 154 scoped_ptr<TouchHandle> end_selection_handle_; | 166 scoped_ptr<TouchHandle> end_selection_handle_; |
| 155 bool is_selection_active_; | |
| 156 bool activate_selection_automatically_; | 167 bool activate_selection_automatically_; |
| 157 | 168 |
| 158 bool selection_empty_; | 169 bool selection_empty_; |
| 159 bool selection_editable_; | 170 bool selection_editable_; |
| 160 | 171 |
| 161 bool temporarily_hidden_; | 172 bool temporarily_hidden_; |
| 162 | 173 |
| 163 base::TimeTicks selection_start_time_; | 174 base::TimeTicks selection_start_time_; |
| 164 // Whether a selection handle was dragged during the current 'selection | 175 // Whether a selection handle was dragged during the current 'selection |
| 165 // session' - i.e. since the current selection has been activated. | 176 // session' - i.e. since the current selection has been activated. |
| 166 bool selection_handle_dragged_; | 177 bool selection_handle_dragged_; |
| 167 | 178 |
| 168 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); | 179 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); |
| 169 }; | 180 }; |
| 170 | 181 |
| 171 } // namespace ui | 182 } // namespace ui |
| 172 | 183 |
| 173 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ | 184 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
| OLD | NEW |