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.

49 lines
896B

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