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

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

Issue 11028127: Implicit coversion operators from integer geometry types to floating point. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase 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
« no previous file with comments | « ui/base/win/hwnd_util.cc ('k') | ui/gfx/point_base.h » ('j') | no next file with comments »
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 #include "ui/gfx/point_f.h"
(...skipping 26 matching lines...) Expand all
37 #endif 37 #endif
38 38
39 ~Point() {} 39 ~Point() {}
40 40
41 #if defined(OS_WIN) 41 #if defined(OS_WIN)
42 POINT ToPOINT() const; 42 POINT ToPOINT() const;
43 #elif defined(OS_MACOSX) 43 #elif defined(OS_MACOSX)
44 CGPoint ToCGPoint() const; 44 CGPoint ToCGPoint() const;
45 #endif 45 #endif
46 46
47 PointF ToPointF() const { 47 operator PointF() const {
48 return PointF(x(), y()); 48 return PointF(x(), y());
49 } 49 }
50 50
51 PointF Scale(float scale) const WARN_UNUSED_RESULT { 51 PointF Scale(float scale) const WARN_UNUSED_RESULT {
52 return Scale(scale, scale); 52 return Scale(scale, scale);
53 } 53 }
54 54
55 PointF Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT { 55 PointF Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT {
56 return PointF(x() * x_scale, y() * y_scale); 56 return PointF(x() * x_scale, y() * y_scale);
57 } 57 }
58 58
59 // Returns a string representation of point. 59 // Returns a string representation of point.
60 std::string ToString() const; 60 std::string ToString() const;
61 }; 61 };
62 62
63 inline bool operator==(const Point& lhs, const Point& rhs) {
64 return lhs.x() == rhs.x() && lhs.y() == rhs.y();
65 }
66
67 inline bool operator!=(const Point& lhs, const Point& rhs) {
68 return !(lhs == rhs);
69 }
70
63 inline Point operator+(Point lhs, Point rhs) { 71 inline Point operator+(Point lhs, Point rhs) {
64 return lhs.Add(rhs); 72 return lhs.Add(rhs);
65 } 73 }
66 74
67 inline Point operator-(Point lhs, Point rhs) { 75 inline Point operator-(Point lhs, Point rhs) {
68 return lhs.Subtract(rhs); 76 return lhs.Subtract(rhs);
69 } 77 }
70 78
71 #if !defined(COMPILER_MSVC) 79 #if !defined(COMPILER_MSVC)
72 extern template class PointBase<Point, int>; 80 extern template class PointBase<Point, int>;
73 #endif 81 #endif
74 82
75 } // namespace gfx 83 } // namespace gfx
76 84
77 #endif // UI_GFX_POINT_H_ 85 #endif // UI_GFX_POINT_H_
OLDNEW
« no previous file with comments | « ui/base/win/hwnd_util.cc ('k') | ui/gfx/point_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698