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.

30 lines
588B

  1. #include "widgets.hpp"
  2. #include "gui.hpp"
  3. namespace rack {
  4. #define SLIDER_SENSITIVITY 0.001
  5. void Slider::draw(NVGcontext *vg) {
  6. float progress = mapf(value, minValue, maxValue, 0.0, 1.0);
  7. bndSlider(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, progress, getText().c_str(), NULL);
  8. }
  9. void Slider::onDragStart() {
  10. state = BND_ACTIVE;
  11. guiCursorLock();
  12. }
  13. void Slider::onDragMove(Vec mouseRel) {
  14. setValue(value + SLIDER_SENSITIVITY * (maxValue - minValue) * mouseRel.x);
  15. }
  16. void Slider::onDragEnd() {
  17. state = BND_DEFAULT;
  18. guiCursorUnlock();
  19. }
  20. } // namespace rack