| 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..e3dd70b820075639afb3483eb57b43731d4113c8
|
| --- /dev/null
|
| +++ b/ash/common/system/chromeos/palette/tools/laser_pointer_points.h
|
| @@ -0,0 +1,74 @@
|
| +// 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 trailing tail.
|
| +class LaserPointerPoints {
|
| + public:
|
| + // Struct to describe each point.
|
| + struct LaserPointerPoint {
|
| + gfx::Point location_;
|
| + base::Time creationTime_;
|
| + };
|
| +
|
| + // Constructor with a parameter to choose the fade out time off the points in
|
| + // the collection.
|
| + LaserPointerPoints(base::TimeDelta life_duration);
|
| + LaserPointerPoints(const LaserPointerPoints& old);
|
| + ~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_
|
|
|