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 |
| 11 #include "base/time/time.h" |
| 12 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/geometry/rect.h" |
| 14 |
| 15 namespace ash { |
| 16 |
| 17 // LaserPointerPoints is a helper class used for displaying the palette tool |
| 18 // laser pointer. It keeps track of the points needed to render the laser |
| 19 // pointer and its tail. |
| 20 class LaserPointerPoints { |
| 21 public: |
| 22 // Struct to describe each point. |
| 23 struct LaserPoint { |
| 24 gfx::Point location; |
| 25 base::Time creation_time; |
| 26 }; |
| 27 |
| 28 // Constructor with a parameter to choose the fade out time of the points in |
| 29 // the collection. |
| 30 explicit LaserPointerPoints(base::TimeDelta life_duration); |
| 31 ~LaserPointerPoints(); |
| 32 |
| 33 // Adds a point. Automatically clears points that are too old. |
| 34 void AddPoint(const gfx::Point& point); |
| 35 // Removes all points. |
| 36 void Clear(); |
| 37 // Gets the bounding box of the points. |
| 38 gfx::Rect GetBoundingBox(); |
| 39 // Returns the oldest point in the collection. |
| 40 LaserPoint GetOldest() const; |
| 41 // Returns the newest point in the collection. |
| 42 LaserPoint GetMostRecent() const; |
| 43 // Returns the number of points in the collection. |
| 44 int GetNumberOfPoints() const; |
| 45 // Whether there are any points or not. |
| 46 bool IsEmpty() const; |
| 47 |
| 48 // Expose the iterator so callers can work with the points. |
| 49 std::deque<LaserPoint>::const_iterator PointsStart() const; |
| 50 std::deque<LaserPoint>::const_iterator PointsEnd() const; |
| 51 |
| 52 private: |
| 53 friend class LaserPointerPointsTestApi; |
| 54 |
| 55 void ClearOldPoints(); |
| 56 |
| 57 base::TimeDelta life_duration_; |
| 58 std::deque<LaserPoint> points_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(LaserPointerPoints); |
| 61 }; |
| 62 |
| 63 } // namespace ash |
| 64 |
| 65 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_H_ |
OLD | NEW |