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.

46 lines
1.1KB

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