Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 ASH_LASER_LASER_POINTER_CONTROLLER_H_ | |
| 6 #define ASH_LASER_LASER_POINTER_CONTROLLER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "ash/ash_export.h" | |
| 11 #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.
| |
| 12 #include "ui/aura/window_observer.h" | |
| 13 #include "ui/events/event.h" | |
| 14 #include "ui/events/event_handler.h" | |
| 15 #include "ui/gfx/geometry/point.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class Timer; | |
| 19 } | |
| 20 | |
| 21 namespace ui { | |
| 22 class LocatedEvent; | |
| 23 class MouseEvent; | |
| 24 class TouchEvent; | |
| 25 } | |
| 26 | |
| 27 namespace ash { | |
| 28 | |
| 29 class LaserPointerView; | |
| 30 | |
| 31 // Controller for the laser pointer functionality. Enables/disables laser | |
| 32 // pointer as well as receives points and passes them off to be rendered. | |
| 33 class ASH_EXPORT LaserPointerController : public ui::EventHandler, | |
| 34 public aura::WindowObserver { | |
| 35 public: | |
| 36 explicit LaserPointerController(); | |
|
James Cook
2016/09/14 17:52:27
no explicit
sammiequon
2016/09/14 21:44:09
Done.
| |
| 37 ~LaserPointerController() override; | |
| 38 | |
| 39 // Turns the laser pointer feature on or off. The user still has to press and | |
| 40 // drag to see the laser pointer. | |
| 41 void SetEnabled(bool enabled); | |
| 42 | |
| 43 private: | |
| 44 friend class LaserPointerControllerTestApi; | |
| 45 | |
| 46 // ui::EventHandler: | |
| 47 void OnMouseEvent(ui::MouseEvent* event) override; | |
| 48 | |
| 49 // aura::WindowObserver: | |
| 50 void OnWindowDestroying(aura::Window* window) override; | |
| 51 | |
| 52 void StopTimer(); | |
| 53 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.
| |
| 54 | |
| 55 // Timer callback which adds a point where the mouse was last seen. This | |
| 56 // 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
| |
| 57 void AddStationaryPoint(); | |
| 58 | |
| 59 // Timer which will add a new stationary point when the mouse stops moving. | |
| 60 // This will remove points that are too old. | |
| 61 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.
| |
| 62 int timer_repeat_count_ = 0; | |
| 63 | |
| 64 bool enabled_ = false; | |
| 65 | |
| 66 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.
| |
| 67 // |laser_pointer_view_| will only hold an instance when the laser pointer is | |
| 68 // 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.
| |
| 69 std::unique_ptr<LaserPointerView> laser_pointer_view_; | |
| 70 | |
| 71 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.
| |
| 72 }; | |
| 73 | |
| 74 } // namespace ash | |
| 75 | |
| 76 #endif // ASH_LASER_LASER_POINTER_CONTROLLER_H_ | |
| OLD | NEW |