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.

MenuOverlay.hpp 821B

6 years ago
6 years ago
6 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041
  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. requestedDelete = true;
  26. }
  27. }
  28. };
  29. } // namespace rack