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.

47 lines
793B

  1. #pragma once
  2. #include "ui/common.hpp"
  3. namespace rack {
  4. struct Button : OpaqueWidget {
  5. std::string text;
  6. BNDwidgetState state = BND_DEFAULT;
  7. Button() {
  8. box.size.y = BND_WIDGET_HEIGHT;
  9. }
  10. void draw(NVGcontext *vg) override {
  11. bndToolButton(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str());
  12. Widget::draw(vg);
  13. }
  14. void onEnter(event::Enter &e) override {
  15. state = BND_HOVER;
  16. }
  17. void onLeave(event::Leave &e) override {
  18. state = BND_DEFAULT;
  19. }
  20. void onDragStart(event::DragStart &e) override {
  21. state = BND_ACTIVE;
  22. }
  23. void onDragEnd(event::DragEnd &e) override {
  24. state = BND_HOVER;
  25. }
  26. void onDragDrop(event::DragDrop &e) override {
  27. if (e.origin == this) {
  28. event::Action eAction;
  29. onAction(eAction);
  30. }
  31. }
  32. };
  33. } // namespace rack