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 // LaserPointerPoints is a helper class used for displaying the palette tool | |
jdufault
2016/08/11 23:41:54
Newline above the comment.
| |
18 // laser pointer. It keeps track of the points needed to render the laser | |
19 // pointer and its trailing tail. | |
jdufault
2016/08/11 23:41:54
drop trailing
| |
20 class LaserPointerPoints { | |
21 public: | |
22 // Struct to describe each point. | |
23 struct LaserPointerPoint { | |
jdufault
2016/08/11 23:41:54
Just Point
| |
24 gfx::Point location_; | |
jdufault
2016/08/11 23:41:54
Public variables should not have a trailing _
| |
25 base::Time creationTime_; | |
26 }; | |
27 | |
28 // Constructor with a parameter to choose the fade out time off the points in | |
29 // the collection. | |
30 LaserPointerPoints(base::TimeDelta life_duration); | |
jdufault
2016/08/11 23:41:54
explicit
| |
31 LaserPointerPoints(const LaserPointerPoints& old); | |
jdufault
2016/08/11 23:41:54
We need to copy this object?
| |
32 ~LaserPointerPoints(); | |
33 | |
34 // Adds a point. Automatically clears points that are too old. | |
35 void AddPoint(const gfx::Point& point); | |
36 // Removes all points. | |
37 void Clear(); | |
38 // Gets the bounding box of the points. | |
39 gfx::Rect GetBoundingBox() const; | |
40 // Returns the oldest point in the collection. | |
41 LaserPointerPoint GetOldest() const; | |
42 // Returns the newest point in the collection. | |
43 LaserPointerPoint GetMostRecent() const; | |
44 // Returns the number of points in the collection. | |
45 int GetNumberOfPoints() const; | |
46 // Whether there are any points or not. | |
47 bool IsEmpty() const; | |
48 | |
49 // Expose the iterator so callers can work with the points. | |
50 std::deque<LaserPointerPoint>::const_iterator PointsStart() const; | |
51 std::deque<LaserPointerPoint>::const_iterator PointsEnd() const; | |
52 | |
53 private: | |
54 // Determines the distance of the points. | |
55 float DistanceMousePoints(const LaserPointerPoint& point1, | |
56 const LaserPointerPoint& point2); | |
57 // Generates extra points in an attempt to make the tail look smoother. | |
58 void GenerateCurvePoints(const LaserPointerPoint& newPoint, | |
59 std::vector<LaserPointerPoint>& generatedPoints); | |
60 // Computes the new cummulative bounding box of the points. | |
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<LaserPointerPoint> points_; | |
71 }; | |
72 | |
73 } // namespace ash | |
74 | |
75 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_H_ | |
OLD | NEW |