Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: ui/gfx/rect.h

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RenderText fixup Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/rect_f.h"
20 #include "ui/gfx/size.h" 20 #include "ui/gfx/size.h"
21 #include "ui/gfx/vector2d.h"
21 22
22 #if defined(OS_WIN) 23 #if defined(OS_WIN)
23 typedef struct tagRECT RECT; 24 typedef struct tagRECT RECT;
24 #elif defined(TOOLKIT_GTK) 25 #elif defined(TOOLKIT_GTK)
25 typedef struct _GdkRectangle GdkRectangle; 26 typedef struct _GdkRectangle GdkRectangle;
26 #elif defined(OS_IOS) 27 #elif defined(OS_IOS)
27 #include <CoreGraphics/CoreGraphics.h> 28 #include <CoreGraphics/CoreGraphics.h>
28 #elif defined(OS_MACOSX) 29 #elif defined(OS_MACOSX)
29 #include <ApplicationServices/ApplicationServices.h> 30 #include <ApplicationServices/ApplicationServices.h>
30 #endif 31 #endif
31 32
32 namespace gfx { 33 namespace gfx {
33 34
34 class Insets; 35 class Insets;
35 36
36 class UI_EXPORT Rect : public RectBase<Rect, Point, Size, Insets, int> { 37 class UI_EXPORT Rect
38 : public RectBase<Rect, Point, Size, Insets, Vector2d, int> {
37 public: 39 public:
38 Rect(); 40 Rect();
39 Rect(int width, int height); 41 Rect(int width, int height);
40 Rect(int x, int y, int width, int height); 42 Rect(int x, int y, int width, int height);
41 #if defined(OS_WIN) 43 #if defined(OS_WIN)
42 explicit Rect(const RECT& r); 44 explicit Rect(const RECT& r);
43 #elif defined(OS_MACOSX) 45 #elif defined(OS_MACOSX)
44 explicit Rect(const CGRect& r); 46 explicit Rect(const CGRect& r);
45 #elif defined(TOOLKIT_GTK) 47 #elif defined(TOOLKIT_GTK)
46 explicit Rect(const GdkRectangle& r); 48 explicit Rect(const GdkRectangle& r);
(...skipping 26 matching lines...) Expand all
73 75
74 inline bool operator!=(const Rect& lhs, const Rect& rhs) { 76 inline bool operator!=(const Rect& lhs, const Rect& rhs) {
75 return !(lhs == rhs); 77 return !(lhs == rhs);
76 } 78 }
77 79
78 UI_EXPORT Rect IntersectRects(const Rect& a, const Rect& b); 80 UI_EXPORT Rect IntersectRects(const Rect& a, const Rect& b);
79 UI_EXPORT Rect UnionRects(const Rect& a, const Rect& b); 81 UI_EXPORT Rect UnionRects(const Rect& a, const Rect& b);
80 UI_EXPORT Rect SubtractRects(const Rect& a, const Rect& b); 82 UI_EXPORT Rect SubtractRects(const Rect& a, const Rect& b);
81 83
82 #if !defined(COMPILER_MSVC) 84 #if !defined(COMPILER_MSVC)
83 extern template class RectBase<Rect, Point, Size, Insets, int>; 85 extern template class RectBase<Rect, Point, Size, Insets, Vector2d, int>;
84 #endif 86 #endif
85 87
86 } // namespace gfx 88 } // namespace gfx
87 89
88 #endif // UI_GFX_RECT_H_ 90 #endif // UI_GFX_RECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698