mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added checks to make sure that the current interface orientation is actually allowed when changing allowed interface orientations
This commit is contained in:
parent
848073d207
commit
40994fcdab
1 changed files with 38 additions and 1 deletions
|
|
@ -48,6 +48,20 @@ namespace Orientations
|
|||
return Desktop::upright;
|
||||
}
|
||||
|
||||
static UIInterfaceOrientation convertFromJuce (Desktop::DisplayOrientation orientation)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
case Desktop::upright: return UIInterfaceOrientationPortrait;
|
||||
case Desktop::upsideDown: return UIInterfaceOrientationPortraitUpsideDown;
|
||||
case Desktop::rotatedClockwise: return UIInterfaceOrientationLandscapeLeft;
|
||||
case Desktop::rotatedAntiClockwise: return UIInterfaceOrientationLandscapeRight;
|
||||
default: jassertfalse; // unknown orientation!
|
||||
}
|
||||
|
||||
return UIInterfaceOrientationPortrait;
|
||||
}
|
||||
|
||||
static CGAffineTransform getCGTransformFor (const Desktop::DisplayOrientation orientation) noexcept
|
||||
{
|
||||
if (isUsingOldRotationMethod())
|
||||
|
|
@ -1029,7 +1043,30 @@ void Desktop::setKioskComponent (Component* kioskModeComp, bool enableOrDisable,
|
|||
}
|
||||
}
|
||||
|
||||
void Desktop::allowedOrientationsChanged() {}
|
||||
void Desktop::allowedOrientationsChanged()
|
||||
{
|
||||
// if the current orientation isn't allowed anymore then switch orientations
|
||||
if (! isOrientationEnabled (getCurrentOrientation()))
|
||||
{
|
||||
DisplayOrientation orientations[] = { upright, upsideDown, rotatedClockwise, rotatedAntiClockwise };
|
||||
|
||||
const int n = sizeof (orientations) / sizeof (DisplayOrientation);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
if (isOrientationEnabled (orientations[i]))
|
||||
break;
|
||||
|
||||
|
||||
// you need to support at least one orientation
|
||||
jassert (i < n);
|
||||
i = jmin (n - 1, i);
|
||||
|
||||
NSNumber *value = [NSNumber numberWithInt:Orientations::convertFromJuce (orientations[i])];
|
||||
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
|
||||
[value release];
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void UIViewComponentPeer::repaint (const Rectangle<int>& area)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue