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

Unified Diff: ui/gfx/mac/coordinate_conversion.mm

Issue 1287573002: [Mac] Add gfx::ScreenPoint[To|From]NSPoint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@openurl
Patch Set: Address comments. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/mac/coordinate_conversion.mm
diff --git a/ui/gfx/mac/coordinate_conversion.mm b/ui/gfx/mac/coordinate_conversion.mm
index b2c41a455d6c96c4aa18e2928937c1c93f3cdb45..54b16e96053f4466ea9a90e6ef14221baf5ea184 100644
--- a/ui/gfx/mac/coordinate_conversion.mm
+++ b/ui/gfx/mac/coordinate_conversion.mm
@@ -6,6 +6,7 @@
#import <Cocoa/Cocoa.h>
+#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
namespace gfx {
@@ -20,18 +21,25 @@ CGFloat PrimaryDisplayHeight() {
} // namespace
-NSRect ScreenRectToNSRect(const gfx::Rect& rect) {
+NSRect ScreenRectToNSRect(const Rect& rect) {
return NSMakeRect(rect.x(),
PrimaryDisplayHeight() - rect.y() - rect.height(),
rect.width(),
rect.height());
}
-gfx::Rect ScreenRectFromNSRect(const NSRect& rect) {
- return gfx::Rect(rect.origin.x,
- PrimaryDisplayHeight() - rect.origin.y - rect.size.height,
- rect.size.width,
- rect.size.height);
+Rect ScreenRectFromNSRect(const NSRect& rect) {
+ return Rect(rect.origin.x,
+ PrimaryDisplayHeight() - rect.origin.y - rect.size.height,
+ rect.size.width, rect.size.height);
+}
+
+NSPoint ScreenPointToNSPoint(const Point& point) {
+ return NSMakePoint(point.x(), PrimaryDisplayHeight() - point.y());
+}
+
+Point ScreenPointFromNSPoint(const NSPoint& point) {
+ return Point(point.x, PrimaryDisplayHeight() - point.y);
}
} // namespace gfx

Powered by Google App Engine
This is Rietveld 408576698