Browse Source

Tweak to ComponentBoundsConstrainer. Fix for iOS when embedding juce windows.

tags/2021-05-28
jules 13 years ago
parent
commit
09dd26bf60
5 changed files with 22 additions and 28 deletions
  1. +11
    -11
      modules/juce_graphics/images/juce_ImageFileFormat.cpp
  2. +2
    -5
      modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp
  3. +1
    -1
      modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h
  4. +7
    -10
      modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm
  5. +1
    -1
      modules/juce_gui_basics/windows/juce_ResizableWindow.h

+ 11
- 11
modules/juce_graphics/images/juce_ImageFileFormat.cpp View File

@@ -26,17 +26,17 @@
BEGIN_JUCE_NAMESPACE
//==============================================================================
struct DefaultImageFormats
ImageFileFormat* ImageFileFormat::findImageFormatForStream (InputStream& input)
{
PNGImageFormat png;
JPEGImageFormat jpg;
GIFImageFormat gif;
};
struct DefaultImageFormats
{
PNGImageFormat png;
JPEGImageFormat jpg;
GIFImageFormat gif;
};
static DefaultImageFormats defaultImageFormats;
static DefaultImageFormats defaultImageFormats;
ImageFileFormat* ImageFileFormat::findImageFormatForStream (InputStream& input)
{
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);
}


+ 2
- 5
modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp View File

@@ -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())


+ 1
- 1
modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h View File

@@ -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,


+ 7
- 10
modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm View File

@@ -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];
}
}


+ 1
- 1
modules/juce_gui_basics/windows/juce_ResizableWindow.h View File

@@ -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…
Cancel
Save