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.

ZoomWidget.hpp 1.3KB

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