Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: ui/touch_selection/touch_selection_controller.h

Issue 698253004: Reland: Implement Aura side of unified touch text selection for contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed overrides in TouchHandleDrawableAura Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 20 matching lines...) Expand all
31 const gfx::PointF& position) = 0; 31 const gfx::PointF& position) = 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 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 ~TouchSelectionController() override; 43 ~TouchSelectionController() override;
43 44
44 // To be called when the selection bounds have changed. 45 // To be called when the selection bounds info has been updated.
45 // Note that such updates will trigger handle updates only if preceded 46 // Note that such updates will trigger handle updates only if preceded
46 // by an appropriate call to allow automatic showing. 47 // by an appropriate call to allow automatic showing.
47 void OnSelectionBoundsChanged(const SelectionBound& start, 48 void OnSelectionBoundsUpdated(const SelectionBound& start,
48 const SelectionBound& end); 49 const SelectionBound& end);
49 50
50 // Allows touch-dragging of the handle. 51 // Allows touch-dragging of the handle.
51 // Returns true iff the event was consumed, in which case the caller should 52 // Returns true iff the event was consumed, in which case the caller should
52 // cease further handling of the event. 53 // cease further handling of the event.
53 bool WillHandleTouchEvent(const MotionEvent& event); 54 bool WillHandleTouchEvent(const MotionEvent& event);
54 55
55 // To be called before forwarding a tap event. This allows automatically 56 // To be called before forwarding a tap event. This allows automatically
56 // showing the insertion handle from subsequent bounds changes. 57 // showing the insertion handle from subsequent bounds changes.
57 void OnTapEvent(); 58 void OnTapEvent();
(...skipping 16 matching lines...) Expand all
74 // To be called when the editability of the focused region changes. 75 // To be called when the editability of the focused region changes.
75 void OnSelectionEditable(bool editable); 76 void OnSelectionEditable(bool editable);
76 77
77 // To be called when the contents of the focused region changes. 78 // To be called when the contents of the focused region changes.
78 void OnSelectionEmpty(bool empty); 79 void OnSelectionEmpty(bool empty);
79 80
80 // Ticks an active animation, as requested to the client by |SetNeedsAnimate|. 81 // Ticks an active animation, as requested to the client by |SetNeedsAnimate|.
81 // Returns true if an animation is active and requires further ticking. 82 // Returns true if an animation is active and requires further ticking.
82 bool Animate(base::TimeTicks animate_time); 83 bool Animate(base::TimeTicks animate_time);
83 84
85 void TryActivateSelection();
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
84 private: 93 private:
94 friend class TouchSelectionControllerAuraTest;
95
85 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; 96 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE };
86 97
87 // TouchHandleClient implementation. 98 // TouchHandleClient implementation.
88 void OnHandleDragBegin(const TouchHandle& handle) override; 99 void OnHandleDragBegin(const TouchHandle& handle) override;
89 void OnHandleDragUpdate(const TouchHandle& handle, 100 void OnHandleDragUpdate(const TouchHandle& handle,
90 const gfx::PointF& new_position) override; 101 const gfx::PointF& new_position) override;
91 void OnHandleDragEnd(const TouchHandle& handle) override; 102 void OnHandleDragEnd(const TouchHandle& handle) override;
92 void OnHandleTapped(const TouchHandle& handle) override; 103 void OnHandleTapped(const TouchHandle& handle) override;
93 void SetNeedsAnimate() override; 104 void SetNeedsAnimate() override;
94 scoped_ptr<TouchHandleDrawable> CreateDrawable() override; 105 scoped_ptr<TouchHandleDrawable> CreateDrawable() override;
(...skipping 13 matching lines...) Expand all
108 void ResetCachedValuesIfInactive(); 119 void ResetCachedValuesIfInactive();
109 120
110 const gfx::PointF& GetStartPosition() const; 121 const gfx::PointF& GetStartPosition() const;
111 const gfx::PointF& GetEndPosition() const; 122 const gfx::PointF& GetEndPosition() const;
112 gfx::Vector2dF GetStartLineOffset() const; 123 gfx::Vector2dF GetStartLineOffset() const;
113 gfx::Vector2dF GetEndLineOffset() const; 124 gfx::Vector2dF GetEndLineOffset() const;
114 bool GetStartVisible() const; 125 bool GetStartVisible() const;
115 bool GetEndVisible() const; 126 bool GetEndVisible() const;
116 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; 127 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const;
117 128
129 TouchHandle* insertion_handle_for_testing() const {
130 return insertion_handle_.get();
131 }
132
118 TouchSelectionControllerClient* const client_; 133 TouchSelectionControllerClient* const client_;
119 const base::TimeDelta tap_timeout_; 134 const base::TimeDelta tap_timeout_;
120 const float tap_slop_; 135 const float tap_slop_;
121 136
137 // Controls whether an insertion handle is shown on a tap for an empty
138 // editable selection.
139 bool show_on_tap_for_empty_editable_;
140
122 InputEventType response_pending_input_event_; 141 InputEventType response_pending_input_event_;
123 142
124 SelectionBound start_; 143 SelectionBound start_;
125 SelectionBound end_; 144 SelectionBound end_;
126 TouchHandleOrientation start_orientation_; 145 TouchHandleOrientation start_orientation_;
127 TouchHandleOrientation end_orientation_; 146 TouchHandleOrientation end_orientation_;
128 147
129 scoped_ptr<TouchHandle> insertion_handle_; 148 scoped_ptr<TouchHandle> insertion_handle_;
130 bool is_insertion_active_; 149 bool is_insertion_active_;
131 bool activate_insertion_automatically_; 150 bool activate_insertion_automatically_;
132 151
133 scoped_ptr<TouchHandle> start_selection_handle_; 152 scoped_ptr<TouchHandle> start_selection_handle_;
134 scoped_ptr<TouchHandle> end_selection_handle_; 153 scoped_ptr<TouchHandle> end_selection_handle_;
135 bool is_selection_active_; 154 bool is_selection_active_;
136 bool activate_selection_automatically_; 155 bool activate_selection_automatically_;
137 156
138 bool selection_empty_; 157 bool selection_empty_;
139 bool selection_editable_; 158 bool selection_editable_;
140 159
141 bool temporarily_hidden_; 160 bool temporarily_hidden_;
142 161
143 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); 162 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController);
144 }; 163 };
145 164
146 } // namespace ui 165 } // namespace ui
147 166
148 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ 167 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698