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.

51 lines
1.2KB

  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. ui::Tooltip* tooltip = NULL;
  16. /** For triggering the Change event. `*/
  17. float lastValue = NAN;
  18. ParamWidget();
  19. ~ParamWidget();
  20. /** Configures ParamQuantity properties based on the type of ParamWidget.
  21. This seems a bit hacky, but it's easier than requiring plugin developers to set `ParamQuantity::randomizeEnabled`, etc.
  22. */
  23. virtual void initParamQuantity() {}
  24. engine::ParamQuantity* getParamQuantity();
  25. void createTooltip();
  26. void destroyTooltip();
  27. void step() override;
  28. void draw(const DrawArgs& args) override;
  29. void onButton(const ButtonEvent& e) override;
  30. void onDoubleClick(const DoubleClickEvent& e) override;
  31. void onEnter(const EnterEvent& e) override;
  32. void onLeave(const LeaveEvent& e) override;
  33. void createContextMenu();
  34. virtual void appendContextMenu(ui::Menu* menu) {}
  35. void resetAction();
  36. };
  37. } // namespace app
  38. } // namespace rack