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.

45 lines
841B

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