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

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