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.

46 lines
866B

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