Dusk Audio Framework
Loading...
Searching...
No Matches
NanoBaseWidget< BaseWidget > Class Template Referenceabstract

#include <NanoVG.hpp>

Inheritance diagram for NanoBaseWidget< BaseWidget >:
NanoVG

Public Member Functions

 NanoBaseWidget (Widget *parentWidget, int flags=CREATE_ANTIALIAS)
 NanoBaseWidget (NanoBaseWidget< SubWidget > *parentWidget)
 NanoBaseWidget (NanoBaseWidget< TopLevelWidget > *parentWidget)
 NanoBaseWidget (Window &windowToMapTo, int flags=CREATE_ANTIALIAS)
 NanoBaseWidget (Application &app, int flags=CREATE_ANTIALIAS)
 NanoBaseWidget (Application &app, Window &transientParentWindow, int flags=CREATE_ANTIALIAS)
 ~NanoBaseWidget () override
bool getClipChildren () const noexcept
void setClipChildren (bool clipChildren=true) noexcept
Public Member Functions inherited from NanoVG
 NanoVG (int flags=CREATE_ANTIALIAS)
 NanoVG (NVGcontext *context)
virtual ~NanoVG ()
NVGcontext * getContext () const noexcept
void beginFrame (const uint width, const uint height, const float scaleFactor=1.0f)
void beginFrame (Widget *const widget)
void cancelFrame ()
void endFrame ()
void save ()
void restore ()
void reset ()
void strokeColor (const Color &color)
void strokeColor (const int red, const int green, const int blue, const int alpha=255)
void strokeColor (const float red, const float green, const float blue, const float alpha=1.0f)
void strokePaint (const Paint &paint)
void fillColor (const Color &color)
void fillColor (const int red, const int green, const int blue, const int alpha=255)
void fillColor (const float red, const float green, const float blue, const float alpha=1.0f)
void fillPaint (const Paint &paint)
void miterLimit (float limit)
void strokeWidth (float size)
void lineCap (LineCap cap=BUTT)
void lineJoin (LineCap join=MITER)
void globalAlpha (float alpha)
void globalTint (Color tint)
void resetTransform ()
void transform (float a, float b, float c, float d, float e, float f)
void translate (float x, float y)
void rotate (float angle)
void skewX (float angle)
void skewY (float angle)
void scale (float x, float y)
void currentTransform (float xform[6])
NanoImage::Handle createImageFromFile (const char *filename, ImageFlags imageFlags)
NanoImage::Handle createImageFromFile (const char *filename, int imageFlags)
NanoImage::Handle createImageFromMemory (const uchar *data, uint dataSize, ImageFlags imageFlags)
NanoImage::Handle createImageFromMemory (const uchar *data, uint dataSize, int imageFlags)
NanoImage::Handle createImageFromRawMemory (uint w, uint h, const uchar *data, ImageFlags imageFlags, ImageFormat format)
NanoImage::Handle createImageFromRawMemory (uint w, uint h, const uchar *data, int imageFlags, ImageFormat format)
NanoImage::Handle createImageFromRGBA (uint w, uint h, const uchar *data, ImageFlags imageFlags)
NanoImage::Handle createImageFromRGBA (uint w, uint h, const uchar *data, int imageFlags)
NanoImage::Handle createImageFromTextureHandle (GLuint textureId, uint w, uint h, ImageFlags imageFlags, bool deleteTexture=false)
NanoImage::Handle createImageFromTextureHandle (GLuint textureId, uint w, uint h, int imageFlags, bool deleteTexture=false)
Paint linearGradient (float sx, float sy, float ex, float ey, const Color &icol, const Color &ocol)
Paint boxGradient (float x, float y, float w, float h, float r, float f, const Color &icol, const Color &ocol)
Paint radialGradient (float cx, float cy, float inr, float outr, const Color &icol, const Color &ocol)
Paint imagePattern (float ox, float oy, float ex, float ey, float angle, const NanoImage &image, float alpha)
void scissor (float x, float y, float w, float h)
void intersectScissor (float x, float y, float w, float h)
void resetScissor ()
void beginPath ()
void moveTo (float x, float y)
void lineTo (float x, float y)
void bezierTo (float c1x, float c1y, float c2x, float c2y, float x, float y)
void quadTo (float cx, float cy, float x, float y)
void arcTo (float x1, float y1, float x2, float y2, float radius)
void closePath ()
void pathWinding (Winding dir)
void arc (float cx, float cy, float r, float a0, float a1, Winding dir)
void rect (float x, float y, float w, float h)
void roundedRect (float x, float y, float w, float h, float r)
void ellipse (float cx, float cy, float rx, float ry)
void circle (float cx, float cy, float r)
void fill ()
void stroke ()
FontId createFontFromFile (const char *name, const char *filename)
FontId createFontFromMemory (const char *name, const uchar *data, uint dataSize, bool freeData)
FontId findFont (const char *name)
void fontSize (float size)
void fontBlur (float blur)
void textLetterSpacing (float spacing)
void textLineHeight (float lineHeight)
void textAlign (Align align)
void textAlign (int align)
void fontFaceId (FontId font)
void fontFace (const char *font)
float text (float x, float y, const char *string, const char *end)
void textBox (float x, float y, float breakRowWidth, const char *string, const char *end=nullptr)
float textBounds (float x, float y, const char *string, const char *end, Rectangle< float > &bounds)
void textBoxBounds (float x, float y, float breakRowWidth, const char *string, const char *end, float bounds[4])
int textGlyphPositions (float x, float y, const char *string, const char *end, GlyphPosition &positions, int maxPositions)
void textMetrics (float *ascender, float *descender, float *lineh)
int textBreakLines (const char *string, const char *end, float breakRowWidth, TextRow &rows, int maxRows)
virtual bool loadSharedResources ()

Protected Member Functions

virtual void onNanoDisplay ()=0

Friends

class NanoBaseWidget< TopLevelWidget >
class NanoBaseWidget< StandaloneWindow >

Additional Inherited Members

Public Types inherited from NanoVG
enum  CreateFlags { CREATE_ANTIALIAS = 1 << 0 , CREATE_STENCIL_STROKES = 1 << 1 , CREATE_DEBUG = 1 << 2 }
enum  ImageFlags {
  IMAGE_GENERATE_MIPMAPS = 1 << 0 , IMAGE_REPEAT_X = 1 << 1 , IMAGE_REPEAT_Y = 1 << 2 , IMAGE_FLIP_Y = 1 << 3 ,
  IMAGE_PREMULTIPLIED = 1 << 4
}
enum  Align {
  ALIGN_LEFT = 1 << 0 , ALIGN_CENTER = 1 << 1 , ALIGN_RIGHT = 1 << 2 , ALIGN_TOP = 1 << 3 ,
  ALIGN_MIDDLE = 1 << 4 , ALIGN_BOTTOM = 1 << 5 , ALIGN_BASELINE = 1 << 6
}
enum  LineCap {
  BUTT , ROUND , SQUARE , BEVEL ,
  MITER
}
enum  Solidity { SOLID = 1 , HOLE = 2 }
enum  Winding { CCW = 1 , CW = 2 }
typedef int FontId
Static Public Member Functions inherited from NanoVG
static void transformIdentity (float dst[6])
static void transformTranslate (float dst[6], float tx, float ty)
static void transformScale (float dst[6], float sx, float sy)
static void transformRotate (float dst[6], float a)
static void transformSkewX (float dst[6], float a)
static void transformSkewY (float dst[6], float a)
static void transformMultiply (float dst[6], const float src[6])
static void transformPremultiply (float dst[6], const float src[6])
static int transformInverse (float dst[6], const float src[6])
static void transformPoint (float &dstx, float &dsty, const float xform[6], float srcx, float srcy)
static float degToRad (float deg)
static float radToDeg (float rad)

Detailed Description

template<class BaseWidget>
class NanoBaseWidget< BaseWidget >

NanoVG Widget class.

This class implements the NanoVG drawing API inside a DGL Widget. The drawing function onDisplay() is implemented internally but a new onNanoDisplay() needs to be overridden instead.

Constructor & Destructor Documentation

◆ NanoBaseWidget() [1/6]

template<class BaseWidget>
NanoBaseWidget< BaseWidget >::NanoBaseWidget ( Widget * parentWidget,
int flags = CREATE_ANTIALIAS )
explicit

Constructor for a NanoSubWidget.

See also
CreateFlags

◆ NanoBaseWidget() [2/6]

template<class BaseWidget>
NanoBaseWidget< BaseWidget >::NanoBaseWidget ( NanoBaseWidget< SubWidget > * parentWidget)
explicit

Constructor for a NanoSubWidget reusing a parent subwidget nanovg context.

◆ NanoBaseWidget() [3/6]

template<class BaseWidget>
NanoBaseWidget< BaseWidget >::NanoBaseWidget ( NanoBaseWidget< TopLevelWidget > * parentWidget)
explicit

Constructor for a NanoSubWidget reusing a parent top-level-widget nanovg context.

◆ NanoBaseWidget() [4/6]

template<class BaseWidget>
NanoBaseWidget< BaseWidget >::NanoBaseWidget ( Window & windowToMapTo,
int flags = CREATE_ANTIALIAS )
explicit

Constructor for a NanoTopLevelWidget.

See also
CreateFlags

◆ NanoBaseWidget() [5/6]

template<class BaseWidget>
NanoBaseWidget< BaseWidget >::NanoBaseWidget ( Application & app,
int flags = CREATE_ANTIALIAS )
explicit

Constructor for a NanoStandaloneWindow without transient parent window.

See also
CreateFlags

◆ NanoBaseWidget() [6/6]

template<class BaseWidget>
NanoBaseWidget< BaseWidget >::NanoBaseWidget ( Application & app,
Window & transientParentWindow,
int flags = CREATE_ANTIALIAS )
explicit

Constructor for a NanoStandaloneWindow with transient parent window.

See also
CreateFlags

◆ ~NanoBaseWidget()

template<class BaseWidget>
NanoBaseWidget< BaseWidget >::~NanoBaseWidget ( )
override

Destructor. Deletes the NanoVG context, if this widget has its own, with the window graphics context current.

Member Function Documentation

◆ getClipChildren()

template<class BaseWidget>
bool NanoBaseWidget< BaseWidget >::getClipChildren ( ) const
noexcept

Whether children sharing this widget's NanoVG context are clipped to the scissor it sets.

See also
setClipChildren

◆ setClipChildren()

template<class BaseWidget>
void NanoBaseWidget< BaseWidget >::setClipChildren ( bool clipChildren = true)
noexcept

Clip the children that share this widget's NanoVG context to the scissor it sets.

A NanoSubWidget created with a NanoSubWidget or NanoTopLevelWidget parent draws into its parent's context. Its onNanoDisplay() runs inside a save()/restore() pair, and by default its children are drawn after that restore(), so a scissor set in onNanoDisplay() does not reach them: they start from the state this widget was given.

With this enabled, the scissor this widget leaves at the end of onNanoDisplay() is carried into its children (the rest of the state still starts from what this widget was given), which lets a scroll area, panel or tab page keep its children inside its own bounds. Children that must draw outside it, such as popups or tooltips, should then reset the scissor themselves or not be children of this widget.

Disabled by default. It has no effect on a widget with its own NanoVG context, whose children already draw in the same state as its onNanoDisplay() left behind.

◆ onNanoDisplay()

template<class BaseWidget>
virtual void NanoBaseWidget< BaseWidget >::onNanoDisplay ( )
protectedpure virtual

New virtual onDisplay function.

See also
onDisplay

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