mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Plugin Windows: Use new decorator constrainer
This commit is contained in:
parent
1c1cbdf18d
commit
d05885c8a9
1 changed files with 49 additions and 4 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue