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.

54 lines
1.3KB

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