#pragma once #include "util.hpp" #include "math.hpp" #include "asset.hpp" #include "plugin.hpp" #include "engine.hpp" #include "gui.hpp" #include "app.hpp" #include "componentlibrary.hpp" namespace rack { //////////////////// // helpers //////////////////// template Model *createModel(std::string manufacturer, std::string slug, std::string name, Tags... tags) { struct TModel : Model { ModuleWidget *createModuleWidget() override { ModuleWidget *moduleWidget = new TModuleWidget(); moduleWidget->model = this; return moduleWidget; } }; Model *model = new TModel(); model->manufacturer = manufacturer; model->slug = slug; model->name = name; model->tags = {tags...}; return model; } template TScrew *createScrew(Vec pos) { TScrew *screw = new TScrew(); screw->box.pos = pos; return screw; } template TParamWidget *createParam(Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) { TParamWidget *param = new TParamWidget(); param->box.pos = pos; param->module = module; param->paramId = paramId; param->setLimits(minValue, maxValue); param->setDefaultValue(defaultValue); return param; } template TPort *createInput(Vec pos, Module *module, int inputId) { TPort *port = new TPort(); port->box.pos = pos; port->module = module; port->type = Port::INPUT; port->portId = inputId; return port; } template TPort *createOutput(Vec pos, Module *module, int outputId) { TPort *port = new TPort(); port->box.pos = pos; port->module = module; port->type = Port::OUTPUT; port->portId = outputId; return port; } template TModuleLightWidget *createLight(Vec pos, Module *module, int firstLightId) { TModuleLightWidget *light = new TModuleLightWidget(); light->box.pos = pos; light->module = module; light->firstLightId = firstLightId; return light; } } // namespace rack