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.

43 lines
781B

  1. #include <ui/RadioButton.hpp>
  2. namespace rack {
  3. namespace ui {
  4. RadioButton::RadioButton() {
  5. box.size.y = BND_WIDGET_HEIGHT;
  6. }
  7. void RadioButton::draw(const DrawArgs& args) {
  8. BNDwidgetState state = BND_DEFAULT;
  9. if (APP->event->hoveredWidget == this)
  10. state = BND_HOVER;
  11. std::string label;
  12. if (quantity) {
  13. label = quantity->getLabel();
  14. if (quantity->isMax())
  15. state = BND_ACTIVE;
  16. }
  17. bndRadioButton(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, label.c_str());
  18. }
  19. void RadioButton::onDragDrop(const event::DragDrop& e) {
  20. if (e.origin == this) {
  21. if (quantity) {
  22. if (quantity->isMax())
  23. quantity->setMin();
  24. else
  25. quantity->setMax();
  26. }
  27. event::Action eAction;
  28. onAction(eAction);
  29. }
  30. }
  31. } // namespace ui
  32. } // namespace rack