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 
21 @end
22 
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 
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 
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 
66  double min_width;
67  double min_height;
68  double max_width;
69  double max_height;
70 };
71 
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 
94  int64_t engine_id,
95  const FlutterWindowCreationRequest* request);
96 
99  int64_t engine_id,
100  const FlutterWindowCreationRequest* request);
101 
104  int64_t engine_id,
105  const FlutterWindowCreationRequest* request);
106 
109  int64_t engine_id,
110  const FlutterWindowCreationRequest* request);
111 
113 void InternalFlutter_Window_Destroy(int64_t engine_id, void* window);
114 
116 void* InternalFlutter_Window_GetHandle(int64_t engine_id, FlutterViewIdentifier view_id);
117 
120 
122 void InternalFlutter_Window_SetContentSize(void* window, const FlutterWindowSize* size);
123 
125 void InternalFlutter_Window_SetConstraints(void* window,
126  const FlutterWindowConstraints* constraints);
127 
129 void InternalFlutter_Window_SetTitle(void* window, const char* title);
130 
132 void InternalFlutter_Window_SetMaximized(void* window, bool maximized);
133 
135 bool InternalFlutter_Window_IsMaximized(void* window);
136 
138 void InternalFlutter_Window_Minimize(void* window);
139 
141 void InternalFlutter_Window_Unminimize(void* window);
142 
144 bool InternalFlutter_Window_IsMinimized(void* window);
145 
147 void InternalFlutter_Window_SetFullScreen(void* window, bool fullScreen);
148 
150 bool InternalFlutter_Window_IsFullScreen(void* window);
151 
153 void InternalFlutter_Window_Activate(void* window);
154 
156 char* InternalFlutter_Window_GetTitle(void* window);
157 
159 bool InternalFlutter_Window_IsActivated(void* window);
160 
162 void InternalFlutter_Window_UpdatePosition(void* window);
163 
166 
167 // NOLINTEND(google-objc-function-naming)
168 }
169 
170 #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)