src/video/uikit/SDL_uikitviewcontroller.m
author Sam Lantinga <slouken@libsdl.org>
Tue, 18 Sep 2012 23:13:35 -0700
changeset 6440 f0ca76958984
parent 6438 2c0fa683b18c
child 6451 52e5a05ca795
permissions -rwxr-xr-x
Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
     1
/*
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     2
  Simple DirectMedia Layer
6138
4c64952a58fb Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6093
diff changeset
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
     4
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     5
  This software is provided 'as-is', without any express or implied
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     7
  arising from the use of this software.
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     8
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    11
  freely, subject to the following restrictions:
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    12
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    14
     claim that you wrote the original software. If you use this software
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    16
     appreciated but is not required.
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    18
     misrepresented as being the original software.
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    20
*/
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    21
#include "SDL_config.h"
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    22
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    23
#if SDL_VIDEO_DRIVER_UIKIT
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    24
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    25
#include "SDL_video.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    26
#include "SDL_assert.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    27
#include "SDL_hints.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    28
#include "../SDL_sysvideo.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    29
#include "../../events/SDL_events_c.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    30
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    31
#include "SDL_uikitwindow.h"
6093
a8696b259e09 Another iOS 3.1 compatibility fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 6079
diff changeset
    32
#include "SDL_uikitviewcontroller.h"
a8696b259e09 Another iOS 3.1 compatibility fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 6079
diff changeset
    33
#include "SDL_uikitvideo.h"
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    34
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    35
@implementation SDL_uikitviewcontroller
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    36
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    37
@synthesize window;
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    38
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    39
- (id)initWithSDLWindow:(SDL_Window *)_window
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    40
{
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    41
    self = [self init];
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    42
    if (self == nil) {
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    43
        return nil;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    44
    }
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    45
    self.window = _window;
6440
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    46
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    47
    // Register for notification when the status bar size changes    
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    48
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    49
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    50
    return self;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    51
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    52
6440
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    53
- (void)loadView
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    54
{
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    55
    // do nothing.
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    56
}
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    57
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    58
- (void)statusBarFrameChanged:(NSNotification*)notification
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    59
{
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    60
    [self onWindowSizeChanged];
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    61
}
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    62
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    63
- (void)onWindowSizeChanged
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    64
{
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    65
    if (self->window->flags & SDL_WINDOW_RESIZABLE) {
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    66
        SDL_WindowData *data = self->window->driverdata;
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    67
        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(self->window);
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    68
        SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    69
        const CGSize size = data->view.bounds.size;
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    70
        int w, h;
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    71
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    72
        w = (int)(size.width * displaymodedata->scale);
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    73
        h = (int)(size.height * displaymodedata->scale);
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    74
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    75
        SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h);
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    76
    }
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    77
}
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    78
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    79
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    80
{
6438
2c0fa683b18c User interface guidelines says that you shouldn't allow upside-down orientation on phones.
Sam Lantinga <slouken@libsdl.org>
parents: 6437
diff changeset
    81
    // Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation
2c0fa683b18c User interface guidelines says that you shouldn't allow upside-down orientation on phones.
Sam Lantinga <slouken@libsdl.org>
parents: 6437
diff changeset
    82
    if (orient == UIInterfaceOrientationPortraitUpsideDown) {
2c0fa683b18c User interface guidelines says that you shouldn't allow upside-down orientation on phones.
Sam Lantinga <slouken@libsdl.org>
parents: 6437
diff changeset
    83
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
2c0fa683b18c User interface guidelines says that you shouldn't allow upside-down orientation on phones.
Sam Lantinga <slouken@libsdl.org>
parents: 6437
diff changeset
    84
            return NO;
2c0fa683b18c User interface guidelines says that you shouldn't allow upside-down orientation on phones.
Sam Lantinga <slouken@libsdl.org>
parents: 6437
diff changeset
    85
    }
2c0fa683b18c User interface guidelines says that you shouldn't allow upside-down orientation on phones.
Sam Lantinga <slouken@libsdl.org>
parents: 6437
diff changeset
    86
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    87
    const char *orientationsCString;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    88
    if ((orientationsCString = SDL_GetHint(SDL_HINT_ORIENTATIONS)) != NULL) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    89
        BOOL rotate = NO;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    90
        NSString *orientationsNSString = [NSString stringWithCString:orientationsCString
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    91
                                                            encoding:NSUTF8StringEncoding];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    92
        NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    93
                                 [NSCharacterSet characterSetWithCharactersInString:@" "]];
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    94
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    95
        switch (orient) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    96
            case UIInterfaceOrientationLandscapeLeft:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    97
                rotate = [orientations containsObject:@"LandscapeLeft"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    98
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    99
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   100
            case UIInterfaceOrientationLandscapeRight:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   101
                rotate = [orientations containsObject:@"LandscapeRight"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   102
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   103
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   104
            case UIInterfaceOrientationPortrait:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   105
                rotate = [orientations containsObject:@"Portrait"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   106
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   107
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   108
            case UIInterfaceOrientationPortraitUpsideDown:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   109
                rotate = [orientations containsObject:@"PortraitUpsideDown"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   110
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   111
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   112
            default: break;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   113
        }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   114
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   115
        return rotate;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   116
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   117
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   118
    if (self->window->flags & SDL_WINDOW_RESIZABLE) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   119
        return YES;  // any orientation is okay.
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   120
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   121
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   122
    // If not resizable, allow device to orient to other matching sizes
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   123
    //  (that is, let the user turn the device upside down...same screen
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   124
    //   dimensions, but it lets the user place the device where it's most
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   125
    //   comfortable in relation to its physical buttons, headphone jack, etc).
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   126
    switch (orient) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   127
        case UIInterfaceOrientationLandscapeLeft:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   128
        case UIInterfaceOrientationLandscapeRight:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   129
            return (self->window->w >= self->window->h);
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   130
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   131
        case UIInterfaceOrientationPortrait:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   132
        case UIInterfaceOrientationPortraitUpsideDown:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   133
            return (self->window->h >= self->window->w);
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   134
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   135
        default: break;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   136
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   137
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   138
    return NO;  // Nothing else is acceptable.
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   139
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   140
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   141
// Send a resized event when the orientation changes.
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   142
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   143
{
6440
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
   144
    [self onWindowSizeChanged];
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   145
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   146
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
   147
#endif /* SDL_VIDEO_DRIVER_UIKIT */
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
   148
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   149
@end
6440
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
   150
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
   151
/* vi: set ts=4 sw=4 expandtab: */