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.

44 lines
815B

  1. #pragma once
  2. #include "widgets.hpp"
  3. namespace rack {
  4. /** Deletes itself from parent when clicked */
  5. struct MenuOverlay : OpaqueWidget {
  6. void step() override {
  7. // Adopt parent's size
  8. box.size = parent->box.size;
  9. // Fit all children in the box
  10. for (Widget *child : children) {
  11. child->box = child->box.nudge(box.zeroPos());
  12. }
  13. Widget::step();
  14. }
  15. void onButton(event::Button &e) override {
  16. OpaqueWidget::onButton(e);
  17. if (e.target == this && e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) {
  18. requestedDelete = true;
  19. }
  20. }
  21. void onHoverKey(event::HoverKey &e) override {
  22. OpaqueWidget::onHoverKey(e);
  23. if (e.target == this && e.action == GLFW_PRESS && e.key == GLFW_KEY_ESCAPE) {
  24. e.target = this;
  25. requestedDelete = true;
  26. return;
  27. }
  28. }
  29. };
  30. } // namespace rack