src/video/uikit/SDL_uikitviewcontroller.m
author Kees Bakker <kees@ijzerbout.nl>
Wed, 28 Sep 2011 21:42:02 +0200
changeset 6011 83a21d3bd5c1
parent 6003 fddf81967e2d
child 6044 35448a5ea044
permissions -rw-r--r--
Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
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
/*
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
     2
 Simple DirectMedia Layer
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
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
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
     5
 This software is provided 'as-is', without any express or implied
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
     6
 warranty.  In no event will the authors be held liable for any damages
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
     7
 arising from the use of this software.
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
     8
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
     9
 Permission is granted to anyone to use this software for any purpose,
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    10
 including commercial applications, and to alter it and redistribute it
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
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
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    13
 1. The origin of this software must not be misrepresented; you must not
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    14
 claim that you wrote the original software. If you use this software
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    15
 in a product, an acknowledgment in the product documentation would be
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    16
 appreciated but is not required.
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    17
 2. Altered source versions must be plainly marked as such, and must not be
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    18
 misrepresented as being the original software.
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    19
 3. This notice may not be removed or altered from any source distribution.
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    20
 */
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    21
#include "SDL_config.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    22
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    23
#include "SDL_video.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    24
#include "SDL_assert.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    25
#include "SDL_hints.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    26
#include "../SDL_sysvideo.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    27
#include "../../events/SDL_events_c.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    28
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    29
#include "SDL_uikitwindow.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
#import "SDL_uikitviewcontroller.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
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    34
@implementation SDL_uikitviewcontroller
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    35
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    36
@synthesize window;
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    37
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    38
- (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
    39
{
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    40
    self = [self init];
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    41
    if (self == nil) {
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    42
        return nil;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    43
    }
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    44
    self.window = _window;
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    45
    return self;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    46
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    47
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    48
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    49
{
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    50
    const char *orientationsCString;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    51
    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
    52
        BOOL rotate = NO;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    53
        NSString *orientationsNSString = [NSString stringWithCString:orientationsCString
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    54
                                                            encoding:NSUTF8StringEncoding];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    55
        NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    56
                                 [NSCharacterSet characterSetWithCharactersInString:@" "]];
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    57
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    58
        switch (orient) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    59
            case UIInterfaceOrientationLandscapeLeft:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    60
                rotate = [orientations containsObject:@"LandscapeLeft"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    61
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    62
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    63
            case UIInterfaceOrientationLandscapeRight:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    64
                rotate = [orientations containsObject:@"LandscapeRight"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    65
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    66
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    67
            case UIInterfaceOrientationPortrait:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    68
                rotate = [orientations containsObject:@"Portrait"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    69
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    70
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    71
            case UIInterfaceOrientationPortraitUpsideDown:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    72
                rotate = [orientations containsObject:@"PortraitUpsideDown"];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    73
                break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    74
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    75
            default: break;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    76
        }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    77
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    78
        return rotate;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    79
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    80
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    81
    if (self->window->flags & SDL_WINDOW_RESIZABLE) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    82
        return YES;  // any orientation is okay.
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    83
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    84
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    85
    // 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
    86
    //  (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
    87
    //   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
    88
    //   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
    89
    switch (orient) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    90
        case UIInterfaceOrientationLandscapeLeft:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    91
        case UIInterfaceOrientationLandscapeRight:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    92
            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
    93
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    94
        case UIInterfaceOrientationPortrait:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    95
        case UIInterfaceOrientationPortraitUpsideDown:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    96
            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
    97
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    98
        default: break;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    99
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   100
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   101
    return NO;  // Nothing else is acceptable.
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   102
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   103
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   104
- (void)loadView
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   105
{
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   106
    // do nothing.
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   107
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   108
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   109
// 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
   110
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   111
{
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   112
    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
   113
        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
   114
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   115
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   116
    const UIInterfaceOrientation toInterfaceOrientation = [self interfaceOrientation];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   117
    SDL_WindowData *data = self->window->driverdata;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   118
    UIWindow *uiwindow = data->uiwindow;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   119
    UIScreen *uiscreen = [uiwindow screen];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   120
    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
   121
    CGRect frame = noborder ? [uiscreen bounds] : [uiscreen applicationFrame];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   122
    const CGSize size = frame.size;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   123
    int w, h;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   124
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   125
    switch (toInterfaceOrientation) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   126
        case UIInterfaceOrientationPortrait:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   127
        case UIInterfaceOrientationPortraitUpsideDown:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   128
            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
   129
            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
   130
            break;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   131
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   132
        case UIInterfaceOrientationLandscapeLeft:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   133
        case UIInterfaceOrientationLandscapeRight:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   134
            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
   135
            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
   136
            break;
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
        default:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   139
            SDL_assert(0 && "Unexpected interface orientation!");
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   140
            return;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   141
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   142
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   143
    frame.size.width = w;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   144
    frame.size.height = h;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   145
    frame.origin.x = 0;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   146
    frame.origin.y = 0;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
   147
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   148
    [uiwindow setFrame:frame];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   149
    [data->view updateFrame];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   150
    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
   151
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   152
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   153
@end