diff --git a/src/AX.cpp b/src/AX.cpp index f5f8873..0b82293 100644 --- a/src/AX.cpp +++ b/src/AX.cpp @@ -48,7 +48,8 @@ struct AUX : Module { for(int k=0;k>(mm2px(Vec(xL,y)),module,AUX::VU_LIGHTS_L+7)); addChild(createLight>(mm2px(Vec(xR,y)),module,AUX::VU_LIGHTS_R+7)); } + + void appendContextMenu(Menu* menu) override { + AUX *module=dynamic_cast(this->module); + assert(module); + + menu->addChild(new MenuSeparator); + + menu->addChild(new SlewMenuItem(module)); + } + }; diff --git a/src/SKF.cpp b/src/SKF.cpp index 86358b3..ccb8ecc 100644 --- a/src/SKF.cpp +++ b/src/SKF.cpp @@ -117,58 +117,6 @@ struct SKF : Module { }; -struct SlewQuantity : Quantity { - SKF* module; - - SlewQuantity(SKF* m) : module(m) {} - - void setValue(float value) override { - value = clamp(value, getMinValue(), getMaxValue()); - if (module) { - module->slew = value; - } - } - - float getValue() override { - if (module) { - return module->slew; - } - return 0.5f; - } - - float getMinValue() override { return 0.0f; } - float getMaxValue() override { return 1.0f; } - float getDefaultValue() override { return 1.f/16.f; } - float getDisplayValue() override { return getValue(); } - void setDisplayValue(float displayValue) override { setValue(displayValue); } - std::string getLabel() override { return "Slew"; } - std::string getUnit() override { return ""; } -}; - -struct SlewSlider : ui::Slider { - SlewSlider(SKF* module) { - quantity = new SlewQuantity(module); - box.size.x = 200.0f; - } - virtual ~SlewSlider() { - delete quantity; - } -}; - -struct SlewMenuItem : MenuItem { - SKF* module; - - SlewMenuItem(SKF* m) : module(m) { - this->text = "Freq Input"; - this->rightText = "▸"; - } - - Menu* createChildMenu() override { - Menu* menu = new Menu; - menu->addChild(new SlewSlider(module)); - return menu; - } -}; struct SKFWidget : ModuleWidget { @@ -205,7 +153,7 @@ struct SKFWidget : ModuleWidget { menu->addChild(new MenuSeparator); - menu->addChild(new SlewMenuItem(module)); + menu->addChild(new SlewMenuItem(module)); } }; diff --git a/src/dcb.h b/src/dcb.h index 455ea8f..81297a9 100644 --- a/src/dcb.h +++ b/src/dcb.h @@ -564,7 +564,60 @@ struct DensMenuItem : MenuItem { return menu; } }; +template +struct SlewQuantity : Quantity { + T *module; + + SlewQuantity(T *m) : module(m) {} + + void setValue(float value) override { + value = clamp(value, getMinValue(), getMaxValue()); + if (module) { + module->slew = value; + } + } + + float getValue() override { + if (module) { + return module->slew; + } + return 0.5f; + } + + float getMinValue() override { return 0.0f; } + float getMaxValue() override { return 1.0f; } + float getDefaultValue() override { return 1.f/16.f; } + float getDisplayValue() override { return getValue(); } + void setDisplayValue(float displayValue) override { setValue(displayValue); } + std::string getLabel() override { return "Slew"; } + std::string getUnit() override { return ""; } +}; +template +struct SlewSlider : ui::Slider { + SlewSlider(T* module) { + quantity = new SlewQuantity(module); + box.size.x = 200.0f; + } + virtual ~SlewSlider() { + delete quantity; + } +}; + +template +struct SlewMenuItem : MenuItem { + T *module; + SlewMenuItem(T *m) : module(m) { + this->text = "Level Input"; + this->rightText = "▸"; + } + + Menu* createChildMenu() override { + Menu* menu = new Menu; + menu->addChild(new SlewSlider(module)); + return menu; + } +}; struct IntSelectItem : MenuItem { int *value; int min;