| Flutter macOS Embedder |

FlutterView.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERVIEW_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERVIEW_H_
7
8 #import <Cocoa/Cocoa.h>
9
10 #import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h"
11 #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h"
12
13 #include <stdint.h>
14
15 /**
16 * Delegate for FlutterView.
17 */
18 @protocol FlutterViewDelegate <NSObject>
19 /**
20 * Called when the view's backing store changes size.
21 */
22 - (void)viewDidReshape:(nonnull NSView*)view;
23
24 /**
25 * Called to determine whether the view should accept first responder status.
26 */
27 - (BOOL)viewShouldAcceptFirstResponder:(nonnull NSView*)view;
28
29 @end
30
31 /**
32 * View capable of acting as a rendering target and input source for the Flutter
33 * engine.
34 */
35 @interface FlutterView : NSView
36
37 /**
38 * Initialize a FlutterView that will be rendered to using Metal rendering apis.
39 */
40 - (nullable instancetype)initWithMTLDevice:(nonnull id<MTLDevice>)device
41 commandQueue:(nonnull id<MTLCommandQueue>)commandQueue
42 delegate:(nonnull id<FlutterViewDelegate>)delegate
43 viewIdentifier:(FlutterViewIdentifier)viewIdentifier
44 NS_DESIGNATED_INITIALIZER;
45
46 - (nullable instancetype)initWithFrame:(NSRect)frameRect
47 pixelFormat:(nullable NSOpenGLPixelFormat*)format NS_UNAVAILABLE;
48 - (nonnull instancetype)initWithFrame:(NSRect)frameRect NS_UNAVAILABLE;
49 - (nullable instancetype)initWithCoder:(nonnull NSCoder*)coder NS_UNAVAILABLE;
50 - (nonnull instancetype)init NS_UNAVAILABLE;
51
52 /**
53 * Returns SurfaceManager for this view. SurfaceManager is responsible for
54 * providing and presenting render surfaces.
55 */
56 @property(readonly, nonatomic, nonnull) FlutterSurfaceManager* surfaceManager;
57
58 /**
59 * By default, the `FlutterSurfaceManager` creates two layers to manage Flutter
60 * content, the content layer and containing layer. To set the native background
61 * color, onto which the Flutter content is drawn, call this method with the
62 * NSColor which you would like to override the default, black background color
63 * with.
64 */
65 - (void)setBackgroundColor:(nonnull NSColor*)color;
66
67 /**
68 * Called from the engine to notify the view that mouse cursor was updated while
69 * the mouse is over the view. The view is responsible from restoring the cursor
70 * when the mouse enters the view from another subview.
71 */
72 - (void)didUpdateMouseCursor:(nonnull NSCursor*)cursor;
73
74 /**
75 * Called from the controller to unblock resize synchronizer when shutting down.
76 */
77 - (void)shutDown;
78
79 @end
80
81 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERVIEW_H_
FlutterSurfaceManager.h
FlutterViewController.h
FlutterViewIdentifier
int64_t FlutterViewIdentifier
Definition: FlutterViewController.h:21
FlutterSurfaceManager
Definition: FlutterSurfaceManager.h:47
FlutterView
Definition: FlutterView.h:36
-[FlutterView shutDown]
void shutDown()
Definition: FlutterView.mm:52
FlutterView::surfaceManager
FlutterSurfaceManager * surfaceManager
Definition: FlutterView.h:56
-[FlutterView NS_UNAVAILABLE]
nonnull instancetype NS_UNAVAILABLE()
FlutterViewDelegate-p
Definition: FlutterView.h:18