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_HANDLE_H_ | 5 #ifndef UI_TOUCH_SELECTION_TOUCH_HANDLE_H_ |
6 #define UI_TOUCH_SELECTION_TOUCH_HANDLE_H_ | 6 #define UI_TOUCH_SELECTION_TOUCH_HANDLE_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
12 #include "ui/events/gesture_detection/motion_event.h" | 13 #include "ui/events/gesture_detection/motion_event.h" |
13 #include "ui/gfx/geometry/point_f.h" | 14 #include "ui/gfx/geometry/point_f.h" |
14 #include "ui/gfx/geometry/rect_f.h" | 15 #include "ui/gfx/geometry/rect_f.h" |
15 #include "ui/gfx/geometry/vector2d_f.h" | 16 #include "ui/gfx/geometry/vector2d_f.h" |
16 #include "ui/touch_selection/touch_handle_orientation.h" | 17 #include "ui/touch_selection/touch_handle_orientation.h" |
17 #include "ui/touch_selection/touch_selection_draggable.h" | 18 #include "ui/touch_selection/touch_selection_draggable.h" |
18 #include "ui/touch_selection/ui_touch_selection_export.h" | 19 #include "ui/touch_selection/ui_touch_selection_export.h" |
19 | 20 |
20 namespace ui { | 21 namespace ui { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 }; | 54 }; |
54 | 55 |
55 // Interface through which |TouchHandle| communicates handle manipulation and | 56 // Interface through which |TouchHandle| communicates handle manipulation and |
56 // requests concrete drawable instances. | 57 // requests concrete drawable instances. |
57 class UI_TOUCH_SELECTION_EXPORT TouchHandleClient | 58 class UI_TOUCH_SELECTION_EXPORT TouchHandleClient |
58 : public TouchSelectionDraggableClient { | 59 : public TouchSelectionDraggableClient { |
59 public: | 60 public: |
60 ~TouchHandleClient() override {} | 61 ~TouchHandleClient() override {} |
61 virtual void OnHandleTapped(const TouchHandle& handle) = 0; | 62 virtual void OnHandleTapped(const TouchHandle& handle) = 0; |
62 virtual void SetNeedsAnimate() = 0; | 63 virtual void SetNeedsAnimate() = 0; |
63 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0; | 64 virtual std::unique_ptr<TouchHandleDrawable> CreateDrawable() = 0; |
64 virtual base::TimeDelta GetMaxTapDuration() const = 0; | 65 virtual base::TimeDelta GetMaxTapDuration() const = 0; |
65 virtual bool IsAdaptiveHandleOrientationEnabled() const = 0; | 66 virtual bool IsAdaptiveHandleOrientationEnabled() const = 0; |
66 }; | 67 }; |
67 | 68 |
68 // Responsible for displaying a selection or insertion handle for text | 69 // Responsible for displaying a selection or insertion handle for text |
69 // interaction. | 70 // interaction. |
70 class UI_TOUCH_SELECTION_EXPORT TouchHandle : public TouchSelectionDraggable { | 71 class UI_TOUCH_SELECTION_EXPORT TouchHandle : public TouchSelectionDraggable { |
71 public: | 72 public: |
72 // The drawable will be enabled but invisible until otherwise specified. | 73 // The drawable will be enabled but invisible until otherwise specified. |
73 TouchHandle(TouchHandleClient* client, | 74 TouchHandle(TouchHandleClient* client, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 125 |
125 private: | 126 private: |
126 gfx::PointF ComputeHandleOrigin() const; | 127 gfx::PointF ComputeHandleOrigin() const; |
127 void BeginDrag(); | 128 void BeginDrag(); |
128 void EndDrag(); | 129 void EndDrag(); |
129 void BeginFade(); | 130 void BeginFade(); |
130 void EndFade(); | 131 void EndFade(); |
131 void SetAlpha(float alpha); | 132 void SetAlpha(float alpha); |
132 void SetUpdateLayoutRequired(); | 133 void SetUpdateLayoutRequired(); |
133 | 134 |
134 scoped_ptr<TouchHandleDrawable> drawable_; | 135 std::unique_ptr<TouchHandleDrawable> drawable_; |
135 | 136 |
136 TouchHandleClient* const client_; | 137 TouchHandleClient* const client_; |
137 | 138 |
138 gfx::PointF focus_bottom_; | 139 gfx::PointF focus_bottom_; |
139 gfx::PointF focus_top_; | 140 gfx::PointF focus_top_; |
140 gfx::RectF viewport_rect_; | 141 gfx::RectF viewport_rect_; |
141 TouchHandleOrientation orientation_; | 142 TouchHandleOrientation orientation_; |
142 TouchHandleOrientation deferred_orientation_; | 143 TouchHandleOrientation deferred_orientation_; |
143 | 144 |
144 gfx::PointF touch_down_position_; | 145 gfx::PointF touch_down_position_; |
(...skipping 18 matching lines...) Expand all Loading... |
163 bool mirror_vertical_; | 164 bool mirror_vertical_; |
164 bool mirror_horizontal_; | 165 bool mirror_horizontal_; |
165 float handle_horizontal_padding_; | 166 float handle_horizontal_padding_; |
166 | 167 |
167 DISALLOW_COPY_AND_ASSIGN(TouchHandle); | 168 DISALLOW_COPY_AND_ASSIGN(TouchHandle); |
168 }; | 169 }; |
169 | 170 |
170 } // namespace ui | 171 } // namespace ui |
171 | 172 |
172 #endif // UI_TOUCH_SELECTION_TOUCH_HANDLE_H_ | 173 #endif // UI_TOUCH_SELECTION_TOUCH_HANDLE_H_ |
OLD | NEW |