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

Unified Diff: ui/gfx/point_f.h

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: vector length and conversion to size Created 8 years, 2 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
« ui/gfx/point.h ('K') | « ui/gfx/point_base.h ('k') | ui/gfx/point_f.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/point_f.h
diff --git a/ui/gfx/point_f.h b/ui/gfx/point_f.h
index d6cded9c6fe11a7380518e6d35426862d19a6043..93ee67fb611011e268b16d1665eaf0da7f278972 100644
--- a/ui/gfx/point_f.h
+++ b/ui/gfx/point_f.h
@@ -9,11 +9,12 @@
#include "ui/base/ui_export.h"
#include "ui/gfx/point_base.h"
+#include "ui/gfx/vector2d_f.h"
namespace gfx {
// A floating version of gfx::Point.
-class UI_EXPORT PointF : public PointBase<PointF, float> {
+class UI_EXPORT PointF : public PointBase<PointF, float, Vector2dF> {
public:
PointF();
PointF(float x, float y);
@@ -39,16 +40,24 @@ inline bool operator!=(const PointF& lhs, const PointF& rhs) {
return !(lhs == rhs);
}
-inline PointF operator+(PointF lhs, PointF rhs) {
+inline PointF operator+(PointF lhs, Vector2dF rhs) {
sky 2012/10/26 20:22:17 const& on both
return lhs.Add(rhs);
}
-inline PointF operator-(PointF lhs, PointF rhs) {
+inline PointF operator-(PointF lhs, Vector2dF rhs) {
sky 2012/10/26 20:22:17 const& on both
return lhs.Subtract(rhs);
}
+inline Vector2dF operator-(PointF lhs, PointF rhs) {
sky 2012/10/26 20:22:17 const& on both
+ return lhs.DistanceFrom(rhs);
+}
+
+inline PointF PointAtDistanceFromOrigin(const Vector2dF& distance_from_origin) {
+ return PointF(distance_from_origin.x(), distance_from_origin.y());
+}
+
#if !defined(COMPILER_MSVC)
-extern template class PointBase<PointF, float>;
+extern template class PointBase<PointF, float, Vector2dF>;
#endif
} // namespace gfx
« ui/gfx/point.h ('K') | « ui/gfx/point_base.h ('k') | ui/gfx/point_f.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698