| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER__IMPL_H_ |
| 6 #define UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER__IMPL_H_ |
| 7 |
| 8 #include "base/timer/timer.h" |
| 9 #include "ui/touch_selection/touch_selection_controller.h" |
| 10 |
| 11 namespace ui { |
| 12 |
| 13 class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerImpl |
| 14 : public TouchSelectionController { |
| 15 public: |
| 16 TouchSelectionControllerImpl(TouchSelectionControllerClient* client, |
| 17 base::TimeDelta tap_timeout, |
| 18 float tap_slop, |
| 19 bool show_on_tap_for_empty_editable); |
| 20 ~TouchSelectionControllerImpl() override; |
| 21 |
| 22 // TouchSelectionController: |
| 23 bool OnSelectionBoundsUpdated(const SelectionBound& start, |
| 24 const SelectionBound& end) override; |
| 25 bool WillHandleTouchEvent(const MotionEvent& event) override; |
| 26 void OnTapEvent() override; |
| 27 void OnLongPressEvent() override; |
| 28 void AllowShowingFromCurrentSelection() override; |
| 29 void HideAndDisallowShowingAutomatically() override; |
| 30 void SetTemporarilyHidden(bool hidden) override; |
| 31 void OnSelectionEditable(bool editable) override; |
| 32 void OnSelectionEmpty(bool empty) override; |
| 33 bool Animate(base::TimeTicks animate_time) override; |
| 34 gfx::Rect GetRectBetweenBounds() const override; |
| 35 void OnNativeViewMoved() override; |
| 36 void OnOverscrollStarted() override; |
| 37 void OnOverscrollCompleted() override; |
| 38 |
| 39 protected: |
| 40 TouchSelectionControllerClient* client() const { return client_; } |
| 41 |
| 42 const SelectionBound& start() const { return start_; } |
| 43 const SelectionBound& end() const { return end_; } |
| 44 |
| 45 bool is_insertion_active() const { return is_insertion_active_; } |
| 46 bool is_selection_active() const { return is_selection_active_; } |
| 47 bool is_selection_editable() const { return selection_editable_; } |
| 48 |
| 49 |
| 50 virtual void ActivateInsertion(); |
| 51 virtual void DeactivateInsertion(); |
| 52 virtual void ActivateSelection(); |
| 53 virtual void DeactivateSelection(); |
| 54 |
| 55 private: |
| 56 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; |
| 57 |
| 58 // TouchHandleClient: |
| 59 void OnHandleDragBegin(const TouchHandle& handle) override; |
| 60 void OnHandleDragUpdate(const TouchHandle& handle, |
| 61 const gfx::PointF& new_position) override; |
| 62 void OnHandleDragEnd(const TouchHandle& handle) override; |
| 63 void OnHandleTapped(const TouchHandle& handle) override; |
| 64 void SetNeedsAnimate() override; |
| 65 scoped_ptr<TouchHandleDrawable> CreateDrawable() override; |
| 66 base::TimeDelta GetTapTimeout() const override; |
| 67 float GetTapSlop() const override; |
| 68 |
| 69 void ShowInsertionHandleAutomatically(); |
| 70 void ShowSelectionHandlesAutomatically(); |
| 71 |
| 72 void OnInsertionChanged(); |
| 73 void OnSelectionChanged(); |
| 74 |
| 75 void ResetCachedValuesIfInactive(); |
| 76 |
| 77 const gfx::PointF& GetStartPosition() const; |
| 78 const gfx::PointF& GetEndPosition() const; |
| 79 gfx::Vector2dF GetStartLineOffset() const; |
| 80 gfx::Vector2dF GetEndLineOffset() const; |
| 81 bool GetStartVisible() const; |
| 82 bool GetEndVisible() const; |
| 83 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; |
| 84 |
| 85 void LogSelectionEnd(); |
| 86 |
| 87 TouchSelectionControllerClient* const client_; |
| 88 const base::TimeDelta tap_timeout_; |
| 89 const float tap_slop_; |
| 90 |
| 91 // Controls whether an insertion handle is shown on a tap for an empty |
| 92 // editable text. |
| 93 bool show_on_tap_for_empty_editable_; |
| 94 |
| 95 InputEventType response_pending_input_event_; |
| 96 |
| 97 SelectionBound start_; |
| 98 SelectionBound end_; |
| 99 TouchHandleOrientation start_orientation_; |
| 100 TouchHandleOrientation end_orientation_; |
| 101 |
| 102 scoped_ptr<TouchHandle> insertion_handle_; |
| 103 bool is_insertion_active_; |
| 104 bool activate_insertion_automatically_; |
| 105 |
| 106 scoped_ptr<TouchHandle> start_selection_handle_; |
| 107 scoped_ptr<TouchHandle> end_selection_handle_; |
| 108 bool is_selection_active_; |
| 109 bool activate_selection_automatically_; |
| 110 |
| 111 bool selection_empty_; |
| 112 bool selection_editable_; |
| 113 |
| 114 bool temporarily_hidden_; |
| 115 |
| 116 base::TimeTicks selection_start_time_; |
| 117 // Whether a selection handle was dragged during the current 'selection |
| 118 // session' - i.e. since the current selection has been activated. |
| 119 bool selection_handle_was_dragged_; |
| 120 |
| 121 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImpl); |
| 122 }; |
| 123 |
| 124 } // namespace ui |
| 125 |
| 126 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER__IMPL_H_ |
| OLD | NEW |