OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ui/gfx/mac/point_utils.h" |
| 6 |
| 7 #import <Cocoa/Cocoa.h> |
| 8 |
| 9 #include "ui/gfx/geometry/point.h" |
| 10 #include "ui/gfx/geometry/rect.h" |
| 11 |
| 12 namespace gfx { |
| 13 |
| 14 namespace { |
| 15 |
| 16 CGFloat PrimaryDisplayHeight() { |
| 17 return NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]); |
| 18 } |
| 19 |
| 20 } // namespace |
| 21 |
| 22 NSPoint ScreenPointToNSPoint(const gfx::Point& point) { |
| 23 return NSMakePoint(point.x(), PrimaryDisplayHeight() - point.y()); |
| 24 } |
| 25 |
| 26 gfx::Point ScreenPointFromNSPoint(const NSPoint& point) { |
| 27 return gfx::Point(point.x, PrimaryDisplayHeight() - point.y); |
| 28 } |
| 29 |
| 30 NSRect ScreenRectToNSRect(const gfx::Rect& rect) { |
| 31 return NSMakeRect(rect.x(), |
| 32 PrimaryDisplayHeight() - rect.y() - rect.height(), |
| 33 rect.width(), |
| 34 rect.height()); |
| 35 } |
| 36 |
| 37 gfx::Rect ScreenRectFromNSRect(const NSRect& rect) { |
| 38 return gfx::Rect(rect.origin.x, |
| 39 PrimaryDisplayHeight() - rect.origin.y - rect.size.height, |
| 40 rect.size.width, |
| 41 rect.size.height); |
| 42 } |
| 43 |
| 44 } // namespace gfx |
OLD | NEW |