1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-03 03:30:06 +00:00

Added display rotation support for iOS - see the Desktop class for implementation methods. Also fixed a couple of minor build issues.

This commit is contained in:
Julian Storer 2010-10-13 19:16:01 +01:00
parent c583b68cd6
commit 4bc85a9dc3
22 changed files with 776 additions and 283 deletions

View file

@ -2531,7 +2531,7 @@ BigInteger::BigInteger()
values.calloc (numValues + 1);
}
BigInteger::BigInteger (const int value)
BigInteger::BigInteger (const int32 value)
: numValues (4),
highestBit (31),
negative (value < 0)
@ -2541,6 +2541,16 @@ BigInteger::BigInteger (const int value)
highestBit = getHighestBit();
}
BigInteger::BigInteger (const uint32 value)
: numValues (4),
highestBit (31),
negative (false)
{
values.calloc (numValues + 1);
values[0] = value;
highestBit = getHighestBit();
}
BigInteger::BigInteger (int64 value)
: numValues (4),
highestBit (63),
@ -2551,28 +2561,18 @@ BigInteger::BigInteger (int64 value)
if (value < 0)
value = -value;
values[0] = (unsigned int) value;
values[1] = (unsigned int) (value >> 32);
highestBit = getHighestBit();
}
BigInteger::BigInteger (const unsigned int value)
: numValues (4),
highestBit (31),
negative (false)
{
values.calloc (numValues + 1);
values[0] = value;
values[0] = (uint32) value;
values[1] = (uint32) (value >> 32);
highestBit = getHighestBit();
}
BigInteger::BigInteger (const BigInteger& other)
: numValues (jmax (4, (other.highestBit >> 5) + 1)),
: numValues (jmax (4, bitToIndex (other.highestBit) + 1)),
highestBit (other.getHighestBit()),
negative (other.negative)
{
values.malloc (numValues + 1);
memcpy (values, other.values, sizeof (unsigned int) * (numValues + 1));
memcpy (values, other.values, sizeof (uint32) * (numValues + 1));
}
BigInteger::~BigInteger()
@ -2592,10 +2592,10 @@ BigInteger& BigInteger::operator= (const BigInteger& other)
if (this != &other)
{
highestBit = other.getHighestBit();
numValues = jmax (4, (highestBit >> 5) + 1);
numValues = jmax (4, bitToIndex (highestBit) + 1);
negative = other.negative;
values.malloc (numValues + 1);
memcpy (values, other.values, sizeof (unsigned int) * (numValues + 1));
memcpy (values, other.values, sizeof (uint32) * (numValues + 1));
}
return *this;
@ -2617,7 +2617,7 @@ void BigInteger::ensureSize (const int numVals)
bool BigInteger::operator[] (const int bit) const throw()
{
return bit <= highestBit && bit >= 0
&& ((values [bit >> 5] & (1 << (bit & 31))) != 0);
&& ((values [bitToIndex (bit)] & bitToMask (bit)) != 0);
}
int BigInteger::toInteger() const throw()
@ -2630,7 +2630,7 @@ const BigInteger BigInteger::getBitRange (int startBit, int numBits) const
{
BigInteger r;
numBits = jmin (numBits, getHighestBit() + 1 - startBit);
r.ensureSize (numBits >> 5);
r.ensureSize (bitToIndex (numBits));
r.highestBit = numBits;
int i = 0;
@ -2658,7 +2658,7 @@ int BigInteger::getBitRangeAsInt (const int startBit, int numBits) const throw()
if (numBits <= 0)
return 0;
const int pos = startBit >> 5;
const int pos = bitToIndex (startBit);
const int offset = startBit & 31;
const int endSpace = 32 - numBits;
@ -2670,7 +2670,7 @@ int BigInteger::getBitRangeAsInt (const int startBit, int numBits) const throw()
return (int) (n & (((uint32) 0xffffffff) >> endSpace));
}
void BigInteger::setBitRangeAsInt (const int startBit, int numBits, unsigned int valueToSet)
void BigInteger::setBitRangeAsInt (const int startBit, int numBits, uint32 valueToSet)
{
if (numBits > 32)
{
@ -2694,7 +2694,7 @@ void BigInteger::clear()
}
else
{
zeromem (values, sizeof (unsigned int) * (numValues + 1));
zeromem (values, sizeof (uint32) * (numValues + 1));
}
highestBit = -1;
@ -2707,11 +2707,11 @@ void BigInteger::setBit (const int bit)
{
if (bit > highestBit)
{
ensureSize (bit >> 5);
ensureSize (bitToIndex (bit));
highestBit = bit;
}
values [bit >> 5] |= (1 << (bit & 31));
values [bitToIndex (bit)] |= bitToMask (bit);
}
}
@ -2726,7 +2726,7 @@ void BigInteger::setBit (const int bit, const bool shouldBeSet)
void BigInteger::clearBit (const int bit) throw()
{
if (bit >= 0 && bit <= highestBit)
values [bit >> 5] &= ~(1 << (bit & 31));
values [bitToIndex (bit)] &= ~bitToMask (bit);
}
void BigInteger::setRange (int startBit, int numBits, const bool shouldBeSet)
@ -2772,9 +2772,9 @@ int BigInteger::countNumberOfSetBits() const throw()
{
int total = 0;
for (int i = (highestBit >> 5) + 1; --i >= 0;)
for (int i = bitToIndex (highestBit) + 1; --i >= 0;)
{
unsigned int n = values[i];
uint32 n = values[i];
if (n == 0xffffffff)
{
@ -2796,7 +2796,7 @@ int BigInteger::countNumberOfSetBits() const throw()
int BigInteger::getHighestBit() const throw()
{
for (int i = highestBit + 1; --i >= 0;)
if ((values [i >> 5] & (1 << (i & 31))) != 0)
if ((values [bitToIndex (i)] & bitToMask (i)) != 0)
return i;
return -1;
@ -2805,7 +2805,7 @@ int BigInteger::getHighestBit() const throw()
int BigInteger::findNextSetBit (int i) const throw()
{
for (; i <= highestBit; ++i)
if ((values [i >> 5] & (1 << (i & 31))) != 0)
if ((values [bitToIndex (i)] & bitToMask (i)) != 0)
return i;
return -1;
@ -2814,7 +2814,7 @@ int BigInteger::findNextSetBit (int i) const throw()
int BigInteger::findNextClearBit (int i) const throw()
{
for (; i <= highestBit; ++i)
if ((values [i >> 5] & (1 << (i & 31))) == 0)
if ((values [bitToIndex (i)] & bitToMask (i)) == 0)
break;
return i;
@ -2848,7 +2848,7 @@ BigInteger& BigInteger::operator+= (const BigInteger& other)
++highestBit;
const int numInts = (highestBit >> 5) + 1;
const int numInts = bitToIndex (highestBit) + 1;
ensureSize (numInts);
int64 remainder = 0;
@ -2861,7 +2861,7 @@ BigInteger& BigInteger::operator+= (const BigInteger& other)
if (i < other.numValues)
remainder += other.values[i];
values[i] = (unsigned int) remainder;
values[i] = (uint32) remainder;
remainder >>= 32;
}
@ -2896,8 +2896,8 @@ BigInteger& BigInteger::operator-= (const BigInteger& other)
return *this;
}
const int numInts = (highestBit >> 5) + 1;
const int maxOtherInts = (other.highestBit >> 5) + 1;
const int numInts = bitToIndex (highestBit) + 1;
const int maxOtherInts = bitToIndex (other.highestBit) + 1;
int64 amountToSubtract = 0;
for (int i = 0; i <= numInts; ++i)
@ -2907,13 +2907,13 @@ BigInteger& BigInteger::operator-= (const BigInteger& other)
if (values[i] >= amountToSubtract)
{
values[i] = (unsigned int) (values[i] - amountToSubtract);
values[i] = (uint32) (values[i] - amountToSubtract);
amountToSubtract = 0;
}
else
{
const int64 n = ((int64) values[i] + (((int64) 1) << 32)) - amountToSubtract;
values[i] = (unsigned int) n;
values[i] = (uint32) n;
amountToSubtract = 1;
}
}
@ -3002,9 +3002,9 @@ BigInteger& BigInteger::operator|= (const BigInteger& other)
if (other.highestBit >= 0)
{
ensureSize (other.highestBit >> 5);
ensureSize (bitToIndex (other.highestBit));
int n = (other.highestBit >> 5) + 1;
int n = bitToIndex (other.highestBit) + 1;
while (--n >= 0)
values[n] |= other.values[n];
@ -3045,9 +3045,9 @@ BigInteger& BigInteger::operator^= (const BigInteger& other)
if (other.highestBit >= 0)
{
ensureSize (other.highestBit >> 5);
ensureSize (bitToIndex (other.highestBit));
int n = (other.highestBit >> 5) + 1;
int n = bitToIndex (other.highestBit) + 1;
while (--n >= 0)
values[n] ^= other.values[n];
@ -3120,7 +3120,7 @@ int BigInteger::compareAbsolute (const BigInteger& other) const throw()
else if (h1 < h2)
return -1;
for (int i = (h1 >> 5) + 1; --i >= 0;)
for (int i = bitToIndex (h1) + 1; --i >= 0;)
if (values[i] != other.values[i])
return (values[i] > other.values[i]) ? 1 : -1;
@ -3172,8 +3172,8 @@ void BigInteger::shiftBits (int bits, const int startBit)
}
else
{
const int wordsToMove = bits >> 5;
int top = 1 + (highestBit >> 5) - wordsToMove;
const int wordsToMove = bitToIndex (bits);
int top = 1 + bitToIndex (highestBit) - wordsToMove;
highestBit -= bits;
if (wordsToMove > 0)
@ -3205,10 +3205,10 @@ void BigInteger::shiftBits (int bits, const int startBit)
else if (bits > 0)
{
// left shift
ensureSize (((highestBit + bits) >> 5) + 1);
ensureSize (bitToIndex (highestBit + bits) + 1);
const int wordsToMove = bits >> 5;
int top = 1 + (highestBit >> 5);
const int wordsToMove = bitToIndex (bits);
int top = 1 + bitToIndex (highestBit);
highestBit += bits;
if (wordsToMove > 0)
@ -3413,7 +3413,7 @@ void BigInteger::parseString (const String& text, const int base)
const juce_wchar c = *t++;
const int digit = CharacterFunctions::getHexDigitValue (c);
if (((unsigned int) digit) < (unsigned int) base)
if (((uint32) digit) < (uint32) base)
{
operator<<= (bits);
operator+= (digit);
@ -3426,7 +3426,7 @@ void BigInteger::parseString (const String& text, const int base)
}
else if (base == 10)
{
const BigInteger ten ((unsigned int) 10);
const BigInteger ten ((uint32) 10);
for (;;)
{
@ -17695,11 +17695,17 @@ Array<UnitTest*>& UnitTest::getAllTests()
return tests;
}
void UnitTest::initalise() {}
void UnitTest::shutdown() {}
void UnitTest::performTest (UnitTestRunner* const runner_)
{
jassert (runner_ != 0);
runner = runner_;
initalise();
runTest();
shutdown();
}
void UnitTest::logMessage (const String& message)
@ -17729,6 +17735,16 @@ UnitTestRunner::~UnitTestRunner()
{
}
int UnitTestRunner::getNumResults() const throw()
{
return results.size();
}
const UnitTestRunner::TestResult* UnitTestRunner::getResult (int index) const throw()
{
return results [index];
}
void UnitTestRunner::resultsUpdated()
{
}
@ -42783,7 +42799,8 @@ BEGIN_JUCE_NAMESPACE
Desktop::Desktop()
: mouseClickCounter (0),
kioskModeComponent (0)
kioskModeComponent (0),
allowedOrientations (allOrientations)
{
createMouseInputSources();
refreshMonitorSizes();
@ -43098,6 +43115,22 @@ void Desktop::setKioskModeComponent (Component* componentToUse, const bool allow
}
}
void Desktop::setOrientationsEnabled (const int newOrientations)
{
// Dodgy set of flags being passed here! Make sure you specify at least one permitted orientation.
jassert (newOrientations != 0 && (newOrientations & ~allOrientations) == 0);
allowedOrientations = newOrientations;
}
bool Desktop::isOrientationEnabled (const DisplayOrientation orientation) const throw()
{
// Make sure you only pass one valid flag in here...
jassert (orientation == upright || orientation == upsideDown || orientation == rotatedClockwise || orientation == rotatedAntiClockwise);
return (allowedOrientations & orientation) != 0;
}
END_JUCE_NAMESPACE
/*** End of inlined file: juce_Desktop.cpp ***/
@ -77589,11 +77622,13 @@ CallOutBox::CallOutBox (Component& contentComponent,
if (parentComponent != 0)
{
updatePosition (parentComponent->getLocalBounds(),
componentToPointTo.getLocalBounds()
+ componentToPointTo.relativePositionToOtherComponent (parentComponent, Point<int>()));
parentComponent->addChildComponent (this);
parentComponent->addAndMakeVisible (this);
updatePosition (componentToPointTo.getLocalBounds()
+ componentToPointTo.relativePositionToOtherComponent (parentComponent, Point<int>()),
parentComponent->getLocalBounds());
setVisible (true);
}
else
{
@ -79109,7 +79144,7 @@ void ResizableWindow::setFullScreen (const bool shouldBeFullScreen)
peer->setFullScreen (shouldBeFullScreen);
if (! shouldBeFullScreen)
if ((! shouldBeFullScreen) && ! lastPos.isEmpty())
setBounds (lastPos);
}
else
@ -241507,6 +241542,11 @@ bool Desktop::canUseSemiTransparentWindows() throw()
return updateLayeredWindow != 0;
}
Desktop::DisplayOrientation Desktop::getCurrentOrientation() const
{
return upright;
}
const int extendedKeyModifier = 0x10000;
const int KeyPress::spaceKey = VK_SPACE;
@ -258735,15 +258775,15 @@ public:
const int width = image.getWidth();
const int height = image.getHeight();
HeapBlock <char> colour (width * height);
HeapBlock <uint32> colour (width * height);
int index = 0;
for (int y = 0; y < height; ++y)
for (int x = 0; x < width; ++x)
colour[index++] = static_cast<char> (image.getPixelAt (x, y).getARGB());
colour[index++] = image.getPixelAt (x, y).getARGB();
XImage* ximage = XCreateImage (display, CopyFromParent, 24, ZPixmap,
0, colour.getData(),
0, reinterpret_cast<char*> (colour.getData()),
width, height, 32, 0);
Pixmap pixmap = XCreatePixmap (display, DefaultRootWindow (display),
@ -260525,6 +260565,11 @@ void Desktop::setMousePosition (const Point<int>& newPosition)
XWarpPointer (display, None, root, 0, 0, 0, 0, newPosition.getX(), newPosition.getY());
}
Desktop::DisplayOrientation Desktop::getCurrentOrientation() const
{
return upright;
}
static bool screenSaverAllowed = true;
void Desktop::setScreenSaverEnabled (const bool isEnabled)
@ -263335,6 +263380,24 @@ BEGIN_JUCE_NAMESPACE
#undef Point
template <class RectType>
static const Rectangle<int> convertToRectInt (const RectType& r)
{
return Rectangle<int> ((int) r.origin.x, (int) r.origin.y, (int) r.size.width, (int) r.size.height);
}
template <class RectType>
static const Rectangle<float> convertToRectFloat (const RectType& r)
{
return Rectangle<float> (r.origin.x, r.origin.y, r.size.width, r.size.height);
}
template <class RectType>
static CGRect convertToCGRect (const RectType& r)
{
return CGRectMake ((CGFloat) r.getX(), (CGFloat) r.getY(), (CGFloat) r.getWidth(), (CGFloat) r.getHeight());
}
#define JUCE_INCLUDED_FILE 1
// Now include the actual code files..
@ -265678,20 +265741,6 @@ bool Desktop::isScreenSaverEnabled()
return ! [[UIApplication sharedApplication] isIdleTimerDisabled];
}
void juce_updateMultiMonitorInfo (Array <Rectangle <int> >& monitorCoords, const bool clipToWorkArea)
{
const ScopedAutoReleasePool pool;
monitorCoords.clear();
CGRect r = clipToWorkArea ? [[UIScreen mainScreen] applicationFrame]
: [[UIScreen mainScreen] bounds];
monitorCoords.add (Rectangle<int> ((int) r.origin.x,
(int) r.origin.y,
(int) r.size.width,
(int) r.size.height));
}
#endif
#endif
@ -265829,6 +265878,11 @@ void Desktop::setMousePosition (const Point<int>& newPosition)
CGAssociateMouseAndMouseCursorPosition (true);
}
Desktop::DisplayOrientation Desktop::getCurrentOrientation() const
{
return upright;
}
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
class ScreenSaverDefeater : public Timer,
public DeletedAtShutdown
@ -265914,10 +265968,9 @@ void juce_updateMultiMonitorInfo (Array <Rectangle<int> >& monitorCoords, const
NSRect r = clipToWorkArea ? [s visibleFrame]
: [s frame];
monitorCoords.add (Rectangle<int> ((int) r.origin.x,
(int) (mainScreenBottom - (r.origin.y + r.size.height)),
(int) r.size.width,
(int) r.size.height));
r.origin.y = mainScreenBottom - (r.origin.y + r.size.height);
monitorCoords.add (convertToRectInt (r));
}
jassert (monitorCoords.size() > 0);
@ -267302,6 +267355,16 @@ END_JUCE_NAMESPACE
- (BOOL) textView: (UITextView*) textView shouldChangeTextInRange: (NSRange) range replacementText: (NSString*) text;
@end
#define JuceUIViewController MakeObjCClassName(JuceUIViewController)
@interface JuceUIViewController : UIViewController
{
}
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation;
- (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation) fromInterfaceOrientation;
@end
#define JuceUIWindow MakeObjCClassName(JuceUIWindow)
@interface JuceUIWindow : UIWindow
@ -267368,6 +267431,9 @@ public:
void updateHiddenTextContent (TextInputTarget* target);
void globalFocusChanged (Component*);
virtual BOOL shouldRotate (UIInterfaceOrientation interfaceOrientation);
virtual void displayRotated();
void handleTouches (UIEvent* e, bool isDown, bool isUp, bool isCancel);
void repaint (const Rectangle<int>& area);
@ -267377,6 +267443,7 @@ public:
UIWindow* window;
JuceUIView* view;
JuceUIViewController* controller;
bool isSharedWindow, fullScreen, insideDrawRect;
static ModifierKeys currentModifiers;
@ -267386,11 +267453,83 @@ public:
+ (int64) ([e timestamp] * 1000.0);
}
static const Rectangle<int> rotatedScreenPosToReal (const Rectangle<int>& r)
{
const Rectangle<int> screen (convertToRectInt ([[UIScreen mainScreen] bounds]));
switch ([[UIApplication sharedApplication] statusBarOrientation])
{
case UIInterfaceOrientationPortrait:
return r;
case UIInterfaceOrientationPortraitUpsideDown:
return Rectangle<int> (screen.getWidth() - r.getRight(), screen.getHeight() - r.getBottom(),
r.getWidth(), r.getHeight());
case UIInterfaceOrientationLandscapeLeft:
return Rectangle<int> (r.getY(), screen.getHeight() - r.getRight(),
r.getHeight(), r.getWidth());
case UIInterfaceOrientationLandscapeRight:
return Rectangle<int> (screen.getWidth() - r.getBottom(), r.getX(),
r.getHeight(), r.getWidth());
default: jassertfalse; // unknown orientation!
}
return r;
}
static const Rectangle<int> realScreenPosToRotated (const Rectangle<int>& r)
{
const Rectangle<int> screen (convertToRectInt ([[UIScreen mainScreen] bounds]));
switch ([[UIApplication sharedApplication] statusBarOrientation])
{
case UIInterfaceOrientationPortrait:
return r;
case UIInterfaceOrientationPortraitUpsideDown:
return Rectangle<int> (screen.getWidth() - r.getRight(), screen.getHeight() - r.getBottom(),
r.getWidth(), r.getHeight());
case UIInterfaceOrientationLandscapeLeft:
return Rectangle<int> (screen.getHeight() - r.getBottom(), r.getX(),
r.getHeight(), r.getWidth());
case UIInterfaceOrientationLandscapeRight:
return Rectangle<int> (r.getY(), screen.getWidth() - r.getRight(),
r.getHeight(), r.getWidth());
default: jassertfalse; // unknown orientation!
}
return r;
}
Array <UITouch*> currentTouches;
};
END_JUCE_NAMESPACE
@implementation JuceUIViewController
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
{
JuceUIView* juceView = (JuceUIView*) [self view];
jassert (juceView != 0 && juceView->owner != 0);
return juceView->owner->shouldRotate (interfaceOrientation);
}
- (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation) fromInterfaceOrientation
{
JuceUIView* juceView = (JuceUIView*) [self view];
jassert (juceView != 0 && juceView->owner != 0);
juceView->owner->displayRotated();
}
@end
@implementation JuceUIView
- (JuceUIView*) initWithOwner: (UIViewComponentPeer*) owner_
@ -267528,12 +267667,12 @@ UIViewComponentPeer::UIViewComponentPeer (Component* const component,
UIView* viewToAttachTo)
: ComponentPeer (component, windowStyleFlags),
window (0),
view (0),
view (0), controller (0),
isSharedWindow (viewToAttachTo != 0),
fullScreen (false),
insideDrawRect (false)
{
CGRect r = CGRectMake (0, 0, (float) component->getWidth(), (float) component->getHeight());
CGRect r = convertToCGRect (component->getLocalBounds());
view = [[JuceUIView alloc] initWithOwner: this withFrame: r];
@ -267546,8 +267685,10 @@ UIViewComponentPeer::UIViewComponentPeer (Component* const component,
}
else
{
r.origin.x = (float) component->getX();
r.origin.y = (float) component->getY();
controller = [[JuceUIViewController alloc] init];
controller.view = view;
r = convertToCGRect (rotatedScreenPosToReal (component->getBounds()));
r.origin.y = [[UIScreen mainScreen] bounds].size.height - (r.origin.y + r.size.height);
window = [[JuceUIWindow alloc] init];
@ -267584,6 +267725,7 @@ UIViewComponentPeer::~UIViewComponentPeer()
view->owner = 0;
[view removeFromSuperview];
[view release];
[controller release];
if (! isSharedWindow)
{
@ -267626,15 +267768,9 @@ void UIViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNo
w = jmax (0, w);
h = jmax (0, h);
CGRect r;
r.origin.x = (float) x;
r.origin.y = (float) y;
r.size.width = (float) w;
r.size.height = (float) h;
if (isSharedWindow)
{
//r.origin.y = [[view superview] frame].size.height - (r.origin.y + r.size.height);
CGRect r = CGRectMake ((float) x, (float) y, (float) w, (float) h);
if ([view frame].size.width != r.size.width
|| [view frame].size.height != r.size.height)
@ -267644,8 +267780,11 @@ void UIViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNo
}
else
{
window.frame = r;
view.frame = CGRectMake (0, 0, r.size.width, r.size.height);
const Rectangle<int> bounds (rotatedScreenPosToReal (Rectangle<int> (x, y, w, h)));
window.frame = convertToCGRect (bounds);
view.frame = CGRectMake (0, 0, (float) bounds.getWidth(), (float) bounds.getHeight());
handleMovedOrResized();
}
}
@ -267657,12 +267796,14 @@ const Rectangle<int> UIViewComponentPeer::getBounds (const bool global) const
{
r = [view convertRect: r toView: nil];
CGRect wr = [[view window] frame];
r.origin.x += wr.origin.x;
r.origin.y += wr.origin.y;
const Rectangle<int> windowBounds (realScreenPosToRotated (convertToRectInt (wr)));
r.origin.x = windowBounds.getX();
r.origin.y = windowBounds.getY();
}
return Rectangle<int> ((int) r.origin.x, (int) r.origin.y,
(int) r.size.width, (int) r.size.height);
return convertToRectInt (r);
}
const Rectangle<int> UIViewComponentPeer::getBounds() const
@ -267694,11 +267835,8 @@ CGRect UIViewComponentPeer::constrainRect (CGRect r)
r.origin.y = [[UIScreen mainScreen] bounds].size.height - r.origin.y - r.size.height;
Rectangle<int> pos ((int) r.origin.x, (int) r.origin.y,
(int) r.size.width, (int) r.size.height);
Rectangle<int> original ((int) current.origin.x, (int) current.origin.y,
(int) current.size.width, (int) current.size.height);
Rectangle<int> pos (convertToRectInt (r));
Rectangle<int> original (convertToRectInt (current));
constrainer->checkBounds (pos, original,
Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(),
@ -267718,7 +267856,6 @@ CGRect UIViewComponentPeer::constrainRect (CGRect r)
void UIViewComponentPeer::setMinimised (bool shouldBeMinimised)
{
// xxx
}
bool UIViewComponentPeer::isMinimised() const
@ -267730,19 +267867,17 @@ void UIViewComponentPeer::setFullScreen (bool shouldBeFullScreen)
{
if (! isSharedWindow)
{
Rectangle<int> r (lastNonFullscreenBounds);
Rectangle<int> r (shouldBeFullScreen ? Desktop::getInstance().getMainMonitorArea()
: lastNonFullscreenBounds);
setMinimised (false);
if ((! shouldBeFullScreen) && r.isEmpty())
r = getBounds();
if (fullScreen != shouldBeFullScreen)
{
if (shouldBeFullScreen)
r = Desktop::getInstance().getMainMonitorArea();
// (can't call the component's setBounds method because that'll reset our fullscreen flag)
if (! r.isEmpty())
setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen);
// (can't call the component's setBounds method because that'll reset our fullscreen flag)
if (r != getComponent()->getBounds() && ! r.isEmpty())
setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen);
}
component->repaint();
}
}
@ -267751,17 +267886,61 @@ bool UIViewComponentPeer::isFullScreen() const
return fullScreen;
}
static Desktop::DisplayOrientation convertToJuceOrientation (UIInterfaceOrientation interfaceOrientation)
{
switch (interfaceOrientation)
{
case UIInterfaceOrientationPortrait: return Desktop::upright;
case UIInterfaceOrientationPortraitUpsideDown: return Desktop::upsideDown;
case UIInterfaceOrientationLandscapeLeft: return Desktop::rotatedClockwise;
case UIInterfaceOrientationLandscapeRight: return Desktop::rotatedAntiClockwise;
default: jassertfalse; // unknown orientation!
}
return Desktop::upright;
}
BOOL UIViewComponentPeer::shouldRotate (UIInterfaceOrientation interfaceOrientation)
{
return Desktop::getInstance().isOrientationEnabled (convertToJuceOrientation (interfaceOrientation));
}
void UIViewComponentPeer::displayRotated()
{
const Rectangle<int> oldArea (component->getBounds());
const Rectangle<int> oldDesktop (Desktop::getInstance().getMainMonitorArea());
Desktop::getInstance().refreshMonitorSizes();
if (fullScreen)
{
fullScreen = false;
setFullScreen (true);
}
else
{
const float l = oldArea.getX() / (float) oldDesktop.getWidth();
const float r = oldArea.getRight() / (float) oldDesktop.getWidth();
const float t = oldArea.getY() / (float) oldDesktop.getHeight();
const float b = oldArea.getBottom() / (float) oldDesktop.getHeight();
const Rectangle<int> newDesktop (Desktop::getInstance().getMainMonitorArea());
setBounds ((int) (l * newDesktop.getWidth()),
(int) (t * newDesktop.getHeight()),
(int) ((r - l) * newDesktop.getWidth()),
(int) ((b - t) * newDesktop.getHeight()),
false);
}
}
bool UIViewComponentPeer::contains (const Point<int>& position, bool trueIfInAChildWindow) const
{
if (((unsigned int) position.getX()) >= (unsigned int) component->getWidth()
|| ((unsigned int) position.getY()) >= (unsigned int) component->getHeight())
return false;
CGPoint p;
p.x = (float) position.getX();
p.y = (float) position.getY();
UIView* v = [view hitTest: p withEvent: nil];
UIView* v = [view hitTest: CGPointMake ((float) position.getX(), (float) position.getY())
withEvent: nil];
if (trueIfInAChildWindow)
return v != nil;
@ -267771,20 +267950,7 @@ bool UIViewComponentPeer::contains (const Point<int>& position, bool trueIfInACh
const BorderSize UIViewComponentPeer::getFrameSize() const
{
BorderSize b;
if (! isSharedWindow)
{
CGRect v = [view convertRect: [view frame] toView: nil];
CGRect w = [window frame];
b.setTop ((int) (w.size.height - (v.origin.y + v.size.height)));
b.setBottom ((int) v.origin.y);
b.setLeft ((int) v.origin.x);
b.setRight ((int) (w.size.width - (v.origin.x + v.size.width)));
}
return b;
return BorderSize();
}
bool UIViewComponentPeer::setAlwaysOnTop (bool alwaysOnTop)
@ -268043,8 +268209,7 @@ void UIViewComponentPeer::repaint (const Rectangle<int>& area)
}
else
{
[view setNeedsDisplayInRect: CGRectMake ((float) area.getX(), (float) area.getY(),
(float) area.getWidth(), (float) area.getHeight())];
[view setNeedsDisplayInRect: convertToCGRect (area)];
}
}
@ -268082,6 +268247,22 @@ void Desktop::setMousePosition (const Point<int>&)
{
}
Desktop::DisplayOrientation Desktop::getCurrentOrientation() const
{
return convertToJuceOrientation ([[UIApplication sharedApplication] statusBarOrientation]);
}
void juce_updateMultiMonitorInfo (Array <Rectangle <int> >& monitorCoords, const bool clipToWorkArea)
{
const ScopedAutoReleasePool pool;
monitorCoords.clear();
CGRect r = clipToWorkArea ? [[UIScreen mainScreen] applicationFrame]
: [[UIScreen mainScreen] bounds];
monitorCoords.add (UIViewComponentPeer::realScreenPosToRotated (convertToRectInt (r)));
}
const int KeyPress::spaceKey = ' ';
const int KeyPress::returnKey = 0x0d;
const int KeyPress::escapeKey = 0x1b;
@ -272823,7 +273004,7 @@ const Rectangle<int> NSViewComponentPeer::getBounds (const bool global) const
r.origin.y = [[view superview] frame].size.height - r.origin.y - r.size.height;
}
return Rectangle<int> ((int) r.origin.x, (int) r.origin.y, (int) r.size.width, (int) r.size.height);
return Rectangle<int> (convertToRectInt (r));
}
const Rectangle<int> NSViewComponentPeer::getBounds() const
@ -272855,11 +273036,8 @@ NSRect NSViewComponentPeer::constrainRect (NSRect r)
r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.origin.y - r.size.height;
Rectangle<int> pos ((int) r.origin.x, (int) r.origin.y,
(int) r.size.width, (int) r.size.height);
Rectangle<int> original ((int) current.origin.x, (int) current.origin.y,
(int) current.size.width, (int) current.size.height);
Rectangle<int> pos (convertToRectInt (r));
Rectangle<int> original (convertToRectInt (current));
constrainer->checkBounds (pos, original,
Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(),