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_RECT_F_H_ | 5 #ifndef UI_GFX_RECT_F_H_ |
6 #define UI_GFX_RECT_F_H_ | 6 #define UI_GFX_RECT_F_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ui/gfx/point_f.h" | 10 #include "ui/gfx/point_f.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 }; | 62 }; |
63 | 63 |
64 inline bool operator==(const RectF& lhs, const RectF& rhs) { | 64 inline bool operator==(const RectF& lhs, const RectF& rhs) { |
65 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); | 65 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); |
66 } | 66 } |
67 | 67 |
68 inline bool operator!=(const RectF& lhs, const RectF& rhs) { | 68 inline bool operator!=(const RectF& lhs, const RectF& rhs) { |
69 return !(lhs == rhs); | 69 return !(lhs == rhs); |
70 } | 70 } |
71 | 71 |
72 UI_EXPORT RectF operator+(const RectF& lhs, const Vector2dF& rhs); | 72 inline RectF operator+(const RectF& lhs, const Vector2dF& rhs) { |
73 UI_EXPORT RectF operator-(const RectF& lhs, const Vector2dF& rhs); | 73 return RectF(lhs.x() + rhs.x(), lhs.y() + rhs.y(), |
74 lhs.width(), lhs.height()); | |
75 } | |
76 | |
77 inline RectF operator-(const RectF& lhs, const Vector2dF& rhs) { | |
78 return RectF(lhs.x() - rhs.x(), lhs.y() - rhs.y(), | |
79 lhs.width(), lhs.height()); | |
80 } | |
74 | 81 |
75 inline RectF operator+(const Vector2dF& lhs, const RectF& rhs) { | 82 inline RectF operator+(const Vector2dF& lhs, const RectF& rhs) { |
76 return rhs + lhs; | 83 return rhs + lhs; |
77 } | 84 } |
78 | 85 |
79 UI_EXPORT RectF IntersectRects(const RectF& a, const RectF& b); | 86 UI_EXPORT RectF IntersectRects(const RectF& a, const RectF& b); |
80 UI_EXPORT RectF UnionRects(const RectF& a, const RectF& b); | 87 UI_EXPORT RectF UnionRects(const RectF& a, const RectF& b); |
81 UI_EXPORT RectF SubtractRects(const RectF& a, const RectF& b); | 88 UI_EXPORT RectF SubtractRects(const RectF& a, const RectF& b); |
82 UI_EXPORT RectF ScaleRect(const RectF& r, float x_scale, float y_scale); | 89 |
90 inline RectF ScaleRect(const RectF& r, float x_scale, float y_scale) { | |
91 return RectF( | |
92 r.x() * x_scale, r.y() * y_scale, | |
tfarina
2013/01/30 14:55:02
nit: this does fit above, so, please move it above
| |
93 r.width() * x_scale, r.height() * y_scale); | |
94 } | |
83 | 95 |
84 inline RectF ScaleRect(const RectF& r, float scale) { | 96 inline RectF ScaleRect(const RectF& r, float scale) { |
85 return ScaleRect(r, scale, scale); | 97 return ScaleRect(r, scale, scale); |
86 } | 98 } |
87 | 99 |
88 // Constructs a rectangle with |p1| and |p2| as opposite corners. | 100 // Constructs a rectangle with |p1| and |p2| as opposite corners. |
89 // | 101 // |
90 // This could also be thought of as "the smallest rect that contains both | 102 // This could also be thought of as "the smallest rect that contains both |
91 // points", except that we consider points on the right/bottom edges of the | 103 // points", except that we consider points on the right/bottom edges of the |
92 // rect to be outside the rect. So technically one or both points will not be | 104 // rect to be outside the rect. So technically one or both points will not be |
93 // contained within the rect, because they will appear on one of these edges. | 105 // contained within the rect, because they will appear on one of these edges. |
94 UI_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2); | 106 UI_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2); |
95 | 107 |
96 #if !defined(COMPILER_MSVC) | 108 #if !defined(COMPILER_MSVC) |
97 extern template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; | 109 extern template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; |
98 #endif | 110 #endif |
99 | 111 |
100 } // namespace gfx | 112 } // namespace gfx |
101 | 113 |
102 #endif // UI_GFX_RECT_F_H_ | 114 #endif // UI_GFX_RECT_F_H_ |
OLD | NEW |