src/video/uikit/SDL_uikitviewcontroller.m
author Sam Lantinga <slouken@libsdl.org>
Mon, 31 Oct 2011 05:56:58 -0400
changeset 6044 35448a5ea044
parent 6011 83a21d3bd5c1
child 6077 ee00e4b80f79
permissions -rw-r--r--
Lots of fixes importing SDL source wholesale into a new iOS project
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
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     3
  Copyright (C) 1997-2011 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"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    32
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    33
#import "SDL_uikitviewcontroller.h"
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
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    36
@implementation SDL_uikitviewcontroller
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    37
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    38
@synthesize window;
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    39
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    40
- (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
    41
{
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    42
    self = [self init];
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    43
    if (self == nil) {
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    44
        return nil;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    45
    }
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    46
    self.window = _window;
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    47
    return self;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    48
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    49
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    50
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    51
{
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    52
    const char *orientationsCString;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    53
    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
    54
        BOOL rotate = NO;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    55
        NSString *orientationsNSString = [NSString stringWithCString:orientationsCString
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    56
                                                            encoding:NSUTF8StringEncoding];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    57
        NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    58
                                 [NSCharacterSet characterSetWithCharactersInString:@" "]];
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    59
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    60
        switch (orient) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    61
            case UIInterfaceOrientationLandscapeLeft:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    62
                rotate = [orientations containsObject:@"LandscapeLeft"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    63
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    64
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    65
            case UIInterfaceOrientationLandscapeRight:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    66
                rotate = [orientations containsObject:@"LandscapeRight"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    67
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    68
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    69
            case UIInterfaceOrientationPortrait:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    70
                rotate = [orientations containsObject:@"Portrait"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    71
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    72
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    73
            case UIInterfaceOrientationPortraitUpsideDown:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    74
                rotate = [orientations containsObject:@"PortraitUpsideDown"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    75
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    76
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    77
            default: break;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    78
        }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    79
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    80
        return rotate;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    81
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    82
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    83
    if (self->window->flags & SDL_WINDOW_RESIZABLE) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    84
        return YES;  // any orientation is okay.
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    85
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    86
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    87
    // 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
    88
    //  (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
    89
    //   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
    90
    //   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
    91
    switch (orient) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    92
        case UIInterfaceOrientationLandscapeLeft:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    93
        case UIInterfaceOrientationLandscapeRight:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    94
            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
    95
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    96
        case UIInterfaceOrientationPortrait:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    97
        case UIInterfaceOrientationPortraitUpsideDown:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    98
            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
    99
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   100
        default: break;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   101
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   102
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   103
    return NO;  // Nothing else is acceptable.
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   104
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   105
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   106
- (void)loadView
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   107
{
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   108
    // do nothing.
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   109
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   110
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   111
// 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
   112
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   113
{
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   114
    if ((self->window->flags & SDL_WINDOW_RESIZABLE) == 0) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   115
        return;   // don't care, we're just flipping over in this case.
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
    const UIInterfaceOrientation toInterfaceOrientation = [self interfaceOrientation];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   119
    SDL_WindowData *data = self->window->driverdata;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   120
    UIWindow *uiwindow = data->uiwindow;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   121
    UIScreen *uiscreen = [uiwindow screen];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   122
    const int noborder = self->window->flags & SDL_WINDOW_BORDERLESS;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   123
    CGRect frame = noborder ? [uiscreen bounds] : [uiscreen applicationFrame];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   124
    const CGSize size = frame.size;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   125
    int w, h;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   126
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   127
    switch (toInterfaceOrientation) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   128
        case UIInterfaceOrientationPortrait:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   129
        case UIInterfaceOrientationPortraitUpsideDown:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   130
            w = (size.width < size.height) ? size.width : size.height;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   131
            h = (size.width > size.height) ? size.width : size.height;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   132
            break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   133
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   134
        case UIInterfaceOrientationLandscapeLeft:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   135
        case UIInterfaceOrientationLandscapeRight:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   136
            w = (size.width > size.height) ? size.width : size.height;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   137
            h = (size.width < size.height) ? size.width : size.height;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   138
            break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   139
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   140
        default:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   141
            SDL_assert(0 && "Unexpected interface orientation!");
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   142
            return;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   143
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   144
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   145
    frame.size.width = w;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   146
    frame.size.height = h;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   147
    frame.origin.x = 0;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   148
    frame.origin.y = 0;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   149
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   150
    [uiwindow setFrame:frame];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   151
    [data->view updateFrame];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   152
    SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h);
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   153
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   154
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
   155
#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
   156
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   157
@end