diff options
author | Yoshi Sugawara | 2018-10-11 17:09:44 -1000 |
---|---|---|
committer | Thierry Crozat | 2018-10-28 17:16:06 +0000 |
commit | b4bad9100a07266b38a0adaa2efa597b362f027f (patch) | |
tree | 429cc8400bc1e5d14da4e72245f0467a9a9fe461 /backends | |
parent | d4087d790222484465de8c2dd4ed1be5e178d22e (diff) | |
download | scummvm-rg350-b4bad9100a07266b38a0adaa2efa597b362f027f.tar.gz scummvm-rg350-b4bad9100a07266b38a0adaa2efa597b362f027f.tar.bz2 scummvm-rg350-b4bad9100a07266b38a0adaa2efa597b362f027f.zip |
IOS: Support building in Xcode 10/iOS 12, and for iPhone X-like devices that have a "safe area"
iOS 12 drops support for libstdc++, so the project needs to be compiled explicitly using libc++.
Support the "safe area" when redrawing the view to leave space for the notch in portrait and
landscape orientations.
Diffstat (limited to 'backends')
-rw-r--r-- | backends/platform/ios7/ios7_video.mm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm index 7ce19f1f4b..35df78ea51 100644 --- a/backends/platform/ios7/ios7_video.mm +++ b/backends/platform/ios7/ios7_video.mm @@ -776,6 +776,7 @@ uint getSizeNextPOT(uint size) { GLfloat ratio = adjustedHeight / adjustedWidth; int height = (int)(screenWidth * ratio); //printf("Making rect (%u, %u)\n", screenWidth, height); + _gameScreenRect = CGRectMake(0, 0, screenWidth, height); overlayPortraitRatio = (_videoContext.overlayHeight * ratio) / _videoContext.overlayWidth; @@ -792,6 +793,32 @@ uint getSizeNextPOT(uint size) { [self setViewTransformation]; [self updateMouseCursorScaling]; + [self adjustViewFrameForSafeArea]; +} + +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + +-(void)adjustViewFrameForSafeArea { +#if __has_builtin(__builtin_available) + if ( @available(iOS 11,*) ) { +#else + if ( [[UIApplication sharedApplication] keyWindow] respondsToSelector:@selector(safeAreaInsets) ) { +#endif + CGRect screenSize = [[UIScreen mainScreen] bounds]; + UIEdgeInsets inset = [[UIApplication sharedApplication] keyWindow].safeAreaInsets; + UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; + CGRect newFrame = screenSize; + if ( orientation == UIInterfaceOrientationPortrait ) { + newFrame = CGRectMake(screenSize.origin.x, screenSize.origin.y + inset.top, screenSize.size.width, screenSize.size.height - inset.top); + } else if ( orientation == UIInterfaceOrientationLandscapeLeft ) { + newFrame = CGRectMake(screenSize.origin.x, screenSize.origin.y, screenSize.size.width - inset.right, screenSize.size.height); + } else if ( orientation == UIInterfaceOrientationLandscapeRight ) { + newFrame = CGRectMake(screenSize.origin.x + inset.left, screenSize.origin.y, screenSize.size.width - inset.left, screenSize.size.height); + } + self.frame = newFrame; + } } - (void)setViewTransformation { |