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
783B

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