| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_GFX_GEOMETRY_POINT_H_ | 5 #ifndef UI_GFX_GEOMETRY_POINT_H_ |
| 6 #define UI_GFX_GEOMETRY_POINT_H_ | 6 #define UI_GFX_GEOMETRY_POINT_H_ |
| 7 | 7 |
| 8 #include <iosfwd> | 8 #include <iosfwd> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <tuple> | 10 #include <tuple> |
| 11 | 11 |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "ui/gfx/geometry/vector2d.h" | 13 #include "ui/gfx/geometry/vector2d.h" |
| 14 #include "ui/gfx/gfx_export.h" | 14 #include "ui/gfx/gfx_export.h" |
| 15 | 15 |
| 16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
| 17 typedef unsigned long DWORD; | 17 typedef unsigned long DWORD; |
| 18 typedef struct tagPOINT POINT; | 18 typedef struct tagPOINT POINT; |
| 19 #elif defined(OS_MACOSX) | 19 #elif defined(OS_MACOSX) |
| 20 typedef struct CGPoint CGPoint; | 20 typedef struct CGPoint CGPoint; |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 namespace gfx { | 23 namespace gfx { |
| 24 | 24 |
| 25 // A point has an x and y coordinate. | 25 // A point has an x and y coordinate. |
| 26 class GFX_EXPORT Point { | 26 class GFX_EXPORT Point { |
| 27 public: | 27 public: |
| 28 Point() : x_(0), y_(0) {} | 28 constexpr Point() : x_(0), y_(0) {} |
| 29 Point(int x, int y) : x_(x), y_(y) {} | 29 constexpr Point(int x, int y) : x_(x), y_(y) {} |
| 30 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
| 31 // |point| is a DWORD value that contains a coordinate. The x-coordinate is | 31 // |point| is a DWORD value that contains a coordinate. The x-coordinate is |
| 32 // the low-order short and the y-coordinate is the high-order short. This | 32 // the low-order short and the y-coordinate is the high-order short. This |
| 33 // value is commonly acquired from GetMessagePos/GetCursorPos. | 33 // value is commonly acquired from GetMessagePos/GetCursorPos. |
| 34 explicit Point(DWORD point); | 34 explicit Point(DWORD point); |
| 35 explicit Point(const POINT& point); | 35 explicit Point(const POINT& point); |
| 36 Point& operator=(const POINT& point); | 36 Point& operator=(const POINT& point); |
| 37 #elif defined(OS_MACOSX) | 37 #elif defined(OS_MACOSX) |
| 38 explicit Point(const CGPoint& point); | 38 explicit Point(const CGPoint& point); |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 ~Point() {} | |
| 42 | |
| 43 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 44 POINT ToPOINT() const; | 42 POINT ToPOINT() const; |
| 45 #elif defined(OS_MACOSX) | 43 #elif defined(OS_MACOSX) |
| 46 CGPoint ToCGPoint() const; | 44 CGPoint ToCGPoint() const; |
| 47 #endif | 45 #endif |
| 48 | 46 |
| 49 int x() const { return x_; } | 47 constexpr int x() const { return x_; } |
| 50 int y() const { return y_; } | 48 constexpr int y() const { return y_; } |
| 51 void set_x(int x) { x_ = x; } | 49 void set_x(int x) { x_ = x; } |
| 52 void set_y(int y) { y_ = y; } | 50 void set_y(int y) { y_ = y; } |
| 53 | 51 |
| 54 void SetPoint(int x, int y) { | 52 void SetPoint(int x, int y) { |
| 55 x_ = x; | 53 x_ = x; |
| 56 y_ = y; | 54 y_ = y; |
| 57 } | 55 } |
| 58 | 56 |
| 59 void Offset(int delta_x, int delta_y) { | 57 void Offset(int delta_x, int delta_y) { |
| 60 x_ += delta_x; | 58 x_ += delta_x; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 float y_scale); | 137 float y_scale); |
| 140 GFX_EXPORT Point ScaleToFlooredPoint(const Point& point, float x_scale); | 138 GFX_EXPORT Point ScaleToFlooredPoint(const Point& point, float x_scale); |
| 141 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point, | 139 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point, |
| 142 float x_scale, | 140 float x_scale, |
| 143 float y_scale); | 141 float y_scale); |
| 144 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point, float x_scale); | 142 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point, float x_scale); |
| 145 | 143 |
| 146 } // namespace gfx | 144 } // namespace gfx |
| 147 | 145 |
| 148 #endif // UI_GFX_GEOMETRY_POINT_H_ | 146 #endif // UI_GFX_GEOMETRY_POINT_H_ |
| OLD | NEW |