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.

42 lines
721B

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