Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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/Source/FlutterSurfaceManager.h"
11#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterThreadSynchronizer.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 threadSynchronizer:(nonnull FlutterThreadSynchronizer*)threadSynchronizer
44 viewIdentifier:(FlutterViewIdentifier)viewIdentifier
45 NS_DESIGNATED_INITIALIZER;
46
47- (nullable instancetype)initWithFrame:(NSRect)frameRect
48 pixelFormat:(nullable NSOpenGLPixelFormat*)format NS_UNAVAILABLE;
49- (nonnull instancetype)initWithFrame:(NSRect)frameRect NS_UNAVAILABLE;
50- (nullable instancetype)initWithCoder:(nonnull NSCoder*)coder NS_UNAVAILABLE;
51- (nonnull instancetype)init NS_UNAVAILABLE;
52
53/**
54 * Returns SurfaceManager for this view. SurfaceManager is responsible for
55 * providing and presenting render surfaces.
56 */
57@property(readonly, nonatomic, nonnull) FlutterSurfaceManager* surfaceManager;
58
59/**
60 * By default, the `FlutterSurfaceManager` creates two layers to manage Flutter
61 * content, the content layer and containing layer. To set the native background
62 * color, onto which the Flutter content is drawn, call this method with the
63 * NSColor which you would like to override the default, black background color
64 * with.
65 */
66- (void)setBackgroundColor:(nonnull NSColor*)color;
67
68/**
69 * Called from the engine to notify the view that mouse cursor was updated while
70 * the mouse is over the view. The view is responsible from restoring the cursor
71 * when the mouse enters the view from another subview.
72 */
73- (void)didUpdateMouseCursor:(nonnull NSCursor*)cursor;
74
75@end
76
77#endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERVIEW_H_
instancetype init()
FlutterSurfaceManager * surfaceManager
Definition FlutterView.h:57
instancetype init NS_UNAVAILABLE
instancetype initWithFrame
instancetype initWithCoder
int64_t FlutterViewIdentifier
int BOOL