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

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

Issue 2231533004: Pointer watcher modifications to support laser pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Initial patch. 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 side-by-side diff with in-line comments
Download patch
Index: ash/common/system/chromeos/palette/tools/laser_pointer_points.h
diff --git a/ash/common/system/chromeos/palette/tools/laser_pointer_points.h b/ash/common/system/chromeos/palette/tools/laser_pointer_points.h
new file mode 100644
index 0000000000000000000000000000000000000000..be22738a4c07663ce6151252847b28dc2cfc764c
--- /dev/null
+++ b/ash/common/system/chromeos/palette/tools/laser_pointer_points.h
@@ -0,0 +1,75 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_H_
+#define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_H_
+
+#include <deque>
+#include <memory>
+#include <vector>
+
+#include "base/timer/timer.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/rect.h"
+
+namespace ash {
+// LaserPointerPoints is a helper class used for displaying the palette tool
jdufault 2016/08/11 23:41:54 Newline above the comment.
+// laser pointer. It keeps track of the points needed to render the laser
+// pointer and its trailing tail.
jdufault 2016/08/11 23:41:54 drop trailing
+class LaserPointerPoints {
+ public:
+ // Struct to describe each point.
+ struct LaserPointerPoint {
jdufault 2016/08/11 23:41:54 Just Point
+ gfx::Point location_;
jdufault 2016/08/11 23:41:54 Public variables should not have a trailing _
+ base::Time creationTime_;
+ };
+
+ // Constructor with a parameter to choose the fade out time off the points in
+ // the collection.
+ LaserPointerPoints(base::TimeDelta life_duration);
jdufault 2016/08/11 23:41:54 explicit
+ LaserPointerPoints(const LaserPointerPoints& old);
jdufault 2016/08/11 23:41:54 We need to copy this object?
+ ~LaserPointerPoints();
+
+ // Adds a point. Automatically clears points that are too old.
+ void AddPoint(const gfx::Point& point);
+ // Removes all points.
+ void Clear();
+ // Gets the bounding box of the points.
+ gfx::Rect GetBoundingBox() const;
+ // Returns the oldest point in the collection.
+ LaserPointerPoint GetOldest() const;
+ // Returns the newest point in the collection.
+ LaserPointerPoint GetMostRecent() const;
+ // Returns the number of points in the collection.
+ int GetNumberOfPoints() const;
+ // Whether there are any points or not.
+ bool IsEmpty() const;
+
+ // Expose the iterator so callers can work with the points.
+ std::deque<LaserPointerPoint>::const_iterator PointsStart() const;
+ std::deque<LaserPointerPoint>::const_iterator PointsEnd() const;
+
+ private:
+ // Determines the distance of the points.
+ float DistanceMousePoints(const LaserPointerPoint& point1,
+ const LaserPointerPoint& point2);
+ // Generates extra points in an attempt to make the tail look smoother.
+ void GenerateCurvePoints(const LaserPointerPoint& newPoint,
+ std::vector<LaserPointerPoint>& generatedPoints);
+ // Computes the new cummulative bounding box of the points.
+ void CalculateBounds(const gfx::Point& point);
+ void ClearOldPoints();
+ // Computes the bounding box of the points from scratch. Iterates over the
+ // entire collection.
+ void RecalculateBounds();
+
+ base::TimeDelta life_duration_;
+ gfx::Rect bounds_;
+ // The collection of points.
+ std::deque<LaserPointerPoint> points_;
+};
+
+} // namespace ash
+
+#endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_H_

Powered by Google App Engine
This is Rietveld 408576698