| @@ -13,7 +13,7 @@ namespace app { | |||||
| /** Manages an engine::Param on a ModuleWidget. */ | /** Manages an engine::Param on a ModuleWidget. */ | ||||
| struct ParamWidget : widget::OpaqueWidget { | struct ParamWidget : widget::OpaqueWidget { | ||||
| engine::Module* module = NULL; | engine::Module* module = NULL; | ||||
| int paramId = 0; | |||||
| int paramId; | |||||
| ui::Tooltip* tooltip = NULL; | ui::Tooltip* tooltip = NULL; | ||||
| /** For triggering the Change event. `*/ | /** For triggering the Change event. `*/ | ||||
| @@ -14,8 +14,8 @@ namespace app { | |||||
| /** Manages an engine::Port on a ModuleWidget. */ | /** Manages an engine::Port on a ModuleWidget. */ | ||||
| struct PortWidget : widget::OpaqueWidget { | struct PortWidget : widget::OpaqueWidget { | ||||
| engine::Module* module = NULL; | engine::Module* module = NULL; | ||||
| engine::Port::Type type = engine::Port::INPUT; | |||||
| int portId = 0; | |||||
| engine::Port::Type type; | |||||
| int portId; | |||||
| ui::Tooltip* tooltip = NULL; | ui::Tooltip* tooltip = NULL; | ||||
| bool hovered = false; | bool hovered = false; | ||||
| @@ -24,7 +24,8 @@ namespace engine { | |||||
| /** DSP processor instance for your module. */ | /** DSP processor instance for your module. */ | ||||
| struct Module { | struct Module { | ||||
| plugin::Model* model = NULL; /** Unique ID for referring to the module in the engine. | |||||
| plugin::Model* model = NULL; | |||||
| /** Unique ID for referring to the module in the engine. | |||||
| Assigned when added to the engine. | Assigned when added to the engine. | ||||
| */ | */ | ||||
| int id = -1; | int id = -1; | ||||
| @@ -120,12 +121,16 @@ struct Module { | |||||
| paramQuantities[paramId] = q; | paramQuantities[paramId] = q; | ||||
| } | } | ||||
| template <class TPortInfo = PortInfo> | |||||
| void configInput(int portId, std::string name = "") { | void configInput(int portId, std::string name = "") { | ||||
| assert(portId < (int) inputs.size() && portId < (int) inputInfos.size()); | assert(portId < (int) inputs.size() && portId < (int) inputInfos.size()); | ||||
| if (inputInfos[portId]) | if (inputInfos[portId]) | ||||
| delete inputInfos[portId]; | delete inputInfos[portId]; | ||||
| PortInfo* p = new PortInfo; | |||||
| PortInfo* p = new TPortInfo; | |||||
| p->module = this; | |||||
| p->type = Port::INPUT; | |||||
| p->portId = portId; | |||||
| if (name == "") | if (name == "") | ||||
| p->name = string::f("#%d", portId + 1); | p->name = string::f("#%d", portId + 1); | ||||
| else | else | ||||
| @@ -133,12 +138,16 @@ struct Module { | |||||
| inputInfos[portId] = p; | inputInfos[portId] = p; | ||||
| } | } | ||||
| template <class TPortInfo = PortInfo> | |||||
| void configOutput(int portId, std::string name = "") { | void configOutput(int portId, std::string name = "") { | ||||
| assert(portId < (int) outputs.size() && portId < (int) outputInfos.size()); | assert(portId < (int) outputs.size() && portId < (int) outputInfos.size()); | ||||
| if (outputInfos[portId]) | if (outputInfos[portId]) | ||||
| delete outputInfos[portId]; | delete outputInfos[portId]; | ||||
| PortInfo* p = new PortInfo; | |||||
| PortInfo* p = new TPortInfo; | |||||
| p->module = this; | |||||
| p->type = Port::OUTPUT; | |||||
| p->portId = portId; | |||||
| if (name == "") | if (name == "") | ||||
| p->name = string::f("#%d", portId + 1); | p->name = string::f("#%d", portId + 1); | ||||
| else | else | ||||
| @@ -13,7 +13,7 @@ struct Module; | |||||
| /** A Quantity that wraps an engine::Param. */ | /** A Quantity that wraps an engine::Param. */ | ||||
| struct ParamQuantity : Quantity { | struct ParamQuantity : Quantity { | ||||
| Module* module = NULL; | Module* module = NULL; | ||||
| int paramId = 0; | |||||
| int paramId; | |||||
| /** The minimum allowed value. */ | /** The minimum allowed value. */ | ||||
| float minValue = 0.f; | float minValue = 0.f; | ||||
| @@ -8,12 +8,20 @@ namespace engine { | |||||
| struct PortInfo { | struct PortInfo { | ||||
| Module* module = NULL; | |||||
| Port::Type type; | |||||
| int portId; | |||||
| /** The name of the port, using sentence capitalization. | /** The name of the port, using sentence capitalization. | ||||
| e.g. "Sine", "Pitch input", "Mode CV" | e.g. "Sine", "Pitch input", "Mode CV" | ||||
| */ | */ | ||||
| std::string name; | std::string name; | ||||
| /** An optional one-sentence description of the parameter. */ | /** An optional one-sentence description of the parameter. */ | ||||
| std::string description; | std::string description; | ||||
| virtual ~PortInfo() {} | |||||
| virtual std::string getName() {return name;} | |||||
| virtual std::string getDescription() {return description;} | |||||
| }; | }; | ||||
| @@ -22,7 +22,7 @@ struct PortTooltip : ui::Tooltip { | |||||
| // Label | // Label | ||||
| text = (portWidget->type == engine::Port::INPUT) ? "Input" : "Output"; | text = (portWidget->type == engine::Port::INPUT) ? "Input" : "Output"; | ||||
| text += ": "; | text += ": "; | ||||
| text += portInfo->name; | |||||
| text += portInfo->getName(); | |||||
| // Voltage, number of channels | // Voltage, number of channels | ||||
| int channels = port->getChannels(); | int channels = port->getChannels(); | ||||
| for (int i = 0; i < channels; i++) { | for (int i = 0; i < channels; i++) { | ||||
| @@ -33,7 +33,7 @@ struct PortTooltip : ui::Tooltip { | |||||
| text += string::f("% .3fV", port->getVoltage(i)); | text += string::f("% .3fV", port->getVoltage(i)); | ||||
| } | } | ||||
| // Description | // Description | ||||
| std::string description = portInfo->description; | |||||
| std::string description = portInfo->getDescription(); | |||||
| if (description != "") { | if (description != "") { | ||||
| text += "\n"; | text += "\n"; | ||||
| text += description; | text += description; | ||||
| @@ -48,7 +48,7 @@ struct PortTooltip : ui::Tooltip { | |||||
| text += "Connected to "; | text += "Connected to "; | ||||
| text += otherPw->module->model->getFullName(); | text += otherPw->module->model->getFullName(); | ||||
| text += ": "; | text += ": "; | ||||
| text += otherPw->getPortInfo()->name; | |||||
| text += otherPw->getPortInfo()->getName(); | |||||
| } | } | ||||
| } | } | ||||
| Tooltip::step(); | Tooltip::step(); | ||||