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
757B

  1. #pragma once
  2. #include "ui/common.hpp"
  3. #include "ui/QuantityWidget.hpp"
  4. namespace rack {
  5. struct RadioButton : OpaqueWidget, QuantityWidget {
  6. BNDwidgetState state = BND_DEFAULT;
  7. RadioButton() {
  8. box.size.y = BND_WIDGET_HEIGHT;
  9. }
  10. void draw(NVGcontext *vg) override {
  11. bndRadioButton(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, value == 0.0 ? state : BND_ACTIVE, -1, label.c_str());
  12. }
  13. void onEnter(event::Enter &e) override {
  14. state = BND_HOVER;
  15. }
  16. void onLeave(event::Leave &e) override {
  17. state = BND_DEFAULT;
  18. }
  19. void onDragDrop(event::DragDrop &e) override {
  20. if (e.origin == this) {
  21. if (value)
  22. setValue(0.0);
  23. else
  24. setValue(1.0);
  25. event::Action eAction;
  26. onAction(eAction);
  27. }
  28. }
  29. };
  30. } // namespace rack