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.

47 lines
1.3KB

  1. #pragma once
  2. #include <app/common.hpp>
  3. #include <app/SliderKnob.hpp>
  4. #include <widget/FramebufferWidget.hpp>
  5. #include <widget/SvgWidget.hpp>
  6. namespace rack {
  7. namespace app {
  8. /** Behaves like a knob but linearly moves an widget::SvgWidget between two points.
  9. Can be used for horizontal or vertical linear faders.
  10. */
  11. struct SvgSlider : app::SliderKnob {
  12. widget::FramebufferWidget* fb;
  13. widget::SvgWidget* background;
  14. widget::SvgWidget* handle;
  15. /** Intermediate positions will be interpolated between these positions */
  16. math::Vec minHandlePos, maxHandlePos;
  17. SvgSlider();
  18. void setBackgroundSvg(std::shared_ptr<window::Svg> svg);
  19. void setHandleSvg(std::shared_ptr<window::Svg> svg);
  20. void setHandlePos(math::Vec minHandlePos, math::Vec maxHandlePos);
  21. void setHandlePosCentered(math::Vec minHandlePosCentered, math::Vec maxHandlePosCentered);
  22. void onChange(const ChangeEvent& e) override;
  23. DEPRECATED void setBackgroundSVG(std::shared_ptr<window::Svg> svg) {
  24. setBackgroundSvg(svg);
  25. }
  26. DEPRECATED void setHandleSVG(std::shared_ptr<window::Svg> svg) {
  27. setBackgroundSvg(svg);
  28. }
  29. DEPRECATED void setSVGs(std::shared_ptr<window::Svg> backgroundSvg, std::shared_ptr<window::Svg> handleSvg) {
  30. setBackgroundSvg(backgroundSvg);
  31. setHandleSvg(handleSvg);
  32. }
  33. };
  34. DEPRECATED typedef SvgSlider SVGSlider;
  35. } // namespace app
  36. } // namespace rack