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.

38 lines
946B

  1. #pragma once
  2. #include "widgets/Widget.hpp"
  3. namespace rack {
  4. /** Caches a widget's draw() result to a framebuffer so it is called less frequently
  5. When `dirty` is true, its children will be re-rendered on the next call to step() override.
  6. Events are not passed to the underlying scene.
  7. */
  8. struct FramebufferWidget : virtual Widget {
  9. /** Set this to true to re-render the children to the framebuffer the next time it is drawn */
  10. bool dirty = true;
  11. /** A margin in pixels around the children in the framebuffer
  12. This prevents cutting the rendered SVG off on the box edges.
  13. */
  14. float oversample;
  15. /** The root object in the framebuffer scene
  16. The FramebufferWidget owns the pointer
  17. */
  18. struct Internal;
  19. Internal *internal;
  20. FramebufferWidget();
  21. ~FramebufferWidget();
  22. void draw(NVGcontext *vg) override;
  23. int getImageHandle();
  24. void onZoom(const event::Zoom &e) override {
  25. dirty = true;
  26. Widget::onZoom(e);
  27. }
  28. };
  29. } // namespace rack