| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_LASER_LASER_POINTER_CONTROLLER_H_ | 5 #ifndef ASH_LASER_LASER_POINTER_CONTROLLER_H_ |
| 6 #define ASH_LASER_LASER_POINTER_CONTROLLER_H_ | 6 #define ASH_LASER_LASER_POINTER_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "ui/aura/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
| 13 #include "ui/events/event_handler.h" | 13 #include "ui/events/event_handler.h" |
| 14 #include "ui/gfx/geometry/point.h" | 14 #include "ui/gfx/geometry/point_f.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class Timer; | 17 class Timer; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace ash { | 20 namespace ash { |
| 21 | 21 |
| 22 class LaserPointerView; | 22 class LaserPointerView; |
| 23 | 23 |
| 24 // Controller for the laser pointer functionality. Enables/disables laser | 24 // Controller for the laser pointer functionality. Enables/disables laser |
| (...skipping 21 matching lines...) Expand all Loading... |
| 46 void SwitchTargetRootWindowIfNeeded(aura::Window* root_window); | 46 void SwitchTargetRootWindowIfNeeded(aura::Window* root_window); |
| 47 | 47 |
| 48 // Timer callback which adds a point where the stylus was last seen. This | 48 // Timer callback which adds a point where the stylus was last seen. This |
| 49 // allows the trail to fade away when the stylus is stationary. | 49 // allows the trail to fade away when the stylus is stationary. |
| 50 void AddStationaryPoint(); | 50 void AddStationaryPoint(); |
| 51 | 51 |
| 52 // Updates |laser_pointer_view_| by changing its root window or creating it if | 52 // Updates |laser_pointer_view_| by changing its root window or creating it if |
| 53 // needed. Also adds the latest point at |event_location| and stops | 53 // needed. Also adds the latest point at |event_location| and stops |
| 54 // propagation of |event|. | 54 // propagation of |event|. |
| 55 void UpdateLaserPointerView(aura::Window* current_window, | 55 void UpdateLaserPointerView(aura::Window* current_window, |
| 56 const gfx::Point& event_location, | 56 const gfx::PointF& event_location, |
| 57 ui::Event* event); | 57 ui::Event* event); |
| 58 | 58 |
| 59 // Destroys |laser_pointer_view_|, if it exists. | 59 // Destroys |laser_pointer_view_|, if it exists. |
| 60 void DestroyLaserPointerView(); | 60 void DestroyLaserPointerView(); |
| 61 | 61 |
| 62 void RestartTimer(); | 62 void RestartTimer(); |
| 63 | 63 |
| 64 // Timer which will add a new stationary point when the stylus stops moving. | 64 // Timer which will add a new stationary point when the stylus stops moving. |
| 65 // This will remove points that are too old. | 65 // This will remove points that are too old. |
| 66 std::unique_ptr<base::Timer> stationary_timer_; | 66 std::unique_ptr<base::Timer> stationary_timer_; |
| 67 int stationary_timer_repeat_count_ = 0; | 67 int stationary_timer_repeat_count_ = 0; |
| 68 | 68 |
| 69 bool enabled_ = false; | 69 bool enabled_ = false; |
| 70 | 70 |
| 71 // |is_fading_away_| determines whether the laser pointer view should accept | 71 // |is_fading_away_| determines whether the laser pointer view should accept |
| 72 // points normally, or just advance the |laser_points_| time so that current | 72 // points normally, or just advance the |laser_points_| time so that current |
| 73 // points start fading away. This should be set to true when the view is about | 73 // points start fading away. This should be set to true when the view is about |
| 74 // to be destroyed, such as when the stylus is released. | 74 // to be destroyed, such as when the stylus is released. |
| 75 bool is_fading_away_ = false; | 75 bool is_fading_away_ = false; |
| 76 | 76 |
| 77 // The last seen stylus location in screen coordinates. | 77 // The last seen stylus location in screen coordinates. |
| 78 gfx::Point current_stylus_location_; | 78 gfx::PointF current_stylus_location_; |
| 79 | 79 |
| 80 // |laser_pointer_view_| will only hold an instance when the laser pointer is | 80 // |laser_pointer_view_| will only hold an instance when the laser pointer is |
| 81 // enabled and activated (pressed or dragged). | 81 // enabled and activated (pressed or dragged). |
| 82 std::unique_ptr<LaserPointerView> laser_pointer_view_; | 82 std::unique_ptr<LaserPointerView> laser_pointer_view_; |
| 83 | 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(LaserPointerController); | 84 DISALLOW_COPY_AND_ASSIGN(LaserPointerController); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 } // namespace ash | 87 } // namespace ash |
| 88 | 88 |
| 89 #endif // ASH_LASER_LASER_POINTER_CONTROLLER_H_ | 89 #endif // ASH_LASER_LASER_POINTER_CONTROLLER_H_ |
| OLD | NEW |