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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 // Returns the manhattan distance from the rect to the point. If the point is | 170 // Returns the manhattan distance from the rect to the point. If the point is |
171 // inside the rect, returns 0. | 171 // inside the rect, returns 0. |
172 int ManhattanDistanceToPoint(const Point& point) const; | 172 int ManhattanDistanceToPoint(const Point& point) const; |
173 | 173 |
174 // Returns the manhattan distance between the contents of this rect and the | 174 // Returns the manhattan distance between the contents of this rect and the |
175 // contents of the given rect. That is, if the intersection of the two rects | 175 // contents of the given rect. That is, if the intersection of the two rects |
176 // is non-empty then the function returns 0. If the rects share a side, it | 176 // is non-empty then the function returns 0. If the rects share a side, it |
177 // returns the smallest non-zero value appropriate for int. | 177 // returns the smallest non-zero value appropriate for int. |
178 int ManhattanInternalDistance(const Rect& rect) const; | 178 int ManhattanInternalDistance(const Rect& rect) const; |
179 | 179 |
180 // Returns the largest distance from |point| to the corners of |this|. | |
181 float MaxDistanceToCorners(const gfx::Point& point) const; | |
sky
2016/06/16 16:50:02
This is very specialized and AFAICT only needed in
bruthig
2016/06/16 19:50:02
Done.
| |
182 | |
180 std::string ToString() const; | 183 std::string ToString() const; |
181 | 184 |
182 bool ApproximatelyEqual(const Rect& rect, int tolerance) const; | 185 bool ApproximatelyEqual(const Rect& rect, int tolerance) const; |
183 | 186 |
184 private: | 187 private: |
185 gfx::Point origin_; | 188 gfx::Point origin_; |
186 gfx::Size size_; | 189 gfx::Size size_; |
187 }; | 190 }; |
188 | 191 |
189 inline bool operator==(const Rect& lhs, const Rect& rhs) { | 192 inline bool operator==(const Rect& lhs, const Rect& rhs) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 } | 273 } |
271 | 274 |
272 // This is declared here for use in gtest-based unit tests but is defined in | 275 // This is declared here for use in gtest-based unit tests but is defined in |
273 // the gfx_test_support target. Depend on that to use this in your unit test. | 276 // the gfx_test_support target. Depend on that to use this in your unit test. |
274 // This should not be used in production code - call ToString() instead. | 277 // This should not be used in production code - call ToString() instead. |
275 void PrintTo(const Rect& rect, ::std::ostream* os); | 278 void PrintTo(const Rect& rect, ::std::ostream* os); |
276 | 279 |
277 } // namespace gfx | 280 } // namespace gfx |
278 | 281 |
279 #endif // UI_GFX_GEOMETRY_RECT_H_ | 282 #endif // UI_GFX_GEOMETRY_RECT_H_ |
OLD | NEW |