mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-21 01:24:21 +00:00
iOS: Ensured that native file choosers also work in iOS apps
This commit is contained in:
parent
7813a45b24
commit
3a8c63f5d4
3 changed files with 52 additions and 7 deletions
|
|
@ -1657,6 +1657,17 @@ JuceAudioUnitv3Base* JuceAudioUnitv3Base::create (AUAudioUnit* audioUnit, AudioC
|
|||
return new JuceAudioUnitv3 (audioUnit, descr, options, error);
|
||||
}
|
||||
|
||||
#if JUCE_IOS
|
||||
namespace juce
|
||||
{
|
||||
struct UIViewPeerControllerReceiver
|
||||
{
|
||||
virtual ~UIViewPeerControllerReceiver();
|
||||
virtual void setViewController (UIViewController*) = 0;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
class JuceAUViewController
|
||||
{
|
||||
|
|
@ -1708,6 +1719,9 @@ public:
|
|||
#if JUCE_IOS
|
||||
if (JUCE_IOS_MAC_VIEW* peerView = [[[myself view] subviews] objectAtIndex: 0])
|
||||
[peerView setContentMode: UIViewContentModeTop];
|
||||
|
||||
if (auto* peer = dynamic_cast<UIViewPeerControllerReceiver*> (editor->getPeer()))
|
||||
peer->setViewController (myself);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,11 +85,27 @@ public:
|
|||
|
||||
setOpaque (false);
|
||||
|
||||
auto chooserBounds = Desktop::getInstance().getDisplays().getMainDisplay().userArea;
|
||||
setBounds (chooserBounds);
|
||||
if (SystemStats::isRunningInAppExtensionSandbox())
|
||||
{
|
||||
[controller.get() setModalPresentationStyle:UIModalPresentationFullScreen];
|
||||
|
||||
setAlwaysOnTop (true);
|
||||
addToDesktop (0);
|
||||
if (auto* editorPeer = ComponentPeer::getPeer (0))
|
||||
{
|
||||
auto chooserBounds = editorPeer->getComponent().getLocalBounds();
|
||||
setBounds (chooserBounds);
|
||||
|
||||
setAlwaysOnTop (true);
|
||||
editorPeer->getComponent().addAndMakeVisible (this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto chooserBounds = Desktop::getInstance().getDisplays().getMainDisplay().userArea;
|
||||
setBounds (chooserBounds);
|
||||
|
||||
setAlwaysOnTop (true);
|
||||
addToDesktop (0);
|
||||
}
|
||||
}
|
||||
|
||||
~Native()
|
||||
|
|
@ -308,7 +324,7 @@ bool FileChooser::isPlatformDialogAvailable()
|
|||
#if JUCE_DISABLE_NATIVE_FILECHOOSERS
|
||||
return false;
|
||||
#else
|
||||
return [[NSFileManager defaultManager] ubiquityIdentityToken] != nil;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -163,8 +163,17 @@ using namespace juce;
|
|||
namespace juce
|
||||
{
|
||||
|
||||
struct UIViewPeerControllerReceiver
|
||||
{
|
||||
virtual ~UIViewPeerControllerReceiver();
|
||||
virtual void setViewController (UIViewController*) = 0;
|
||||
};
|
||||
|
||||
UIViewPeerControllerReceiver::~UIViewPeerControllerReceiver() {}
|
||||
|
||||
class UIViewComponentPeer : public ComponentPeer,
|
||||
public FocusChangeListener
|
||||
public FocusChangeListener,
|
||||
public UIViewPeerControllerReceiver
|
||||
{
|
||||
public:
|
||||
UIViewComponentPeer (Component&, int windowStyleFlags, UIView* viewToAttachTo);
|
||||
|
|
@ -176,6 +185,12 @@ public:
|
|||
void setTitle (const String& title) override;
|
||||
void setBounds (const Rectangle<int>&, bool isNowFullScreen) override;
|
||||
|
||||
void setViewController (UIViewController* newController) override
|
||||
{
|
||||
jassert (controller == nullptr);
|
||||
controller = [newController retain];
|
||||
}
|
||||
|
||||
Rectangle<int> getBounds() const override { return getBounds (! isSharedWindow); }
|
||||
Rectangle<int> getBounds (bool global) const;
|
||||
Point<float> localToGlobal (Point<float> relativePosition) override;
|
||||
|
|
@ -218,7 +233,7 @@ public:
|
|||
//==============================================================================
|
||||
UIWindow* window;
|
||||
JuceUIView* view;
|
||||
JuceUIViewController* controller;
|
||||
UIViewController* controller;
|
||||
bool isSharedWindow, fullScreen, insideDrawRect, isAppex;
|
||||
|
||||
static int64 getMouseTime (UIEvent* e) noexcept
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue