summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-04-15 18:29:36 +0300
committerTor Lillqvist <tml@iki.fi>2013-04-15 21:25:43 +0300
commitcfe512ac7bdbc79603ca5ffe89980d6a0489e0ca (patch)
tree362f2b643fad867d37b4e5da94709a5d8d88cf55 /ios
parentc02f96f0bb2ae3bb9c9cb91fff40d3435260c155 (diff)
Start hacking on handling orientation changes
Change-Id: I94cfdc1b334539399faff29c046185bbbf698d23
Diffstat (limited to 'ios')
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/AppDelegate.m33
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/View.m22
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/ViewController.m4
3 files changed, 56 insertions, 3 deletions
diff --git a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
index a12585b4ef0f..2285f04f412e 100644
--- a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
+++ b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
@@ -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];
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.m b/ios/experimental/LibreOffice/LibreOffice/View.m
index 2dd4ab899cc3..430839223c41 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.m
+++ b/ios/experimental/LibreOffice/LibreOffice/View.m
@@ -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);
diff --git a/ios/experimental/LibreOffice/LibreOffice/ViewController.m b/ios/experimental/LibreOffice/LibreOffice/ViewController.m
index 8a44526401ab..58da5db5aa06 100644
--- a/ios/experimental/LibreOffice/LibreOffice/ViewController.m
+++ b/ios/experimental/LibreOffice/LibreOffice/ViewController.m
@@ -9,6 +9,10 @@
#import "ViewController.h"
+#include <osl/detail/ios-bootstrap.h>
+
+#import "lo.h"
+
@implementation ViewController
- (void)viewDidLoad