|
|
@@ -75,6 +75,12 @@ before including blendish.h, otherwise the file will be in header-only mode. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
// you can override this from the outside to pick |
|
|
|
// the export level you need |
|
|
|
#ifndef BND_EXPORT |
|
|
|
#define BND_EXPORT |
|
|
|
#endif |
|
|
|
|
|
|
|
// if that typedef is provided elsewhere, you may define |
|
|
|
// BLENDISH_NO_NVG_TYPEDEFS before including the header. |
|
|
|
#ifndef BLENDISH_NO_NVG_TYPEDEFS |
|
|
@@ -245,23 +251,23 @@ typedef enum BNDcornerFlags { |
|
|
|
|
|
|
|
// set the current theme all widgets will be drawn with. |
|
|
|
// the default Blender 2.6 theme is set by default. |
|
|
|
void bndSetTheme(BNDtheme theme); |
|
|
|
BND_EXPORT void bndSetTheme(BNDtheme theme); |
|
|
|
|
|
|
|
// Returns the currently set theme |
|
|
|
const BNDtheme *bndGetTheme(); |
|
|
|
BND_EXPORT const BNDtheme *bndGetTheme(); |
|
|
|
|
|
|
|
// designates an image handle as returned by nvgCreateImage*() as the themes' |
|
|
|
// icon sheet. The icon sheet format must be compatible to Blender 2.6's icon |
|
|
|
// sheet; the order of icons does not matter. |
|
|
|
// A valid icon sheet is e.g. shown at |
|
|
|
// http://wiki.blender.org/index.php/Dev:2.5/Doc/How_to/Add_an_icon |
|
|
|
void bndSetIconImage(int image); |
|
|
|
BND_EXPORT void bndSetIconImage(int image); |
|
|
|
|
|
|
|
// designates an image handle as returned by nvgCreateFont*() as the themes' |
|
|
|
// UI font. Blender's original UI font Droid Sans is perfectly suited and |
|
|
|
// available here: |
|
|
|
// https://svn.blender.org/svnroot/bf-blender/trunk/blender/release/datafiles/fonts/ |
|
|
|
void bndSetFont(int font); |
|
|
|
BND_EXPORT void bndSetFont(int font); |
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
|
|
|
|
@@ -273,7 +279,7 @@ void bndSetFont(int font); |
|
|
|
// if iconid >= 0, an icon will be added to the widget |
|
|
|
// if label is not NULL, a label will be added to the widget |
|
|
|
// widget looks best when height is BND_WIDGET_HEIGHT |
|
|
|
void bndLabel(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndLabel(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, int iconid, const char *label); |
|
|
|
|
|
|
|
// Draw a tool button with its lower left origin at (x,y) and size of (w,h), |
|
|
@@ -282,7 +288,7 @@ void bndLabel(NVGcontext *ctx, |
|
|
|
// if iconid >= 0, an icon will be added to the widget |
|
|
|
// if label is not NULL, a label will be added to the widget |
|
|
|
// widget looks best when height is BND_WIDGET_HEIGHT |
|
|
|
void bndToolButton(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndToolButton(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, int flags, BNDwidgetState state, |
|
|
|
int iconid, const char *label); |
|
|
|
|
|
|
@@ -292,7 +298,7 @@ void bndToolButton(NVGcontext *ctx, |
|
|
|
// if iconid >= 0, an icon will be added to the widget |
|
|
|
// if label is not NULL, a label will be added to the widget |
|
|
|
// widget looks best when height is BND_WIDGET_HEIGHT |
|
|
|
void bndRadioButton(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndRadioButton(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, int flags, BNDwidgetState state, |
|
|
|
int iconid, const char *label); |
|
|
|
|
|
|
@@ -305,7 +311,7 @@ void bndRadioButton(NVGcontext *ctx, |
|
|
|
// cend must be >= cbegin and <= strlen(text) and denotes the end of the caret |
|
|
|
// if cend < cbegin, then no caret will be drawn |
|
|
|
// widget looks best when height is BND_WIDGET_HEIGHT |
|
|
|
void bndTextField(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndTextField(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, int flags, BNDwidgetState state, |
|
|
|
int iconid, const char *text, int cbegin, int cend); |
|
|
|
|
|
|
@@ -314,7 +320,7 @@ void bndTextField(NVGcontext *ctx, |
|
|
|
// the widgets current UI state. |
|
|
|
// if label is not NULL, a label will be added to the widget |
|
|
|
// widget looks best when height is BND_WIDGET_HEIGHT |
|
|
|
void bndOptionButton(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndOptionButton(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, BNDwidgetState state, |
|
|
|
const char *label); |
|
|
|
|
|
|
@@ -324,7 +330,7 @@ void bndOptionButton(NVGcontext *ctx, |
|
|
|
// if iconid >= 0, an icon will be added to the widget |
|
|
|
// if label is not NULL, a label will be added to the widget |
|
|
|
// widget looks best when height is BND_WIDGET_HEIGHT |
|
|
|
void bndChoiceButton(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndChoiceButton(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, int flags, BNDwidgetState state, |
|
|
|
int iconid, const char *label); |
|
|
|
|
|
|
@@ -335,7 +341,7 @@ void bndChoiceButton(NVGcontext *ctx, |
|
|
|
// if value is not NULL, a value will be added to the widget, along with |
|
|
|
// a ":" separator |
|
|
|
// widget looks best when height is BND_WIDGET_HEIGHT |
|
|
|
void bndNumberField(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndNumberField(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, int flags, BNDwidgetState state, |
|
|
|
const char *label, const char *value); |
|
|
|
|
|
|
@@ -347,7 +353,7 @@ void bndNumberField(NVGcontext *ctx, |
|
|
|
// if value is not NULL, a value will be added to the widget, along with |
|
|
|
// a ":" separator |
|
|
|
// widget looks best when height is BND_WIDGET_HEIGHT |
|
|
|
void bndSlider(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndSlider(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, int flags, BNDwidgetState state, |
|
|
|
float progress, const char *label, const char *value); |
|
|
|
|
|
|
@@ -357,20 +363,20 @@ void bndSlider(NVGcontext *ctx, |
|
|
|
// size is in the range 0..1 and controls the size of the scroll handle |
|
|
|
// horizontal widget looks best when height is BND_SCROLLBAR_HEIGHT, |
|
|
|
// vertical looks best when width is BND_SCROLLBAR_WIDTH |
|
|
|
void bndScrollBar(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndScrollBar(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, BNDwidgetState state, |
|
|
|
float offset, float size); |
|
|
|
|
|
|
|
// Draw a menu background with its lower left origin at (x,y) and size of (w,h), |
|
|
|
// where flags is one or multiple flags from BNDcornerFlags. |
|
|
|
void bndMenuBackground(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndMenuBackground(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, int flags); |
|
|
|
|
|
|
|
// Draw a menu label with its lower left origin at (x,y) and size of (w,h). |
|
|
|
// if iconid >= 0, an icon will be added to the widget |
|
|
|
// if label is not NULL, a label will be added to the widget |
|
|
|
// widget looks best when height is BND_WIDGET_HEIGHT |
|
|
|
void bndMenuLabel(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndMenuLabel(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, int iconid, const char *label); |
|
|
|
|
|
|
|
// Draw a menu item with its lower left origin at (x,y) and size of (w,h), |
|
|
@@ -378,15 +384,15 @@ void bndMenuLabel(NVGcontext *ctx, |
|
|
|
// if iconid >= 0, an icon will be added to the widget |
|
|
|
// if label is not NULL, a label will be added to the widget |
|
|
|
// widget looks best when height is BND_WIDGET_HEIGHT |
|
|
|
void bndMenuItem(NVGcontext *ctx, |
|
|
|
BND_EXPORT void bndMenuItem(NVGcontext *ctx, |
|
|
|
float x, float y, float w, float h, BNDwidgetState state, |
|
|
|
int iconid, const char *label); |
|
|
|
|
|
|
|
// Draw a tooltip background with its lower left origin at (x,y) and size of (w,h) |
|
|
|
void bndTooltipBackground(NVGcontext *ctx, float x, float y, float w, float h); |
|
|
|
BND_EXPORT void bndTooltipBackground(NVGcontext *ctx, float x, float y, float w, float h); |
|
|
|
|
|
|
|
// Draw a node port at the given position filled with the given color |
|
|
|
void bndNodePort(NVGcontext *ctx, float x, float y, BNDwidgetState state, |
|
|
|
BND_EXPORT void bndNodePort(NVGcontext *ctx, float x, float y, BNDwidgetState state, |
|
|
|
NVGcolor color); |
|
|
|
|
|
|
|
// Draw a node wire originating at (x0,y0) and floating to (x1,y1), with |
|
|
@@ -394,23 +400,23 @@ void bndNodePort(NVGcontext *ctx, float x, float y, BNDwidgetState state, |
|
|
|
// BND_DEFAULT: default wire color |
|
|
|
// BND_HOVER: selected wire color |
|
|
|
// BND_ACTIVE: dragged wire color |
|
|
|
void bndNodeWire(NVGcontext *ctx, float x0, float y0, float x1, float y1, |
|
|
|
BND_EXPORT void bndNodeWire(NVGcontext *ctx, float x0, float y0, float x1, float y1, |
|
|
|
BNDwidgetState state0, BNDwidgetState state1); |
|
|
|
|
|
|
|
// Draw a node background with its upper left origin at (x,y) and size of (w,h) |
|
|
|
// where titleColor provides the base color for the title bar |
|
|
|
void bndNodeBackground(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
BND_EXPORT void bndNodeBackground(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
BNDwidgetState state, int iconid, const char *label, NVGcolor titleColor); |
|
|
|
|
|
|
|
// Draw a window with the upper right and lower left splitter widgets into |
|
|
|
// the rectangle at origin (x,y) and size (w, h) |
|
|
|
void bndSplitterWidgets(NVGcontext *ctx, float x, float y, float w, float h); |
|
|
|
BND_EXPORT void bndSplitterWidgets(NVGcontext *ctx, float x, float y, float w, float h); |
|
|
|
|
|
|
|
// Draw the join area overlay stencil into the rectangle |
|
|
|
// at origin (x,y) and size (w,h) |
|
|
|
// vertical is 0 or 1 and designates the arrow orientation, |
|
|
|
// mirror is 0 or 1 and flips the arrow side |
|
|
|
void bndJoinAreaOverlay(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
BND_EXPORT void bndJoinAreaOverlay(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
int vertical, int mirror); |
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
@@ -420,7 +426,7 @@ void bndJoinAreaOverlay(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
// Use these functions to estimate sizes for widgets with your NVGcontext. |
|
|
|
|
|
|
|
// returns the ideal width for a label with given icon and text |
|
|
|
float bndLabelWidth(NVGcontext *ctx, int iconid, const char *label); |
|
|
|
BND_EXPORT float bndLabelWidth(NVGcontext *ctx, int iconid, const char *label); |
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
|
|
|
|
@@ -430,31 +436,31 @@ float bndLabelWidth(NVGcontext *ctx, int iconid, const char *label); |
|
|
|
// new kinds of controls in a similar fashion. |
|
|
|
|
|
|
|
// make color transparent using the default alpha value |
|
|
|
NVGcolor bndTransparent(NVGcolor color); |
|
|
|
BND_EXPORT NVGcolor bndTransparent(NVGcolor color); |
|
|
|
|
|
|
|
// offset a color by a given integer delta in the range -100 to 100 |
|
|
|
NVGcolor bndOffsetColor(NVGcolor color, int delta); |
|
|
|
BND_EXPORT NVGcolor bndOffsetColor(NVGcolor color, int delta); |
|
|
|
|
|
|
|
// assigns radius r to the four entries of array radiuses depending on whether |
|
|
|
// the corner is marked as sharp or not; see BNDcornerFlags for possible |
|
|
|
// flag values. |
|
|
|
void bndSelectCorners(float *radiuses, float r, int flags); |
|
|
|
BND_EXPORT void bndSelectCorners(float *radiuses, float r, int flags); |
|
|
|
|
|
|
|
// computes the upper and lower gradient colors for the inner box from a widget |
|
|
|
// theme and the widgets state. If flipActive is set and the state is |
|
|
|
// BND_ACTIVE, the upper and lower colors will be swapped. |
|
|
|
void bndInnerColors(NVGcolor *shade_top, NVGcolor *shade_down, |
|
|
|
BND_EXPORT void bndInnerColors(NVGcolor *shade_top, NVGcolor *shade_down, |
|
|
|
const BNDwidgetTheme *theme, BNDwidgetState state, int flipActive); |
|
|
|
|
|
|
|
// computes the text color for a widget label from a widget theme and the |
|
|
|
// widgets state. |
|
|
|
NVGcolor bndTextColor(const BNDwidgetTheme *theme, BNDwidgetState state); |
|
|
|
BND_EXPORT NVGcolor bndTextColor(const BNDwidgetTheme *theme, BNDwidgetState state); |
|
|
|
|
|
|
|
// computes the bounds of the scrollbar handle from the scrollbar size |
|
|
|
// and the handles offset and size. |
|
|
|
// offset is in the range 0..1 and defines the position of the scroll handle |
|
|
|
// size is in the range 0..1 and defines the size of the scroll handle |
|
|
|
void bndScrollHandleRect(float *x, float *y, float *w, float *h, |
|
|
|
BND_EXPORT void bndScrollHandleRect(float *x, float *y, float *w, float *h, |
|
|
|
float offset, float size); |
|
|
|
|
|
|
|
// Add a rounded box path at position (x,y) with size (w,h) and a separate |
|
|
@@ -462,43 +468,43 @@ void bndScrollHandleRect(float *x, float *y, float *w, float *h, |
|
|
|
// cr1 = top right, cr2 = bottom right, cr3 = bottom left; |
|
|
|
// this is a low level drawing function: the path must be stroked or filled |
|
|
|
// to become visible. |
|
|
|
void bndRoundedBox(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
BND_EXPORT void bndRoundedBox(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
float cr0, float cr1, float cr2, float cr3); |
|
|
|
|
|
|
|
// Draw a flat panel without any decorations at position (x,y) with size (w,h) |
|
|
|
// and fills it with backgroundColor |
|
|
|
void bndBackground(NVGcontext *ctx, float x, float y, float w, float h); |
|
|
|
BND_EXPORT void bndBackground(NVGcontext *ctx, float x, float y, float w, float h); |
|
|
|
|
|
|
|
// Draw a beveled border at position (x,y) with size (w,h) shaded with |
|
|
|
// lighter and darker versions of backgroundColor |
|
|
|
void bndBevel(NVGcontext *ctx, float x, float y, float w, float h); |
|
|
|
BND_EXPORT void bndBevel(NVGcontext *ctx, float x, float y, float w, float h); |
|
|
|
|
|
|
|
// Draw a lower inset for a rounded box at position (x,y) with size (w,h) |
|
|
|
// that gives the impression the surface has been pushed in. |
|
|
|
// cr2 and cr3 contain the radiuses of the bottom right and bottom left |
|
|
|
// corners of the rounded box. |
|
|
|
void bndBevelInset(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
BND_EXPORT void bndBevelInset(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
float cr2, float cr3); |
|
|
|
|
|
|
|
// Draw an icon with (x,y) as its upper left coordinate; the iconid selects |
|
|
|
// the icon from the sheet; use the BND_ICONID macro to build icon IDs. |
|
|
|
void bndIcon(NVGcontext *ctx, float x, float y, int iconid); |
|
|
|
BND_EXPORT void bndIcon(NVGcontext *ctx, float x, float y, int iconid); |
|
|
|
|
|
|
|
// Draw a drop shadow around the rounded box at (x,y) with size (w,h) and |
|
|
|
// radius r, with feather as its maximum range in pixels. |
|
|
|
// No shadow will be painted inside the rounded box. |
|
|
|
void bndDropShadow(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
BND_EXPORT void bndDropShadow(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
float r, float feather, float alpha); |
|
|
|
|
|
|
|
// Draw the inner part of a widget box, with a gradient from shade_top to |
|
|
|
// shade_down. If h>w, the gradient will be horizontal instead of |
|
|
|
// vertical. |
|
|
|
void bndInnerBox(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
BND_EXPORT void bndInnerBox(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
float cr0, float cr1, float cr2, float cr3, |
|
|
|
NVGcolor shade_top, NVGcolor shade_down); |
|
|
|
|
|
|
|
// Draw the outline part of a widget box with the given color |
|
|
|
void bndOutlineBox(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
BND_EXPORT void bndOutlineBox(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
float cr0, float cr1, float cr2, float cr3, NVGcolor color); |
|
|
|
|
|
|
|
// Draw an optional icon specified by <iconid> and an optional label with |
|
|
@@ -509,7 +515,7 @@ void bndOutlineBox(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
// and color. |
|
|
|
// if value is not NULL, label and value will be drawn with a ":" separator |
|
|
|
// inbetween. |
|
|
|
void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
BND_EXPORT void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
int iconid, NVGcolor color, int align, float fontsize, const char *label, |
|
|
|
const char *value); |
|
|
|
|
|
|
@@ -518,7 +524,7 @@ void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
// if iconid is >= 0, an icon will be drawn |
|
|
|
// if label is not NULL, it will be drawn with the specified alignment, fontsize |
|
|
|
// and color. |
|
|
|
void bndNodeIconLabel(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
BND_EXPORT void bndNodeIconLabel(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
int iconid, NVGcolor color, NVGcolor shadowColor, int align, |
|
|
|
float fontsize, const char *label); |
|
|
|
|
|
|
@@ -531,28 +537,28 @@ void bndNodeIconLabel(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
// cbegin must be >= 0 and <= strlen(text) and denotes the beginning of the caret |
|
|
|
// cend must be >= cbegin and <= strlen(text) and denotes the end of the caret |
|
|
|
// if cend < cbegin, then no caret will be drawn |
|
|
|
void bndIconLabelCaret(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
BND_EXPORT void bndIconLabelCaret(NVGcontext *ctx, float x, float y, float w, float h, |
|
|
|
int iconid, NVGcolor color, float fontsize, const char *label, |
|
|
|
NVGcolor caretcolor, int cbegin, int cend); |
|
|
|
|
|
|
|
// Draw a checkmark for an option box with the given upper left coordinates |
|
|
|
// (ox,oy) with the specified color. |
|
|
|
void bndCheck(NVGcontext *ctx, float ox, float oy, NVGcolor color); |
|
|
|
BND_EXPORT void bndCheck(NVGcontext *ctx, float ox, float oy, NVGcolor color); |
|
|
|
|
|
|
|
// Draw a horizontal arrow for a number field with its center at (x,y) and |
|
|
|
// size s; if s is negative, the arrow points to the left. |
|
|
|
void bndArrow(NVGcontext *ctx, float x, float y, float s, NVGcolor color); |
|
|
|
BND_EXPORT void bndArrow(NVGcontext *ctx, float x, float y, float s, NVGcolor color); |
|
|
|
|
|
|
|
// Draw an up/down arrow for a choice box with its center at (x,y) and size s |
|
|
|
void bndUpDownArrow(NVGcontext *ctx, float x, float y, float s, NVGcolor color); |
|
|
|
BND_EXPORT void bndUpDownArrow(NVGcontext *ctx, float x, float y, float s, NVGcolor color); |
|
|
|
|
|
|
|
// Draw a node down-arrow with its tip at (x,y) and size s |
|
|
|
void bndNodeArrowDown(NVGcontext *ctx, float x, float y, float s, NVGcolor color); |
|
|
|
BND_EXPORT void bndNodeArrowDown(NVGcontext *ctx, float x, float y, float s, NVGcolor color); |
|
|
|
|
|
|
|
// return the color of a node wire based on state |
|
|
|
// BND_HOVER indicates selected state, |
|
|
|
// BND_ACTIVE indicates dragged state |
|
|
|
NVGcolor bndNodeWireColor(const BNDnodeTheme *theme, BNDwidgetState state); |
|
|
|
BND_EXPORT NVGcolor bndNodeWireColor(const BNDnodeTheme *theme, BNDwidgetState state); |
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
}; |
|
|
|