Implemented fullscreen on OS X.
This commit is contained in:
parent
69cafde7f3
commit
fd9af04123
|
@ -15,6 +15,7 @@ struct uiWindow {
|
|||
void (*onContentSizeChanged)(uiWindow *, void *);
|
||||
void *onContentSizeChangedData;
|
||||
BOOL suppressSizeChanged;
|
||||
int fullscreen;
|
||||
};
|
||||
|
||||
@interface windowDelegateClass : NSObject<NSWindowDelegate> {
|
||||
|
@ -23,6 +24,8 @@ struct uiWindow {
|
|||
- (BOOL)windowShouldClose:(id)sender;
|
||||
- (void)windowDidMove:(NSNotification *)note;
|
||||
- (void)windowDidResize:(NSNotification *)note;
|
||||
- (void)windowDidEnterFullScreen:(NSNotification *)note;
|
||||
- (void)windowDidExitFullScreen:(NSNotification *)note;
|
||||
- (void)registerWindow:(uiWindow *)w;
|
||||
- (void)unregisterWindow:(uiWindow *)w;
|
||||
- (uiWindow *)lookupWindow:(NSWindow *)w;
|
||||
|
@ -74,6 +77,24 @@ struct uiWindow {
|
|||
(*(w->onContentSizeChanged))(w, w->onContentSizeChangedData);
|
||||
}
|
||||
|
||||
- (void)windowDidEnterFullScreen:(NSNotification *)note
|
||||
{
|
||||
uiWindow *w;
|
||||
|
||||
w = [self lookupWindow:((NSWindow *) [note object])];
|
||||
if (!w->suppressSizeChanged)
|
||||
w->fullscreen = 1;
|
||||
}
|
||||
|
||||
- (void)windowDidExitFullScreen:(NSNotification *)note
|
||||
{
|
||||
uiWindow *w;
|
||||
|
||||
w = [self lookupWindow:((NSWindow *) [note object])];
|
||||
if (!w->suppressSizeChanged)
|
||||
w->fullscreen = 0;
|
||||
}
|
||||
|
||||
- (void)registerWindow:(uiWindow *)w
|
||||
{
|
||||
mapSet(self->windows, w->window, w);
|
||||
|
@ -290,6 +311,23 @@ void uiWindowSetContentSize(uiWindow *w, int width, int height)
|
|||
w->suppressSizeChanged = NO;
|
||||
}
|
||||
|
||||
int uiWindowFullscreen(uiWindow *w)
|
||||
{
|
||||
return w->fullscreen;
|
||||
}
|
||||
|
||||
void uiWindowSetFullscreen(uiWindow *w, int fullscreen)
|
||||
{
|
||||
if (w->fullscreen && fullscreen)
|
||||
return;
|
||||
if (!w->fullscreen && !fullscreen)
|
||||
return;
|
||||
w->fullscreen = fullscreen;
|
||||
w->suppressSizeChanged = YES;
|
||||
[w->window toggleFullScreen:w->window];
|
||||
w->suppressSizeChanged = NO;
|
||||
}
|
||||
|
||||
void uiWindowOnContentSizeChanged(uiWindow *w, void (*f)(uiWindow *, void *), void *data)
|
||||
{
|
||||
w->onContentSizeChanged = f;
|
||||
|
|
|
@ -75,6 +75,7 @@ static void updatesize(uiWindow *w)
|
|||
uiWindowContentSize(w, &xp, &yp);
|
||||
uiSpinboxSetValue(width, xp);
|
||||
uiSpinboxSetValue(height, yp);
|
||||
// TODO on OS X this is updated AFTER sending the size change, not before
|
||||
uiCheckboxSetChecked(fullscreen, uiWindowFullscreen(w));
|
||||
}
|
||||
|
||||
|
@ -88,7 +89,7 @@ void setFullscreen(uiCheckbox *cb, void *data)
|
|||
{
|
||||
uiWindow *w = uiWindow(data);
|
||||
|
||||
uiWindowSetFullscreen(w, uiCheckboxChecked(tb));
|
||||
uiWindowSetFullscreen(w, uiCheckboxChecked(fullscreen));
|
||||
updatesize(w);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue