VCV Rack API v2
Loading...
Searching...
No Matches
rack::widget::FramebufferWidget Struct Reference

Caches its children's draw() result to a framebuffer image. More...

#include <FramebufferWidget.hpp>

Inheritance diagram for rack::widget::FramebufferWidget:
[legend]
Collaboration diagram for rack::widget::FramebufferWidget:
[legend]

Public Member Functions

 FramebufferWidget ()
 
 ~FramebufferWidget ()
 
void setDirty (bool dirty=true)
 Requests to re-render children to the framebuffer on the next draw().
 
int getImageHandle ()
 
NVGLUframebuffer * getFramebuffer ()
 
math::Vec getFramebufferSize ()
 
void deleteFramebuffer ()
 
void step () override
 Advances the module by one frame.
 
void draw (const DrawArgs &args) override
 Draws the framebuffer to the NanoVG scene, re-rendering it if necessary.
 
void render (math::Vec scale=math::Vec(1, 1), math::Vec offsetF=math::Vec(0, 0), math::Rect clipBox=math::Rect::inf())
 Re-renders the framebuffer, re-creating it if necessary.
 
virtual void drawFramebuffer ()
 Initializes the current GL context and draws children to it.
 
void onDirty (const DirtyEvent &e) override
 
void onContextCreate (const ContextCreateEvent &e) override
 
void onContextDestroy (const ContextDestroyEvent &e) override
 
- Public Member Functions inherited from rack::widget::Widget
virtual ~Widget ()
 
math::Rect getBox ()
 
void setBox (math::Rect box)
 Calls setPosition() and then setSize().
 
math::Vec getPosition ()
 
void setPosition (math::Vec pos)
 Sets position and triggers RepositionEvent if position changed.
 
math::Vec getSize ()
 
void setSize (math::Vec size)
 Sets size and triggers ResizeEvent if size changed.
 
widget::WidgetgetParent ()
 
bool isVisible ()
 
void setVisible (bool visible)
 Sets visible and triggers ShowEvent or HideEvent if changed.
 
void show ()
 Makes Widget visible and triggers ShowEvent if changed.
 
void hide ()
 Makes Widget not visible and triggers HideEvent if changed.
 
void requestDelete ()
 Requests this Widget's parent to delete it in the next step().
 
virtual math::Rect getChildrenBoundingBox ()
 Returns the smallest rectangle containing this widget's children (visible and invisible) in its local coordinates.
 
virtual math::Rect getVisibleChildrenBoundingBox ()
 
bool isDescendantOf (Widget *ancestor)
 Returns whether ancestor is a parent or distant parent of this widget.
 
virtual math::Vec getRelativeOffset (math::Vec v, Widget *ancestor)
 Returns v (given in local coordinates) transformed into the coordinate system of ancestor.
 
math::Vec getAbsoluteOffset (math::Vec v)
 Returns v transformed into world/root/global/absolute coordinates.
 
virtual float getRelativeZoom (Widget *ancestor)
 Returns the zoom level in the coordinate system of ancestor.
 
float getAbsoluteZoom ()
 
virtual math::Rect getViewport (math::Rect r=math::Rect::inf())
 Returns a subset of the given Rect bounded by the box of this widget and all ancestors.
 
template<class T >
T * getAncestorOfType ()
 
template<class T >
T * getFirstDescendantOfType ()
 
bool hasChild (Widget *child)
 Checks if the given widget is a child of this widget.
 
void addChild (Widget *child)
 Adds widget to the top of the children.
 
void addChildBottom (Widget *child)
 Adds widget to the bottom of the children.
 
void addChildBelow (Widget *child, Widget *sibling)
 Adds widget directly below another widget.
 
void addChildAbove (Widget *child, Widget *sibling)
 
void removeChild (Widget *child)
 Removes widget from list of children if it exists.
 
void clearChildren ()
 Removes and deletes all child Widgets.
 
virtual DEPRECATED void draw (NVGcontext *vg)
 Override draw(const DrawArgs &args) instead.
 
virtual void drawLayer (const DrawArgs &args, int layer)
 Draw additional layers.
 
void drawChild (Widget *child, const DrawArgs &args, int layer=0)
 Draws a particular child.
 
template<typename TMethod , class TEvent >
void recurseEvent (TMethod f, const TEvent &e)
 Recurses an event to all visible Widgets.
 
template<typename TMethod , class TEvent >
void recursePositionEvent (TMethod f, const TEvent &e)
 Recurses an event to all visible Widgets until it is consumed.
 
virtual void onHover (const HoverEvent &e)
 
virtual void onButton (const ButtonEvent &e)
 
virtual void onDoubleClick (const DoubleClickEvent &e)
 
virtual void onHoverKey (const HoverKeyEvent &e)
 
virtual void onHoverText (const HoverTextEvent &e)
 
virtual void onHoverScroll (const HoverScrollEvent &e)
 
virtual void onEnter (const EnterEvent &e)
 
virtual void onLeave (const LeaveEvent &e)
 
virtual void onSelect (const SelectEvent &e)
 
virtual void onDeselect (const DeselectEvent &e)
 
virtual void onSelectKey (const SelectKeyEvent &e)
 
virtual void onSelectText (const SelectTextEvent &e)
 
virtual void onDragStart (const DragStartEvent &e)
 
virtual void onDragEnd (const DragEndEvent &e)
 
virtual void onDragMove (const DragMoveEvent &e)
 
virtual void onDragHover (const DragHoverEvent &e)
 
virtual void onDragEnter (const DragEnterEvent &e)
 
virtual void onDragLeave (const DragLeaveEvent &e)
 
virtual void onDragDrop (const DragDropEvent &e)
 
virtual void onPathDrop (const PathDropEvent &e)
 
virtual void onAction (const ActionEvent &e)
 
virtual void onChange (const ChangeEvent &e)
 
virtual void onReposition (const RepositionEvent &e)
 
virtual void onResize (const ResizeEvent &e)
 
virtual void onAdd (const AddEvent &e)
 
virtual void onRemove (const RemoveEvent &e)
 
virtual void onShow (const ShowEvent &e)
 
virtual void onHide (const HideEvent &e)
 
- Public Member Functions inherited from rack::WeakBase
 ~WeakBase ()
 
size_t getWeakCount ()
 

Public Attributes

Internal * internal
 
bool dirty = true
 
bool bypassed = false
 
float oversample = 1.0
 
bool dirtyOnSubpixelChange = true
 Redraw when the world offset of the FramebufferWidget changes its fractional value.
 
math::Vec viewportMargin = math::Vec(INFINITY, INFINITY)
 If finite, the maximum size of the framebuffer is the viewport expanded by this margin.
 
- Public Attributes inherited from rack::widget::Widget
math::Rect box = math::Rect(math::Vec(), math::Vec(INFINITY, INFINITY))
 Position relative to parent and size of widget.
 
Widgetparent = NULL
 Automatically set when Widget is added as a child to another Widget.
 
std::list< Widget * > children
 
bool visible = true
 Disables rendering but allow stepping.
 
bool requestedDelete = false
 If set to true, parent will delete Widget in the next step().
 
- Public Attributes inherited from rack::WeakBase
WeakHandleweakHandle = nullptr
 

Additional Inherited Members

- Public Types inherited from rack::widget::Widget
using BaseEvent = widget::BaseEvent
 

Detailed Description

Caches its children's draw() result to a framebuffer image.

When dirty, its children will be re-rendered on the next call to step().

Constructor & Destructor Documentation

◆ FramebufferWidget()

rack::widget::FramebufferWidget::FramebufferWidget ( )

◆ ~FramebufferWidget()

rack::widget::FramebufferWidget::~FramebufferWidget ( )

Member Function Documentation

◆ setDirty()

void rack::widget::FramebufferWidget::setDirty ( bool dirty = true)

Requests to re-render children to the framebuffer on the next draw().

◆ getImageHandle()

int rack::widget::FramebufferWidget::getImageHandle ( )

◆ getFramebuffer()

NVGLUframebuffer * rack::widget::FramebufferWidget::getFramebuffer ( )

◆ getFramebufferSize()

math::Vec rack::widget::FramebufferWidget::getFramebufferSize ( )

◆ deleteFramebuffer()

void rack::widget::FramebufferWidget::deleteFramebuffer ( )

◆ step()

void rack::widget::FramebufferWidget::step ( )
overridevirtual

Advances the module by one frame.

Reimplemented from rack::widget::Widget.

Reimplemented in rack::widget::OpenGlWidget.

◆ draw()

void rack::widget::FramebufferWidget::draw ( const DrawArgs & args)
overridevirtual

Draws the framebuffer to the NanoVG scene, re-rendering it if necessary.

Reimplemented from rack::widget::Widget.

◆ render()

void rack::widget::FramebufferWidget::render ( math::Vec scale = math::Vec(1, 1),
math::Vec offsetF = math::Vec(0, 0),
math::Rect clipBox = math::Rect::inf() )

Re-renders the framebuffer, re-creating it if necessary.

Handles oversampling (if >1) by rendering to a temporary (larger) framebuffer and then downscaling it to the main persistent framebuffer.

◆ drawFramebuffer()

virtual void rack::widget::FramebufferWidget::drawFramebuffer ( )
virtual

Initializes the current GL context and draws children to it.

Reimplemented in rack::widget::OpenGlWidget.

◆ onDirty()

void rack::widget::FramebufferWidget::onDirty ( const DirtyEvent & e)
overridevirtual

Reimplemented from rack::widget::Widget.

◆ onContextCreate()

void rack::widget::FramebufferWidget::onContextCreate ( const ContextCreateEvent & e)
overridevirtual

Reimplemented from rack::widget::Widget.

◆ onContextDestroy()

void rack::widget::FramebufferWidget::onContextDestroy ( const ContextDestroyEvent & e)
overridevirtual

Reimplemented from rack::widget::Widget.

Member Data Documentation

◆ internal

Internal* rack::widget::FramebufferWidget::internal

◆ dirty

bool rack::widget::FramebufferWidget::dirty = true

◆ bypassed

bool rack::widget::FramebufferWidget::bypassed = false

◆ oversample

float rack::widget::FramebufferWidget::oversample = 1.0

◆ dirtyOnSubpixelChange

bool rack::widget::FramebufferWidget::dirtyOnSubpixelChange = true

Redraw when the world offset of the FramebufferWidget changes its fractional value.

◆ viewportMargin

math::Vec rack::widget::FramebufferWidget::viewportMargin = math::Vec(INFINITY, INFINITY)

If finite, the maximum size of the framebuffer is the viewport expanded by this margin.

The framebuffer is re-rendered when the viewport moves outside the margin.


The documentation for this struct was generated from the following file: