Index: ash/autoclick/common/autoclick_controller_common.h |
diff --git a/ash/autoclick/common/autoclick_controller_common.h b/ash/autoclick/common/autoclick_controller_common.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..099239326d4386f23ba1dffb670e7fe418ce790d |
--- /dev/null |
+++ b/ash/autoclick/common/autoclick_controller_common.h |
@@ -0,0 +1,90 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
sadrul
2016/08/12 15:00:35
2016
riajiang
2016/08/12 16:31:39
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_H |
+#define ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_H |
+ |
+#include "ash/autoclick/common/autoclick_ring_handler.h" |
+#include "base/macros.h" |
+#include "base/timer/timer.h" |
+#include "ui/events/keycodes/keyboard_codes.h" |
+#include "ui/gfx/geometry/point.h" |
+ |
+namespace views { |
+class Widget; |
+} |
+ |
+namespace ui { |
+class MouseEvent; |
+class KeyEvent; |
+class TouchEvent; |
+class GestureEvent; |
+class ScrollEvent; |
+} |
+ |
+namespace ash { |
+ |
+// Autoclick controller common code for ash and mus. |
+class AutoclickControllerCommon { |
+ public: |
+ class Delegate { |
+ public: |
+ Delegate() {} |
+ virtual ~Delegate() {} |
+ |
+ // Called when given |event_location| to create a ring widget at that |
+ // location. |
sadrul
2016/08/12 15:00:35
* Creates a ring widget at |event_location|.
riajiang
2016/08/12 16:31:38
Done.
|
+ virtual views::Widget* CreateAutoclickRingWidget( |
+ const gfx::Point& event_location) = 0; |
sadrul
2016/08/12 15:00:36
Document the ownership of the returned Widget (e.g
riajiang
2016/08/12 16:31:39
Done.
|
+ |
+ // Called when the |event_location| is changed to update the parent of |
+ // the |widget| if necessary. |
sadrul
2016/08/12 15:00:35
* Moves |widget| to |event_location|
riajiang
2016/08/12 16:31:38
Done.
|
+ virtual void UpdateAutoclickRingWidget( |
+ views::Widget* widget, |
+ const gfx::Point& event_location) = 0; |
+ |
+ virtual void DoAutoclick(const gfx::Point& event_location, |
sadrul
2016/08/12 15:00:36
Generates a click with |mouse_event_flags| at |eve
riajiang
2016/08/12 16:31:38
Done.
|
+ const int mouse_event_flags) = 0; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(Delegate); |
+ }; |
+ |
+ AutoclickControllerCommon(base::TimeDelta delay, Delegate* delegate); |
+ ~AutoclickControllerCommon(); |
+ |
+ void HandleMouseEvent(const ui::MouseEvent& event); |
+ void HandleKeyEvent(const ui::KeyEvent& event); |
+ void HandleTouchEvent(const ui::TouchEvent& event); |
+ void HandleGestureEvent(const ui::GestureEvent& event); |
+ void HandleScrollEvent(const ui::ScrollEvent& event); |
+ |
+ void SetAutoclickDelay(const base::TimeDelta delay); |
+ void StopAutoclickTimer(); |
+ void StopGesture(); |
+ bool IsModifierKey(const ui::KeyboardCode key_code); |
+ |
+ private: |
+ void InitClickTimer(); |
+ |
+ void DoAutoclick(); |
+ |
+ void GetAutoclickRingWidget(const gfx::Point& mouse_location); |
sadrul
2016/08/12 15:00:35
Call this UpdateRingWidget(). (Get* implies the fu
riajiang
2016/08/12 16:31:38
Done.
|
+ |
+ base::TimeDelta delay_; |
+ int mouse_event_flags_; |
+ std::unique_ptr<base::Timer> autoclick_timer_; |
+ Delegate* delegate_; |
+ views::Widget* widget_; |
sadrul
2016/08/12 15:00:35
Make this a std::unique_ptr<> if this owns the wid
riajiang
2016/08/12 16:31:39
Done.
|
+ // The position in screen coordinates used to determine |
+ // the distance the mouse has moved. |
+ gfx::Point anchor_location_; |
+ std::unique_ptr<AutoclickRingHandler> autoclick_ring_handler_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AutoclickControllerCommon); |
+}; |
+ |
+} // namespace ash |
+ |
+#endif // ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_H |