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_POINTS_H_ | |
6 #define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_H_ | |
7 | |
8 #include <deque> | |
9 #include <memory> | |
10 #include <vector> | |
11 | |
12 #include "base/timer/timer.h" | |
13 #include "ui/gfx/geometry/point.h" | |
14 #include "ui/gfx/geometry/rect.h" | |
15 | |
16 namespace ash { | |
17 | |
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 | |
20 // pointer and its tail. | |
21 class LaserPointerPoints { | |
22 public: | |
23 // Struct to describe each point. | |
24 struct LaserPoint { | |
25 gfx::Point location; | |
26 base::Time creationTime; | |
jdufault
2016/08/12 19:57:59
creation_time
sammiequon
2016/08/16 17:00:05
Done.
| |
27 }; | |
28 | |
29 // Constructor with a parameter to choose the fade out time off the points in | |
30 // the collection. | |
31 explicit LaserPointerPoints(base::TimeDelta life_duration); | |
32 LaserPointerPoints(const LaserPointerPoints& old); | |
jdufault
2016/08/12 19:57:59
Do we need copy ctor?
Can we add DISALLOW_COPY_AN
sammiequon
2016/08/16 17:00:05
Done.
| |
33 ~LaserPointerPoints(); | |
34 | |
35 // Adds a point. Automatically clears points that are too old. | |
36 void AddPoint(const gfx::Point& point); | |
37 // Removes all points. | |
38 void Clear(); | |
39 // Gets the bounding box of the points. | |
40 gfx::Rect GetBoundingBox() const; | |
41 // Returns the oldest point in the collection. | |
42 LaserPoint GetOldest() const; | |
43 // Returns the newest point in the collection. | |
44 LaserPoint GetMostRecent() const; | |
45 // Returns the number of points in the collection. | |
46 int GetNumberOfPoints() const; | |
47 // Whether there are any points or not. | |
48 bool IsEmpty() const; | |
49 | |
50 // Expose the iterator so callers can work with the points. | |
51 std::deque<LaserPoint>::const_iterator PointsStart() const; | |
52 std::deque<LaserPoint>::const_iterator PointsEnd() const; | |
53 | |
54 private: | |
55 // Determines the distance of the points. | |
56 float DistanceMousePoints(const LaserPoint& point1, const LaserPoint& point2); | |
jdufault
2016/08/12 19:57:59
DistanceBetween?
Move this function to anonymous
sammiequon
2016/08/16 17:00:05
Done.
| |
57 // Generates extra points in an attempt to make the tail look smoother. | |
58 void GenerateCurvePoints(const LaserPoint& newPoint, | |
jdufault
2016/08/12 19:57:59
new_point
sammiequon
2016/08/16 17:00:05
Done.
| |
59 std::vector<LaserPoint>& generatedPoints); | |
jdufault
2016/08/12 19:57:59
generated_points
sammiequon
2016/08/16 17:00:05
Done.
| |
60 // Computes the new cummulative bounding box of the points. | |
jdufault
2016/08/12 19:57:59
Spelling; cummulative => cumulative
What does |po
sammiequon
2016/08/16 17:00:05
Done.
| |
61 void CalculateBounds(const gfx::Point& point); | |
62 void ClearOldPoints(); | |
63 // Computes the bounding box of the points from scratch. Iterates over the | |
64 // entire collection. | |
65 void RecalculateBounds(); | |
66 | |
67 base::TimeDelta life_duration_; | |
68 gfx::Rect bounds_; | |
69 // The collection of points. | |
70 std::deque<LaserPoint> points_; | |
71 }; | |
72 | |
73 } // namespace ash | |
74 | |
75 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_H_ | |
OLD | NEW |