Vuo  2.3.2
VuoGraphicsWindowDelegate.m
Go to the documentation of this file.
1 
10 #import "module.h"
12 #import "VuoApp.h"
13 
14 #ifdef VUO_COMPILER
16  "title" : "VuoGraphicsWindow",
17  "dependencies" : [
18  "VuoGraphicsWindow",
19  "VuoWindow",
20  "VuoWindowReference"
21  ]
22 });
23 #endif
24 
29 @property(assign) VuoGraphicsWindow *window;
30 @end
31 
32 @implementation VuoGraphicsWindowDelegate
33 
37 - (instancetype)initWithWindow:(VuoGraphicsWindow *)window
38 {
39  if (self = [super init])
40  {
41  _window = window;
42  }
43  return self;
44 }
45 
49 - (void)windowWillClose:(NSNotification *)notification
50 {
51  if (_window.oldMenu)
52  {
53  VuoApp_setMenu(_window.oldMenu);
54  _window.oldMenu = nil;
55  }
56  _window.isClosed = YES;
57 }
58 
62 - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize
63 {
64  NSRect contentRect = [_window contentRectForFrameRect:NSMakeRect(0,0,frameSize.width,frameSize.height)];
65  contentRect.size.width = MAX(VuoGraphicsWindowMinSize, contentRect.size.width);
66  contentRect.size.height = MAX(VuoGraphicsWindowMinSize, contentRect.size.height);
67  NSRect frameRect = [_window frameRectForContentRect:contentRect];
68  return frameRect.size;
69 }
70 
77 - (void)windowDidResize:(NSNotification *)notification
78 {
79  if (!_window.programmaticallyResizingWindow)
80  {
81  _window.userResizedWindow = YES;
82  if (_window.updatedWindow)
83  {
86  _window.updatedWindow(rl);
87  }
88  if (_window.showedWindow)
89  _window.showedWindow(VuoWindowReference_make(_window));
90  }
91 
92  NSView *gv = _window.contentView;
93  _window.contentRectCached = gv.frame;
94 }
95 
100 - (void)windowWillEnterFullScreen:(NSNotification *)notification
101 {
102  _window.isInMacFullScreenMode = YES;
103 }
104 
108 - (void)windowDidEnterFullScreen:(NSNotification *)notification
109 {
110  if (_window.programmaticallyTransitioningFullScreen)
111  {
112  dispatch_semaphore_signal(VuoGraphicsWindow_fullScreenTransitionSemaphore);
113  _window.programmaticallyTransitioningFullScreen = false;
114  [_window finishFullScreenTransition];
115  }
116 }
117 
122 - (void)windowWillExitFullScreen:(NSNotification *)notification
123 {
124  _window.isInMacFullScreenMode = NO;
125 }
126 
130 - (void)windowDidExitFullScreen:(NSNotification *)notification
131 {
132  if (_window.programmaticallyTransitioningFullScreen)
133  {
134  dispatch_semaphore_signal(VuoGraphicsWindow_fullScreenTransitionSemaphore);
135  _window.programmaticallyTransitioningFullScreen = false;
136  [_window finishFullScreenTransition];
137  }
138 }
139 
145 - (void)windowDidMove:(NSNotification *)notification
146 {
147  if (_window.updatedWindow)
148  {
151  _window.updatedWindow(rl);
152  }
153  if (_window.showedWindow && !_window.programmaticallyResizingWindow)
154  _window.showedWindow(VuoWindowReference_make(_window));
155 }
156 
157 @end