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.

29 lines
578B

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