Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
coordinate_conversion.mm
Go to the documentation of this file.
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
6
7#import <Cocoa/Cocoa.h>
8
10#include "gfx/geometry/rect.h"
11
12namespace gfx {
13
14namespace {
15
16// The height of the primary display, which OSX defines as the monitor with the
17// menubar. This is always at index 0.
18CGFloat PrimaryDisplayHeight() {
19 return NSMaxY([[[NSScreen screens] firstObject] frame]);
20}
21
22} // namespace
23
25 return NSMakeRect(rect.x(), PrimaryDisplayHeight() - rect.y() - rect.height(), rect.width(),
26 rect.height());
27}
28
30 return Rect(rect.origin.x, PrimaryDisplayHeight() - rect.origin.y - rect.size.height,
31 rect.size.width, rect.size.height);
32}
33
34NSPoint ScreenPointToNSPoint(const Point& point) {
35 return NSMakePoint(point.x(), PrimaryDisplayHeight() - point.y());
36}
37
38Point ScreenPointFromNSPoint(const NSPoint& point) {
39 return Point(point.x, PrimaryDisplayHeight() - point.y);
40}
41
42} // namespace gfx
constexpr int y() const
Definition: point.h:49
constexpr int x() const
Definition: point.h:48
Definition: rect.h:36
double frame
Definition: examples.cpp:31
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
Definition: insets.cc:10
GFX_EXPORT NSRect ScreenRectToNSRect(const Rect &rect)
GFX_EXPORT Point ScreenPointFromNSPoint(const NSPoint &point)
GFX_EXPORT Rect ScreenRectFromNSRect(const NSRect &point)
GFX_EXPORT NSPoint ScreenPointToNSPoint(const Point &point)
TRect< Scalar > Rect
Definition: rect.h:769
TPoint< Scalar > Point
Definition: point.h:322