You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2KB

  1. #pragma once
  2. #include "bogaudio.hpp"
  3. namespace bogaudio {
  4. struct DisableOutputLimitModule : Module {
  5. bool _disableOutputLimit = false;
  6. DisableOutputLimitModule(int numParams, int numInputs, int numOutputs, int numLights = 0)
  7. : Module(numParams, numInputs, numOutputs, numLights)
  8. {
  9. }
  10. json_t* toJson() override;
  11. void fromJson(json_t* root) override;
  12. };
  13. struct DisableOutputLimitMenuItem : MenuItem {
  14. DisableOutputLimitModule* _module;
  15. DisableOutputLimitMenuItem(DisableOutputLimitModule* module, const char* label)
  16. : _module(module)
  17. {
  18. this->text = label;
  19. }
  20. void onAction(EventAction &e) override {
  21. _module->_disableOutputLimit = !_module->_disableOutputLimit;
  22. }
  23. void step() override {
  24. rightText = _module->_disableOutputLimit ? "✔" : "";
  25. }
  26. };
  27. struct DisableOutputLimitModuleWidget : ModuleWidget {
  28. DisableOutputLimitModuleWidget(Module* module) : ModuleWidget(module) {
  29. }
  30. void appendContextMenu(Menu* menu) override {
  31. DisableOutputLimitModule* dolm = dynamic_cast<DisableOutputLimitModule*>(module);
  32. assert(dolm);
  33. menu->addChild(new MenuLabel());
  34. menu->addChild(new DisableOutputLimitMenuItem(dolm, "Disable output limit"));
  35. }
  36. };
  37. } // namespace bogaudio