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

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

Issue 2362063002: cros: Laser pointer fades out on release, do not cover palette. (Closed)
Patch Set: Fixed patch set 5 errors. Created 4 years, 2 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
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_LASER_LASER_POINTER_POINTS_H_ 5 #ifndef ASH_LASER_LASER_POINTER_POINTS_H_
6 #define ASH_LASER_LASER_POINTER_POINTS_H_ 6 #define ASH_LASER_LASER_POINTER_POINTS_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <memory> 9 #include <memory>
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "ui/gfx/geometry/point.h" 13 #include "ui/gfx/geometry/point.h"
14 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
15 15
16 namespace ash { 16 namespace ash {
17 17
18 // LaserPointerPoints is a helper class used for displaying the palette tool 18 // LaserPointerPoints is a helper class used for displaying the palette tool
19 // laser pointer. It keeps track of the points needed to render the laser 19 // laser pointer. It keeps track of the points needed to render the laser
20 // pointer and its tail. 20 // pointer and its tail.
21 class ASH_EXPORT LaserPointerPoints { 21 class ASH_EXPORT LaserPointerPoints {
22 public: 22 public:
23 // Struct to describe each point. 23 // Struct to describe each point.
24 struct LaserPoint { 24 struct LaserPoint {
25 gfx::Point location; 25 gfx::Point location;
26 base::Time creation_time; 26 // age is a value between [0,1] where 0 means the point was just added and 1
27 // means that the point is just about to be removed.
28 double age;
27 }; 29 };
28 30
29 // Constructor with a parameter to choose the fade out time of the points in 31 // Constructor with a parameter to choose the fade out time of the points in
30 // the collection. 32 // the collection.
31 explicit LaserPointerPoints(base::TimeDelta life_duration); 33 explicit LaserPointerPoints(base::TimeDelta life_duration);
32 ~LaserPointerPoints(); 34 ~LaserPointerPoints();
33 35
34 // Adds a point. Automatically clears points that are too old. 36 // Adds a point. Automatically clears points that are too old.
35 void AddPoint(const gfx::Point& point); 37 void AddPoint(const gfx::Point& point);
38 // Updates the collection latest time. Automatically clears points that are
39 // too old.
40 void MoveForwardToCurrentTime();
jdufault 2016/10/05 21:36:05 It looks like this is only used once. I don't thin
sammiequon 2016/10/06 00:19:15 Done.
41 void MoveForwardToTime(const base::Time& new_latest_time);
36 // Removes all points. 42 // Removes all points.
37 void Clear(); 43 void Clear();
38 // Gets the bounding box of the points. 44 // Gets the bounding box of the points.
39 gfx::Rect GetBoundingBox(); 45 gfx::Rect GetBoundingBox();
40 // Returns the oldest point in the collection. 46 // Returns the oldest point in the collection.
41 LaserPoint GetOldest() const; 47 LaserPoint GetOldest() const;
42 // Returns the newest point in the collection. 48 // Returns the newest point in the collection.
43 LaserPoint GetNewest() const; 49 LaserPoint GetNewest() const;
44 // Returns the number of points in the collection. 50 // Returns the number of points in the collection.
45 int GetNumberOfPoints() const; 51 int GetNumberOfPoints() const;
46 // Whether there are any points or not. 52 // Whether there are any points or not.
47 bool IsEmpty() const; 53 bool IsEmpty() const;
48 // Expose the collection so callers can work with the points. 54 // Expose the collection so callers can work with the points.
49 const std::deque<LaserPoint>& laser_points(); 55 const std::deque<LaserPoint>& laser_points();
50 56
51 private: 57 private:
52 friend class LaserPointerPointsTestApi; 58 friend class LaserPointerPointsTestApi;
53 59
54 void ClearOldPoints(); 60 void ClearOldPoints();
55 61
56 base::TimeDelta life_duration_; 62 base::TimeDelta life_duration_;
57 std::deque<LaserPoint> points_; 63 std::deque<LaserPoint> points_;
64 // The latest time of the collection of points. This gets updated when new
65 // points are added or when MoveForwardInTime is called.
66 base::Time collection_latest_time_;
58 67
59 DISALLOW_COPY_AND_ASSIGN(LaserPointerPoints); 68 DISALLOW_COPY_AND_ASSIGN(LaserPointerPoints);
60 }; 69 };
61 70
62 } // namespace ash 71 } // namespace ash
63 72
64 #endif // ASH_LASER_LASER_POINTER_POINTS_H_ 73 #endif // ASH_LASER_LASER_POINTER_POINTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698