| 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 FlutterWindowOffset {
54 double x;
55 double y;
56
57 static FlutterWindowOffset fromNSPoint(const NSPoint& point) {
58 return {
59 point.x,
60 point.y,
61 };
62 }
63 };
64
65 struct FlutterWindowConstraints {
66 double min_width;
67 double min_height;
68 double max_width;
69 double max_height;
70 };
71
72 struct FlutterWindowCreationRequest {
73 bool has_size;
74 struct FlutterWindowSize size;
75 bool has_constraints;
76 struct FlutterWindowConstraints constraints;
77 int64_t parent_view_id;
78 void (*on_should_close)();
79 void (*on_will_close)();
80 void (*notify_listeners)();
81 // For sized to content windows with positioner returns the desired window position for given
82 // configuration. All coordinates are in logical space.
83 FlutterWindowRect* (*on_get_window_position)(const FlutterWindowSize& child_size,
84 const FlutterWindowRect& parent_rect,
85 const FlutterWindowRect& output_rect);
86 };
87
88 extern "C" {
89
90 // NOLINTBEGIN(google-objc-function-naming)
91
92 FLUTTER_DARWIN_EXPORT
93 int64_t InternalFlutter_WindowController_CreateRegularWindow(
94 int64_t engine_id,
95 const FlutterWindowCreationRequest* request);
96
97 FLUTTER_DARWIN_EXPORT
98 int64_t InternalFlutter_WindowController_CreateDialogWindow(
99 int64_t engine_id,
100 const FlutterWindowCreationRequest* request);
101
102 FLUTTER_DARWIN_EXPORT
103 int64_t InternalFlutter_WindowController_CreateTooltipWindow(
104 int64_t engine_id,
105 const FlutterWindowCreationRequest* request);
106
107 FLUTTER_DARWIN_EXPORT
108 int64_t InternalFlutter_WindowController_CreatePopupWindow(
109 int64_t engine_id,
110 const FlutterWindowCreationRequest* request);
111
112 FLUTTER_DARWIN_EXPORT
113 void InternalFlutter_Window_Destroy(int64_t engine_id, void* window);
114
115 FLUTTER_DARWIN_EXPORT
116 void* InternalFlutter_Window_GetHandle(int64_t engine_id, FlutterViewIdentifier view_id);
117
118 FLUTTER_DARWIN_EXPORT
119 FlutterWindowSize InternalFlutter_Window_GetContentSize(void* window);
120
121 FLUTTER_DARWIN_EXPORT
122 void InternalFlutter_Window_SetContentSize(void* window, const FlutterWindowSize* size);
123
124 FLUTTER_DARWIN_EXPORT
125 void InternalFlutter_Window_SetConstraints(void* window,
126 const FlutterWindowConstraints* constraints);
127
128 FLUTTER_DARWIN_EXPORT
129 void InternalFlutter_Window_SetTitle(void* window, const char* title);
130
131 FLUTTER_DARWIN_EXPORT
132 void InternalFlutter_Window_SetMaximized(void* window, bool maximized);
133
134 FLUTTER_DARWIN_EXPORT
135 bool InternalFlutter_Window_IsMaximized(void* window);
136
137 FLUTTER_DARWIN_EXPORT
138 void InternalFlutter_Window_Minimize(void* window);
139
140 FLUTTER_DARWIN_EXPORT
141 void InternalFlutter_Window_Unminimize(void* window);
142
143 FLUTTER_DARWIN_EXPORT
144 bool InternalFlutter_Window_IsMinimized(void* window);
145
146 FLUTTER_DARWIN_EXPORT
147 void InternalFlutter_Window_SetFullScreen(void* window, bool fullScreen);
148
149 FLUTTER_DARWIN_EXPORT
150 bool InternalFlutter_Window_IsFullScreen(void* window);
151
152 FLUTTER_DARWIN_EXPORT
153 void InternalFlutter_Window_Activate(void* window);
154
155 FLUTTER_DARWIN_EXPORT
156 char* InternalFlutter_Window_GetTitle(void* window);
157
158 FLUTTER_DARWIN_EXPORT
159 bool InternalFlutter_Window_IsActivated(void* window);
160
161 FLUTTER_DARWIN_EXPORT
162 void InternalFlutter_Window_UpdatePosition(void* window);
163
164 FLUTTER_DARWIN_EXPORT
165 FlutterWindowOffset InternalFlutter_Window_GetOffsetInParent(void* window);
166
167 // NOLINTEND(google-objc-function-naming)
168 }
169
170 #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:522
InternalFlutter_Window_UpdatePosition
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_UpdatePosition(void *window)
Definition: FlutterWindowController.mm:653
InternalFlutter_Window_GetContentSize
FLUTTER_DARWIN_EXPORT FlutterWindowSize InternalFlutter_Window_GetContentSize(void *window)
Definition: FlutterWindowController.mm:566
InternalFlutter_Window_GetOffsetInParent
FLUTTER_DARWIN_EXPORT FlutterWindowOffset InternalFlutter_Window_GetOffsetInParent(void *window)
Definition: FlutterWindowController.mm:659
InternalFlutter_WindowController_CreateTooltipWindow
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreateTooltipWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
Definition: FlutterWindowController.mm:538
InternalFlutter_Window_SetMaximized
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetMaximized(void *window, bool maximized)
Definition: FlutterWindowController.mm:593
InternalFlutter_WindowController_CreatePopupWindow
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreatePopupWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
Definition: FlutterWindowController.mm:546
InternalFlutter_Window_SetConstraints
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetConstraints(void *window, const FlutterWindowConstraints *constraints)
Definition: FlutterWindowController.mm:581
InternalFlutter_Window_Destroy
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Destroy(int64_t engine_id, void *window)
Definition: FlutterWindowController.mm:554
InternalFlutter_Window_Unminimize
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Unminimize(void *window)
Definition: FlutterWindowController.mm:612
InternalFlutter_Window_SetContentSize
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetContentSize(void *window, const FlutterWindowSize *size)
Definition: FlutterWindowController.mm:575
InternalFlutter_Window_SetFullScreen
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetFullScreen(void *window, bool fullScreen)
Definition: FlutterWindowController.mm:622
InternalFlutter_Window_IsMaximized
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsMaximized(void *window)
Definition: FlutterWindowController.mm:602
InternalFlutter_Window_IsMinimized
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsMinimized(void *window)
Definition: FlutterWindowController.mm:617
InternalFlutter_Window_GetTitle
FLUTTER_DARWIN_EXPORT char * InternalFlutter_Window_GetTitle(void *window)
Definition: FlutterWindowController.mm:643
InternalFlutter_WindowController_CreateDialogWindow
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreateDialogWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
Definition: FlutterWindowController.mm:530
InternalFlutter_Window_SetTitle
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetTitle(void *window, const char *title)
Definition: FlutterWindowController.mm:588
InternalFlutter_Window_Activate
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Activate(void *window)
Definition: FlutterWindowController.mm:637
InternalFlutter_Window_GetHandle
FLUTTER_DARWIN_EXPORT void * InternalFlutter_Window_GetHandle(int64_t engine_id, FlutterViewIdentifier view_id)
Definition: FlutterWindowController.mm:560
InternalFlutter_Window_IsFullScreen
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsFullScreen(void *window)
Definition: FlutterWindowController.mm:632
InternalFlutter_Window_IsActivated
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsActivated(void *window)
Definition: FlutterWindowController.mm:648
InternalFlutter_Window_Minimize
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Minimize(void *window)
Definition: FlutterWindowController.mm:607
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:489
FlutterWindowConstraints
Definition: FlutterWindowController.h:65
FlutterWindowConstraints::max_width
double max_width
Definition: FlutterWindowController.h:68
FlutterWindowConstraints::min_height
double min_height
Definition: FlutterWindowController.h:67
FlutterWindowConstraints::max_height
double max_height
Definition: FlutterWindowController.h:69
FlutterWindowConstraints::min_width
double min_width
Definition: FlutterWindowController.h:66
FlutterWindowCreationRequest
Definition: FlutterWindowController.h:72
FlutterWindowCreationRequest::has_size
bool has_size
Definition: FlutterWindowController.h:73
FlutterWindowCreationRequest::parent_view_id
int64_t parent_view_id
Definition: FlutterWindowController.h:77
FlutterWindowOffset
Definition: FlutterWindowController.h:53
FlutterWindowOffset::x
double x
Definition: FlutterWindowController.h:54
FlutterWindowOffset::fromNSPoint
static FlutterWindowOffset fromNSPoint(const NSPoint &point)
Definition: FlutterWindowController.h:57
FlutterWindowOffset::y
double y
Definition: FlutterWindowController.h:55
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