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.

61 lines
1.4KB

  1. #pragma once
  2. #include <widget/Widget.hpp>
  3. namespace rack {
  4. namespace widget {
  5. /** A Widget with a dynamic zoom level. */
  6. struct ZoomWidget : Widget {
  7. float zoom = 1.f;
  8. math::Vec getRelativeOffset(math::Vec v, Widget* relative) override;
  9. math::Rect getViewport(math::Rect r) override;
  10. void setZoom(float zoom);
  11. float getZoom() {
  12. return zoom;
  13. }
  14. void draw(const DrawArgs& args) override;
  15. void onHover(const event::Hover& e) override {
  16. event::Hover e2 = e;
  17. e2.pos = e.pos.div(zoom);
  18. Widget::onHover(e2);
  19. }
  20. void onButton(const event::Button& e) override {
  21. event::Button e2 = e;
  22. e2.pos = e.pos.div(zoom);
  23. Widget::onButton(e2);
  24. }
  25. void onHoverKey(const event::HoverKey& e) override {
  26. event::HoverKey e2 = e;
  27. e2.pos = e.pos.div(zoom);
  28. Widget::onHoverKey(e2);
  29. }
  30. void onHoverText(const event::HoverText& e) override {
  31. event::HoverText e2 = e;
  32. e2.pos = e.pos.div(zoom);
  33. Widget::onHoverText(e2);
  34. }
  35. void onHoverScroll(const event::HoverScroll& e) override {
  36. event::HoverScroll e2 = e;
  37. e2.pos = e.pos.div(zoom);
  38. Widget::onHoverScroll(e2);
  39. }
  40. void onDragHover(const event::DragHover& e) override {
  41. event::DragHover e2 = e;
  42. e2.pos = e.pos.div(zoom);
  43. Widget::onDragHover(e2);
  44. }
  45. void onPathDrop(const event::PathDrop& e) override {
  46. event::PathDrop e2 = e;
  47. e2.pos = e.pos.div(zoom);
  48. Widget::onPathDrop(e2);
  49. }
  50. };
  51. } // namespace widget
  52. } // namespace rack