diff --git a/hi_tools/hi_multipage/PageFactory.h b/hi_tools/hi_multipage/PageFactory.h index e9f7c22f5..838dad69c 100644 --- a/hi_tools/hi_multipage/PageFactory.h +++ b/hi_tools/hi_multipage/PageFactory.h @@ -260,14 +260,42 @@ struct DummyContent: public Component, void paint(Graphics& g) override { - g.fillAll(Colours::white.withAlpha(0.1f)); - g.setColour(Colours::white.withAlpha(0.7f)); - g.setFont(GLOBAL_MONOSPACE_FONT()); - g.drawRect(getLocalBounds(), 1); - g.drawText("Placeholder for " + classId, getLocalBounds().toFloat(), Justification::centred); + if(dynamicContent == nullptr) + { + g.fillAll(Colours::white.withAlpha(0.1f)); + g.setColour(Colours::white.withAlpha(0.7f)); + g.setFont(GLOBAL_MONOSPACE_FONT()); + g.drawRect(getLocalBounds(), 1); + g.drawText("Placeholder for " + classId, getLocalBounds().toFloat(), Justification::centred); + } } - void postInit() override {}; + void resized() override + { + if(dynamicContent != nullptr) + { + dynamicContent->setBounds(getLocalBounds()); + } + } + + void postInit() override + { + auto& s = rootDialog.getState(); + + if(s.dynamicComponentFactory) + { + auto newComponent = s.dynamicComponentFactory(classId); + + if(newComponent != nullptr) + { + addAndMakeVisible(dynamicContent = newComponent); + resized(); + } + } + }; + + ScopedPointer dynamicContent; + Result checkGlobalState(var state) override { return Result::ok(); } String classId; diff --git a/hi_tools/hi_multipage/State.h b/hi_tools/hi_multipage/State.h index 6ea5f9f45..ebb8c7158 100644 --- a/hi_tools/hi_multipage/State.h +++ b/hi_tools/hi_multipage/State.h @@ -272,6 +272,8 @@ class State: public Thread, logMessage(MessageType::Hlac, message); jassertfalse; } + + std::function dynamicComponentFactory; ScopedPointer stateProvider;