|
|
@@ -1,36 +1,42 @@ |
|
|
|
#include <ui/RadioButton.hpp> |
|
|
|
#include <context.hpp> |
|
|
|
|
|
|
|
|
|
|
|
namespace rack { |
|
|
|
namespace ui { |
|
|
|
|
|
|
|
|
|
|
|
RadioButton::RadioButton() { |
|
|
|
box.size.y = BND_WIDGET_HEIGHT; |
|
|
|
} |
|
|
|
|
|
|
|
void RadioButton::draw(const DrawArgs& args) { |
|
|
|
BNDwidgetState state = BND_DEFAULT; |
|
|
|
if (APP->event->hoveredWidget == this) |
|
|
|
if (APP->event->getHoveredWidget() == this) |
|
|
|
state = BND_HOVER; |
|
|
|
|
|
|
|
std::string label; |
|
|
|
if (quantity) { |
|
|
|
label = quantity->getLabel(); |
|
|
|
if (quantity->isMax()) |
|
|
|
state = BND_ACTIVE; |
|
|
|
} |
|
|
|
bndRadioButton(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, label.c_str()); |
|
|
|
|
|
|
|
std::string text = this->text; |
|
|
|
if (text.empty() && quantity) |
|
|
|
text = quantity->getLabel(); |
|
|
|
bndRadioButton(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RadioButton::onDragStart(const DragStartEvent& e) { |
|
|
|
OpaqueWidget::onDragStart(e); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RadioButton::onDragEnd(const DragEndEvent& e) { |
|
|
|
OpaqueWidget::onDragEnd(e); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RadioButton::onDragDrop(const DragDropEvent& e) { |
|
|
|
if (e.origin == this) { |
|
|
|
if (quantity) { |
|
|
|
if (quantity->isMax()) |
|
|
|
quantity->setMin(); |
|
|
|
else |
|
|
|
quantity->setMax(); |
|
|
|
} |
|
|
|
if (quantity) |
|
|
|
quantity->toggle(); |
|
|
|
|
|
|
|
ActionEvent eAction; |
|
|
|
onAction(eAction); |
|
|
|