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