Browse Source

Workaround for VST3 plugin resizing in Wavelab.

tags/2021-05-28
jules 11 years ago
parent
commit
df9701430a
3 changed files with 58 additions and 52 deletions
  1. +4
    -1
      modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp
  2. +50
    -50
      modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.mm
  3. +4
    -1
      modules/juce_gui_basics/components/juce_Component.cpp

+ 4
- 1
modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp View File

@@ -488,7 +488,7 @@ private:
#if JUCE_WINDOWS
setSize (w, h);
#else
if (owner.macHostWindow != nullptr)
if (owner.macHostWindow != nullptr && ! getHostType().isWavelab())
juce::setNativeHostWindowSize (owner.macHostWindow, this, w, h, owner.isNSView);
#endif
@@ -496,6 +496,9 @@ private:
{
ViewRect newSize (0, 0, w, h);
owner.plugFrame->resizeView (&owner, &newSize);
if (getHostType().isWavelab())
setBounds (0, 0, w, h);
}
}
}


+ 50
- 50
modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.mm View File

@@ -196,76 +196,76 @@ namespace juce
static void detachComponentFromWindowRef (Component* comp, void* nsWindow, bool isHIView)
{
#if JUCE_64BIT
(void) nsWindow; (void) isHIView;
comp->removeFromDesktop();
#else
//treat NSView like 64bit
if (! isHIView)
{
comp->removeFromDesktop();
}
else
JUCE_AUTORELEASEPOOL
{
JUCE_AUTORELEASEPOOL
#if ! JUCE_64BIT
if (isHIView)
{
EventHandlerRef ref = (EventHandlerRef) (void*) (pointer_sized_int)
comp->getProperties() ["boundsEventRef"].toString().getHexValue64();
RemoveEventHandler (ref);
JUCE_AUTORELEASEPOOL
{
EventHandlerRef ref = (EventHandlerRef) (void*) (pointer_sized_int)
comp->getProperties() ["boundsEventRef"].toString().getHexValue64();
RemoveEventHandler (ref);
removeWindowHidingHooks (comp);
removeWindowHidingHooks (comp);
HIViewRef dummyView = (HIViewRef) (void*) (pointer_sized_int)
comp->getProperties() ["dummyViewRef"].toString().getHexValue64();
HIViewRef dummyView = (HIViewRef) (void*) (pointer_sized_int)
comp->getProperties() ["dummyViewRef"].toString().getHexValue64();
if (HIViewIsValid (dummyView))
CFRelease (dummyView);
if (HIViewIsValid (dummyView))
CFRelease (dummyView);
NSWindow* hostWindow = (NSWindow*) nsWindow;
NSView* pluginView = (NSView*) comp->getWindowHandle();
NSWindow* pluginWindow = [pluginView window];
NSWindow* hostWindow = (NSWindow*) nsWindow;
NSView* pluginView = (NSView*) comp->getWindowHandle();
NSWindow* pluginWindow = [pluginView window];
[hostWindow removeChildWindow: pluginWindow];
comp->removeFromDesktop();
[hostWindow removeChildWindow: pluginWindow];
comp->removeFromDesktop();
[hostWindow release];
}
[hostWindow release];
// The event loop needs to be run between closing the window and deleting the plugin,
// presumably to let the cocoa objects get tidied up. Leaving out this line causes crashes
// in Live and Reaper when you delete the plugin with its window open.
// (Doing it this way rather than using a single longer timout means that we can guarantee
// how many messages will be dispatched, which seems to be vital in Reaper)
for (int i = 20; --i >= 0;)
MessageManager::getInstance()->runDispatchLoopUntil (1);
return;
}
#endif
// The event loop needs to be run between closing the window and deleting the plugin,
// presumably to let the cocoa objects get tidied up. Leaving out this line causes crashes
// in Live and Reaper when you delete the plugin with its window open.
// (Doing it this way rather than using a single longer timout means that we can guarantee
// how many messages will be dispatched, which seems to be vital in Reaper)
for (int i = 20; --i >= 0;)
MessageManager::getInstance()->runDispatchLoopUntil (1);
(void) nsWindow; (void) isHIView;
comp->removeFromDesktop();
}
#endif
}
static void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight, bool isHIView)
{
(void) nsWindow; (void) isHIView;
JUCE_AUTORELEASEPOOL
{
#if JUCE_64BIT
component->setSize (newWidth, newHeight);
#else
if (! isHIView)
{ //Treat NSView like 64bit:
component->setSize (newWidth, newHeight);
}
else if (HIViewRef dummyView = (HIViewRef) (void*) (pointer_sized_int)
component->getProperties() ["dummyViewRef"].toString().getHexValue64())
#if ! JUCE_64BIT
if (isHIView)
{
HIRect frameRect;
HIViewGetFrame (dummyView, &frameRect);
frameRect.size.width = newWidth;
frameRect.size.height = newHeight;
HIViewSetFrame (dummyView, &frameRect);
if (HIViewRef dummyView = (HIViewRef) (void*) (pointer_sized_int)
component->getProperties() ["dummyViewRef"].toString().getHexValue64())
{
HIRect frameRect;
HIViewGetFrame (dummyView, &frameRect);
frameRect.size.width = newWidth;
frameRect.size.height = newHeight;
HIViewSetFrame (dummyView, &frameRect);
}
return;
}
#endif
}
(void) nsWindow; (void) isHIView;
component->setSize (newWidth, newHeight);
}
}
} // (juce namespace)


+ 4
- 1
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -2064,7 +2064,10 @@ void Component::paintEntireComponent (Graphics& g, const bool ignoreAlphaLevel)
// If sizing a top-level-window and the OS paint message is delivered synchronously
// before resized() is called, then we'll invoke the callback here, to make sure
// the components inside have had a chance to sort their sizes out..
sendMovedResizedMessagesIfPending();
#if JUCE_DEBUG
if (! flags.isInsidePaintCall) // (avoids an assertion in plugins hosted in WaveLab)
#endif
sendMovedResizedMessagesIfPending();
#if JUCE_DEBUG
flags.isInsidePaintCall = true;


Loading…
Cancel
Save