| 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_TOUCH_SELECTION_CONTROLLER_AURA_H_ |
| 6 #define UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_AURA_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 #include "ui/touch_selection/touch_selection_menu_runner.h" |
| 13 |
| 14 namespace aura { |
| 15 class Window; |
| 16 } |
| 17 |
| 18 namespace ui { |
| 19 class MotionEventAura; |
| 20 class TouchEvent; |
| 21 class TouchSelectionControllerAuraTestApi; |
| 22 |
| 23 // The interface used by TouchSelectionControllerAura to communicate with its |
| 24 // client. |
| 25 class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerAuraClient { |
| 26 public: |
| 27 virtual ~TouchSelectionControllerAuraClient() {}; |
| 28 |
| 29 virtual EventTarget* GetEventTarget() const = 0; |
| 30 virtual void MoveCaret(const gfx::PointF& position) = 0; |
| 31 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) = 0; |
| 32 virtual void SelectBetweenCoordinates(const gfx::PointF& base, |
| 33 const gfx::PointF& extent) = 0; |
| 34 virtual aura::Window* GetParentWindow() const = 0; |
| 35 virtual gfx::Rect GetClientBounds() const = 0; |
| 36 virtual bool IsCommandIdEnabled(int command_id) const = 0; |
| 37 virtual void ExecuteCommand(int command_id, int event_flags) = 0; |
| 38 virtual void OpenContextMenu(const gfx::PointF& point) = 0; |
| 39 }; |
| 40 |
| 41 // Aura specific implementaion of a touch selection controller. Wraps an |
| 42 // instance of TouchSelectionController and augments it with additional behavior |
| 43 // needed in Aura. |
| 44 class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerAura |
| 45 : public TouchSelectionControllerClient, |
| 46 public TouchSelectionMenuClient, |
| 47 public EventHandler { |
| 48 public: |
| 49 explicit TouchSelectionControllerAura( |
| 50 TouchSelectionControllerAuraClient* client); |
| 51 ~TouchSelectionControllerAura() override; |
| 52 |
| 53 void OnSelectionEditable(bool editable); |
| 54 void OnSelectionEmpty(bool empty); |
| 55 void OnSelectionBoundsUpdated(const SelectionBound& start, |
| 56 const SelectionBound& end); |
| 57 void HideAndDisallowShowingAutomatically(); |
| 58 void OnWindowMoved(); |
| 59 void OnOverscrollStarted(); |
| 60 void OnOverscrollCompleted(); |
| 61 void OnFlingCompleted(); |
| 62 |
| 63 protected: |
| 64 // TouchSelectionControllerClient: |
| 65 bool SupportsAnimation() const override; |
| 66 void SetNeedsAnimate() override; |
| 67 void MoveCaret(const gfx::PointF& position) override; |
| 68 void MoveRangeSelectionExtent(const gfx::PointF& extent) override; |
| 69 void SelectBetweenCoordinates(const gfx::PointF& base, |
| 70 const gfx::PointF& extent) override; |
| 71 void OnSelectionEvent(SelectionEventType event, |
| 72 const gfx::PointF& position) override; |
| 73 scoped_ptr<TouchHandleDrawable> CreateDrawable() override; |
| 74 |
| 75 private: |
| 76 friend class TouchSelectionControllerAuraTestApi; |
| 77 class EnvPreTargetHandler; |
| 78 |
| 79 gfx::Rect GetMenuAnchorRect() const; |
| 80 void ShowQuickMenu(); |
| 81 void UpdateQuickMenu(); |
| 82 bool IsQuickMenuAllowed() const; |
| 83 |
| 84 // TouchSelectionMenuClient: |
| 85 bool IsCommandIdEnabled(int command_id) const override; |
| 86 void ExecuteCommand(int command_id, int event_flags) override; |
| 87 void OpenContextMenu() override; |
| 88 |
| 89 // EventHandler: |
| 90 void OnTouchEvent(TouchEvent* event) override; |
| 91 void OnGestureEvent(GestureEvent* event) override; |
| 92 |
| 93 TouchSelectionControllerAuraClient* client_; |
| 94 scoped_ptr<MotionEventAura> motion_event_; |
| 95 scoped_ptr<TouchSelectionController> controller_; |
| 96 scoped_ptr<EnvPreTargetHandler> env_pre_target_handler_; |
| 97 base::OneShotTimer<TouchSelectionControllerAura> quick_menu_timer_; |
| 98 bool scroll_in_progress_; |
| 99 bool overscroll_in_progress_; |
| 100 bool handle_drag_in_progress_; |
| 101 bool selection_editable_; |
| 102 |
| 103 TouchSelectionControllerAuraTestApi* test_api_; |
| 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerAura); |
| 106 }; |
| 107 |
| 108 } // namespace ui |
| 109 |
| 110 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_AURA_H_ |
| OLD | NEW |