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