17 #ifndef DGL_NANO_WIDGET_HPP_INCLUDED 18 #define DGL_NANO_WIDGET_HPP_INCLUDED 23 #ifndef DGL_NO_SHARED_RESOURCES 24 # define NANOVG_DEJAVU_SANS_TTF "__dpf_dejavusans_ttf__" 58 Handle(NVGcontext* c,
int id) noexcept
107 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
NanoImage)
212 CREATE_ANTIALIAS = 1 << 0,
218 CREATE_STENCIL_STROKES = 1 << 1,
223 CREATE_DEBUG = 1 << 2,
227 IMAGE_GENERATE_MIPMAPS = 1 << 0,
228 IMAGE_REPEAT_X = 1 << 1,
229 IMAGE_REPEAT_Y = 1 << 2,
230 IMAGE_FLIP_Y = 1 << 3,
231 IMAGE_PREMULTIPLIED = 1 << 4
237 ALIGN_CENTER = 1 << 1,
238 ALIGN_RIGHT = 1 << 2,
241 ALIGN_MIDDLE = 1 << 4,
242 ALIGN_BOTTOM = 1 << 5,
243 ALIGN_BASELINE = 1 << 6
278 Paint(
const NVGpaint&) noexcept;
279 operator NVGpaint()
const noexcept;
302 NanoVG(
int flags = CREATE_ANTIALIAS);
326 void beginFrame(
const uint width,
const uint height,
const float scaleFactor = 1.0f);
331 void beginFrame(
Widget*
const widget);
368 void strokeColor(
const Color& color);
374 void strokeColor(
const int red,
const int green,
const int blue,
const int alpha = 255);
380 void strokeColor(
const float red,
const float green,
const float blue,
const float alpha = 1.0f);
385 void strokePaint(
const Paint& paint);
390 void fillColor(
const Color& color);
396 void fillColor(
const int red,
const int green,
const int blue,
const int alpha = 255);
402 void fillColor(
const float red,
const float green,
const float blue,
const float alpha = 1.0f);
407 void fillPaint(
const Paint& paint);
413 void miterLimit(
float limit);
418 void strokeWidth(
float size);
424 void lineCap(LineCap cap = BUTT);
430 void lineJoin(LineCap join = MITER);
436 void globalAlpha(
float alpha);
444 void resetTransform();
453 void transform(
float a,
float b,
float c,
float d,
float e,
float f);
458 void translate(
float x,
float y);
463 void rotate(
float angle);
468 void skewX(
float angle);
473 void skewY(
float angle);
478 void scale(
float x,
float y);
486 void currentTransform(
float xform[6]);
495 static void transformIdentity(
float dst[6]);
500 static void transformTranslate(
float dst[6],
float tx,
float ty);
505 static void transformScale(
float dst[6],
float sx,
float sy);
510 static void transformRotate(
float dst[6],
float a);
515 static void transformSkewX(
float dst[6],
float a);
520 static void transformSkewY(
float dst[6],
float a);
525 static void transformMultiply(
float dst[6],
const float src[6]);
530 static void transformPremultiply(
float dst[6],
const float src[6]);
536 static int transformInverse(
float dst[6],
const float src[6]);
541 static void transformPoint(
float& dstx,
float& dsty,
const float xform[6],
float srcx,
float srcy);
546 static float degToRad(
float deg);
551 static float radToDeg(
float rad);
559 NanoImage::Handle createImageFromFile(
const char* filename, ImageFlags imageFlags);
566 NanoImage::Handle createImageFromFile(
const char* filename,
int imageFlags);
571 NanoImage::Handle createImageFromMemory(uchar* data, uint dataSize, ImageFlags imageFlags);
578 NanoImage::Handle createImageFromMemory(uchar* data, uint dataSize,
int imageFlags);
583 NanoImage::Handle createImageFromRGBA(uint w, uint h,
const uchar* data, ImageFlags imageFlags);
590 NanoImage::Handle createImageFromRGBA(uint w, uint h,
const uchar* data,
int imageFlags);
595 NanoImage::Handle createImageFromTextureHandle(GLuint textureId, uint w, uint h, ImageFlags imageFlags,
bool deleteTexture =
false);
602 NanoImage::Handle createImageFromTextureHandle(GLuint textureId, uint w, uint h,
int imageFlags,
bool deleteTexture =
false);
612 Paint linearGradient(
float sx,
float sy,
float ex,
float ey,
const Color& icol,
const Color& ocol);
621 Paint boxGradient(
float x,
float y,
float w,
float h,
float r,
float f,
const Color& icol,
const Color& ocol);
628 Paint radialGradient(
float cx,
float cy,
float inr,
float outr,
const Color& icol,
const Color& ocol);
635 Paint imagePattern(
float ox,
float oy,
float ex,
float ey,
float angle,
const NanoImage& image,
float alpha);
644 void scissor(
float x,
float y,
float w,
float h);
654 void intersectScissor(
float x,
float y,
float w,
float h);
672 void moveTo(
float x,
float y);
677 void lineTo(
float x,
float y);
682 void bezierTo(
float c1x,
float c1y,
float c2x,
float c2y,
float x,
float y);
687 void quadTo(
float cx,
float cy,
float x,
float y);
692 void arcTo(
float x1,
float y1,
float x2,
float y2,
float radius);
702 void pathWinding(Winding dir);
709 void arc(
float cx,
float cy,
float r,
float a0,
float a1, Winding dir);
714 void rect(
float x,
float y,
float w,
float h);
719 void roundedRect(
float x,
float y,
float w,
float h,
float r);
724 void ellipse(
float cx,
float cy,
float rx,
float ry);
729 void circle(
float cx,
float cy,
float r);
748 FontId createFontFromFile(
const char* name,
const char* filename);
754 FontId createFontFromMemory(
const char* name,
const uchar* data, uint dataSize,
bool freeData);
759 FontId findFont(
const char* name);
764 void fontSize(
float size);
769 void fontBlur(
float blur);
774 void textLetterSpacing(
float spacing);
779 void textLineHeight(
float lineHeight);
784 void textAlign(Align align);
791 void textAlign(
int align);
796 void fontFaceId(FontId font);
801 void fontFace(
const char* font);
806 float text(
float x,
float y,
const char*
string,
const char* end);
814 void textBox(
float x,
float y,
float breakRowWidth,
const char*
string,
const char* end =
nullptr);
821 float textBounds(
float x,
float y,
const char*
string,
const char* end,
Rectangle<float>& bounds);
828 void textBoxBounds(
float x,
float y,
float breakRowWidth,
const char*
string,
const char* end,
float bounds[4]);
834 int textGlyphPositions(
float x,
float y,
const char*
string,
const char* end,
GlyphPosition& positions,
int maxPositions);
840 void textMetrics(
float* ascender,
float* descender,
float* lineh);
847 int textBreakLines(
const char*
string,
const char* end,
float breakRowWidth,
TextRow& rows,
int maxRows);
849 #ifndef DGL_NO_SHARED_RESOURCES 853 virtual void loadSharedResources();
857 NVGcontext*
const fContext;
860 friend class BlendishWidget;
862 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
NanoVG)
905 virtual void onNanoDisplay() = 0;
909 PrivateData*
const nData;
915 void onDisplay()
override;
918 void beginFrame(uint,uint) {}
919 void beginFrame(uint,uint,
float) {}
920 void beginFrame(
Widget*) {}
921 void cancelFrame() {}
924 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
NanoWidget)
931 #endif // DGL_NANO_WIDGET_HPP_INCLUDED NVGcontext * getContext() const noexcept
Definition: NanoVG.hpp:318
Definition: NanoVG.hpp:288
Definition: NanoVG.hpp:47
Definition: Window.hpp:36
GLuint getTextureHandle() const
Definition: Geometry.hpp:30
Definition: NanoVG.hpp:264
Definition: NanoVG.hpp:205
Size< uint > getSize() const noexcept
Definition: NanoVG.hpp:282
NanoImage & operator=(const Handle &handle)
bool isValid() const noexcept
CreateFlags
Definition: NanoVG.hpp:208