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  bool resizable;
80  int64_t parent_view_id;
81  void (*on_should_close)();
82  void (*on_will_close)();
83  void (*notify_listeners)();
84  // For sized to content windows with positioner returns the desired window position for given
85  // configuration. All coordinates are in logical space.
86  FlutterWindowRect* (*on_get_window_position)(const FlutterWindowSize& child_size,
87  const FlutterWindowRect& parent_rect,
88  const FlutterWindowRect& output_rect);
89 };
90 
91 extern "C" {
92 
93 // NOLINTBEGIN(google-objc-function-naming)
94 
97  int64_t engine_id,
98  const FlutterWindowCreationRequest* request);
99 
102  int64_t engine_id,
103  const FlutterWindowCreationRequest* request);
104 
107  int64_t engine_id,
108  const FlutterWindowCreationRequest* request);
109 
112  int64_t engine_id,
113  const FlutterWindowCreationRequest* request);
114 
116 void InternalFlutter_Window_Destroy(int64_t engine_id, void* window);
117 
119 void* InternalFlutter_Window_GetHandle(int64_t engine_id, FlutterViewIdentifier view_id);
120 
123 
125 void InternalFlutter_Window_SetContentSize(void* window, const FlutterWindowSize* size);
126 
128 void InternalFlutter_Window_SetConstraints(void* window,
129  const FlutterWindowConstraints* constraints);
130 
132 void InternalFlutter_Window_SetTitle(void* window, const char* title);
133 
135 void InternalFlutter_Window_SetMaximized(void* window, bool maximized);
136 
138 bool InternalFlutter_Window_IsMaximized(void* window);
139 
141 void InternalFlutter_Window_Minimize(void* window);
142 
144 void InternalFlutter_Window_Unminimize(void* window);
145 
147 bool InternalFlutter_Window_IsMinimized(void* window);
148 
150 void InternalFlutter_Window_SetFullScreen(void* window, bool fullScreen);
151 
153 bool InternalFlutter_Window_IsFullScreen(void* window);
154 
156 void InternalFlutter_Window_Activate(void* window);
157 
159 char* InternalFlutter_Window_GetTitle(void* window);
160 
162 bool InternalFlutter_Window_IsActivated(void* window);
163 
165 void InternalFlutter_Window_UpdatePosition(void* window);
166 
169 
170 // NOLINTEND(google-objc-function-naming)
171 }
172 
173 #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)