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.

52 lines
1.2KB

  1. #pragma once
  2. #include "widgets/Widget.hpp"
  3. namespace rack {
  4. /** Widget that consumes recursing events but gives a chance for children to consume first.
  5. You can of course override the events.
  6. You may also call OpaqueWidget::on*() from the overridden method to continue recursing/consuming the event.
  7. */
  8. struct OpaqueWidget : Widget {
  9. void onHover(const event::Hover &e) override {
  10. Widget::onHover(e);
  11. if (!e.getConsumed())
  12. e.consume(this);
  13. }
  14. void onButton(const event::Button &e) override {
  15. Widget::onButton(e);
  16. if (!e.getConsumed())
  17. e.consume(this);
  18. }
  19. void onHoverKey(const event::HoverKey &e) override {
  20. Widget::onHoverKey(e);
  21. if (!e.getConsumed())
  22. e.consume(this);
  23. }
  24. void onHoverText(const event::HoverText &e) override {
  25. Widget::onHoverText(e);
  26. if (!e.getConsumed())
  27. e.consume(this);
  28. }
  29. void onHoverScroll(const event::HoverScroll &e) override {
  30. Widget::onHoverScroll(e);
  31. if (!e.getConsumed())
  32. e.consume(this);
  33. }
  34. void onDragHover(const event::DragHover &e) override {
  35. Widget::onDragHover(e);
  36. if (!e.getConsumed())
  37. e.consume(this);
  38. }
  39. void onPathDrop(const event::PathDrop &e) override {
  40. Widget::onPathDrop(e);
  41. if (!e.getConsumed())
  42. e.consume(this);
  43. }
  44. };
  45. } // namespace rack