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

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

Issue 903143003: wip: Touch Text Selection Prototypes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@selection_granularity_on_unified
Patch Set: Created 5 years, 10 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
« no previous file with comments | « ui/touch_selection/touch_handle.cc ('k') | ui/touch_selection/touch_selection_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "ui/touch_selection/selection_event_type.h" 11 #include "ui/touch_selection/selection_event_type.h"
12 #include "ui/touch_selection/selection_granularity.h" 12 #include "ui/touch_selection/selection_granularity.h"
13 #include "ui/touch_selection/touch_handle.h" 13 #include "ui/touch_selection/touch_handle.h"
14 #include "ui/touch_selection/ui_touch_selection_export.h" 14 #include "ui/touch_selection/ui_touch_selection_export.h"
15 15
16 namespace ui { 16 namespace ui {
17 class MotionEvent; 17 class MotionEvent;
18 class GranularityStrategy;
18 19
19 // Interface through which |TouchSelectionController| issues selection-related 20 // Interface through which |TouchSelectionController| issues selection-related
20 // commands, notifications and requests. 21 // commands, notifications and requests.
21 class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerClient { 22 class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerClient {
22 public: 23 public:
23 virtual ~TouchSelectionControllerClient() {} 24 virtual ~TouchSelectionControllerClient() {}
24 25
25 virtual bool SupportsAnimation() const = 0; 26 virtual bool SupportsAnimation() const = 0;
26 virtual void SetNeedsAnimate() = 0; 27 virtual void SetNeedsAnimate() = 0;
27 virtual void MoveCaret(const gfx::PointF& position) = 0; 28 virtual void MoveCaret(const gfx::PointF& position) = 0;
28 virtual void MoveRangeSelectionExtent( 29 virtual void MoveRangeSelectionExtent(
29 const gfx::PointF& extent, 30 const gfx::PointF& extent,
30 ui::TextSelectionGranularity granularity) = 0; 31 ui::TextSelectionGranularity granularity) = 0;
31 virtual void SelectBetweenCoordinates(const gfx::PointF& base, 32 virtual void SelectBetweenCoordinates(const gfx::PointF& base,
32 const gfx::PointF& extent) = 0; 33 const gfx::PointF& extent) = 0;
33 virtual void OnSelectionEvent(SelectionEventType event, 34 virtual void OnSelectionEvent(SelectionEventType event,
34 const gfx::PointF& position) = 0; 35 const gfx::PointF& position) = 0;
35 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0; 36 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0;
36 }; 37 };
37 38
38 // Controller for manipulating text selection via touch input. 39 // Controller for manipulating text selection via touch input.
39 class UI_TOUCH_SELECTION_EXPORT TouchSelectionController 40 class UI_TOUCH_SELECTION_EXPORT TouchSelectionController
40 : public TouchHandleClient { 41 : public TouchHandleClient {
41 public: 42 public:
42 TouchSelectionController(TouchSelectionControllerClient* client, 43 TouchSelectionController(
43 base::TimeDelta tap_timeout, 44 TouchSelectionControllerClient* client,
44 float tap_slop, 45 base::TimeDelta tap_timeout,
45 bool show_on_tap_for_empty_editable); 46 float tap_slop,
47 bool show_on_tap_for_empty_editable,
48 TextSelectionGranularityStrategy selection_granularity_strategy);
46 ~TouchSelectionController() override; 49 ~TouchSelectionController() override;
47 50
51 void SetVelocityStrategyParameters(int halfDecayMs, int threshold);
52
48 // To be called when the selection bounds info has been updated. 53 // To be called when the selection bounds info has been updated.
49 // Note that such updates will trigger handle updates only if preceded 54 // Note that such updates will trigger handle updates only if preceded
50 // by an appropriate call to allow automatic showing. 55 // by an appropriate call to allow automatic showing.
51 void OnSelectionBoundsUpdated(const SelectionBound& start, 56 void OnSelectionBoundsUpdated(const SelectionBound& start,
52 const SelectionBound& end); 57 const SelectionBound& end);
53 58
54 // Allows touch-dragging of the handle. 59 // Allows touch-dragging of the handle.
55 // Returns true iff the event was consumed, in which case the caller should 60 // Returns true iff the event was consumed, in which case the caller should
56 // cease further handling of the event. 61 // cease further handling of the event.
57 bool WillHandleTouchEvent(const MotionEvent& event); 62 bool WillHandleTouchEvent(const MotionEvent& event);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 97
93 bool is_insertion_active() const { return is_insertion_active_; } 98 bool is_insertion_active() const { return is_insertion_active_; }
94 bool is_selection_active() const { return is_selection_active_; } 99 bool is_selection_active() const { return is_selection_active_; }
95 100
96 private: 101 private:
97 friend class TouchSelectionControllerAuraTest; 102 friend class TouchSelectionControllerAuraTest;
98 103
99 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; 104 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE };
100 105
101 // TouchHandleClient implementation. 106 // TouchHandleClient implementation.
102 void OnHandleDragBegin(const TouchHandle& handle) override; 107 void OnHandleDragBegin(const TouchHandle& handle,
108 base::TimeTicks event_time) override;
103 void OnHandleDragUpdate(const TouchHandle& handle, 109 void OnHandleDragUpdate(const TouchHandle& handle,
104 const gfx::PointF& new_position) override; 110 const gfx::PointF& new_position,
111 base::TimeTicks event_time) override;
105 void OnHandleDragEnd(const TouchHandle& handle) override; 112 void OnHandleDragEnd(const TouchHandle& handle) override;
106 void OnHandleTapped(const TouchHandle& handle) override; 113 void OnHandleTapped(const TouchHandle& handle) override;
107 void SetNeedsAnimate() override; 114 void SetNeedsAnimate() override;
108 scoped_ptr<TouchHandleDrawable> CreateDrawable() override; 115 scoped_ptr<TouchHandleDrawable> CreateDrawable() override;
109 base::TimeDelta GetTapTimeout() const override; 116 base::TimeDelta GetTapTimeout() const override;
110 float GetTapSlop() const override; 117 float GetTapSlop() const override;
111 118
112 void ShowInsertionHandleAutomatically(); 119 void ShowInsertionHandleAutomatically();
113 void ShowSelectionHandlesAutomatically(); 120 void ShowSelectionHandlesAutomatically();
114 121
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 SelectionBound end_; 154 SelectionBound end_;
148 TouchHandleOrientation start_orientation_; 155 TouchHandleOrientation start_orientation_;
149 TouchHandleOrientation end_orientation_; 156 TouchHandleOrientation end_orientation_;
150 157
151 scoped_ptr<TouchHandle> insertion_handle_; 158 scoped_ptr<TouchHandle> insertion_handle_;
152 bool is_insertion_active_; 159 bool is_insertion_active_;
153 bool activate_insertion_automatically_; 160 bool activate_insertion_automatically_;
154 161
155 scoped_ptr<TouchHandle> start_selection_handle_; 162 scoped_ptr<TouchHandle> start_selection_handle_;
156 scoped_ptr<TouchHandle> end_selection_handle_; 163 scoped_ptr<TouchHandle> end_selection_handle_;
164
157 bool is_selection_active_; 165 bool is_selection_active_;
158 bool activate_selection_automatically_; 166 bool activate_selection_automatically_;
159 167
160 bool selection_empty_; 168 bool selection_empty_;
161 bool selection_editable_; 169 bool selection_editable_;
162 170
163 bool temporarily_hidden_; 171 bool temporarily_hidden_;
164 172
173 TextSelectionGranularityStrategy selection_granularity_strategy_;
174 scoped_ptr<GranularityStrategy> granularity_strategy_;
175
165 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); 176 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController);
166 }; 177 };
167 178
168 } // namespace ui 179 } // namespace ui
169 180
170 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ 181 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ui/touch_selection/touch_handle.cc ('k') | ui/touch_selection/touch_selection_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698