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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 | 103 |
104 Vector2d OffsetFromOrigin() const { return Vector2d(x(), y()); } | 104 Vector2d OffsetFromOrigin() const { return Vector2d(x(), y()); } |
105 | 105 |
106 void SetRect(int x, int y, int width, int height) { | 106 void SetRect(int x, int y, int width, int height) { |
107 origin_.SetPoint(x, y); | 107 origin_.SetPoint(x, y); |
108 // Ensure that width and height remain valid. | 108 // Ensure that width and height remain valid. |
109 set_width(width); | 109 set_width(width); |
110 set_height(height); | 110 set_height(height); |
111 } | 111 } |
112 | 112 |
113 // Safely(heuristically) take min and max to the internal representation. | |
danakj
2017/03/28 20:40:34
I get what this is talking about but I'm not reall
Peter Mayo
2017/03/29 18:49:26
I wanted it there to highlight to devs that there
| |
114 void SetByBounds(int left, int right, int top, int bottom); | |
danakj
2017/03/28 20:40:34
Can you reorder these as left, top, right, bottom?
Peter Mayo
2017/03/29 18:49:25
I kind of like Skia's practice of putting the orde
| |
115 | |
113 // Shrink the rectangle by a horizontal and vertical distance on all sides. | 116 // Shrink the rectangle by a horizontal and vertical distance on all sides. |
114 void Inset(int horizontal, int vertical) { | 117 void Inset(int horizontal, int vertical) { |
115 Inset(horizontal, vertical, horizontal, vertical); | 118 Inset(horizontal, vertical, horizontal, vertical); |
116 } | 119 } |
117 | 120 |
118 // Shrink the rectangle by the given insets. | 121 // Shrink the rectangle by the given insets. |
119 void Inset(const Insets& insets); | 122 void Inset(const Insets& insets); |
120 | 123 |
121 // Shrink the rectangle by the specified amount on each side. | 124 // Shrink the rectangle by the specified amount on each side. |
122 void Inset(int left, int top, int right, int bottom); | 125 void Inset(int left, int top, int right, int bottom); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 } | 339 } |
337 | 340 |
338 // This is declared here for use in gtest-based unit tests but is defined in | 341 // This is declared here for use in gtest-based unit tests but is defined in |
339 // the //ui/gfx:test_support target. Depend on that to use this in your unit | 342 // the //ui/gfx:test_support target. Depend on that to use this in your unit |
340 // test. This should not be used in production code - call ToString() instead. | 343 // test. This should not be used in production code - call ToString() instead. |
341 void PrintTo(const Rect& rect, ::std::ostream* os); | 344 void PrintTo(const Rect& rect, ::std::ostream* os); |
342 | 345 |
343 } // namespace gfx | 346 } // namespace gfx |
344 | 347 |
345 #endif // UI_GFX_GEOMETRY_RECT_H_ | 348 #endif // UI_GFX_GEOMETRY_RECT_H_ |
OLD | NEW |