Index: ash/common/system/chromeos/palette/tools/laser_pointer_mode.h |
diff --git a/ash/common/system/chromeos/palette/tools/laser_pointer_mode.h b/ash/common/system/chromeos/palette/tools/laser_pointer_mode.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..69f9c1b80c88d87c1d4a19b68a6812888beed816 |
--- /dev/null |
+++ b/ash/common/system/chromeos/palette/tools/laser_pointer_mode.h |
@@ -0,0 +1,63 @@ |
+// 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_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ |
+#define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ |
+ |
+#include "ash/common/system/chromeos/palette/common_palette_tool.h" |
+#include "ash/common/system/chromeos/palette/tools/laser_pointer_points.h" |
+#include "ash/common/system/chromeos/palette/tools/laser_pointer_view.h" |
+ |
+namespace ash { |
+ |
+class LaserPointerMode : public CommonPaletteTool, public ui::EventHandler { |
+ public: |
+ explicit LaserPointerMode(Delegate* delegate); |
+ ~LaserPointerMode() override; |
+ |
+ protected: |
+ // Timer which will add a new stationary point when the mouse stops moving. |
+ // This will remove points past a certain threshold. |
+ std::unique_ptr<base::Timer> timer_; |
+ base::Lock points_lock_; |
+ int timer_repeat_count_; |
+ |
+ gfx::Point current_mouse_location_; |
+ LaserPointerPoints laser_points_; |
+ LaserPointerView* laser_pointer_view_ = nullptr; |
+ |
+ private: |
+ // PaletteTool overrides. |
+ PaletteGroup GetGroup() const override; |
+ PaletteToolId GetToolId() const override; |
+ void OnEnable() override; |
+ void OnDisable() override; |
+ gfx::VectorIconId GetActiveTrayIcon() override; |
+ |
+ // CommonPaletteTool overrides. |
+ gfx::VectorIconId GetPaletteIconId() override; |
+ |
+ // EventHandler overrides. |
+ void OnMouseEvent(ui::MouseEvent* event) override; |
+ void OnKeyEvent(ui::KeyEvent* event) override; |
+ void OnTouchEvent(ui::TouchEvent* event) override; |
+ void OnGestureEvent(ui::GestureEvent* event) override; |
+ void OnScrollEvent(ui::ScrollEvent* event) override; |
+ |
+ void InitializeTimer(); |
+ void StartTimer(); |
+ void StopTimer(); |
+ // Timer callback which adds a point where the mouse was last seen. This takes |
+ // care of fading away the tail of the laser when the mouse is stationary. |
+ void AddStationaryPoint(); |
+ |
+ static const int kAddStationaryPointsDelayMs; |
+ static const int kPointLifeDurationMs; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(LaserPointerMode); |
+}; |
+ |
+} // namespace ash |
+ |
+#endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_H_ |