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

Side by Side Diff: ui/gfx/mac/point_utils.mm

Issue 309483009: Remaining bits to get views_examples_with_content_exe to work on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: neater still Created 6 years, 6 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
OLDNEW
(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]);
Andre 2014/06/04 23:55:08 How about multiple screens?
tapted 2014/06/11 07:38:00 screen coordinates are always relative to the bott
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698