Add method for module widgets to persist their black/silver screws
This commit is contained in:
parent
f5ff42b8d6
commit
a808190e9a
4 changed files with 70 additions and 12 deletions
|
@ -36,6 +36,10 @@
|
|||
|
||||
namespace rack {
|
||||
|
||||
namespace asset {
|
||||
void updateForcingBlackSilverScrewMode(std::string slug);
|
||||
}
|
||||
|
||||
struct CardinalPluginModelHelper : plugin::Model {
|
||||
virtual app::ModuleWidget* createModuleWidgetFromEngineLoad(engine::Module* m) = 0;
|
||||
virtual void removeCachedModuleWidget(engine::Module* m) = 0;
|
||||
|
@ -47,6 +51,11 @@ struct CardinalPluginModel : CardinalPluginModelHelper
|
|||
std::unordered_map<engine::Module*, TModuleWidget*> widgets;
|
||||
std::unordered_map<engine::Module*, bool> widgetNeedsDeletion;
|
||||
|
||||
CardinalPluginModel(const std::string slug)
|
||||
{
|
||||
this->slug = slug;
|
||||
}
|
||||
|
||||
engine::Module* createModule() override
|
||||
{
|
||||
engine::Module* const m = new TModule;
|
||||
|
@ -67,6 +76,7 @@ struct CardinalPluginModel : CardinalPluginModelHelper
|
|||
}
|
||||
tm = dynamic_cast<TModule*>(m);
|
||||
}
|
||||
asset::updateForcingBlackSilverScrewMode(slug);
|
||||
app::ModuleWidget* const tmw = new TModuleWidget(tm);
|
||||
DISTRHO_CUSTOM_SAFE_ASSERT_RETURN(m != nullptr ? m->model->name.c_str() : "null", tmw->module == m, nullptr);
|
||||
tmw->setModel(this);
|
||||
|
@ -81,6 +91,7 @@ struct CardinalPluginModel : CardinalPluginModelHelper
|
|||
TModule* const tm = dynamic_cast<TModule*>(m);
|
||||
DISTRHO_SAFE_ASSERT_RETURN(tm != nullptr, nullptr);
|
||||
|
||||
asset::updateForcingBlackSilverScrewMode(slug);
|
||||
TModuleWidget* const tmw = new TModuleWidget(tm);
|
||||
DISTRHO_SAFE_ASSERT_RETURN(tmw->module == m, nullptr);
|
||||
tmw->setModel(this);
|
||||
|
@ -107,11 +118,9 @@ struct CardinalPluginModel : CardinalPluginModelHelper
|
|||
};
|
||||
|
||||
template <class TModule, class TModuleWidget>
|
||||
CardinalPluginModel<TModule, TModuleWidget>* createModel(std::string slug)
|
||||
CardinalPluginModel<TModule, TModuleWidget>* createModel(const std::string slug)
|
||||
{
|
||||
CardinalPluginModel<TModule, TModuleWidget>* const o = new CardinalPluginModel<TModule, TModuleWidget>();
|
||||
o->slug = slug;
|
||||
return o;
|
||||
return new CardinalPluginModel<TModule, TModuleWidget>(slug);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue