| 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_F_H_ | 5 #ifndef UI_GFX_GEOMETRY_POINT_F_H_ |
| 6 #define UI_GFX_GEOMETRY_POINT_F_H_ | 6 #define UI_GFX_GEOMETRY_POINT_F_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 "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/geometry/vector2d_f.h" | 13 #include "ui/gfx/geometry/vector2d_f.h" |
| 14 #include "ui/gfx/gfx_export.h" | 14 #include "ui/gfx/gfx_export.h" |
| 15 | 15 |
| 16 namespace gfx { | 16 namespace gfx { |
| 17 | 17 |
| 18 // A floating version of gfx::Point. | 18 // A floating version of gfx::Point. |
| 19 class GFX_EXPORT PointF { | 19 class GFX_EXPORT PointF { |
| 20 public: | 20 public: |
| 21 PointF() : x_(0.f), y_(0.f) {} | 21 constexpr PointF() : x_(0.f), y_(0.f) {} |
| 22 PointF(float x, float y) : x_(x), y_(y) {} | 22 constexpr PointF(float x, float y) : x_(x), y_(y) {} |
| 23 ~PointF() {} | |
| 24 | 23 |
| 25 explicit PointF(const Point& p) | 24 constexpr explicit PointF(const Point& p) |
| 26 : PointF(static_cast<float>(p.x()), static_cast<float>(p.y())) {} | 25 : PointF(static_cast<float>(p.x()), static_cast<float>(p.y())) {} |
| 27 | 26 |
| 28 float x() const { return x_; } | 27 constexpr float x() const { return x_; } |
| 29 float y() const { return y_; } | 28 constexpr float y() const { return y_; } |
| 30 void set_x(float x) { x_ = x; } | 29 void set_x(float x) { x_ = x; } |
| 31 void set_y(float y) { y_ = y; } | 30 void set_y(float y) { y_ = y; } |
| 32 | 31 |
| 33 void SetPoint(float x, float y) { | 32 void SetPoint(float x, float y) { |
| 34 x_ = x; | 33 x_ = x; |
| 35 y_ = y; | 34 y_ = y; |
| 36 } | 35 } |
| 37 | 36 |
| 38 void Offset(float delta_x, float delta_y) { | 37 void Offset(float delta_x, float delta_y) { |
| 39 x_ += delta_x; | 38 x_ += delta_x; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 117 } |
| 119 | 118 |
| 120 // This is declared here for use in gtest-based unit tests but is defined in | 119 // This is declared here for use in gtest-based unit tests but is defined in |
| 121 // the gfx_test_support target. Depend on that to use this in your unit test. | 120 // the gfx_test_support target. Depend on that to use this in your unit test. |
| 122 // This should not be used in production code - call ToString() instead. | 121 // This should not be used in production code - call ToString() instead. |
| 123 void PrintTo(const PointF& point, ::std::ostream* os); | 122 void PrintTo(const PointF& point, ::std::ostream* os); |
| 124 | 123 |
| 125 } // namespace gfx | 124 } // namespace gfx |
| 126 | 125 |
| 127 #endif // UI_GFX_GEOMETRY_POINT_F_H_ | 126 #endif // UI_GFX_GEOMETRY_POINT_F_H_ |
| OLD | NEW |