| Flutter macOS Embedder |

FlutterWindowController.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_FLUTTERWINDOWCONTROLLER_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERWINDOWCONTROLLER_H_
7
8 #import <Cocoa/Cocoa.h>
9
10 #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
11 #import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h"
12
13 @class FlutterEngine;
14
15 @interface FlutterWindowController : NSObject
16
17 @property(nonatomic, weak) FlutterEngine* engine;
18
19 - (void)closeAllWindows;
20
21 @end
22
23 struct FlutterWindowRect {
24 double left;
25 double top;
26 double width;
27 double height;
28
29 static FlutterWindowRect fromNSRect(const NSRect& rect) {
30 return {
31 rect.origin.x,
32 rect.origin.y,
33 rect.size.width,
34 rect.size.height,
35 };
36 }
37
38 NSRect toNSRect() const { return NSMakeRect(left, top, width, height); }
39 };
40
41 struct FlutterWindowSize {
42 double width;
43 double height;
44
45 static FlutterWindowSize fromNSSize(const NSSize& size) {
46 return {
47 size.width,
48 size.height,
49 };
50 }
51 };
52
53 struct FlutterWindowConstraints {
54 double min_width;
55 double min_height;
56 double max_width;
57 double max_height;
58 };
59
60 struct FlutterWindowCreationRequest {
61 bool has_size;
62 struct FlutterWindowSize size;
63 bool has_constraints;
64 struct FlutterWindowConstraints constraints;
65 int64_t parent_view_id;
66 void (*on_should_close)();
67 void (*on_will_close)();
68 void (*notify_listeners)();
69 // For sized to content windows with positioner returns the desired window position for given
70 // configuration. All coordinates are in logical space.
71 FlutterWindowRect* (*on_get_window_position)(const FlutterWindowSize& child_size,
72 const FlutterWindowRect& parent_rect,
73 const FlutterWindowRect& output_rect);
74 };
75
76 extern "C" {
77
78 // NOLINTBEGIN(google-objc-function-naming)
79
80 FLUTTER_DARWIN_EXPORT
81 int64_t InternalFlutter_WindowController_CreateRegularWindow(
82 int64_t engine_id,
83 const FlutterWindowCreationRequest* request);
84
85 FLUTTER_DARWIN_EXPORT
86 int64_t InternalFlutter_WindowController_CreateDialogWindow(
87 int64_t engine_id,
88 const FlutterWindowCreationRequest* request);
89
90 FLUTTER_DARWIN_EXPORT
91 int64_t InternalFlutter_WindowController_CreateTooltipWindow(
92 int64_t engine_id,
93 const FlutterWindowCreationRequest* request);
94
95 FLUTTER_DARWIN_EXPORT
96 void InternalFlutter_Window_Destroy(int64_t engine_id, void* window);
97
98 FLUTTER_DARWIN_EXPORT
99 void* InternalFlutter_Window_GetHandle(int64_t engine_id, FlutterViewIdentifier view_id);
100
101 FLUTTER_DARWIN_EXPORT
102 FlutterWindowSize InternalFlutter_Window_GetContentSize(void* window);
103
104 FLUTTER_DARWIN_EXPORT
105 void InternalFlutter_Window_SetContentSize(void* window, const FlutterWindowSize* size);
106
107 FLUTTER_DARWIN_EXPORT
108 void InternalFlutter_Window_SetConstraints(void* window,
109 const FlutterWindowConstraints* constraints);
110
111 FLUTTER_DARWIN_EXPORT
112 void InternalFlutter_Window_SetTitle(void* window, const char* title);
113
114 FLUTTER_DARWIN_EXPORT
115 void InternalFlutter_Window_SetMaximized(void* window, bool maximized);
116
117 FLUTTER_DARWIN_EXPORT
118 bool InternalFlutter_Window_IsMaximized(void* window);
119
120 FLUTTER_DARWIN_EXPORT
121 void InternalFlutter_Window_Minimize(void* window);
122
123 FLUTTER_DARWIN_EXPORT
124 void InternalFlutter_Window_Unminimize(void* window);
125
126 FLUTTER_DARWIN_EXPORT
127 bool InternalFlutter_Window_IsMinimized(void* window);
128
129 FLUTTER_DARWIN_EXPORT
130 void InternalFlutter_Window_SetFullScreen(void* window, bool fullScreen);
131
132 FLUTTER_DARWIN_EXPORT
133 bool InternalFlutter_Window_IsFullScreen(void* window);
134
135 FLUTTER_DARWIN_EXPORT
136 void InternalFlutter_Window_Activate(void* window);
137
138 FLUTTER_DARWIN_EXPORT
139 char* InternalFlutter_Window_GetTitle(void* window);
140
141 FLUTTER_DARWIN_EXPORT
142 bool InternalFlutter_Window_IsActivated(void* window);
143
144 FLUTTER_DARWIN_EXPORT
145 void InternalFlutter_Window_UpdatePosition(void* window);
146
147 // NOLINTEND(google-objc-function-naming)
148 }
149
150 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERWINDOWCONTROLLER_H_
FlutterMacros.h
FLUTTER_DARWIN_EXPORT
#define FLUTTER_DARWIN_EXPORT
Definition: FlutterMacros.h:14
FlutterViewController.h
FlutterViewIdentifier
int64_t FlutterViewIdentifier
Definition: FlutterViewController.h:21
InternalFlutter_WindowController_CreateRegularWindow
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreateRegularWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
Definition: FlutterWindowController.mm:454
InternalFlutter_Window_UpdatePosition
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_UpdatePosition(void *window)
Definition: FlutterWindowController.mm:577
InternalFlutter_Window_GetContentSize
FLUTTER_DARWIN_EXPORT FlutterWindowSize InternalFlutter_Window_GetContentSize(void *window)
Definition: FlutterWindowController.mm:490
InternalFlutter_WindowController_CreateTooltipWindow
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreateTooltipWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
Definition: FlutterWindowController.mm:470
InternalFlutter_Window_SetMaximized
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetMaximized(void *window, bool maximized)
Definition: FlutterWindowController.mm:517
InternalFlutter_Window_SetConstraints
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetConstraints(void *window, const FlutterWindowConstraints *constraints)
Definition: FlutterWindowController.mm:505
InternalFlutter_Window_Destroy
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Destroy(int64_t engine_id, void *window)
Definition: FlutterWindowController.mm:478
InternalFlutter_Window_Unminimize
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Unminimize(void *window)
Definition: FlutterWindowController.mm:536
InternalFlutter_Window_SetContentSize
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetContentSize(void *window, const FlutterWindowSize *size)
Definition: FlutterWindowController.mm:499
InternalFlutter_Window_SetFullScreen
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetFullScreen(void *window, bool fullScreen)
Definition: FlutterWindowController.mm:546
InternalFlutter_Window_IsMaximized
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsMaximized(void *window)
Definition: FlutterWindowController.mm:526
InternalFlutter_Window_IsMinimized
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsMinimized(void *window)
Definition: FlutterWindowController.mm:541
InternalFlutter_Window_GetTitle
FLUTTER_DARWIN_EXPORT char * InternalFlutter_Window_GetTitle(void *window)
Definition: FlutterWindowController.mm:567
InternalFlutter_WindowController_CreateDialogWindow
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreateDialogWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
Definition: FlutterWindowController.mm:462
InternalFlutter_Window_SetTitle
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetTitle(void *window, const char *title)
Definition: FlutterWindowController.mm:512
InternalFlutter_Window_Activate
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Activate(void *window)
Definition: FlutterWindowController.mm:561
InternalFlutter_Window_GetHandle
FLUTTER_DARWIN_EXPORT void * InternalFlutter_Window_GetHandle(int64_t engine_id, FlutterViewIdentifier view_id)
Definition: FlutterWindowController.mm:484
InternalFlutter_Window_IsFullScreen
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsFullScreen(void *window)
Definition: FlutterWindowController.mm:556
InternalFlutter_Window_IsActivated
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsActivated(void *window)
Definition: FlutterWindowController.mm:572
InternalFlutter_Window_Minimize
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Minimize(void *window)
Definition: FlutterWindowController.mm:531
FlutterEngine
Definition: FlutterEngine.h:32
FlutterWindowController
Definition: FlutterWindowController.h:16
FlutterWindowController::engine
FlutterEngine * engine
Definition: FlutterWindowController.h:17
-[FlutterWindowController closeAllWindows]
void closeAllWindows()
Definition: FlutterWindowController.mm:421
FlutterWindowConstraints
Definition: FlutterWindowController.h:53
FlutterWindowConstraints::max_width
double max_width
Definition: FlutterWindowController.h:56
FlutterWindowConstraints::min_height
double min_height
Definition: FlutterWindowController.h:55
FlutterWindowConstraints::max_height
double max_height
Definition: FlutterWindowController.h:57
FlutterWindowConstraints::min_width
double min_width
Definition: FlutterWindowController.h:54
FlutterWindowCreationRequest
Definition: FlutterWindowController.h:60
FlutterWindowCreationRequest::has_size
bool has_size
Definition: FlutterWindowController.h:61
FlutterWindowCreationRequest::parent_view_id
int64_t parent_view_id
Definition: FlutterWindowController.h:65
FlutterWindowRect
Definition: FlutterWindowController.h:23
FlutterWindowRect::toNSRect
NSRect toNSRect() const
Definition: FlutterWindowController.h:38
FlutterWindowRect::top
double top
Definition: FlutterWindowController.h:25
FlutterWindowRect::fromNSRect
static FlutterWindowRect fromNSRect(const NSRect &rect)
Definition: FlutterWindowController.h:29
FlutterWindowRect::width
double width
Definition: FlutterWindowController.h:26
FlutterWindowRect::left
double left
Definition: FlutterWindowController.h:24
FlutterWindowRect::height
double height
Definition: FlutterWindowController.h:27
FlutterWindowSize
Definition: FlutterWindowController.h:41
FlutterWindowSize::height
double height
Definition: FlutterWindowController.h:43
FlutterWindowSize::fromNSSize
static FlutterWindowSize fromNSSize(const NSSize &size)
Definition: FlutterWindowController.h:45
FlutterWindowSize::width
double width
Definition: FlutterWindowController.h:42