From 0937ee4c378c8a12303890603a4dc1f37b8eea7e Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 23 Jan 2014 22:10:36 +0000 Subject: [PATCH] VST hosting: handling resizing of NSView based plugin windows. --- .../format_types/juce_VSTPluginFormat.cpp | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 3109eac6c4..cb0378804d 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -1915,10 +1915,10 @@ public: recursiveResize (false), pluginWantsKeys (false), pluginRefusesToResize (false), - alreadyInside (false) + alreadyInside (false), + sizeCheckCount (0) { #if JUCE_WINDOWS - sizeCheckCount = 0; pluginHWND = 0; #elif JUCE_LINUX @@ -2026,8 +2026,16 @@ public: void childBoundsChanged (Component*) override { if (cocoaWrapper != nullptr) - setSize (cocoaWrapper->getWidth(), - cocoaWrapper->getHeight()); + { + int w = cocoaWrapper->getWidth(); + int h = cocoaWrapper->getHeight(); + + if (w != getWidth() || h != getHeight()) + { + sizeCheckCount = 0; + setSize (w, h); + } + } } #endif @@ -2076,13 +2084,19 @@ public: { if (isShowing()) { - #if JUCE_WINDOWS if (--sizeCheckCount <= 0) { sizeCheckCount = 10; + + #if JUCE_WINDOWS checkPluginWindowSize(); + #endif + + #if JUCE_MAC + if (cocoaWrapper != nullptr) + cocoaWrapper->resizeToFitView(); + #endif } - #endif static bool reentrant = false; @@ -2132,11 +2146,11 @@ private: VSTPluginInstance& plugin; bool isOpen, recursiveResize; bool pluginWantsKeys, pluginRefusesToResize, alreadyInside; + int sizeCheckCount; #if JUCE_WINDOWS HWND pluginHWND; void* originalWndProc; - int sizeCheckCount; #elif JUCE_LINUX Window pluginWindow; EventProcPtr pluginProc;