Browse Source

Plugin Windows: Use new decorator constrainer

v7.0.9
reuk 2 years ago
parent
commit
d05885c8a9
No known key found for this signature in database GPG Key ID: FCB43929F012EE5C
1 changed files with 49 additions and 4 deletions
  1. +49
    -4
      extras/AudioPluginHost/Source/UI/PluginWindow.h

+ 49
- 4
extras/AudioPluginHost/Source/UI/PluginWindow.h View File

@@ -175,6 +175,8 @@ public:
setResizable (ui->isResizable(), false);
}
setConstrainer (&constrainer);
#if JUCE_IOS || JUCE_ANDROID
const auto screenBounds = Desktop::getInstance().getDisplays().getTotalBounds (true).toFloat();
const auto scaleFactor = jmin ((screenBounds.getWidth() - 50.0f) / (float) getWidth(),
@@ -233,6 +235,38 @@ public:
}
private:
class DecoratorConstrainer : public BorderedComponentBoundsConstrainer
{
public:
explicit DecoratorConstrainer (DocumentWindow& windowIn)
: window (windowIn) {}
ComponentBoundsConstrainer* getWrappedConstrainer() const override
{
auto* editor = dynamic_cast<AudioProcessorEditor*> (window.getContentComponent());
return editor != nullptr ? editor->getConstrainer() : nullptr;
}
BorderSize<int> getAdditionalBorder() const override
{
const auto nativeFrame = [&]() -> BorderSize<int>
{
if (auto* peer = window.getPeer())
if (const auto frameSize = peer->getFrameSizeIfPresent())
return *frameSize;
return {};
}();
return nativeFrame.addedTo (window.getContentComponentBorder());
}
private:
DocumentWindow& window;
};
DecoratorConstrainer constrainer { *this };
float getDesktopScaleFactor() const override { return 1.0f; }
static AudioProcessorEditor* createProcessorEditor (AudioProcessor& processor,
@@ -257,10 +291,21 @@ private:
return {};
}
if (type == PluginWindow::Type::generic) return new GenericAudioProcessorEditor (processor);
if (type == PluginWindow::Type::programs) return new ProgramAudioProcessorEditor (processor);
if (type == PluginWindow::Type::audioIO) return new IOConfigurationWindow (processor);
if (type == PluginWindow::Type::debug) return new PluginDebugWindow (processor);
if (type == PluginWindow::Type::generic)
{
auto* result = new GenericAudioProcessorEditor (processor);
result->setResizeLimits (200, 300, 1'000, 10'000);
return result;
}
if (type == PluginWindow::Type::programs)
return new ProgramAudioProcessorEditor (processor);
if (type == PluginWindow::Type::audioIO)
return new IOConfigurationWindow (processor);
if (type == PluginWindow::Type::debug)
return new PluginDebugWindow (processor);
jassertfalse;
return {};


Loading…
Cancel
Save