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

Unified Diff: ui/gfx/point.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: build 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
« no previous file with comments | « ui/gfx/canvas.cc ('k') | ui/gfx/point.cc » ('j') | ui/gfx/vector2d.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/point.h
diff --git a/ui/gfx/point.h b/ui/gfx/point.h
index 5984d74655d9ab14ddda6074f703e72e7ad88da0..ae8247675d538532ca03d1a217c45fe33b252d66 100644
--- a/ui/gfx/point.h
+++ b/ui/gfx/point.h
@@ -8,6 +8,7 @@
#include "ui/base/ui_export.h"
#include "ui/gfx/point_base.h"
#include "ui/gfx/point_f.h"
+#include "ui/gfx/vector2d.h"
#if defined(OS_WIN)
typedef unsigned long DWORD;
@@ -21,7 +22,7 @@ typedef struct tagPOINT POINT;
namespace gfx {
// A point has an x and y coordinate.
-class UI_EXPORT Point : public PointBase<Point, int> {
+ class UI_EXPORT Point : public PointBase<Point, int, Vector2d> {
tfarina 2012/10/25 00:41:53 nit: indent less two spaces back! somehow you mess
danakj 2012/10/25 00:59:09 Done.
public:
Point();
Point(int x, int y);
@@ -68,16 +69,24 @@ inline bool operator!=(const Point& lhs, const Point& rhs) {
return !(lhs == rhs);
}
-inline Point operator+(Point lhs, Point rhs) {
+inline Point operator+(Point lhs, Vector2d rhs) {
return lhs.Add(rhs);
}
-inline Point operator-(Point lhs, Point rhs) {
+inline Point operator-(Point lhs, Vector2d rhs) {
return lhs.Subtract(rhs);
}
+inline Vector2d operator-(Point lhs, Point rhs) {
+ return lhs.DistanceFrom(rhs);
+}
+
+inline Point PointAtDistanceFromOrigin(const Vector2d& distance_from_origin) {
+ return Point(distance_from_origin.x(), distance_from_origin.y());
+}
+
#if !defined(COMPILER_MSVC)
-extern template class PointBase<Point, int>;
+extern template class PointBase<Point, int, Vector2d>;
#endif
} // namespace gfx
« no previous file with comments | « ui/gfx/canvas.cc ('k') | ui/gfx/point.cc » ('j') | ui/gfx/vector2d.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698