Browse Source

Add doc comments

tags/v2.2.2
Andrew Belt 1 year ago
parent
commit
02ca4c66f7
4 changed files with 19 additions and 6 deletions
  1. +1
    -1
      include/widget/FramebufferWidget.hpp
  2. +2
    -2
      include/widget/OpaqueWidget.hpp
  3. +14
    -2
      include/widget/Widget.hpp
  4. +2
    -1
      include/widget/ZoomWidget.hpp

+ 1
- 1
include/widget/FramebufferWidget.hpp View File

@@ -13,7 +13,6 @@ struct FramebufferWidget : Widget {
struct Internal; struct Internal;
Internal* internal; Internal* internal;


/** Set this to true to re-render the children to the framebuffer the next time it is drawn */
bool dirty = true; bool dirty = true;
bool bypassed = false; bool bypassed = false;
float oversample = 1.0; float oversample = 1.0;
@@ -26,6 +25,7 @@ struct FramebufferWidget : Widget {


FramebufferWidget(); FramebufferWidget();
~FramebufferWidget(); ~FramebufferWidget();
/** Requests to re-render children to the framebuffer on the next draw(). */
void setDirty(bool dirty = true); void setDirty(bool dirty = true);
int getImageHandle(); int getImageHandle();
NVGLUframebuffer* getFramebuffer(); NVGLUframebuffer* getFramebuffer();


+ 2
- 2
include/widget/OpaqueWidget.hpp View File

@@ -6,8 +6,8 @@ namespace rack {
namespace widget { namespace widget {




/** A Widget that stops propagation of all recursive PositionEvents but gives a chance for children to consume first.
Also consumes Hover and Button for left-clicks.
/** A Widget that stops propagation of all recursive PositionEvents (such as ButtonEvent) but gives a chance for children to consume first.
Also consumes HoverEvent and ButtonEvent for left-clicks.
*/ */
struct OpaqueWidget : Widget { struct OpaqueWidget : Widget {
void onHover(const HoverEvent& e) override { void onHover(const HoverEvent& e) override {


+ 14
- 2
include/widget/Widget.hpp View File

@@ -36,21 +36,28 @@ struct Widget : WeakBase {
virtual ~Widget(); virtual ~Widget();


math::Rect getBox(); math::Rect getBox();
/** Calls setPosition() and then setSize(). */
void setBox(math::Rect box); void setBox(math::Rect box);
math::Vec getPosition(); math::Vec getPosition();
/** Sets position and triggers RepositionEvent if position changed. */
void setPosition(math::Vec pos); void setPosition(math::Vec pos);
math::Vec getSize(); math::Vec getSize();
/** Sets size and triggers ResizeEvent if size changed. */
void setSize(math::Vec size); void setSize(math::Vec size);
widget::Widget* getParent(); widget::Widget* getParent();
bool isVisible(); bool isVisible();
/** Sets `visible` and triggers ShowEvent or HideEvent if changed. */
void setVisible(bool visible); void setVisible(bool visible);
/** Makes Widget visible and triggers ShowEvent if changed. */
void show() { void show() {
setVisible(true); setVisible(true);
} }
/** Makes Widget not visible and triggers HideEvent if changed. */
void hide() { void hide() {
setVisible(false); setVisible(false);
} }


/** Requests this Widget's parent to delete it in the next step(). */
void requestDelete(); void requestDelete();


/** Returns the smallest rectangle containing this widget's children (visible and invisible) in its local coordinates. /** Returns the smallest rectangle containing this widget's children (visible and invisible) in its local coordinates.
@@ -119,10 +126,13 @@ struct Widget : WeakBase {
void addChildBelow(Widget* child, Widget* sibling); void addChildBelow(Widget* child, Widget* sibling);
void addChildAbove(Widget* child, Widget* sibling); void addChildAbove(Widget* child, Widget* sibling);
/** Removes widget from list of children if it exists. /** Removes widget from list of children if it exists.
Triggers RemoveEvent of child.
Does not delete widget but transfers ownership to caller Does not delete widget but transfers ownership to caller
*/ */
void removeChild(Widget* child); void removeChild(Widget* child);
/** Removes and deletes all children */
/** Removes and deletes all child Widgets.
Triggers RemoveEvent of all children.
*/
void clearChildren(); void clearChildren();


/** Advances the module by one frame */ /** Advances the module by one frame */
@@ -152,7 +162,9 @@ struct Widget : WeakBase {
*/ */
virtual void drawLayer(const DrawArgs& args, int layer); virtual void drawLayer(const DrawArgs& args, int layer);


/** Draws a particular child. */
/** Draws a particular child.
Saves and restores NanoVG context to prevent changing the given context.
*/
void drawChild(Widget* child, const DrawArgs& args, int layer = 0); void drawChild(Widget* child, const DrawArgs& args, int layer = 0);


// Events // Events


+ 2
- 1
include/widget/ZoomWidget.hpp View File

@@ -6,7 +6,7 @@ namespace rack {
namespace widget { namespace widget {




/** A Widget with a dynamic zoom level. */
/** Resizes the scale of appearance and PositionEvents of children. */
struct ZoomWidget : Widget { struct ZoomWidget : Widget {
/** Use setZoom() and getZoom() instead of using this variable directly. */ /** Use setZoom() and getZoom() instead of using this variable directly. */
float zoom = 1.f; float zoom = 1.f;
@@ -15,6 +15,7 @@ struct ZoomWidget : Widget {
float getRelativeZoom(Widget* ancestor) override; float getRelativeZoom(Widget* ancestor) override;
math::Rect getViewport(math::Rect r) override; math::Rect getViewport(math::Rect r) override;
float getZoom(); float getZoom();
/** Sets zoom scale and triggers DirtyEvent recursively if scale is changed, so children FramebufferWidgets are redrawn. */
void setZoom(float zoom); void setZoom(float zoom);
void draw(const DrawArgs& args) override; void draw(const DrawArgs& args) override;
void drawLayer(const DrawArgs& args, int layer) override; void drawLayer(const DrawArgs& args, int layer) override;


Loading…
Cancel
Save