Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / panels / panel_utils_cocoa.mm
bloba5f173903485ed3790fa9ded08102ee7a8327780
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
3 // found in the LICENSE file.
5 #import "chrome/browser/ui/cocoa/panels/panel_utils_cocoa.h"
7 namespace cocoa_utils {
9 NSRect ConvertRectToCocoaCoordinates(const gfx::Rect& bounds) {
10   // Flip coordinates based on the primary screen.
11   NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
13   return NSMakeRect(
14       bounds.x(), NSHeight([screen frame]) - bounds.height() - bounds.y(),
15       bounds.width(), bounds.height());
18 gfx::Rect ConvertRectFromCocoaCoordinates(NSRect bounds) {
19   // Flip coordinates based on the primary screen.
20   NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
22   return gfx::Rect(
23       NSMinX(bounds), NSHeight([screen frame]) - NSMaxY(bounds),
24       NSWidth(bounds), NSHeight(bounds));
27 NSPoint ConvertPointToCocoaCoordinates(const gfx::Point& point) {
28   // Flip coordinates based on the primary screen.
29   NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
31   return NSMakePoint(point.x(), NSHeight([screen frame]) - point.y());
34 gfx::Point ConvertPointFromCocoaCoordinates(NSPoint point) {
35   // Flip coordinates based on the primary screen.
36   NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
38   return gfx::Point(point.x, NSHeight([screen frame]) - point.y);
41 }  // namespace cocoa_utils