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

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