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

Unified 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: Addressed comments from issue 2231533004. 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..d8fea28d3c21cb30029858f339bf15ab25fb5eb8
--- /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
+// laser pointer. It keeps track of the points needed to render the laser
+// pointer and its tail.
+class LaserPointerPoints {
+ public:
+ // Struct to describe each point.
+ struct LaserPoint {
+ gfx::Point location;
+ base::Time creationTime;
jdufault 2016/08/12 19:57:59 creation_time
sammiequon 2016/08/16 17:00:05 Done.
+ };
+
+ // Constructor with a parameter to choose the fade out time off the points in
+ // the collection.
+ explicit LaserPointerPoints(base::TimeDelta life_duration);
+ 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.
+ ~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.
+ LaserPoint GetOldest() const;
+ // Returns the newest point in the collection.
+ LaserPoint 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<LaserPoint>::const_iterator PointsStart() const;
+ std::deque<LaserPoint>::const_iterator PointsEnd() const;
+
+ private:
+ // Determines the distance of the points.
+ 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.
+ // Generates extra points in an attempt to make the tail look smoother.
+ void GenerateCurvePoints(const LaserPoint& newPoint,
jdufault 2016/08/12 19:57:59 new_point
sammiequon 2016/08/16 17:00:05 Done.
+ std::vector<LaserPoint>& generatedPoints);
jdufault 2016/08/12 19:57:59 generated_points
sammiequon 2016/08/16 17:00:05 Done.
+ // 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.
+ 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<LaserPoint> points_;
+};
+
+} // namespace ash
+
+#endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_H_

Powered by Google App Engine
This is Rietveld 408576698