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;
Internal* internal;

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

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


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

@@ -6,8 +6,8 @@ namespace rack {
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 {
void onHover(const HoverEvent& e) override {


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

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

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

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

/** 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 addChildAbove(Widget* child, Widget* sibling);
/** Removes widget from list of children if it exists.
Triggers RemoveEvent of child.
Does not delete widget but transfers ownership to caller
*/
void removeChild(Widget* child);
/** Removes and deletes all children */
/** Removes and deletes all child Widgets.
Triggers RemoveEvent of all children.
*/
void clearChildren();

/** Advances the module by one frame */
@@ -152,7 +162,9 @@ struct Widget : WeakBase {
*/
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);

// Events


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

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


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


Loading…
Cancel
Save