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 // Defines a simple integer rectangle class. The containment semantics | 5 // Defines a simple integer rectangle class. The containment semantics |
6 // are array-like; that is, the coordinate (x, y) is considered to be | 6 // are array-like; that is, the coordinate (x, y) is considered to be |
7 // contained by the rectangle, but the coordinate (x + width, y) is not. | 7 // contained by the rectangle, but the coordinate (x + width, y) is not. |
8 // The class will happily let you create malformed rectangles (that is, | 8 // The class will happily let you create malformed rectangles (that is, |
9 // rectangles with negative width and/or height), but there will be assertions | 9 // rectangles with negative width and/or height), but there will be assertions |
10 // in the operations (such as Contains()) to complain in this case. | 10 // in the operations (such as Contains()) to complain in this case. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 }; | 70 }; |
71 | 71 |
72 inline bool operator==(const Rect& lhs, const Rect& rhs) { | 72 inline bool operator==(const Rect& lhs, const Rect& rhs) { |
73 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); | 73 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); |
74 } | 74 } |
75 | 75 |
76 inline bool operator!=(const Rect& lhs, const Rect& rhs) { | 76 inline bool operator!=(const Rect& lhs, const Rect& rhs) { |
77 return !(lhs == rhs); | 77 return !(lhs == rhs); |
78 } | 78 } |
79 | 79 |
80 UI_EXPORT Rect operator+(const Rect& lhs, const Vector2d& rhs); | |
81 UI_EXPORT Rect operator-(const Rect& lhs, const Vector2d& rhs); | |
Peter Kasting
2012/11/09 22:02:36
Nit: Probably want to define operators for the opp
danakj
2012/11/09 22:10:10
I was wondering about that as well.
Is it as easy
| |
82 | |
80 UI_EXPORT Rect IntersectRects(const Rect& a, const Rect& b); | 83 UI_EXPORT Rect IntersectRects(const Rect& a, const Rect& b); |
81 UI_EXPORT Rect UnionRects(const Rect& a, const Rect& b); | 84 UI_EXPORT Rect UnionRects(const Rect& a, const Rect& b); |
82 UI_EXPORT Rect SubtractRects(const Rect& a, const Rect& b); | 85 UI_EXPORT Rect SubtractRects(const Rect& a, const Rect& b); |
83 | 86 |
84 // Constructs a rectangle with |p1| and |p2| as opposite corners. | 87 // Constructs a rectangle with |p1| and |p2| as opposite corners. |
85 // | 88 // |
86 // This could also be thought of as "the smallest rect that contains both | 89 // This could also be thought of as "the smallest rect that contains both |
87 // points", except that we consider points on the right/bottom edges of the | 90 // points", except that we consider points on the right/bottom edges of the |
88 // rect to be outside the rect. So technically one or both points will not be | 91 // rect to be outside the rect. So technically one or both points will not be |
89 // contained within the rect, because they will appear on one of these edges. | 92 // contained within the rect, because they will appear on one of these edges. |
90 UI_EXPORT Rect BoundingRect(const Point& p1, const Point& p2); | 93 UI_EXPORT Rect BoundingRect(const Point& p1, const Point& p2); |
91 | 94 |
92 #if !defined(COMPILER_MSVC) | 95 #if !defined(COMPILER_MSVC) |
93 extern template class RectBase<Rect, Point, Size, Insets, Vector2d, int>; | 96 extern template class RectBase<Rect, Point, Size, Insets, Vector2d, int>; |
94 #endif | 97 #endif |
95 | 98 |
96 } // namespace gfx | 99 } // namespace gfx |
97 | 100 |
98 #endif // UI_GFX_RECT_H_ | 101 #endif // UI_GFX_RECT_H_ |
OLD | NEW |