Generate resize event when the status bar changes size (e.g. call in progress, etc.)
This commit is contained in:
parent
97995a79c8
commit
ef68bf1b32
2 changed files with 36 additions and 17 deletions
|
@ -31,8 +31,10 @@
|
|||
@property (readwrite) SDL_Window *window;
|
||||
|
||||
- (id)initWithSDLWindow:(SDL_Window *)_window;
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient;
|
||||
- (void)loadView;
|
||||
- (void)statusBarFrameChanged:(NSNotification*)notification;
|
||||
- (void)onWindowSizeChanged;
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient;
|
||||
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
|
||||
|
||||
@end
|
||||
|
|
|
@ -43,9 +43,39 @@
|
|||
return nil;
|
||||
}
|
||||
self.window = _window;
|
||||
|
||||
// Register for notification when the status bar size changes
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)loadView
|
||||
{
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
- (void)statusBarFrameChanged:(NSNotification*)notification
|
||||
{
|
||||
[self onWindowSizeChanged];
|
||||
}
|
||||
|
||||
- (void)onWindowSizeChanged
|
||||
{
|
||||
if (self->window->flags & SDL_WINDOW_RESIZABLE) {
|
||||
SDL_WindowData *data = self->window->driverdata;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(self->window);
|
||||
SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
|
||||
const CGSize size = data->view.bounds.size;
|
||||
int w, h;
|
||||
|
||||
w = (int)(size.width * displaymodedata->scale);
|
||||
h = (int)(size.height * displaymodedata->scale);
|
||||
|
||||
SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient
|
||||
{
|
||||
// Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation
|
||||
|
@ -108,27 +138,14 @@
|
|||
return NO; // Nothing else is acceptable.
|
||||
}
|
||||
|
||||
- (void)loadView
|
||||
{
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
// Send a resized event when the orientation changes.
|
||||
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
|
||||
{
|
||||
const UIInterfaceOrientation toInterfaceOrientation = [self interfaceOrientation];
|
||||
SDL_WindowData *data = self->window->driverdata;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(self->window);
|
||||
SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
|
||||
const CGSize size = data->view.bounds.size;
|
||||
int w, h;
|
||||
|
||||
w = (int)(size.width * displaymodedata->scale);
|
||||
h = (int)(size.height * displaymodedata->scale);
|
||||
|
||||
SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h);
|
||||
[self onWindowSizeChanged];
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_UIKIT */
|
||||
|
||||
@end
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue