summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/uikit/quikitwindow.mm
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2011-08-08 13:26:30 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2011-08-08 13:26:30 (GMT)
commite28e1f919cdc2b82c45b2a5ceee7a9261e70433d (patch)
tree31e2cf533867b86545b509dd7ee472182a4527f3 /src/plugins/platforms/uikit/quikitwindow.mm
parent74b7d4c2c4036e9f2c0da7f0eaad06cef954b923 (diff)
parent82a18deee74bef3e545bf6426164dbe12548e5d9 (diff)
downloadQt-e28e1f919cdc2b82c45b2a5ceee7a9261e70433d.zip
Qt-e28e1f919cdc2b82c45b2a5ceee7a9261e70433d.tar.gz
Qt-e28e1f919cdc2b82c45b2a5ceee7a9261e70433d.tar.bz2
Merge branch '4.8' of scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'src/plugins/platforms/uikit/quikitwindow.mm')
-rw-r--r--src/plugins/platforms/uikit/quikitwindow.mm67
1 files changed, 51 insertions, 16 deletions
diff --git a/src/plugins/platforms/uikit/quikitwindow.mm b/src/plugins/platforms/uikit/quikitwindow.mm
index ec33cd0..6e018fe 100644
--- a/src/plugins/platforms/uikit/quikitwindow.mm
+++ b/src/plugins/platforms/uikit/quikitwindow.mm
@@ -320,10 +320,7 @@ QUIKitWindow::QUIKitWindow(QWidget *tlw) :
mContext(0)
{
mScreen = static_cast<QUIKitScreen *>(QPlatformScreen::platformScreenForWidget(tlw));
- CGRect screenBounds = [mScreen->uiScreen() bounds];
- QRect geom(screenBounds.origin.x, screenBounds.origin.y, screenBounds.size.width, screenBounds.size.height);
- QPlatformWindow::setGeometry(geom);
- mView = [[EAGLView alloc] initWithFrame:CGRectMake(geom.x(), geom.y(), geom.width(), geom.height())];
+ mView = [[EAGLView alloc] init];
}
QUIKitWindow::~QUIKitWindow()
@@ -335,29 +332,23 @@ QUIKitWindow::~QUIKitWindow()
void QUIKitWindow::setGeometry(const QRect &rect)
{
- if (mWindow && rect != geometry()) {
- mWindow.frame = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
- mView.frame = CGRectMake(0, 0, rect.width(), rect.height());
- [mView deleteFramebuffer];
- [mWindow setNeedsDisplay];
- }
+ // Not supported. Only a single "full screen" window is supported
QPlatformWindow::setGeometry(rect);
}
UIWindow *QUIKitWindow::ensureNativeWindow()
{
if (!mWindow) {
- // window
- CGRect frame = [mScreen->uiScreen() applicationFrame];
- QRect geom = QRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
- widget()->setGeometry(geom);
mWindow = [[UIWindow alloc] init];
+ updateGeometryAndOrientation();
+ // window
mWindow.screen = mScreen->uiScreen();
- mWindow.frame = frame; // for some reason setting the screen resets frame.origin, so we need to set the frame afterwards
+ // for some reason setting the screen resets frame.origin, so we need to set the frame afterwards
+ mWindow.frame = mFrame;
// view
[mView deleteFramebuffer];
- mView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height); // fill
+ mView.frame = CGRectMake(0, 0, mWindow.bounds.size.width, mWindow.bounds.size.height); // fill
[mView setMultipleTouchEnabled:YES];
[mView setWindow:this];
[mWindow addSubview:mView];
@@ -367,6 +358,50 @@ UIWindow *QUIKitWindow::ensureNativeWindow()
return mWindow;
}
+void QUIKitWindow::updateGeometryAndOrientation()
+{
+ if (!mWindow)
+ return;
+ mFrame = [mScreen->uiScreen() applicationFrame];
+ CGRect screen = [mScreen->uiScreen() bounds];
+ QRect geom;
+ CGFloat angle = 0;
+ switch ([[UIApplication sharedApplication] statusBarOrientation]) {
+ case UIInterfaceOrientationPortrait:
+ geom = QRect(mFrame.origin.x, mFrame.origin.y, mFrame.size.width, mFrame.size.height);
+ break;
+ case UIInterfaceOrientationPortraitUpsideDown:
+ geom = QRect(screen.size.width - mFrame.origin.x - mFrame.size.width,
+ screen.size.height - mFrame.origin.y - mFrame.size.height,
+ mFrame.size.width,
+ mFrame.size.height);
+ angle = M_PI;
+ break;
+ case UIInterfaceOrientationLandscapeLeft:
+ geom = QRect(screen.size.height - mFrame.origin.y - mFrame.size.height,
+ mFrame.origin.x,
+ mFrame.size.height,
+ mFrame.size.width);
+ angle = -M_PI/2.;
+ break;
+ case UIInterfaceOrientationLandscapeRight:
+ geom = QRect(mFrame.origin.y,
+ screen.size.width - mFrame.origin.x - mFrame.size.width,
+ mFrame.size.height,
+ mFrame.size.width);
+ angle = +M_PI/2.;
+ break;
+ }
+ if (angle != 0) {
+ [mView layer].transform = CATransform3DMakeRotation(angle, 0, 0, 1.);
+ } else {
+ [mView layer].transform = CATransform3DIdentity;
+ }
+ [mView setNeedsDisplay];
+ widget()->setGeometry(geom);
+ widget()->update();
+}
+
QPlatformGLContext *QUIKitWindow::glContext() const
{
if (!mContext) {