| 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 // Use in place of SetRect() when you know the edges of the rectangle instead |
| 114 // of the dimensions, rather than trying to determine the width/height |
| 115 // yourself. This safely handles cases where the width/height would overflow. |
| 116 void SetByBounds(int left, int top, int right, int bottom); |
| 117 |
| 113 // Shrink the rectangle by a horizontal and vertical distance on all sides. | 118 // Shrink the rectangle by a horizontal and vertical distance on all sides. |
| 114 void Inset(int horizontal, int vertical) { | 119 void Inset(int horizontal, int vertical) { |
| 115 Inset(horizontal, vertical, horizontal, vertical); | 120 Inset(horizontal, vertical, horizontal, vertical); |
| 116 } | 121 } |
| 117 | 122 |
| 118 // Shrink the rectangle by the given insets. | 123 // Shrink the rectangle by the given insets. |
| 119 void Inset(const Insets& insets); | 124 void Inset(const Insets& insets); |
| 120 | 125 |
| 121 // Shrink the rectangle by the specified amount on each side. | 126 // Shrink the rectangle by the specified amount on each side. |
| 122 void Inset(int left, int top, int right, int bottom); | 127 void Inset(int left, int top, int right, int bottom); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 } | 341 } |
| 337 | 342 |
| 338 // This is declared here for use in gtest-based unit tests but is defined in | 343 // 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 | 344 // 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. | 345 // test. This should not be used in production code - call ToString() instead. |
| 341 void PrintTo(const Rect& rect, ::std::ostream* os); | 346 void PrintTo(const Rect& rect, ::std::ostream* os); |
| 342 | 347 |
| 343 } // namespace gfx | 348 } // namespace gfx |
| 344 | 349 |
| 345 #endif // UI_GFX_GEOMETRY_RECT_H_ | 350 #endif // UI_GFX_GEOMETRY_RECT_H_ |
| OLD | NEW |