OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_TOUCH_SELECTION_LONGPRESS_DRAG_SELECTOR_H_ |
| 6 #define UI_TOUCH_SELECTION_LONGPRESS_DRAG_SELECTOR_H_ |
| 7 |
| 8 #include "base/time/time.h" |
| 9 #include "ui/gfx/geometry/point_f.h" |
| 10 #include "ui/gfx/geometry/vector2d_f.h" |
| 11 #include "ui/touch_selection/touch_selection_draggable.h" |
| 12 #include "ui/touch_selection/ui_touch_selection_export.h" |
| 13 |
| 14 namespace ui { |
| 15 |
| 16 class MotionEvent; |
| 17 |
| 18 class UI_TOUCH_SELECTION_EXPORT LongPressDragSelectorClient |
| 19 : public TouchSelectionDraggableClient { |
| 20 public: |
| 21 ~LongPressDragSelectorClient() override {} |
| 22 virtual void OnLongPressDragActiveStateChanged() = 0; |
| 23 virtual gfx::PointF GetSelectionStart() const = 0; |
| 24 virtual gfx::PointF GetSelectionEnd() const = 0; |
| 25 }; |
| 26 |
| 27 // Supports text selection via touch dragging after a longpress-initiated |
| 28 // selection. |
| 29 class UI_TOUCH_SELECTION_EXPORT LongPressDragSelector |
| 30 : public TouchSelectionDraggable { |
| 31 public: |
| 32 explicit LongPressDragSelector(LongPressDragSelectorClient* client); |
| 33 ~LongPressDragSelector() override; |
| 34 |
| 35 // TouchSelectionDraggable implementation. |
| 36 bool WillHandleTouchEvent(const MotionEvent& event) override; |
| 37 bool IsActive() const override; |
| 38 |
| 39 // Called just prior to a longpress event being handled. |
| 40 void OnLongPressEvent(base::TimeTicks event_time, |
| 41 const gfx::PointF& position); |
| 42 |
| 43 // Called when the active selection changes. |
| 44 void OnSelectionActivated(); |
| 45 void OnSelectionDeactivated(); |
| 46 |
| 47 private: |
| 48 enum SelectionState { |
| 49 INACTIVE, |
| 50 LONGPRESS_PENDING, |
| 51 SELECTION_PENDING, |
| 52 DRAG_PENDING, |
| 53 DRAGGING |
| 54 }; |
| 55 |
| 56 void SetState(SelectionState state); |
| 57 |
| 58 LongPressDragSelectorClient* const client_; |
| 59 |
| 60 SelectionState state_; |
| 61 |
| 62 base::TimeTicks touch_down_time_; |
| 63 gfx::PointF touch_down_position_; |
| 64 |
| 65 gfx::Vector2dF longpress_drag_selection_offset_; |
| 66 gfx::PointF longpress_drag_start_anchor_; |
| 67 bool has_longpress_drag_start_anchor_; |
| 68 }; |
| 69 |
| 70 } // namespace ui |
| 71 |
| 72 #endif // UI_TOUCH_SELECTION_LONGPRESS_DRAG_SELECTOR_H_ |
OLD | NEW |