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 // A template for a simple rectangle class. The containment semantics | 5 // A template for a simple 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 29 matching lines...) Expand all Loading... |
40 | 40 |
41 const PointClass& origin() const { return origin_; } | 41 const PointClass& origin() const { return origin_; } |
42 void set_origin(const PointClass& origin) { origin_ = origin; } | 42 void set_origin(const PointClass& origin) { origin_ = origin; } |
43 | 43 |
44 const SizeClass& size() const { return size_; } | 44 const SizeClass& size() const { return size_; } |
45 void set_size(const SizeClass& size) { size_ = size; } | 45 void set_size(const SizeClass& size) { size_ = size; } |
46 | 46 |
47 Type right() const { return x() + width(); } | 47 Type right() const { return x() + width(); } |
48 Type bottom() const { return y() + height(); } | 48 Type bottom() const { return y() + height(); } |
49 | 49 |
| 50 PointClass top_right() const { return PointClass(right(), y()); } |
| 51 PointClass bottom_left() const { return PointClass(x(), bottom()); } |
| 52 PointClass bottom_right() const { return PointClass(right(), bottom()); } |
| 53 |
50 VectorClass OffsetFromOrigin() const { | 54 VectorClass OffsetFromOrigin() const { |
51 return VectorClass(x(), y()); | 55 return VectorClass(x(), y()); |
52 } | 56 } |
53 | 57 |
54 void SetRect(Type x, Type y, Type width, Type height); | 58 void SetRect(Type x, Type y, Type width, Type height); |
55 | 59 |
56 // Shrink the rectangle by a horizontal and vertical distance on all sides. | 60 // Shrink the rectangle by a horizontal and vertical distance on all sides. |
57 void Inset(Type horizontal, Type vertical) { | 61 void Inset(Type horizontal, Type vertical) { |
58 Inset(horizontal, vertical, horizontal, vertical); | 62 Inset(horizontal, vertical, horizontal, vertical); |
59 } | 63 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 ~RectBase(); | 153 ~RectBase(); |
150 | 154 |
151 private: | 155 private: |
152 PointClass origin_; | 156 PointClass origin_; |
153 SizeClass size_; | 157 SizeClass size_; |
154 }; | 158 }; |
155 | 159 |
156 } // namespace gfx | 160 } // namespace gfx |
157 | 161 |
158 #endif // UI_GFX_RECT_BASE_H_ | 162 #endif // UI_GFX_RECT_BASE_H_ |
OLD | NEW |