Index: ash/laser/laser_pointer_controller.h |
diff --git a/ash/laser/laser_pointer_controller.h b/ash/laser/laser_pointer_controller.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2e4145d16da99b04eafcab504b6f7d6a829c1e7c |
--- /dev/null |
+++ b/ash/laser/laser_pointer_controller.h |
@@ -0,0 +1,76 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ASH_LASER_LASER_POINTER_CONTROLLER_H_ |
+#define ASH_LASER_LASER_POINTER_CONTROLLER_H_ |
+ |
+#include <memory> |
+ |
+#include "ash/ash_export.h" |
+#include "base/timer/timer.h" |
James Cook
2016/09/14 17:52:27
You can forward declare this
sammiequon
2016/09/14 21:44:09
Done.
|
+#include "ui/aura/window_observer.h" |
+#include "ui/events/event.h" |
+#include "ui/events/event_handler.h" |
+#include "ui/gfx/geometry/point.h" |
+ |
+namespace base { |
+class Timer; |
+} |
+ |
+namespace ui { |
+class LocatedEvent; |
+class MouseEvent; |
+class TouchEvent; |
+} |
+ |
+namespace ash { |
+ |
+class LaserPointerView; |
+ |
+// Controller for the laser pointer functionality. Enables/disables laser |
+// pointer as well as receives points and passes them off to be rendered. |
+class ASH_EXPORT LaserPointerController : public ui::EventHandler, |
+ public aura::WindowObserver { |
+ public: |
+ explicit LaserPointerController(); |
James Cook
2016/09/14 17:52:27
no explicit
sammiequon
2016/09/14 21:44:09
Done.
|
+ ~LaserPointerController() override; |
+ |
+ // Turns the laser pointer feature on or off. The user still has to press and |
+ // drag to see the laser pointer. |
+ void SetEnabled(bool enabled); |
+ |
+ private: |
+ friend class LaserPointerControllerTestApi; |
+ |
+ // ui::EventHandler: |
+ void OnMouseEvent(ui::MouseEvent* event) override; |
+ |
+ // aura::WindowObserver: |
+ void OnWindowDestroying(aura::Window* window) override; |
+ |
+ void StopTimer(); |
+ void SwitchTargetRootWindowIfNeeded(); |
James Cook
2016/09/14 17:52:26
nit: document (why does it need to switch? if need
sammiequon
2016/09/14 21:44:09
Done.
|
+ |
+ // Timer callback which adds a point where the mouse was last seen. This |
+ // allows the trail to fade away when the mouse is stationary. |
James Cook
2016/09/14 17:52:27
nice comment
sammiequon
2016/09/14 21:44:09
thanks
|
+ void AddStationaryPoint(); |
+ |
+ // Timer which will add a new stationary point when the mouse stops moving. |
+ // This will remove points that are too old. |
+ std::unique_ptr<base::Timer> timer_; |
James Cook
2016/09/14 17:52:27
optional: How about stationary_timer_ or mouse_mov
sammiequon
2016/09/14 21:44:09
Done.
|
+ int timer_repeat_count_ = 0; |
+ |
+ bool enabled_ = false; |
+ |
+ gfx::Point current_mouse_location_; |
James Cook
2016/09/14 17:52:27
Document screen coords or root coords. Or rename t
sammiequon
2016/09/14 21:44:09
Done.
|
+ // |laser_pointer_view_| will only hold an instance when the laser pointer is |
+ // enabled and activated(pressed or dragged). |
James Cook
2016/09/14 17:52:27
nit: space after activated
sammiequon
2016/09/14 21:44:09
Done.
|
+ std::unique_ptr<LaserPointerView> laser_pointer_view_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(LaserPointerController); |
James Cook
2016/09/14 17:52:26
#include base/macros.h
sammiequon
2016/09/14 21:44:09
Done.
|
+}; |
+ |
+} // namespace ash |
+ |
+#endif // ASH_LASER_LASER_POINTER_CONTROLLER_H_ |