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. |
11 | 11 |
12 #ifndef UI_GFX_RECT_H_ | 12 #ifndef UI_GFX_RECT_H_ |
13 #define UI_GFX_RECT_H_ | 13 #define UI_GFX_RECT_H_ |
14 | 14 |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "ui/gfx/point.h" | 17 #include "ui/gfx/point.h" |
18 #include "ui/gfx/rect_base.h" | 18 #include "ui/gfx/rect_base.h" |
| 19 #include "ui/gfx/rect_f.h" |
19 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" |
20 | 21 |
21 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
22 typedef struct tagRECT RECT; | 23 typedef struct tagRECT RECT; |
23 #elif defined(TOOLKIT_GTK) | 24 #elif defined(TOOLKIT_GTK) |
24 typedef struct _GdkRectangle GdkRectangle; | 25 typedef struct _GdkRectangle GdkRectangle; |
25 #elif defined(OS_IOS) | 26 #elif defined(OS_IOS) |
26 #include <CoreGraphics/CoreGraphics.h> | 27 #include <CoreGraphics/CoreGraphics.h> |
27 #elif defined(OS_MACOSX) | 28 #elif defined(OS_MACOSX) |
28 #include <ApplicationServices/ApplicationServices.h> | 29 #include <ApplicationServices/ApplicationServices.h> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
61 // Construct an equivalent Win32 RECT object. | 62 // Construct an equivalent Win32 RECT object. |
62 RECT ToRECT() const; | 63 RECT ToRECT() const; |
63 #elif defined(TOOLKIT_GTK) | 64 #elif defined(TOOLKIT_GTK) |
64 GdkRectangle ToGdkRectangle() const; | 65 GdkRectangle ToGdkRectangle() const; |
65 #elif defined(OS_MACOSX) | 66 #elif defined(OS_MACOSX) |
66 // Construct an equivalent CoreGraphics object. | 67 // Construct an equivalent CoreGraphics object. |
67 CGRect ToCGRect() const; | 68 CGRect ToCGRect() const; |
68 #endif | 69 #endif |
69 | 70 |
| 71 RectF ToRectF() const WARN_UNUSED_RESULT { |
| 72 return RectF(origin().x(), origin().y(), size().width(), size().height()); |
| 73 } |
| 74 |
| 75 RectF Scale(float scale) const WARN_UNUSED_RESULT { |
| 76 return Scale(scale, scale); |
| 77 } |
| 78 |
| 79 RectF Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT { |
| 80 return ToRectF().Scale(x_scale, y_scale); |
| 81 } |
| 82 |
70 std::string ToString() const; | 83 std::string ToString() const; |
71 }; | 84 }; |
72 | 85 |
73 #if !defined(COMPILER_MSVC) | 86 #if !defined(COMPILER_MSVC) |
74 extern template class RectBase<Rect, Point, Size, Insets, int>; | 87 extern template class RectBase<Rect, Point, Size, Insets, int>; |
75 #endif | 88 #endif |
76 | 89 |
77 } // namespace gfx | 90 } // namespace gfx |
78 | 91 |
79 #endif // UI_GFX_RECT_H_ | 92 #endif // UI_GFX_RECT_H_ |
OLD | NEW |