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 
12 
13 #include <stdint.h>
14 
15 typedef int64_t FlutterViewId;
16 
17 /**
18  * The view ID for APIs that don't support multi-view.
19  *
20  * Some single-view APIs will eventually be replaced by their multi-view
21  * variant. During the deprecation period, the single-view APIs will coexist with
22  * and work with the multi-view APIs as if the other views don't exist. For
23  * backward compatibility, single-view APIs will always operate on the view with
24  * this ID. Also, the first view assigned to the engine will also have this ID.
25  */
27 
28 /**
29  * Delegate for FlutterView.
30  */
31 @protocol FlutterViewDelegate <NSObject>
32 /**
33  * Called when the view's backing store changes size.
34  */
35 - (void)viewDidReshape:(nonnull NSView*)view;
36 
37 /**
38  * Called to determine whether the view should accept first responder status.
39  */
40 - (BOOL)viewShouldAcceptFirstResponder:(nonnull NSView*)view;
41 
42 @end
43 
44 /**
45  * View capable of acting as a rendering target and input source for the Flutter
46  * engine.
47  */
48 @interface FlutterView : NSView
49 
50 /**
51  * Initialize a FlutterView that will be rendered to using Metal rendering apis.
52  */
53 - (nullable instancetype)initWithMTLDevice:(nonnull id<MTLDevice>)device
54  commandQueue:(nonnull id<MTLCommandQueue>)commandQueue
55  delegate:(nonnull id<FlutterViewDelegate>)delegate
56  threadSynchronizer:(nonnull FlutterThreadSynchronizer*)threadSynchronizer
57  viewId:(int64_t)viewId NS_DESIGNATED_INITIALIZER;
58 
59 - (nullable instancetype)initWithFrame:(NSRect)frameRect
60  pixelFormat:(nullable NSOpenGLPixelFormat*)format NS_UNAVAILABLE;
61 - (nonnull instancetype)initWithFrame:(NSRect)frameRect NS_UNAVAILABLE;
62 - (nullable instancetype)initWithCoder:(nonnull NSCoder*)coder NS_UNAVAILABLE;
63 - (nonnull instancetype)init NS_UNAVAILABLE;
64 
65 /**
66  * Returns SurfaceManager for this view. SurfaceManager is responsible for
67  * providing and presenting render surfaces.
68  */
69 @property(readonly, nonatomic, nonnull) FlutterSurfaceManager* surfaceManager;
70 
71 /**
72  * By default, the `FlutterSurfaceManager` creates two layers to manage Flutter
73  * content, the content layer and containing layer. To set the native background
74  * color, onto which the Flutter content is drawn, call this method with the
75  * NSColor which you would like to override the default, black background color
76  * with.
77  */
78 - (void)setBackgroundColor:(nonnull NSColor*)color;
79 
80 @end
81 
82 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERVIEW_H_
FlutterView::surfaceManager
FlutterSurfaceManager * surfaceManager
Definition: FlutterView.h:69
FlutterSurfaceManager.h
FlutterSurfaceManager
Definition: FlutterSurfaceManager.h:44
kFlutterImplicitViewId
constexpr FlutterViewId kFlutterImplicitViewId
Definition: FlutterView.h:26
FlutterThreadSynchronizer
Definition: FlutterThreadSynchronizer.h:16
FlutterView
Definition: FlutterView.h:48
FlutterThreadSynchronizer.h
-[FlutterView NS_UNAVAILABLE]
nonnull instancetype NS_UNAVAILABLE()
FlutterViewDelegate-p
Definition: FlutterView.h:31
FlutterViewId
int64_t FlutterViewId
Definition: FlutterView.h:15