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 15 matching lines...) Expand all Loading... |
26 #elif defined(OS_IOS) | 26 #elif defined(OS_IOS) |
27 #include <CoreGraphics/CoreGraphics.h> | 27 #include <CoreGraphics/CoreGraphics.h> |
28 #elif defined(OS_MACOSX) | 28 #elif defined(OS_MACOSX) |
29 #include <ApplicationServices/ApplicationServices.h> | 29 #include <ApplicationServices/ApplicationServices.h> |
30 #endif | 30 #endif |
31 | 31 |
32 namespace gfx { | 32 namespace gfx { |
33 | 33 |
34 class Insets; | 34 class Insets; |
35 | 35 |
36 class UI_EXPORT Rect : public RectBase<Rect, Point, Size, Insets, int> { | 36 class UI_EXPORT Rect |
| 37 : public RectBase<Rect, Point, Size, Insets, Vector2d, int> { |
37 public: | 38 public: |
38 Rect(); | 39 Rect(); |
39 Rect(int width, int height); | 40 Rect(int width, int height); |
40 Rect(int x, int y, int width, int height); | 41 Rect(int x, int y, int width, int height); |
41 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
42 explicit Rect(const RECT& r); | 43 explicit Rect(const RECT& r); |
43 #elif defined(OS_MACOSX) | 44 #elif defined(OS_MACOSX) |
44 explicit Rect(const CGRect& r); | 45 explicit Rect(const CGRect& r); |
45 #elif defined(TOOLKIT_GTK) | 46 #elif defined(TOOLKIT_GTK) |
46 explicit Rect(const GdkRectangle& r); | 47 explicit Rect(const GdkRectangle& r); |
(...skipping 22 matching lines...) Expand all Loading... |
69 | 70 |
70 inline bool operator==(const Rect& lhs, const Rect& rhs) { | 71 inline bool operator==(const Rect& lhs, const Rect& rhs) { |
71 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); | 72 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); |
72 } | 73 } |
73 | 74 |
74 inline bool operator!=(const Rect& lhs, const Rect& rhs) { | 75 inline bool operator!=(const Rect& lhs, const Rect& rhs) { |
75 return !(lhs == rhs); | 76 return !(lhs == rhs); |
76 } | 77 } |
77 | 78 |
78 #if !defined(COMPILER_MSVC) | 79 #if !defined(COMPILER_MSVC) |
79 extern template class RectBase<Rect, Point, Size, Insets, int>; | 80 extern template class RectBase<Rect, Point, Size, Insets, Vector2d, int>; |
80 #endif | 81 #endif |
81 | 82 |
82 } // namespace gfx | 83 } // namespace gfx |
83 | 84 |
84 #endif // UI_GFX_RECT_H_ | 85 #endif // UI_GFX_RECT_H_ |
OLD | NEW |