17 #ifndef DGL_NANO_WIDGET_HPP_INCLUDED 18 #define DGL_NANO_WIDGET_HPP_INCLUDED 23 #define NANOVG_DEJAVU_SANS_TTF "__dpf_dejavusans_ttf__" 56 Handle(NVGcontext* c,
int id) noexcept
105 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
NanoImage)
210 CREATE_ANTIALIAS = 1 << 0,
216 CREATE_STENCIL_STROKES = 1 << 1,
221 CREATE_DEBUG = 1 << 2,
225 IMAGE_GENERATE_MIPMAPS = 1 << 0,
226 IMAGE_REPEAT_X = 1 << 1,
227 IMAGE_REPEAT_Y = 1 << 2,
228 IMAGE_FLIP_Y = 1 << 3,
229 IMAGE_PREMULTIPLIED = 1 << 4
235 ALIGN_CENTER = 1 << 1,
236 ALIGN_RIGHT = 1 << 2,
239 ALIGN_MIDDLE = 1 << 4,
240 ALIGN_BOTTOM = 1 << 5,
241 ALIGN_BASELINE = 1 << 6
276 Paint(
const NVGpaint&) noexcept;
277 operator NVGpaint()
const noexcept;
300 NanoVG(
int flags = CREATE_ANTIALIAS);
324 void beginFrame(
const uint width,
const uint height,
const float scaleFactor = 1.0f);
329 void beginFrame(
Widget*
const widget);
366 void strokeColor(
const Color& color);
372 void strokeColor(
const int red,
const int green,
const int blue,
const int alpha = 255);
378 void strokeColor(
const float red,
const float green,
const float blue,
const float alpha = 1.0f);
383 void strokePaint(
const Paint& paint);
388 void fillColor(
const Color& color);
394 void fillColor(
const int red,
const int green,
const int blue,
const int alpha = 255);
400 void fillColor(
const float red,
const float green,
const float blue,
const float alpha = 1.0f);
405 void fillPaint(
const Paint& paint);
411 void miterLimit(
float limit);
416 void strokeWidth(
float size);
422 void lineCap(LineCap cap = BUTT);
428 void lineJoin(LineCap join = MITER);
434 void globalAlpha(
float alpha);
442 void resetTransform();
451 void transform(
float a,
float b,
float c,
float d,
float e,
float f);
456 void translate(
float x,
float y);
461 void rotate(
float angle);
466 void skewX(
float angle);
471 void skewY(
float angle);
476 void scale(
float x,
float y);
484 void currentTransform(
float xform[6]);
493 static void transformIdentity(
float dst[6]);
498 static void transformTranslate(
float dst[6],
float tx,
float ty);
503 static void transformScale(
float dst[6],
float sx,
float sy);
508 static void transformRotate(
float dst[6],
float a);
513 static void transformSkewX(
float dst[6],
float a);
518 static void transformSkewY(
float dst[6],
float a);
523 static void transformMultiply(
float dst[6],
const float src[6]);
528 static void transformPremultiply(
float dst[6],
const float src[6]);
534 static int transformInverse(
float dst[6],
const float src[6]);
539 static void transformPoint(
float& dstx,
float& dsty,
const float xform[6],
float srcx,
float srcy);
544 static float degToRad(
float deg);
549 static float radToDeg(
float rad);
557 NanoImage::Handle createImageFromFile(
const char* filename, ImageFlags imageFlags);
564 NanoImage::Handle createImageFromFile(
const char* filename,
int imageFlags);
569 NanoImage::Handle createImageFromMemory(uchar* data, uint dataSize, ImageFlags imageFlags);
576 NanoImage::Handle createImageFromMemory(uchar* data, uint dataSize,
int imageFlags);
581 NanoImage::Handle createImageFromRGBA(uint w, uint h,
const uchar* data, ImageFlags imageFlags);
588 NanoImage::Handle createImageFromRGBA(uint w, uint h,
const uchar* data,
int imageFlags);
593 NanoImage::Handle createImageFromTextureHandle(GLuint textureId, uint w, uint h, ImageFlags imageFlags,
bool deleteTexture =
false);
600 NanoImage::Handle createImageFromTextureHandle(GLuint textureId, uint w, uint h,
int imageFlags,
bool deleteTexture =
false);
610 Paint linearGradient(
float sx,
float sy,
float ex,
float ey,
const Color& icol,
const Color& ocol);
619 Paint boxGradient(
float x,
float y,
float w,
float h,
float r,
float f,
const Color& icol,
const Color& ocol);
626 Paint radialGradient(
float cx,
float cy,
float inr,
float outr,
const Color& icol,
const Color& ocol);
633 Paint imagePattern(
float ox,
float oy,
float ex,
float ey,
float angle,
const NanoImage& image,
float alpha);
642 void scissor(
float x,
float y,
float w,
float h);
652 void intersectScissor(
float x,
float y,
float w,
float h);
670 void moveTo(
float x,
float y);
675 void lineTo(
float x,
float y);
680 void bezierTo(
float c1x,
float c1y,
float c2x,
float c2y,
float x,
float y);
685 void quadTo(
float cx,
float cy,
float x,
float y);
690 void arcTo(
float x1,
float y1,
float x2,
float y2,
float radius);
700 void pathWinding(Winding dir);
707 void arc(
float cx,
float cy,
float r,
float a0,
float a1, Winding dir);
712 void rect(
float x,
float y,
float w,
float h);
717 void roundedRect(
float x,
float y,
float w,
float h,
float r);
722 void ellipse(
float cx,
float cy,
float rx,
float ry);
727 void circle(
float cx,
float cy,
float r);
746 FontId createFontFromFile(
const char* name,
const char* filename);
752 FontId createFontFromMemory(
const char* name,
const uchar* data, uint dataSize,
bool freeData);
757 FontId findFont(
const char* name);
762 void fontSize(
float size);
767 void fontBlur(
float blur);
772 void textLetterSpacing(
float spacing);
777 void textLineHeight(
float lineHeight);
782 void textAlign(Align align);
789 void textAlign(
int align);
794 void fontFaceId(FontId font);
799 void fontFace(
const char* font);
804 float text(
float x,
float y,
const char*
string,
const char* end);
812 void textBox(
float x,
float y,
float breakRowWidth,
const char*
string,
const char* end =
nullptr);
819 float textBounds(
float x,
float y,
const char*
string,
const char* end,
Rectangle<float>& bounds);
826 void textBoxBounds(
float x,
float y,
float breakRowWidth,
const char*
string,
const char* end,
float bounds[4]);
832 int textGlyphPositions(
float x,
float y,
const char*
string,
const char* end,
GlyphPosition& positions,
int maxPositions);
838 void textMetrics(
float* ascender,
float* descender,
float* lineh);
845 int textBreakLines(
const char*
string,
const char* end,
float breakRowWidth,
TextRow& rows,
int maxRows);
850 virtual void loadSharedResources();
853 NVGcontext*
const fContext;
856 friend class BlendishWidget;
858 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
NanoVG)
901 virtual void onNanoDisplay() = 0;
905 PrivateData*
const nData;
911 void onDisplay()
override;
914 void beginFrame(uint,uint) {}
915 void beginFrame(uint,uint,
float) {}
916 void beginFrame(
Widget*) {}
917 void cancelFrame() {}
920 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
NanoWidget)
927 #endif // DGL_NANO_WIDGET_HPP_INCLUDED NVGcontext * getContext() const noexcept
Definition: NanoVG.hpp:316
Definition: NanoVG.hpp:286
Definition: NanoVG.hpp:45
Definition: Window.hpp:30
Definition: Geometry.hpp:30
Definition: NanoVG.hpp:262
Definition: NanoVG.hpp:203
Size< uint > getSize() const noexcept
Definition: NanoVG.hpp:280
NanoImage & operator=(const Handle &handle)
GLuint getTextureHandle() const
bool isValid() const noexcept
CreateFlags
Definition: NanoVG.hpp:206