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_RECT_F_H_ | 5 #ifndef UI_GFX_GEOMETRY_RECT_F_H_ |
6 #define UI_GFX_GEOMETRY_RECT_F_H_ | 6 #define UI_GFX_GEOMETRY_RECT_F_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ui/gfx/geometry/point_f.h" | 11 #include "ui/gfx/geometry/point_f.h" |
12 #include "ui/gfx/geometry/size_f.h" | 12 #include "ui/gfx/geometry/size_f.h" |
13 #include "ui/gfx/geometry/vector2d_f.h" | 13 #include "ui/gfx/geometry/vector2d_f.h" |
14 | 14 |
| 15 #if defined(OS_MACOSX) |
| 16 typedef struct CGRect CGRect; |
| 17 #endif |
| 18 |
15 namespace gfx { | 19 namespace gfx { |
16 | 20 |
17 class InsetsF; | 21 class InsetsF; |
18 | 22 |
19 // A floating version of gfx::Rect. | 23 // A floating version of gfx::Rect. |
20 class GFX_EXPORT RectF { | 24 class GFX_EXPORT RectF { |
21 public: | 25 public: |
22 RectF() {} | 26 RectF() {} |
23 RectF(float width, float height) : size_(width, height) {} | 27 RectF(float width, float height) : size_(width, height) {} |
24 RectF(float x, float y, float width, float height) | 28 RectF(float x, float y, float width, float height) |
25 : origin_(x, y), size_(width, height) {} | 29 : origin_(x, y), size_(width, height) {} |
26 explicit RectF(const SizeF& size) : size_(size) {} | 30 explicit RectF(const SizeF& size) : size_(size) {} |
27 RectF(const PointF& origin, const SizeF& size) | 31 RectF(const PointF& origin, const SizeF& size) |
28 : origin_(origin), size_(size) {} | 32 : origin_(origin), size_(size) {} |
29 | 33 |
| 34 #if defined(OS_MACOSX) |
| 35 explicit RectF(const CGRect& r); |
| 36 // Construct an equivalent CoreGraphics object. |
| 37 CGRect ToCGRect() const; |
| 38 #endif |
| 39 |
30 ~RectF() {} | 40 ~RectF() {} |
31 | 41 |
32 float x() const { return origin_.x(); } | 42 float x() const { return origin_.x(); } |
33 void set_x(float x) { origin_.set_x(x); } | 43 void set_x(float x) { origin_.set_x(x); } |
34 | 44 |
35 float y() const { return origin_.y(); } | 45 float y() const { return origin_.y(); } |
36 void set_y(float y) { origin_.set_y(y); } | 46 void set_y(float y) { origin_.set_y(y); } |
37 | 47 |
38 float width() const { return size_.width(); } | 48 float width() const { return size_.width(); } |
39 void set_width(float width) { size_.set_width(width); } | 49 void set_width(float width) { size_.set_width(width); } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 GFX_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2); | 227 GFX_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2); |
218 | 228 |
219 // This is declared here for use in gtest-based unit tests but is defined in | 229 // This is declared here for use in gtest-based unit tests but is defined in |
220 // the gfx_test_support target. Depend on that to use this in your unit test. | 230 // the gfx_test_support target. Depend on that to use this in your unit test. |
221 // This should not be used in production code - call ToString() instead. | 231 // This should not be used in production code - call ToString() instead. |
222 void PrintTo(const RectF& rect, ::std::ostream* os); | 232 void PrintTo(const RectF& rect, ::std::ostream* os); |
223 | 233 |
224 } // namespace gfx | 234 } // namespace gfx |
225 | 235 |
226 #endif // UI_GFX_GEOMETRY_RECT_F_H_ | 236 #endif // UI_GFX_GEOMETRY_RECT_F_H_ |
OLD | NEW |