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

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

Issue 1066053002: [Android] Allow custom ActionMode creation via ContentViewClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix null check Created 5 years, 8 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"
(...skipping 10 matching lines...) Expand all
21 class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerClient { 21 class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerClient {
22 public: 22 public:
23 virtual ~TouchSelectionControllerClient() {} 23 virtual ~TouchSelectionControllerClient() {}
24 24
25 virtual bool SupportsAnimation() const = 0; 25 virtual bool SupportsAnimation() const = 0;
26 virtual void SetNeedsAnimate() = 0; 26 virtual void SetNeedsAnimate() = 0;
27 virtual void MoveCaret(const gfx::PointF& position) = 0; 27 virtual void MoveCaret(const gfx::PointF& position) = 0;
28 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) = 0; 28 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) = 0;
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, 31 virtual void OnSelectionEvent(SelectionEventType event) = 0;
32 const gfx::PointF& position) = 0;
33 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0; 32 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0;
34 }; 33 };
35 34
36 // Controller for manipulating text selection via touch input. 35 // Controller for manipulating text selection via touch input.
37 class UI_TOUCH_SELECTION_EXPORT TouchSelectionController 36 class UI_TOUCH_SELECTION_EXPORT TouchSelectionController
38 : public TouchHandleClient { 37 : public TouchHandleClient {
39 public: 38 public:
40 TouchSelectionController(TouchSelectionControllerClient* client, 39 TouchSelectionController(TouchSelectionControllerClient* client,
41 base::TimeDelta tap_timeout, 40 base::TimeDelta tap_timeout,
42 float tap_slop, 41 float tap_slop,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // To be called when the editability of the focused region changes. 75 // To be called when the editability of the focused region changes.
77 void OnSelectionEditable(bool editable); 76 void OnSelectionEditable(bool editable);
78 77
79 // To be called when the contents of the focused region changes. 78 // To be called when the contents of the focused region changes.
80 void OnSelectionEmpty(bool empty); 79 void OnSelectionEmpty(bool empty);
81 80
82 // Ticks an active animation, as requested to the client by |SetNeedsAnimate|. 81 // Ticks an active animation, as requested to the client by |SetNeedsAnimate|.
83 // Returns true if an animation is active and requires further ticking. 82 // Returns true if an animation is active and requires further ticking.
84 bool Animate(base::TimeTicks animate_time); 83 bool Animate(base::TimeTicks animate_time);
85 84
85 // 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
87 // that bound. If no selection is active, an empty rect will be returned.
88 gfx::RectF GetRectBetweenBounds() const;
89
90 // Returns the visible rect of specified touch handle. For an active insertion
91 // these values will be identical.
92 gfx::RectF GetStartHandleRect() const;
93 gfx::RectF GetEndHandleRect() const;
94
95 // Returns the focal point of the start and end bounds, as defined by
96 // their bottom coordinate.
97 const gfx::PointF& GetStartPosition() const;
98 const gfx::PointF& GetEndPosition() const;
99
86 private: 100 private:
87 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; 101 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE };
88 102
89 // TouchHandleClient implementation. 103 // TouchHandleClient implementation.
90 void OnHandleDragBegin(const TouchHandle& handle) override; 104 void OnHandleDragBegin(const TouchHandle& handle) override;
91 void OnHandleDragUpdate(const TouchHandle& handle, 105 void OnHandleDragUpdate(const TouchHandle& handle,
92 const gfx::PointF& new_position) override; 106 const gfx::PointF& new_position) override;
93 void OnHandleDragEnd(const TouchHandle& handle) override; 107 void OnHandleDragEnd(const TouchHandle& handle) override;
94 void OnHandleTapped(const TouchHandle& handle) override; 108 void OnHandleTapped(const TouchHandle& handle) override;
95 void SetNeedsAnimate() override; 109 void SetNeedsAnimate() override;
96 scoped_ptr<TouchHandleDrawable> CreateDrawable() override; 110 scoped_ptr<TouchHandleDrawable> CreateDrawable() override;
97 base::TimeDelta GetTapTimeout() const override; 111 base::TimeDelta GetTapTimeout() const override;
98 float GetTapSlop() const override; 112 float GetTapSlop() const override;
99 113
100 void ShowInsertionHandleAutomatically(); 114 void ShowInsertionHandleAutomatically();
101 void ShowSelectionHandlesAutomatically(); 115 void ShowSelectionHandlesAutomatically();
102 116
103 void OnInsertionChanged(); 117 void OnInsertionChanged();
104 void OnSelectionChanged(); 118 void OnSelectionChanged();
105 119
106 void ActivateInsertion(); 120 void ActivateInsertion();
107 void DeactivateInsertion(); 121 void DeactivateInsertion();
108 void ActivateSelection(); 122 void ActivateSelection();
109 void DeactivateSelection(); 123 void DeactivateSelection();
110 void ResetCachedValuesIfInactive(); 124 void ResetCachedValuesIfInactive();
111 125
112 const gfx::PointF& GetStartPosition() const;
113 const gfx::PointF& GetEndPosition() const;
114 gfx::Vector2dF GetStartLineOffset() const; 126 gfx::Vector2dF GetStartLineOffset() const;
115 gfx::Vector2dF GetEndLineOffset() const; 127 gfx::Vector2dF GetEndLineOffset() const;
116 bool GetStartVisible() const; 128 bool GetStartVisible() const;
117 bool GetEndVisible() const; 129 bool GetEndVisible() const;
118 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; 130 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const;
119 131
120 void LogSelectionEnd(); 132 void LogSelectionEnd();
121 133
122 TouchSelectionControllerClient* const client_; 134 TouchSelectionControllerClient* const client_;
123 const base::TimeDelta tap_timeout_; 135 const base::TimeDelta tap_timeout_;
(...skipping 28 matching lines...) Expand all
152 // Whether a selection handle was dragged during the current 'selection 164 // Whether a selection handle was dragged during the current 'selection
153 // session' - i.e. since the current selection has been activated. 165 // session' - i.e. since the current selection has been activated.
154 bool selection_handle_dragged_; 166 bool selection_handle_dragged_;
155 167
156 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); 168 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController);
157 }; 169 };
158 170
159 } // namespace ui 171 } // namespace ui
160 172
161 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ 173 #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