The OpenD Programming Language

arsd.blendish

Blendish is a small collection of drawing functions for NanoVega, designed to replicate the look of the Blender 2.5+ User Interface. You can use these functions to theme your UI library. Several metric constants for faithful reproduction are also included.

Blendish supports the original Blender icon sheet; As the licensing of Blenders icons is unclear, they are not included in Blendishes repository, but a SVG template, "icons_template.svg" is provided, which you can use to build your own icon sheet.

To use icons, you must first load the icon sheet using one of the nvgCreateImage*() functions and then pass the image handle to bndSetIconImage(); otherwise, no icons will be drawn. See bndSetIconImage() for more information.

Blendish will not render text until a suitable UI font has been passed to bndSetFont() has been called. See bndSetFont() for more information.

More...

Members

Aliases

BNDcornerFlags
alias BNDcornerFlags = int

flags indicating which corners are sharp (for grouping widgets)

BNDtextAlignment
alias BNDtextAlignment = int

how text on a control is aligned

BNDwidgetState
alias BNDwidgetState = int

states altering the styling of a widget

Enums

BND_DEFAULT
anonymousenum BND_DEFAULT

states altering the styling of a widget (values)

BND_ICONID
eponymoustemplate BND_ICONID(int x, int y)

build an icon ID from two coordinates into the icon sheet, where * (0, 0) designates the upper-leftmost icon, (1, 0) the one right next to it, * and so on.

BND_LEFT
anonymousenum BND_LEFT

how text on a control is aligned (values)

Functions

bndArrow
void bndArrow(NVGContext ctx, float x, float y, float s, 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.

bndBackground
void bndBackground(NVGContext ctx, float x, float y, float w, float h)

Draw a flat panel without any decorations at position (x, y) with size (w, h) and fills it with backgroundColor

bndBevel
void bndBevel(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

bndBevelInset
void bndBevelInset(NVGContext ctx, float x, float y, float w, float h, float cr2, float cr3)

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.

bndCheck
void bndCheck(NVGContext ctx, float ox, float oy, NVGColor color)

Draw a checkmark for an option box with the given upper left coordinates (ox, oy) with the specified color.

bndChoiceButton
void bndChoiceButton(NVGContext ctx, float x, float y, float w, float h, int flags, BNDwidgetState state, int iconid, const(T)[] label)

Draw a choice button with its lower left origin at (x, y) and size of (w, h), where flags is one or multiple flags from BNDcornerFlags and state denotes the widgets current UI state.

bndClamp
float bndClamp(float v, float mn, float mx)

/////////////////////////////////////////////////////////////////////////////

bndClearIconImage
void bndClearIconImage()

Clears current icon image.

bndColorButton
void bndColorButton(NVGContext ctx, float x, float y, float w, float h, int flags, NVGColor color)

Draw a color button with its lower left origin at (x, y) and size of (w, h), where flags is one or multiple flags from BNDcornerFlags and state denotes the widgets current UI state.

bndColoredNodeWire
void bndColoredNodeWire(NVGContext ctx, float x0, float y0, float x1, float y1, NVGColor color0, NVGColor color1)

Draw a node wire originating at (x0, y0) and floating to (x1, y1), with a colored gradient based on the two colors color0 and color1

bndDropShadow
void bndDropShadow(NVGContext ctx, float x, float y, float w, float h, float r, float feather, float alpha)

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.

bndGetFont
BndFontSaviour bndGetFont()

Returns opaque object with the current font.

bndGetIconImage
NVGImage bndGetIconImage()

Returns icon sheet image.

bndGetTheme
BNDtheme* bndGetTheme()

Returns the currently set theme

bndIcon
void bndIcon(NVGContext ctx, float x, float y, int iconid)

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.

bndIconLabelCaret
void bndIconLabelCaret(NVGContext ctx, float x, float y, float w, float h, int iconid, NVGColor color, float fontsize, const(T)[] label, NVGColor caretcolor, int cbegin, int cend, NVGColor thinCaretColor)

Draw an optional icon specified by <iconid>, an optional label and a caret with given fontsize and color within a widget box.

bndIconLabelTextPosition
int bndIconLabelTextPosition(NVGContext ctx, float x, float y, float w, float h, int iconid, float fontsize, const(T)[] label, int px, int py)

Calculate the corresponding text position for given coordinates px/py in an iconLabel. See bndIconLabelCaret for more info.

bndIconLabelValue
void bndIconLabelValue(NVGContext ctx, float x, float y, float w, float h, int iconid, NVGColor color, int align_, float fontsize, const(T)[] label, const(TV)[] value)

Draw an optional icon specified by <iconid> and an optional label with given alignment (BNDtextAlignment), fontsize and color within a widget box.

bndInnerColors
void bndInnerColors(NVGColor* shadeTop, NVGColor* shadeDown, const(BNDwidgetTheme)* theme, BNDwidgetState state, int flipActive)

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.

bndJoinAreaOverlay
void bndJoinAreaOverlay(NVGContext ctx, float x, float y, float w, float h, bool vertical, bool mirror)

Draw the join area overlay stencil into the rectangle at origin (x, y) and size (w, h)

bndLabel
void bndLabel(NVGContext ctx, float x, float y, float w, float h, int iconid, const(T)[] label, int align_)

Draw a label with its lower left origin at (x, y) and size of (w, h).

bndLabelHeight
float bndLabelHeight(NVGContext ctx, int iconid, const(T)[] label, float width)

returns the height for a label with given icon, text and width; this function is primarily useful in conjunction with multiline labels and textboxes

bndLabelWidth
float bndLabelWidth(NVGContext ctx, int iconid, const(T)[] label)

///////////////////////////////////////////////////////////////////////////// Estimator Functions Use these functions to estimate sizes for widgets with your NVGcontext. returns the ideal width for a label with given icon and text

bndMenuBackground
void bndMenuBackground(NVGContext ctx, float x, float y, float w, float h, int flags)

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.

bndMenuItem
void bndMenuItem(NVGContext ctx, float x, float y, float w, float h, BNDwidgetState state, int iconid, const(T)[] label)

Draw a menu item with its lower left origin at (x, y) and size of (w, h), where state denotes the widgets current UI state.

bndMenuLabel
void bndMenuLabel(NVGContext ctx, float x, float y, float w, float h, int iconid, const(T)[] label)

Draw a menu label with its lower left origin at (x, y) and size of (w, h).

bndMin
float bndMin(T a, T b)

/////////////////////////////////////////////////////////////////////////////

bndNodeArrowDown
void bndNodeArrowDown(NVGContext ctx, float x, float y, float s, NVGColor color)

Draw a node down-arrow with its tip at (x, y) and size s

bndNodeBackground
void bndNodeBackground(NVGContext ctx, float x, float y, float w, float h, BNDwidgetState state, int iconid, const(T)[] label, NVGColor titleColor)

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

bndNodeIconLabel
void bndNodeIconLabel(NVGContext ctx, float x, float y, float w, float h, int iconid, NVGColor color, NVGColor shadowColor, int align_, float fontsize, const(T)[] label)

Draw an optional icon specified by <iconid> and an optional label with given alignment (BNDtextAlignment), fontsize and color within a node title bar

bndNodePort
void bndNodePort(NVGContext ctx, float x, float y, BNDwidgetState state, NVGColor color)

Draw a node port at the given position filled with the given color

bndNodeWire
void bndNodeWire(NVGContext ctx, float x0, float y0, float x1, float y1, BNDwidgetState state0, BNDwidgetState state1)

Draw a node wire originating at (x0, y0) and floating to (x1, y1), with a colored gradient based on the states state0 and state1:

bndNodeWireColor
NVGColor bndNodeWireColor(const(BNDnodeTheme)* theme, BNDwidgetState state)

return the color of a node wire based on state

bndNumberField
void bndNumberField(NVGContext ctx, float x, float y, float w, float h, int flags, BNDwidgetState state, const(T)[] label, const(char)[] value)

Draw a number field with its lower left origin at (x, y) and size of (w, h), where flags is one or multiple flags from BNDcornerFlags and state denotes the widgets current UI state.

bndOffsetColor
NVGColor bndOffsetColor(NVGColor color, int delta)

offset a color by a given integer delta in the range -100 to 100

bndOptionButton
void bndOptionButton(NVGContext ctx, float x, float y, float w, float h, BNDwidgetState state, const(T)[] label)

Draw an option button with its lower left origin at (x, y) and size of (w, h), where flags is one or multiple flags from BNDcornerFlags and state denotes the widgets current UI state.

bndOutlineBox
void bndOutlineBox(NVGContext ctx, float x, float y, float w, float h, float cr0, float cr1, float cr2, float cr3, NVGColor color)

Draw the outline part of a widget box with the given color

bndRadioButton
void bndRadioButton(NVGContext ctx, float x, float y, float w, float h, int flags, BNDwidgetState state, int iconid, const(T)[] label)

Draw a radio button with its lower left origin at (x, y) and size of (w, h), where flags is one or multiple flags from BNDcornerFlags and state denotes the widgets current UI state.

bndRadioButton2
void bndRadioButton2(NVGContext ctx, float x, float y, float w, float h, int flags, BNDwidgetState state, int iconid, const(T)[] label)

Draw a radio button with its lower left origin at (x, y) and size of (w, h), where flags is one or multiple flags from BNDcornerFlags and state denotes the widgets current UI state.

bndRadioCheck
void bndRadioCheck(NVGContext ctx, float ox, float oy, NVGColor color)

Draw a checkmark for a radio with the given upper left coordinates (ox, oy) with the specified color.

bndRoundedBox
void bndRoundedBox(NVGContext ctx, float x, float y, float w, float h, float cr0, float cr1, float cr2, float cr3)

Add a rounded box path at position (x, y) with size (w, h) and a separate radius for each corner listed in clockwise order, so that cr0 = top left, cr1 = top right, cr2 = bottom right, cr3 = bottom left;

bndScrollBar
void bndScrollBar(NVGContext ctx, float x, float y, float w, float h, BNDwidgetState state, float offset, float size)

Draw scrollbar with its lower left origin at (x, y) and size of (w, h), where state denotes the widgets current UI state.

bndScrollHandleRect
void bndScrollHandleRect(float* x, float* y, float* w, float* h, float offset, float size)

computes the bounds of the scrollbar handle from the scrollbar size and the handles offset and size.

bndScrollSlider
void bndScrollSlider(NVGContext ctx, float x, float y, float w, float h, BNDwidgetState state, float offset, float size)

Draw scrollbar with its lower left origin at (x, y) and size of (w, h), where state denotes the widgets current UI state.

bndScrollSliderRect
void bndScrollSliderRect(float* w, float* h, float offset, float size)

computes the bounds of the scroll slider from the scrollbar size and the handles offset and size.

bndSelectCorners
void bndSelectCorners(float[] radiuses, float r, int flags)

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.

bndSetFont
void bndSetFont(int font)

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/

bndSetFont
void bndSetFont(string font)

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/

bndSetFont
void bndSetFont(BndFontSaviour fsv)

Sets current font from the opaque object, returned by bndGetFont.

bndSetIconImage
void bndSetIconImage(NVGImage image)

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.

bndSetTheme
void bndSetTheme(BNDtheme theme)

///////////////////////////////////////////////////////////////////////////// Sets the current theme all widgets will be drawn with. the default Blender 2.6 theme is set by default.

bndSlider
void bndSlider(NVGContext ctx, float x, float y, float w, float h, int flags, BNDwidgetState state, float progress, const(T)[] label, const(TV)[] value)

Draw slider control with its lower left origin at (x, y) and size of (w, h), where flags is one or multiple flags from BNDcornerFlags and state denotes the widgets current UI state.

bndSplitterWidgets
void bndSplitterWidgets(NVGContext ctx, float x, float y, float w, float h)

Draw a window with the upper right and lower left splitter widgets into the rectangle at origin (x, y) and size (w, h)

bndTextColor
NVGColor bndTextColor(const(BNDwidgetTheme)* theme, BNDwidgetState state)

computes the text color for a widget label from a widget theme and the widgets state.

bndTextField
void bndTextField(NVGContext ctx, float x, float y, float w, float h, int flags, BNDwidgetState state, int iconid, const(T)[] text, int cbegin, int cend)

Draw a text field with its lower left origin at (x, y) and size of (w, h), where flags is one or multiple flags from BNDcornerFlags and state denotes the widgets current UI state.

bndTextFieldTextPosition
int bndTextFieldTextPosition(NVGContext ctx, float x, float y, float w, float h, int iconid, const(T)[] text, int px, int py)

Calculate the corresponding text position for given coordinates px/py in a text field. See bndTextField for more info.

bndToolButton
void bndToolButton(NVGContext ctx, float x, float y, float w, float h, int flags, BNDwidgetState state, int iconid, const(T)[] label)

Draw a tool button with its lower left origin at (x, y) and size of (w, h), where flags is one or multiple flags from BNDcornerFlags and state denotes the widgets current UI state.

bndTooltipBackground
void bndTooltipBackground(NVGContext ctx, float x, float y, float w, float h)

Draw a tooltip background with its lower left origin at (x, y) and size of (w, h)

bndTransparent
NVGColor bndTransparent(NVGColor color)

make color transparent using the default alpha value

bndUpDownArrow
void bndUpDownArrow(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

Manifest constants

BND_COLOR_ACTIVE
enum BND_COLOR_ACTIVE;

default color for active element

BND_COLOR_TEXT
enum BND_COLOR_TEXT;

default text color

BND_COLOR_TEXT_SELECTED
enum BND_COLOR_TEXT_SELECTED;

default highlighted text color

BND_MAX_GLYPHS
enum BND_MAX_GLYPHS;

max glyphs for position testing

BND_MAX_ROWS
enum BND_MAX_ROWS;

max rows for position testing

Static variables

BND_BEVEL_SHADE
int BND_BEVEL_SHADE;

shade intensity of beveled panels

BND_DISABLED_ALPHA
float BND_DISABLED_ALPHA;

alpha of disabled widget groups; can be used in conjunction with nvgGlobalAlpha()

BND_HOVER_SHADE
int BND_HOVER_SHADE;

shade intensity of hovered inner boxes

BND_HSPACING
int BND_HSPACING;

default horizontal spacing

BND_ICON_SHEET_GRID
int BND_ICON_SHEET_GRID;

gridsize of icon sheet in both dimensions

BND_ICON_SHEET_HEIGHT
int BND_ICON_SHEET_HEIGHT;

height of icon sheet

BND_ICON_SHEET_OFFSET_X
int BND_ICON_SHEET_OFFSET_X;

offset of first icon tile relative to left border

BND_ICON_SHEET_OFFSET_Y
int BND_ICON_SHEET_OFFSET_Y;

offset of first icon tile relative to top border

BND_ICON_SHEET_RES
int BND_ICON_SHEET_RES;

resolution of single icon

BND_ICON_SHEET_WIDTH
int BND_ICON_SHEET_WIDTH;

width of icon sheet

BND_INSET_BEVEL_SHADE
int BND_INSET_BEVEL_SHADE;

shade intensity of beveled insets

BND_LABEL_FONT_SIZE
float BND_LABEL_FONT_SIZE;

///////////////////////////////////////////////////////////////////////////// default text size

BND_LABEL_SEPARATOR
string BND_LABEL_SEPARATOR;

label: value separator string

BND_MENU_RADIUS
float BND_MENU_RADIUS;

radius of menu popup

BND_NODE_ARROW_AREA_WIDTH
int BND_NODE_ARROW_AREA_WIDTH;

width of node title arrow click area

BND_NODE_ARROW_SIZE
float BND_NODE_ARROW_SIZE;

size of node title arrow

BND_NODE_MARGIN_DOWN
int BND_NODE_MARGIN_DOWN;

bottom margin of node content

BND_NODE_MARGIN_SIDE
int BND_NODE_MARGIN_SIDE;

left and right margin of node content

BND_NODE_MARGIN_TOP
int BND_NODE_MARGIN_TOP;

top margin of node content

BND_NODE_PORT_RADIUS
int BND_NODE_PORT_RADIUS;

default radius of node ports

BND_NODE_RADIUS
float BND_NODE_RADIUS;

radius of node box

BND_NODE_TITLE_FEATHER
float BND_NODE_TITLE_FEATHER;

feather of node title text

BND_NODE_TITLE_HEIGHT
int BND_NODE_TITLE_HEIGHT;

height of node title bar

BND_NODE_WIRE_OUTLINE_WIDTH
float BND_NODE_WIRE_OUTLINE_WIDTH;

stroke width of wire outline

BND_NODE_WIRE_WIDTH
float BND_NODE_WIRE_WIDTH;

stroke width of wire

BND_NUMBER_ARROW_SIZE
float BND_NUMBER_ARROW_SIZE;

size of number field arrow

BND_NUMBER_RADIUS
float BND_NUMBER_RADIUS;

radius of number button

BND_OPTION_HEIGHT
float BND_OPTION_HEIGHT;

height of option button checkbox

BND_OPTION_RADIUS
float BND_OPTION_RADIUS;

radius of option button

BND_OPTION_WIDTH
float BND_OPTION_WIDTH;

width of option button checkbox

BND_PAD_LEFT
int BND_PAD_LEFT;

default text padding in inner box

BND_SCROLLBAR_ACTIVE_SHADE
int BND_SCROLLBAR_ACTIVE_SHADE;

shade intensity of active scrollbar

BND_SCROLLBAR_HEIGHT
int BND_SCROLLBAR_HEIGHT;

height of horizontal scrollbar

BND_SCROLLBAR_RADIUS
float BND_SCROLLBAR_RADIUS;

radius of scrollbar

BND_SCROLLBAR_WIDTH
int BND_SCROLLBAR_WIDTH;

width of vertical scrollbar

BND_SHADOW_ALPHA
float BND_SHADOW_ALPHA;

alpha of menu popup shadow

BND_SHADOW_FEATHER
float BND_SHADOW_FEATHER;

feather of menu popup shadow

BND_SPLITTER_AREA_SIZE
int BND_SPLITTER_AREA_SIZE;

size of splitter corner click area

BND_SPLITTER_SHADE
int BND_SPLITTER_SHADE;

shade intensity of splitter bevels

BND_TEXT_PAD_DOWN
int BND_TEXT_PAD_DOWN;

text distance from bottom

BND_TEXT_RADIUS
float BND_TEXT_RADIUS;

radius of text field

BND_TOOL_RADIUS
float BND_TOOL_RADIUS;

radius of tool button

BND_TOOL_WIDTH
int BND_TOOL_WIDTH;

default toolbutton width (if icon only)

BND_TRANSPARENT_ALPHA
float BND_TRANSPARENT_ALPHA;

alpha intensity of transparent items (0xa4)

BND_VSPACING
int BND_VSPACING;

default vertical spacing

BND_VSPACING_GROUP
int BND_VSPACING_GROUP;

default vertical spacing between groups

BND_WIDGET_HEIGHT
int BND_WIDGET_HEIGHT;

default widget height

bndTheme
BNDtheme bndTheme;

///////////////////////////////////////////////////////////////////////////// the initial theme

Structs

BNDnodeTheme
struct BNDnodeTheme

describes the theme used to draw nodes

BNDtheme
struct BNDtheme

describes the theme used to draw widgets

BNDwidgetTheme
struct BNDwidgetTheme

describes the theme used to draw a single widget or widget box; * these values correspond to the same values that can be retrieved from * the Theme panel in the Blender preferences

Detailed Description

Drawbacks

There is no support for varying dpi resolutions yet. The library is hardcoded to the equivalent of 72 dpi in the Blender system settings.

Support for label truncation is missing. Text rendering breaks when widgets are too short to contain their labels.

Meta

Version

Revision 6 (2014-09-21)