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 { | |
jdduke (slow)
2015/05/07 20:38:15
Do we need to expose this publicly?
mohsen
2015/05/07 21:21:55
In a few places for Aura implementation, we'll nee
| |
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 22 matching lines...) Expand all Loading... | |
71 | 77 |
72 // Override the handle visibility according to |hidden|. | 78 // Override the handle visibility according to |hidden|. |
73 void SetTemporarilyHidden(bool hidden); | 79 void SetTemporarilyHidden(bool hidden); |
74 | 80 |
75 // To be called when the editability of the focused region changes. | 81 // To be called when the editability of the focused region changes. |
76 void OnSelectionEditable(bool editable); | 82 void OnSelectionEditable(bool editable); |
77 | 83 |
78 // To be called when the contents of the focused region changes. | 84 // To be called when the contents of the focused region changes. |
79 void OnSelectionEmpty(bool empty); | 85 void OnSelectionEmpty(bool empty); |
80 | 86 |
87 // To be called when native view moves around. | |
88 void OnNativeViewMoved(); | |
89 | |
81 // Ticks an active animation, as requested to the client by |SetNeedsAnimate|. | 90 // Ticks an active animation, as requested to the client by |SetNeedsAnimate|. |
82 // Returns true if an animation is active and requires further ticking. | 91 // Returns true if an animation is active and requires further ticking. |
83 bool Animate(base::TimeTicks animate_time); | 92 bool Animate(base::TimeTicks animate_time); |
84 | 93 |
85 // Returns the rect between the two active selection bounds. If just one of | 94 // Returns the rect between the two active selection bounds. If just one of |
86 // the bounds is visible, the rect is simply the (one-dimensional) rect of | 95 // the bounds is visible, the rect is simply the (one-dimensional) rect of |
87 // that bound. If no selection is active, an empty rect will be returned. | 96 // that bound. If no selection is active, an empty rect will be returned. |
88 gfx::RectF GetRectBetweenBounds() const; | 97 gfx::RectF GetRectBetweenBounds() const; |
89 | 98 |
90 // Returns the visible rect of specified touch handle. For an active insertion | 99 // Returns the visible rect of specified touch handle. For an active insertion |
91 // these values will be identical. | 100 // these values will be identical. |
92 gfx::RectF GetStartHandleRect() const; | 101 gfx::RectF GetStartHandleRect() const; |
93 gfx::RectF GetEndHandleRect() const; | 102 gfx::RectF GetEndHandleRect() const; |
94 | 103 |
95 // Returns the focal point of the start and end bounds, as defined by | 104 // Returns the focal point of the start and end bounds, as defined by |
96 // their bottom coordinate. | 105 // their bottom coordinate. |
97 const gfx::PointF& GetStartPosition() const; | 106 const gfx::PointF& GetStartPosition() const; |
98 const gfx::PointF& GetEndPosition() const; | 107 const gfx::PointF& GetEndPosition() const; |
99 | 108 |
109 const SelectionBound& start() const { return start_; } | |
110 const SelectionBound& end() const { return end_; } | |
111 | |
112 ActiveStatus active_status() const { return active_status_; } | |
113 | |
100 private: | 114 private: |
101 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; | 115 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; |
102 | 116 |
103 // TouchHandleClient implementation. | 117 // TouchHandleClient implementation. |
104 void OnHandleDragBegin(const TouchHandle& handle) override; | 118 void OnHandleDragBegin(const TouchHandle& handle) override; |
105 void OnHandleDragUpdate(const TouchHandle& handle, | 119 void OnHandleDragUpdate(const TouchHandle& handle, |
106 const gfx::PointF& new_position) override; | 120 const gfx::PointF& new_position) override; |
107 void OnHandleDragEnd(const TouchHandle& handle) override; | 121 void OnHandleDragEnd(const TouchHandle& handle) override; |
108 void OnHandleTapped(const TouchHandle& handle) override; | 122 void OnHandleTapped(const TouchHandle& handle) override; |
109 void SetNeedsAnimate() override; | 123 void SetNeedsAnimate() override; |
(...skipping 29 matching lines...) Expand all Loading... | |
139 // editable text. | 153 // editable text. |
140 bool show_on_tap_for_empty_editable_; | 154 bool show_on_tap_for_empty_editable_; |
141 | 155 |
142 InputEventType response_pending_input_event_; | 156 InputEventType response_pending_input_event_; |
143 | 157 |
144 SelectionBound start_; | 158 SelectionBound start_; |
145 SelectionBound end_; | 159 SelectionBound end_; |
146 TouchHandleOrientation start_orientation_; | 160 TouchHandleOrientation start_orientation_; |
147 TouchHandleOrientation end_orientation_; | 161 TouchHandleOrientation end_orientation_; |
148 | 162 |
163 ActiveStatus active_status_; | |
164 | |
149 scoped_ptr<TouchHandle> insertion_handle_; | 165 scoped_ptr<TouchHandle> insertion_handle_; |
150 bool is_insertion_active_; | |
151 bool activate_insertion_automatically_; | 166 bool activate_insertion_automatically_; |
152 | 167 |
153 scoped_ptr<TouchHandle> start_selection_handle_; | 168 scoped_ptr<TouchHandle> start_selection_handle_; |
154 scoped_ptr<TouchHandle> end_selection_handle_; | 169 scoped_ptr<TouchHandle> end_selection_handle_; |
155 bool is_selection_active_; | |
156 bool activate_selection_automatically_; | 170 bool activate_selection_automatically_; |
157 | 171 |
158 bool selection_empty_; | 172 bool selection_empty_; |
159 bool selection_editable_; | 173 bool selection_editable_; |
160 | 174 |
161 bool temporarily_hidden_; | 175 bool temporarily_hidden_; |
162 | 176 |
163 base::TimeTicks selection_start_time_; | 177 base::TimeTicks selection_start_time_; |
164 // Whether a selection handle was dragged during the current 'selection | 178 // Whether a selection handle was dragged during the current 'selection |
165 // session' - i.e. since the current selection has been activated. | 179 // session' - i.e. since the current selection has been activated. |
166 bool selection_handle_dragged_; | 180 bool selection_handle_dragged_; |
167 | 181 |
168 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); | 182 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); |
169 }; | 183 }; |
170 | 184 |
171 } // namespace ui | 185 } // namespace ui |
172 | 186 |
173 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ | 187 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
OLD | NEW |