|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #include "plugin.hpp"
- #include "engine.hpp"
- #include "app.hpp"
-
-
- namespace rack {
-
-
- template <class TModule, class TModuleWidget, typename... Tags>
- Model *createModel(std::string author, std::string slug, std::string name, Tags... tags) {
- struct TModel : Model {
- Module *createModule() override {
- TModule *module = new TModule();
- return module;
- }
- ModuleWidget *createModuleWidget() override {
- TModule *module = new TModule();
- TModuleWidget *moduleWidget = new TModuleWidget(module);
- moduleWidget->model = this;
- return moduleWidget;
- }
- ModuleWidget *createModuleWidgetNull() override {
- TModuleWidget *moduleWidget = new TModuleWidget(NULL);
- moduleWidget->model = this;
- return moduleWidget;
- }
- };
- Model *model = new TModel();
- model->author = author;
- model->slug = slug;
- model->name = name;
- model->tags = {tags...};
- return model;
- }
-
- template <class TWidget>
- TWidget *createWidget(math::Vec pos) {
- TWidget *w = new TWidget();
- w->box.pos = pos;
- return w;
- }
-
- template <class TParamWidget>
- TParamWidget *createParam(math::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 <class TParamWidget>
- TParamWidget *createParamCentered(math::Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) {
- TParamWidget *param = new TParamWidget();
- param->box.pos = pos.minus(param->box.size.div(2));
- param->module = module;
- param->paramId = paramId;
- param->setLimits(minValue, maxValue);
- param->setDefaultValue(defaultValue);
- return param;
- }
-
- template <class TPort>
- TPort *createInput(math::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 <class TPort>
- TPort *createInputCentered(math::Vec pos, Module *module, int inputId) {
- TPort *port = new TPort();
- port->box.pos = pos.minus(port->box.size.div(2));
- port->module = module;
- port->type = Port::INPUT;
- port->portId = inputId;
- return port;
- }
-
- template <class TPort>
- TPort *createOutput(math::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 <class TPort>
- TPort *createOutputCentered(math::Vec pos, Module *module, int outputId) {
- TPort *port = new TPort();
- port->box.pos = pos.minus(port->box.size.div(2));
- port->module = module;
- port->type = Port::OUTPUT;
- port->portId = outputId;
- return port;
- }
-
- template <class TModuleLightWidget>
- TModuleLightWidget *createLight(math::Vec pos, Module *module, int firstLightId) {
- TModuleLightWidget *light = new TModuleLightWidget();
- light->box.pos = pos;
- light->module = module;
- light->firstLightId = firstLightId;
- return light;
- }
-
- template <class TModuleLightWidget>
- TModuleLightWidget *createLightCentered(math::Vec pos, Module *module, int firstLightId) {
- TModuleLightWidget *light = new TModuleLightWidget();
- light->box.pos = pos.minus(light->box.size.div(2));
- light->module = module;
- light->firstLightId = firstLightId;
- return light;
- }
-
-
- } // namespace rack
|