diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp index 5d3dc1c31b..c802da1be3 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp @@ -33,7 +33,7 @@ void AudioPluginFormatManager::addDefaultFormats() // you should only call this method once! for (int i = formats.size(); --i >= 0;) { - #if JUCE_PLUGINHOST_VST && ! (JUCE_MAC && JUCE_64BIT) + #if JUCE_PLUGINHOST_VST jassert (dynamic_cast (formats[i]) == nullptr); #endif @@ -55,7 +55,7 @@ void AudioPluginFormatManager::addDefaultFormats() formats.add (new AudioUnitPluginFormat()); #endif - #if JUCE_PLUGINHOST_VST && ! (JUCE_MAC && JUCE_64BIT) + #if JUCE_PLUGINHOST_VST formats.add (new VSTPluginFormat()); #endif diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 9e1810c907..09c4175bb1 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -26,8 +26,6 @@ #if JUCE_PLUGINHOST_VST //============================================================================== -#if ! (JUCE_MAC && JUCE_64BIT) - #if JUCE_MAC && JUCE_SUPPORT_CARBON #include "../../juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h" #endif @@ -381,7 +379,10 @@ public: : file (file_), moduleMain (0) #if JUCE_MAC - , fragId (0), resHandle (0), bundleRef (0), resFileId (0) + #if JUCE_PPC + , fragId (0) + #endif + , resHandle (0), bundleRef (0), resFileId (0) #endif { getActiveModules().add (this); @@ -443,7 +444,9 @@ public: } #else + #if JUCE_PPC CFragConnectionID fragId; + #endif Handle resHandle; CFBundleRef bundleRef; FSSpec parentDirFSSpec; @@ -1131,8 +1134,13 @@ public: #elif JUCE_LINUX pluginWindow = None; pluginProc = None; - #else + #elif JUCE_MAC && JUCE_SUPPORT_CARBON addAndMakeVisible (innerWrapper = new InnerWrapperComponent (*this)); + #elif JUCE_MAC + addAndMakeVisible (innerWrapper = new NSViewComponent()); + NSView* innerView = [[NSView alloc] init]; + innerWrapper->setView (innerView); + [innerView release]; #endif activeVSTWindows.add (this); @@ -1144,10 +1152,10 @@ public: ~VSTPluginWindow() { + closePluginWindow(); + #if JUCE_MAC innerWrapper = nullptr; - #else - closePluginWindow(); #endif activeVSTWindows.removeFirstMatchingValue (this); @@ -1155,7 +1163,7 @@ public: } //============================================================================== -#if ! JUCE_MAC + #if ! JUCE_MAC void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) { if (recursiveResize) @@ -1200,26 +1208,36 @@ public: closePluginWindow(); openPluginWindow(); } -#endif + #endif - //============================================================================== - bool keyStateChanged (bool) + #if JUCE_MAC && ! JUCE_SUPPORT_CARBON + void visibilityChanged() { - return pluginWantsKeys; + if (isVisible()) + openPluginWindow(); + else + closePluginWindow(); } - bool keyPressed (const juce::KeyPress&) + void childBoundsChanged (Component*) { - return pluginWantsKeys; + if (innerWrapper != nullptr) + setSize (innerWrapper->getWidth(), + innerWrapper->getHeight()); } + #endif //============================================================================== -#if JUCE_MAC + bool keyStateChanged (bool) { return pluginWantsKeys; } + bool keyPressed (const juce::KeyPress&) { return pluginWantsKeys; } + + //============================================================================== + #if JUCE_MAC void paint (Graphics& g) { g.fillAll (Colours::black); } -#else + #else void paint (Graphics& g) { if (isOpen) @@ -1254,7 +1272,7 @@ public: g.fillAll (Colours::black); } } -#endif + #endif //============================================================================== void timerCallback() @@ -1341,8 +1359,15 @@ private: //============================================================================== #if JUCE_MAC + #if JUCE_SUPPORT_CARBON void openPluginWindow (WindowRef parentWindow) { + #else + void openPluginWindow() + { + NSView* parentWindow = (NSView*) innerWrapper->getView(); + #endif + if (isOpen || parentWindow == 0) return; @@ -1499,39 +1524,35 @@ private: #endif //============================================================================== -#if ! JUCE_MAC void closePluginWindow() { if (isOpen) { + #if ! (JUCE_MAC && JUCE_SUPPORT_CARBON) log ("Closing VST UI: " + plugin.getName()); isOpen = false; dispatch (effEditClose, 0, 0, 0, 0); + stopTimer(); #if JUCE_WINDOWS #pragma warning (push) #pragma warning (disable: 4244) - if (pluginHWND != 0 && IsWindow (pluginHWND)) SetWindowLongPtr (pluginHWND, GWLP_WNDPROC, (LONG_PTR) originalWndProc); - #pragma warning (pop) - stopTimer(); - if (pluginHWND != 0 && IsWindow (pluginHWND)) DestroyWindow (pluginHWND); pluginHWND = 0; #elif JUCE_LINUX - stopTimer(); pluginWindow = 0; pluginProc = 0; #endif + #endif } } -#endif //============================================================================== int dispatch (const int opcode, const int index, const int value, void* const ptr, float opt) @@ -1743,17 +1764,13 @@ private: #endif #if JUCE_MAC + #if JUCE_SUPPORT_CARBON //============================================================================== - #if ! JUCE_SUPPORT_CARBON - #error "To build VSTs, you need to enable the JUCE_SUPPORT_CARBON flag in your config!" - #endif - class InnerWrapperComponent : public CarbonViewWrapperComponent { public: InnerWrapperComponent (VSTPluginWindow& owner_) - : owner (owner_), - alreadyInside (false) + : owner (owner_), alreadyInside (false) { } @@ -1804,9 +1821,7 @@ private: void paint() { - ComponentPeer* const peer = getPeer(); - - if (peer != nullptr) + if (ComponentPeer* const peer = getPeer()) { const Point pos (getScreenPosition() - peer->getScreenPosition()); ERect r; @@ -1829,6 +1844,10 @@ private: friend class InnerWrapperComponent; ScopedPointer innerWrapper; + #else + ScopedPointer innerWrapper; + #endif + void resized() { if (innerWrapper != nullptr) @@ -2919,4 +2938,3 @@ FileSearchPath VSTPluginFormat::getDefaultLocationsToSearch() #endif #undef log -#endif