Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: ash/laser/laser_pointer_controller.h

Issue 2311393004: Laser tool blocks events from propagating. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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"
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();
37 ~LaserPointerController() override;
38
39 void SetEnabled(bool enabled);
jdufault 2016/09/12 21:10:11 Add a comment
sammiequon 2016/09/13 01:09:56 Done.
40
41 private:
42 friend class LaserPointerControllerTestApi;
43
44 // WindowObserver:
jdufault 2016/09/12 21:10:11 aura::WindowObserver
jdufault 2016/09/12 21:10:11 Move this to below the ui::EventHandler overrides
sammiequon 2016/09/13 01:09:56 Done.
sammiequon 2016/09/13 01:09:56 Done.
45 void OnWindowDestroying(aura::Window* window) override;
46
47 // ui::EventHandler:
48 void OnMouseEvent(ui::MouseEvent* event) override;
49 void OnTouchEvent(ui::TouchEvent* event) override;
50
51 // Contains common logic between OnMouseEvent and OnTouchEvent.
52 void OnLocatedEvent(ui::LocatedEvent* event,
53 const ui::PointerDetails& pointer_details);
54
55 void StopTimer();
56 void SwitchTargetRootWindowIfNeeded();
57
58 // Timer callback which adds a point where the mouse was last seen. This
59 // allows the trail to fade away when the mouse is stationary.
60 void AddStationaryPoint();
61
62 // Timer which will add a new stationary point when the mouse stops moving.
63 // This will remove points that are too old.
64 std::unique_ptr<base::Timer> timer_;
65 int timer_repeat_count_ = 0;
66
67 bool enabled_ = false;
68
69 gfx::Point current_mouse_location_;
70 std::unique_ptr<LaserPointerView> laser_pointer_view_;
jdufault 2016/09/12 21:10:11 I'd add a comment saying that laser_pointer_view_
sammiequon 2016/09/13 01:09:56 Done.
71
72 DISALLOW_COPY_AND_ASSIGN(LaserPointerController);
73 };
74
75 } // namespace ash
76
77 #endif // ASH_LASER_LASER_POINTER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698