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

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

Issue 10993094: Make adding and subtracting gfx:: point types simpler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove some patch noise Created 8 years, 2 months 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
« no previous file with comments | « no previous file | ui/gfx/point.cc » ('j') | ui/gfx/point_f.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef UI_GFX_POINT_H_ 5 #ifndef UI_GFX_POINT_H_
6 #define UI_GFX_POINT_H_ 6 #define UI_GFX_POINT_H_
7 7
8 #include "ui/base/ui_export.h" 8 #include "ui/base/ui_export.h"
9 #include "ui/gfx/point_base.h" 9 #include "ui/gfx/point_base.h"
10 #include "ui/gfx/point_f.h"
10 11
11 #if defined(OS_WIN) 12 #if defined(OS_WIN)
12 typedef unsigned long DWORD; 13 typedef unsigned long DWORD;
13 typedef struct tagPOINT POINT; 14 typedef struct tagPOINT POINT;
14 #elif defined(OS_IOS) 15 #elif defined(OS_IOS)
15 #include <CoreGraphics/CoreGraphics.h> 16 #include <CoreGraphics/CoreGraphics.h>
16 #elif defined(OS_MACOSX) 17 #elif defined(OS_MACOSX)
17 #include <ApplicationServices/ApplicationServices.h> 18 #include <ApplicationServices/ApplicationServices.h>
18 #endif 19 #endif
19 20
20 namespace gfx { 21 namespace gfx {
21 22
22 // A point has an x and y coordinate. 23 // A point has an x and y coordinate.
23 class UI_EXPORT Point : public PointBase<Point, int> { 24 class UI_EXPORT Point : public PointBase<Point, int> {
24 public: 25 public:
25 Point(); 26 Point();
26 Point(int x, int y); 27 Point(int x, int y);
28 Point(const Point& other);
sky 2012/09/28 23:05:49 explicit
danakj 2012/09/28 23:19:14 thanks. i was able to remove the copy constructors
27 #if defined(OS_WIN) 29 #if defined(OS_WIN)
28 // |point| is a DWORD value that contains a coordinate. The x-coordinate is 30 // |point| is a DWORD value that contains a coordinate. The x-coordinate is
29 // the low-order short and the y-coordinate is the high-order short. This 31 // the low-order short and the y-coordinate is the high-order short. This
30 // value is commonly acquired from GetMessagePos/GetCursorPos. 32 // value is commonly acquired from GetMessagePos/GetCursorPos.
31 explicit Point(DWORD point); 33 explicit Point(DWORD point);
32 explicit Point(const POINT& point); 34 explicit Point(const POINT& point);
33 Point& operator=(const POINT& point); 35 Point& operator=(const POINT& point);
34 #elif defined(OS_MACOSX) 36 #elif defined(OS_MACOSX)
35 explicit Point(const CGPoint& point); 37 explicit Point(const CGPoint& point);
36 #endif 38 #endif
37 39
38 ~Point() {} 40 ~Point() {}
39 41
40 #if defined(OS_WIN) 42 #if defined(OS_WIN)
41 POINT ToPOINT() const; 43 POINT ToPOINT() const;
42 #elif defined(OS_MACOSX) 44 #elif defined(OS_MACOSX)
43 CGPoint ToCGPoint() const; 45 CGPoint ToCGPoint() const;
44 #endif 46 #endif
45 47
46 // Returns a string representation of point. 48 // Returns a string representation of point.
47 std::string ToString() const; 49 std::string ToString() const;
50
51 operator PointF() const WARN_UNUSED_RESULT {
sky 2012/09/28 23:05:49 Why the WARN_UNUSED_RESULT?
danakj 2012/09/28 23:19:14 removed.
52 return PointF(x(), y());
53 }
48 }; 54 };
49 55
56 inline Point operator+(Point lhs, Point rhs) {
57 return lhs.Add(rhs);
58 }
59
60 inline Point operator-(Point lhs, Point rhs) {
61 return lhs.Subtract(rhs);
62 }
63
50 #if !defined(COMPILER_MSVC) 64 #if !defined(COMPILER_MSVC)
51 extern template class PointBase<Point, int>; 65 extern template class PointBase<Point, int>;
52 #endif 66 #endif
53 67
54 } // namespace gfx 68 } // namespace gfx
55 69
56 #endif // UI_GFX_POINT_H_ 70 #endif // UI_GFX_POINT_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/point.cc » ('j') | ui/gfx/point_f.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698