mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Tweak to ComponentBoundsConstrainer. Fix for iOS when embedding juce windows.
This commit is contained in:
parent
674aa73dd7
commit
09dd26bf60
5 changed files with 23 additions and 29 deletions
|
|
@ -26,17 +26,17 @@
|
|||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
//==============================================================================
|
||||
struct DefaultImageFormats
|
||||
{
|
||||
PNGImageFormat png;
|
||||
JPEGImageFormat jpg;
|
||||
GIFImageFormat gif;
|
||||
};
|
||||
|
||||
static DefaultImageFormats defaultImageFormats;
|
||||
|
||||
ImageFileFormat* ImageFileFormat::findImageFormatForStream (InputStream& input)
|
||||
{
|
||||
struct DefaultImageFormats
|
||||
{
|
||||
PNGImageFormat png;
|
||||
JPEGImageFormat jpg;
|
||||
GIFImageFormat gif;
|
||||
};
|
||||
|
||||
static DefaultImageFormats defaultImageFormats;
|
||||
|
||||
ImageFileFormat* formats[] = { &defaultImageFormats.png,
|
||||
&defaultImageFormats.jpg,
|
||||
&defaultImageFormats.gif };
|
||||
|
|
@ -68,11 +68,11 @@ Image ImageFileFormat::loadFrom (InputStream& input)
|
|||
|
||||
Image ImageFileFormat::loadFrom (const File& file)
|
||||
{
|
||||
InputStream* const in = file.createInputStream();
|
||||
FileInputStream stream (file);
|
||||
|
||||
if (in != nullptr)
|
||||
if (stream.openedOk())
|
||||
{
|
||||
BufferedInputStream b (in, 8192, true);
|
||||
BufferedInputStream b (stream, 8192);
|
||||
return loadFrom (b);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,17 +201,14 @@ void ComponentBoundsConstrainer::checkBounds (Rectangle<int>& bounds,
|
|||
const bool isStretchingBottom,
|
||||
const bool isStretchingRight)
|
||||
{
|
||||
// constrain the size if it's being stretched..
|
||||
if (isStretchingLeft)
|
||||
bounds.setLeft (jlimit (old.getRight() - maxW, old.getRight() - minW, bounds.getX()));
|
||||
|
||||
if (isStretchingRight)
|
||||
else
|
||||
bounds.setWidth (jlimit (minW, maxW, bounds.getWidth()));
|
||||
|
||||
if (isStretchingTop)
|
||||
bounds.setTop (jlimit (old.getBottom() - maxH, old.getBottom() - minH, bounds.getY()));
|
||||
|
||||
if (isStretchingBottom)
|
||||
else
|
||||
bounds.setHeight (jlimit (minH, maxH, bounds.getHeight()));
|
||||
|
||||
if (bounds.isEmpty())
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ public:
|
|||
/** Called by setBoundsForComponent() to apply a new constrained size to a
|
||||
component.
|
||||
|
||||
By default this just calls setBounds(), but it virtual in case it's needed for
|
||||
By default this just calls setBounds(), but is virtual in case it's needed for
|
||||
extremely cunning purposes.
|
||||
*/
|
||||
virtual void applyBoundsToComponent (Component* component,
|
||||
|
|
|
|||
|
|
@ -388,12 +388,15 @@ UIViewComponentPeer::UIViewComponentPeer (Component* const component,
|
|||
|
||||
view = [[JuceUIView alloc] initWithOwner: this withFrame: r];
|
||||
|
||||
view.multipleTouchEnabled = YES;
|
||||
view.hidden = ! component->isVisible();
|
||||
view.opaque = component->isOpaque();
|
||||
view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0];
|
||||
|
||||
if (isSharedWindow)
|
||||
{
|
||||
window = [viewToAttachTo window];
|
||||
[viewToAttachTo addSubview: view];
|
||||
|
||||
setVisible (component->isVisible());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -405,11 +408,8 @@ UIViewComponentPeer::UIViewComponentPeer (Component* const component,
|
|||
|
||||
window = [[JuceUIWindow alloc] init];
|
||||
window.frame = r;
|
||||
|
||||
window.opaque = component->isOpaque();
|
||||
view.opaque = component->isOpaque();
|
||||
window.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0];
|
||||
view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0];
|
||||
|
||||
[((JuceUIWindow*) window) setOwner: this];
|
||||
|
||||
|
|
@ -419,10 +419,7 @@ UIViewComponentPeer::UIViewComponentPeer (Component* const component,
|
|||
[window addSubview: view];
|
||||
view.frame = CGRectMake (0, 0, r.size.width, r.size.height);
|
||||
|
||||
view.hidden = ! component->isVisible();
|
||||
window.hidden = ! component->isVisible();
|
||||
|
||||
view.multipleTouchEnabled = YES;
|
||||
window.hidden = view.hidden;
|
||||
}
|
||||
|
||||
setTitle (component->getName());
|
||||
|
|
@ -441,7 +438,7 @@ UIViewComponentPeer::~UIViewComponentPeer()
|
|||
|
||||
if (! isSharedWindow)
|
||||
{
|
||||
[((JuceUIWindow*) window) setOwner: 0];
|
||||
[((JuceUIWindow*) window) setOwner: nil];
|
||||
[window release];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ private:
|
|||
|
||||
void initialise (bool addToDesktop);
|
||||
void updateLastPos();
|
||||
void setContent (Component* newComp, bool takeOwnership, bool resizeToFit);
|
||||
void setContent (Component*, bool takeOwnership, bool resizeToFit);
|
||||
|
||||
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE
|
||||
// The parameters for these methods have changed - please update your code!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue