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

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: RenderText fixup 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
Index: ui/gfx/point.h
diff --git a/ui/gfx/point.h b/ui/gfx/point.h
index 5984d74655d9ab14ddda6074f703e72e7ad88da0..2e476d0e061464af2111e431ab551fa9ce21ec2f 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> {
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+(const Point& lhs, const Vector2d& rhs) {
return lhs.Add(rhs);
}
-inline Point operator-(Point lhs, Point rhs) {
+inline Point operator-(const Point& lhs, const Vector2d& rhs) {
return lhs.Subtract(rhs);
}
+inline Vector2d operator-(const Point& lhs, const Point& rhs) {
+ return lhs.OffsetFrom(rhs);
+}
+
+inline Point PointAtOffsetFromOrigin(const Vector2d& offset_from_origin) {
+ return Point(offset_from_origin.x(), offset_from_origin.y());
+}
+
#if !defined(COMPILER_MSVC)
-extern template class PointBase<Point, int>;
+extern template class PointBase<Point, int, Vector2d>;
#endif
} // namespace gfx

Powered by Google App Engine
This is Rietveld 408576698