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_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ | 5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ |
6 #define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ | 6 #define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/common/system/chromeos/palette/common_palette_tool.h" | 9 #include "ash/common/system/chromeos/palette/common_palette_tool.h" |
10 #include "ui/gfx/geometry/point.h" | |
11 #include "ui/views/pointer_watcher.h" | |
12 | 10 |
13 namespace base { | 11 namespace base { |
14 class Timer; | 12 class Timer; |
15 } | 13 } |
16 | 14 |
17 namespace ash { | 15 namespace ash { |
18 | 16 |
19 class LaserPointerView; | 17 // Controller for the laser pointer functionality. |
20 | 18 class ASH_EXPORT LaserPointerMode : public CommonPaletteTool { |
21 // Controller for the laser pointer functionality. Enables/disables laser | |
22 // pointer as well as receives points and passes them off to be rendered. | |
23 class ASH_EXPORT LaserPointerMode : public CommonPaletteTool, | |
24 public views::PointerWatcher { | |
25 public: | 19 public: |
26 explicit LaserPointerMode(Delegate* delegate); | 20 explicit LaserPointerMode(Delegate* delegate); |
27 ~LaserPointerMode() override; | 21 ~LaserPointerMode() override; |
28 | 22 |
29 private: | 23 private: |
30 friend class LaserPointerModeTestApi; | |
31 | |
32 // PaletteTool: | 24 // PaletteTool: |
33 PaletteGroup GetGroup() const override; | 25 PaletteGroup GetGroup() const override; |
34 PaletteToolId GetToolId() const override; | 26 PaletteToolId GetToolId() const override; |
35 void OnEnable() override; | 27 void OnEnable() override; |
36 void OnDisable() override; | 28 void OnDisable() override; |
37 const gfx::VectorIcon& GetActiveTrayIcon() const override; | 29 const gfx::VectorIcon& GetActiveTrayIcon() const override; |
38 views::View* CreateView() override; | 30 views::View* CreateView() override; |
39 | 31 |
40 // CommonPaletteTool: | 32 // CommonPaletteTool: |
41 const gfx::VectorIcon& GetPaletteIcon() const override; | 33 const gfx::VectorIcon& GetPaletteIcon() const override; |
42 | 34 |
43 // views::PointerWatcher: | |
44 void OnPointerEventObserved(const ui::PointerEvent& event, | |
45 const gfx::Point& location_in_screen, | |
46 views::Widget* target) override; | |
47 | |
48 void StopTimer(); | |
49 | |
50 // Timer callback which adds a point where the mouse was last seen. This | |
51 // allows the trail to fade away when the mouse is stationary. | |
52 void AddStationaryPoint(); | |
53 | |
54 // Timer which will add a new stationary point when the mouse stops moving. | |
55 // This will remove points that are too old. | |
56 std::unique_ptr<base::Timer> timer_; | |
57 int timer_repeat_count_ = 0; | |
58 | |
59 gfx::Point current_mouse_location_; | |
60 std::unique_ptr<LaserPointerView> laser_pointer_view_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(LaserPointerMode); | 35 DISALLOW_COPY_AND_ASSIGN(LaserPointerMode); |
63 }; | 36 }; |
64 | 37 |
65 } // namespace ash | 38 } // namespace ash |
66 | 39 |
67 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ | 40 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ |
OLD | NEW |