diff --git a/app/darwin_armx.go b/app/darwin_armx.go index 3639c7d..5a4f6d8 100644 --- a/app/darwin_armx.go +++ b/app/darwin_armx.go @@ -13,6 +13,7 @@ package app #include #include #include +#include extern struct utsname sysInfo; @@ -97,15 +98,23 @@ func setScreen(scale int) { } //export updateConfig -func updateConfig(width, height int) { - widthPx := screenScale * width - heightPx := screenScale * height +func updateConfig(width, height, orientation int32) { + o := config.OrientationUnknown + switch orientation { + case C.UIDeviceOrientationPortrait, C.UIDeviceOrientationPortraitUpsideDown: + o = config.OrientationPortrait + case C.UIDeviceOrientationLandscapeLeft, C.UIDeviceOrientationLandscapeRight: + o = config.OrientationLandscape + } + widthPx := screenScale * int(width) + heightPx := screenScale * int(height) eventsIn <- config.Event{ WidthPx: widthPx, HeightPx: heightPx, WidthPt: geom.Pt(float32(widthPx) / pixelsPerPt), HeightPt: geom.Pt(float32(heightPx) / pixelsPerPt), PixelsPerPt: pixelsPerPt, + Orientation: o, } } diff --git a/app/darwin_armx.m b/app/darwin_armx.m index c8ea451..c521bba 100644 --- a/app/darwin_armx.m +++ b/app/darwin_armx.m @@ -54,11 +54,17 @@ struct utsname sysInfo; setScreen(scale); CGSize size = [UIScreen mainScreen].bounds.size; - updateConfig((int)size.width, (int)size.height); + UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; + updateConfig((int)size.width, (int)size.height, orientation); } - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { - updateConfig((int)size.width, (int)size.height); + [coordinator animateAlongsideTransition:^(id context) { + // TODO(crawshaw): come up with a plan to handle animations. + } completion:^(id context) { + UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; + updateConfig((int)size.width, (int)size.height, orientation); + }]; } - (void)update {