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

Side by Side Diff: ash/common/system/chromeos/palette/tools/laser_pointer_points.h

Issue 2239743004: Palette tool laser prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch
Patch Set: Fixed patch set 8 errors. Created 4 years, 4 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_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 GetNewest() 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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698