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.

37 lines
699B

  1. #include "widgets.hpp"
  2. namespace rack {
  3. QuantityWidget::QuantityWidget() {
  4. EventChange e;
  5. onChange(e);
  6. }
  7. void QuantityWidget::setValue(float value) {
  8. this->value = clampf(value, fminf(minValue, maxValue), fmaxf(minValue, maxValue));
  9. EventChange e;
  10. onChange(e);
  11. }
  12. void QuantityWidget::setLimits(float minValue, float maxValue) {
  13. this->minValue = minValue;
  14. this->maxValue = maxValue;
  15. }
  16. void QuantityWidget::setDefaultValue(float defaultValue) {
  17. this->defaultValue = defaultValue;
  18. setValue(defaultValue);
  19. }
  20. std::string QuantityWidget::getText() {
  21. std::string text = label;
  22. text += ": ";
  23. text += stringf("%.*f", precision, value);
  24. text += unit;
  25. return text;
  26. }
  27. } // namespace rack