Kaydet (Commit) cfe512ac authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Start hacking on handling orientation changes

Change-Id: I94cfdc1b334539399faff29c046185bbbf698d23
üst c02f96f0
......@@ -26,6 +26,17 @@ static View *theView;
(void) launchOptions;
CGRect bounds = [[UIScreen mainScreen] bounds];
NSLog(@"mainScreen bounds: %dx%d@(%d,%d)",
(int) bounds.size.width, (int) bounds.size.height,
(int) bounds.origin.x, (int) bounds.origin.y);
CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
NSLog(@"mainScreen applicationFrame: %dx%d@(%d,%d)",
(int) applicationFrame.size.width, (int) applicationFrame.size.height,
(int) applicationFrame.origin.x, (int) applicationFrame.origin.y);
self.window = [[UIWindow alloc] initWithFrame:bounds];
self.window.backgroundColor = [UIColor whiteColor];
......@@ -51,7 +62,10 @@ static View *theView;
[self.window addGestureRecognizer: tapRecognizer];
lo_set_view_size(bounds.size.width, bounds.size.height);
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
lo_set_view_size(applicationFrame.size.height, applicationFrame.size.width);
else
lo_set_view_size(applicationFrame.size.width, applicationFrame.size.height);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];
......@@ -110,6 +124,23 @@ static View *theView;
(void) application;
}
- (void)application:(UIApplication *)application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame
{
(void) application;
(void) oldStatusBarFrame;
CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
NSLog(@"New applicationFrame: %dx%d@(%d,%d)",
(int) applicationFrame.size.width, (int) applicationFrame.size.height,
(int) applicationFrame.origin.x, (int) applicationFrame.origin.y);
NSLog(@"statusBarOrientation: %d", [[UIApplication sharedApplication] statusBarOrientation]);
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
lo_set_view_size(applicationFrame.size.height, applicationFrame.size.width);
else
lo_set_view_size(applicationFrame.size.width, applicationFrame.size.height);
}
- (void)keyboardWillShow:(NSNotification *)note
{
NSDictionary *info = [note userInfo];
......
......@@ -20,8 +20,26 @@
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextTranslateCTM(context, 0, self.frame.size.height);
CGContextScaleCTM(context, 1, -1);
switch ([[UIApplication sharedApplication] statusBarOrientation]) {
case UIInterfaceOrientationPortrait:
CGContextTranslateCTM(context, 0, self.frame.size.height);
CGContextScaleCTM(context, 1, -1);
break;
case UIInterfaceOrientationLandscapeLeft:
CGContextTranslateCTM(context, self.frame.size.width, self.frame.size.height);
CGContextRotateCTM(context, M_PI/2);
CGContextScaleCTM(context, -1, 1);
break;
case UIInterfaceOrientationLandscapeRight:
CGContextRotateCTM(context, -M_PI/2);
CGContextScaleCTM(context, -1, 1);
break;
case UIInterfaceOrientationPortraitUpsideDown:
CGContextTranslateCTM(context, self.frame.size.width, 0);
CGContextScaleCTM(context, -1, 1);
break;
}
lo_render_windows(context, rect);
CGContextRestoreGState(context);
......
......@@ -9,6 +9,10 @@
#import "ViewController.h"
#include <osl/detail/ios-bootstrap.h>
#import "lo.h"
@implementation ViewController
- (void)viewDidLoad
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment