use of org.robovm.apple.uikit.UIInterfaceOrientation in project libgdx by libgdx.
the class IOSApplication method getBounds.
/** GL View spans whole screen, that is, even under the status bar. iOS can also rotate the screen, which is not handled
* consistently over iOS versions. This method returns, in pixels, rectangle in which libGDX draws.
*
* @return dimensions of space we draw to, adjusted for device orientation */
protected CGRect getBounds() {
final CGRect screenBounds = UIScreen.getMainScreen().getBounds();
final CGRect statusBarFrame = uiApp.getStatusBarFrame();
final UIInterfaceOrientation statusBarOrientation = uiApp.getStatusBarOrientation();
double statusBarHeight = Math.min(statusBarFrame.getWidth(), statusBarFrame.getHeight());
double screenWidth = screenBounds.getWidth();
double screenHeight = screenBounds.getHeight();
// Make sure that the orientation is consistent with ratios. Should be, but may not be on older iOS versions
switch(statusBarOrientation) {
case LandscapeLeft:
case LandscapeRight:
if (screenHeight > screenWidth) {
debug("IOSApplication", "Switching reported width and height (w=" + screenWidth + " h=" + screenHeight + ")");
double tmp = screenHeight;
// noinspection SuspiciousNameCombination
screenHeight = screenWidth;
screenWidth = tmp;
}
}
// update width/height depending on display scaling selected
screenWidth *= displayScaleFactor;
screenHeight *= displayScaleFactor;
if (statusBarHeight != 0.0) {
debug("IOSApplication", "Status bar is visible (height = " + statusBarHeight + ")");
statusBarHeight *= displayScaleFactor;
screenHeight -= statusBarHeight;
} else {
debug("IOSApplication", "Status bar is not visible");
}
debug("IOSApplication", "Total computed bounds are w=" + screenWidth + " h=" + screenHeight);
return lastScreenBounds = new CGRect(0.0, statusBarHeight, screenWidth, screenHeight);
}
Aggregations