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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 void ClampToCenteredSize(const SizeClass& size); | 138 void ClampToCenteredSize(const SizeClass& size); |
139 | 139 |
140 // Splits |this| in two halves, |left_half| and |right_half|. | 140 // Splits |this| in two halves, |left_half| and |right_half|. |
141 void SplitVertically(Class* left_half, Class* right_half) const; | 141 void SplitVertically(Class* left_half, Class* right_half) const; |
142 | 142 |
143 // Returns true if this rectangle shares an entire edge (i.e., same width or | 143 // Returns true if this rectangle shares an entire edge (i.e., same width or |
144 // same height) with the given rectangle, and the rectangles do not overlap. | 144 // same height) with the given rectangle, and the rectangles do not overlap. |
145 bool SharesEdgeWith(const Class& rect) const; | 145 bool SharesEdgeWith(const Class& rect) const; |
146 | 146 |
147 protected: | 147 protected: |
148 RectBase(const PointClass& origin, const SizeClass& size); | 148 RectBase(const PointClass& origin, const SizeClass& size) |
149 explicit RectBase(const SizeClass& size); | 149 : origin_(origin), size_(size) {} |
150 explicit RectBase(const PointClass& origin); | 150 explicit RectBase(const SizeClass& size) |
| 151 : size_(size) {} |
| 152 explicit RectBase(const PointClass& origin) |
| 153 : origin_(origin) {} |
151 // Destructor is intentionally made non virtual and protected. | 154 // Destructor is intentionally made non virtual and protected. |
152 // Do not make this public. | 155 // Do not make this public. |
153 ~RectBase(); | 156 ~RectBase() {} |
154 | 157 |
155 private: | 158 private: |
156 PointClass origin_; | 159 PointClass origin_; |
157 SizeClass size_; | 160 SizeClass size_; |
158 }; | 161 }; |
159 | 162 |
160 } // namespace gfx | 163 } // namespace gfx |
161 | 164 |
162 #endif // UI_GFX_RECT_BASE_H_ | 165 #endif // UI_GFX_RECT_BASE_H_ |
OLD | NEW |