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_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ |
| 6 #define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ |
| 7 |
| 8 #include "ash/common/system/chromeos/palette/common_palette_tool.h" |
| 9 #include "ash/common/system/chromeos/palette/tools/laser_pointer_points.h" |
| 10 #include "ash/common/system/chromeos/palette/tools/laser_pointer_view.h" |
| 11 |
| 12 namespace ash { |
| 13 |
| 14 class LaserPointerMode : public CommonPaletteTool, public ui::EventHandler { |
| 15 public: |
| 16 explicit LaserPointerMode(Delegate* delegate); |
| 17 ~LaserPointerMode() override; |
| 18 |
| 19 protected: |
| 20 // Timer which will add a new stationary point when the mouse stops moving. |
| 21 // This will remove points past a certain threshold. |
| 22 std::unique_ptr<base::Timer> timer_; |
| 23 base::Lock points_lock_; |
| 24 int timer_repeat_count_; |
| 25 |
| 26 gfx::Point current_mouse_location_; |
| 27 LaserPointerPoints laser_points_; |
| 28 LaserPointerView* laser_pointer_view_ = nullptr; |
| 29 |
| 30 private: |
| 31 // PaletteTool overrides. |
| 32 PaletteGroup GetGroup() const override; |
| 33 PaletteToolId GetToolId() const override; |
| 34 void OnEnable() override; |
| 35 void OnDisable() override; |
| 36 gfx::VectorIconId GetActiveTrayIcon() override; |
| 37 |
| 38 // CommonPaletteTool overrides. |
| 39 gfx::VectorIconId GetPaletteIconId() override; |
| 40 |
| 41 // EventHandler overrides. |
| 42 void OnMouseEvent(ui::MouseEvent* event) override; |
| 43 void OnKeyEvent(ui::KeyEvent* event) override; |
| 44 void OnTouchEvent(ui::TouchEvent* event) override; |
| 45 void OnGestureEvent(ui::GestureEvent* event) override; |
| 46 void OnScrollEvent(ui::ScrollEvent* event) override; |
| 47 |
| 48 void InitializeTimer(); |
| 49 void StartTimer(); |
| 50 void StopTimer(); |
| 51 // Timer callback which adds a point where the mouse was last seen. This takes |
| 52 // care of fading away the tail of the laser when the mouse is stationary. |
| 53 void AddStationaryPoint(); |
| 54 |
| 55 static const int kAddStationaryPointsDelayMs; |
| 56 static const int kPointLifeDurationMs; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(LaserPointerMode); |
| 59 }; |
| 60 |
| 61 } // namespace ash |
| 62 |
| 63 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ |
OLD | NEW |