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.

ParamWidget.hpp 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include <app/common.hpp>
  3. #include <widget/OpaqueWidget.hpp>
  4. #include <ui/Tooltip.hpp>
  5. #include <ui/Menu.hpp>
  6. #include <engine/ParamQuantity.hpp>
  7. namespace rack {
  8. namespace app {
  9. /** Manages an engine::Param on a ModuleWidget. */
  10. struct ParamWidget : widget::OpaqueWidget {
  11. struct Internal;
  12. Internal* internal;
  13. engine::Module* module = NULL;
  14. int paramId = -1;
  15. ParamWidget();
  16. ~ParamWidget();
  17. /** Configures ParamQuantity properties based on the type of ParamWidget.
  18. This seems a bit hacky, but it's easier than requiring plugin developers to set `ParamQuantity::randomizeEnabled`, etc.
  19. */
  20. virtual void initParamQuantity() {}
  21. engine::ParamQuantity* getParamQuantity();
  22. void createTooltip();
  23. void destroyTooltip();
  24. void step() override;
  25. void draw(const DrawArgs& args) override;
  26. void onButton(const ButtonEvent& e) override;
  27. void onDoubleClick(const DoubleClickEvent& e) override;
  28. void onEnter(const EnterEvent& e) override;
  29. void onLeave(const LeaveEvent& e) override;
  30. void createContextMenu();
  31. /** Override to add custom menu items at the bottom of the parameter context menu.
  32. It is recommended to add a MenuSeparator before other menu items.
  33. menu->addChild(new MenuSeparator);
  34. */
  35. virtual void appendContextMenu(ui::Menu* menu) {}
  36. void resetAction();
  37. };
  38. } // namespace app
  39. } // namespace rack