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

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

Issue 2311393004: Laser tool blocks events from propagating. (Closed)
Patch Set: Fixed patch set 4 errors. 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/macros.h"
12 #include "ui/aura/window_observer.h"
13 #include "ui/events/event.h"
jdufault 2016/09/16 18:43:53 Do you need this include?
sammiequon 2016/09/16 19:21:03 Done.
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;
jdufault 2016/09/16 18:43:53 Is this needed?
sammiequon 2016/09/16 19:21:03 Done.
23 class MouseEvent;
24 class TouchEvent;
jdufault 2016/09/16 18:43:53 Is this needed?
sammiequon 2016/09/16 19:21:03 Done.
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 LaserPointerController();
37 ~LaserPointerController() override;
38
39 // Turns the laser pointer feature on or off. The user still has to press and
40 // drag to see the laser pointer.
41 void SetEnabled(bool enabled);
42
43 private:
44 friend class LaserPointerControllerTestApi;
45
46 // ui::EventHandler:
47 void OnMouseEvent(ui::MouseEvent* event) override;
48
49 // aura::WindowObserver:
50 void OnWindowDestroying(aura::Window* window) override;
51
52 void StopTimer();
jdufault 2016/09/16 18:43:53 StopStationaryTimer?
sammiequon 2016/09/16 19:21:03 Done.
53
54 // Reparent, recreate or destroy LaserPointerView instance as needed based on
55 // the current window and the widgets window.
56 void SwitchTargetRootWindowIfNeeded(aura::Window* root_window);
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> stationary_timer_;
65 int stationary_timer_repeat_count_ = 0;
66
67 bool enabled_ = false;
68
69 // The last seen mouse location in screen coordinates.
70 gfx::Point current_mouse_location_;
71
72 // |laser_pointer_view_| will only hold an instance when the laser pointer is
73 // enabled and activated (pressed or dragged).
74 std::unique_ptr<LaserPointerView> laser_pointer_view_;
75
76 DISALLOW_COPY_AND_ASSIGN(LaserPointerController);
77 };
78
79 } // namespace ash
80
81 #endif // ASH_LASER_LASER_POINTER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698