diff --git a/source/modules/juce_audio_processors/juce_audio_processors.cpp b/source/modules/juce_audio_processors/juce_audio_processors.cpp index d1f1679fb..efdddee27 100644 --- a/source/modules/juce_audio_processors/juce_audio_processors.cpp +++ b/source/modules/juce_audio_processors/juce_audio_processors.cpp @@ -79,61 +79,71 @@ static inline bool arrayContainsPlugin (const OwnedArray& lis #if JUCE_MAC //============================================================================== -struct AutoResizingNSViewComponent : public NSViewComponent, - private AsyncUpdater -{ - AutoResizingNSViewComponent() : recursive (false) {} +struct AutoResizingNSViewComponent : public NSViewComponent, + private AsyncUpdater { + AutoResizingNSViewComponent(); + void childBoundsChanged(Component*) override; + void handleAsyncUpdate() override; + bool recursive; +}; + +struct AutoResizingNSViewComponentWithParent : public AutoResizingNSViewComponent, + private Timer { + AutoResizingNSViewComponentWithParent(); + NSView* getChildView() const; + void timerCallback() override; +}; + +//============================================================================== +AutoResizingNSViewComponent::AutoResizingNSViewComponent() + : recursive (false) {} - void childBoundsChanged (Component*) override +void AutoResizingNSViewComponent::childBoundsChanged(Component*) +{ + if (recursive) { - if (recursive) - { - triggerAsyncUpdate(); - } - else - { - recursive = true; - resizeToFitView(); - recursive = true; - } + triggerAsyncUpdate(); } + else + { + recursive = true; + resizeToFitView(); + recursive = true; + } +} - void handleAsyncUpdate() override { resizeToFitView(); } - - bool recursive; -}; +void AutoResizingNSViewComponent::handleAsyncUpdate() +{ + resizeToFitView(); +} //============================================================================== -struct AutoResizingNSViewComponentWithParent : public AutoResizingNSViewComponent, - private Timer +AutoResizingNSViewComponentWithParent::AutoResizingNSViewComponentWithParent() { - AutoResizingNSViewComponentWithParent() - { - NSView* v = [[NSView alloc] init]; - setView (v); - [v release]; + NSView* v = [[NSView alloc] init]; + setView (v); + [v release]; - startTimer (30); - } + startTimer(500); +} - NSView* getChildView() const - { - if (NSView* parent = (NSView*) getView()) - if ([[parent subviews] count] > 0) - return [[parent subviews] objectAtIndex: 0]; +NSView* AutoResizingNSViewComponentWithParent::getChildView() const +{ + if (NSView* parent = (NSView*)getView()) + if ([[parent subviews] count] > 0) + return [[parent subviews] objectAtIndex: 0]; - return nil; - } + return nil; +} - void timerCallback() override +void AutoResizingNSViewComponentWithParent::timerCallback() +{ + if (NSView* child = getChildView()) { - if (NSView* child = getChildView()) - { - stopTimer(); - setView (child); - } + stopTimer(); + setView(child); } -}; +} #endif #if JUCE_CLANG