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 
12 
13 @class FlutterEngine;
14 
15 @interface FlutterWindowController : NSObject
16 
17 @property(nonatomic, weak) FlutterEngine* engine;
18 
19 - (void)closeAllWindows;
20 
22 
23 @end
24 
26  double left;
27  double top;
28  double width;
29  double height;
30 
31  static FlutterWindowRect fromNSRect(const NSRect& rect) {
32  return {
33  rect.origin.x,
34  rect.origin.y,
35  rect.size.width,
36  rect.size.height,
37  };
38  }
39 
40  NSRect toNSRect() const { return NSMakeRect(left, top, width, height); }
41 };
42 
44  double width;
45  double height;
46 
47  static FlutterWindowSize fromNSSize(const NSSize& size) {
48  return {
49  size.width,
50  size.height,
51  };
52  }
53 };
54 
56  double x;
57  double y;
58 
59  static FlutterWindowOffset fromNSPoint(const NSPoint& point) {
60  return {
61  point.x,
62  point.y,
63  };
64  }
65 };
66 
68  double min_width;
69  double min_height;
70  double max_width;
71  double max_height;
72 };
73 
75  bool has_size;
76  struct FlutterWindowSize size;
77  bool has_constraints;
78  struct FlutterWindowConstraints constraints;
79  int64_t parent_view_id;
80  void (*on_should_close)();
81  void (*on_will_close)();
82  void (*notify_listeners)();
83  // For sized to content windows with positioner returns the desired window position for given
84  // configuration. All coordinates are in logical space.
85  FlutterWindowRect* (*on_get_window_position)(const FlutterWindowSize& child_size,
86  const FlutterWindowRect& parent_rect,
87  const FlutterWindowRect& output_rect);
88 };
89 
90 extern "C" {
91 
92 // NOLINTBEGIN(google-objc-function-naming)
93 
96  int64_t engine_id,
97  const FlutterWindowCreationRequest* request);
98 
101  int64_t engine_id,
102  const FlutterWindowCreationRequest* request);
103 
106  int64_t engine_id,
107  const FlutterWindowCreationRequest* request);
108 
111  int64_t engine_id,
112  const FlutterWindowCreationRequest* request);
113 
115 void InternalFlutter_Window_Destroy(int64_t engine_id, void* window);
116 
118 void* InternalFlutter_Window_GetHandle(int64_t engine_id, FlutterViewIdentifier view_id);
119 
122 
124 void InternalFlutter_Window_SetContentSize(void* window, const FlutterWindowSize* size);
125 
127 void InternalFlutter_Window_SetConstraints(void* window,
128  const FlutterWindowConstraints* constraints);
129 
131 void InternalFlutter_Window_SetTitle(void* window, const char* title);
132 
134 void InternalFlutter_Window_SetMaximized(void* window, bool maximized);
135 
137 bool InternalFlutter_Window_IsMaximized(void* window);
138 
140 void InternalFlutter_Window_Minimize(void* window);
141 
143 void InternalFlutter_Window_Unminimize(void* window);
144 
146 bool InternalFlutter_Window_IsMinimized(void* window);
147 
149 void InternalFlutter_Window_SetFullScreen(void* window, bool fullScreen);
150 
152 bool InternalFlutter_Window_IsFullScreen(void* window);
153 
155 void InternalFlutter_Window_Activate(void* window);
156 
158 char* InternalFlutter_Window_GetTitle(void* window);
159 
161 bool InternalFlutter_Window_IsActivated(void* window);
162 
164 void InternalFlutter_Window_UpdatePosition(void* window);
165 
168 
169 // NOLINTEND(google-objc-function-naming)
170 }
171 
172 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERWINDOWCONTROLLER_H_
#define FLUTTER_DARWIN_EXPORT
Definition: FlutterMacros.h:14
int64_t FlutterViewIdentifier
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreateRegularWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_UpdatePosition(void *window)
FLUTTER_DARWIN_EXPORT FlutterWindowSize InternalFlutter_Window_GetContentSize(void *window)
FLUTTER_DARWIN_EXPORT FlutterWindowOffset InternalFlutter_Window_GetOffsetInParent(void *window)
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreateTooltipWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetMaximized(void *window, bool maximized)
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreatePopupWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetConstraints(void *window, const FlutterWindowConstraints *constraints)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Destroy(int64_t engine_id, void *window)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Unminimize(void *window)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetContentSize(void *window, const FlutterWindowSize *size)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetFullScreen(void *window, bool fullScreen)
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsMaximized(void *window)
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsMinimized(void *window)
FLUTTER_DARWIN_EXPORT char * InternalFlutter_Window_GetTitle(void *window)
FLUTTER_DARWIN_EXPORT int64_t InternalFlutter_WindowController_CreateDialogWindow(int64_t engine_id, const FlutterWindowCreationRequest *request)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_SetTitle(void *window, const char *title)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Activate(void *window)
FLUTTER_DARWIN_EXPORT void * InternalFlutter_Window_GetHandle(int64_t engine_id, FlutterViewIdentifier view_id)
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsFullScreen(void *window)
FLUTTER_DARWIN_EXPORT bool InternalFlutter_Window_IsActivated(void *window)
FLUTTER_DARWIN_EXPORT void InternalFlutter_Window_Minimize(void *window)
static FlutterWindowOffset fromNSPoint(const NSPoint &point)
static FlutterWindowRect fromNSRect(const NSRect &rect)
static FlutterWindowSize fromNSSize(const NSSize &size)