Lua logo

Preface

This is the reference manual of MoonNuklear, which is a Lua binding library for the Nuklear immediate mode GUI toolkit. [1]

It is assumed that the reader is familiar with both Nuklear and the Lua programming language.

For convenience of reference, this document contains external (deep) links to the Lua Reference Manual and the Nuklear documentation.

Getting and installing

For installation intructions, refer to the README file in the MoonNuklear official repository on GitHub.

Module organization

The MoonNuklear module is loaded using Lua’s require() and returns a table containing the functions it provides (as usual with Lua modules). This manual assumes that such table is named nk, i.e. that it is loaded with:

 nk = require("moonnuklear")

but nothing forbids the use of a different name.

Examples

Complete examples can be found in the examples/ directory of the release package.

License

MoonNuklear is released under the MIT/X11 license (same as Lua, and with the same only requirement to give proper credits to the original author). The copyright notice is in the LICENSE file in the base directory of the official repository on GitHub.

See also

MoonNuklear is part of MoonLibs, a collection of Lua libraries for graphics and audio programming.

Overview

A (Moon)Nuklear application is a GUI application having two main components: [2]

  • a frontend, whose task is to define ('draw') the GUI independently of the system API, and

  • a backend, whose task is to interface Nuklear to the system API.

By system API we mean here the set of APIs through which we access the window system, handle input, render pixels on the screen, and so on (e.g. GLFW+OpenGL, GLUT+OpenGL, GLFW+Vulkan, …​).

To create a GUI, the application must first create a context, which is an object that mantains minimal state for the application and links together the frontend and the backend. The application creates a context by calling the init( ) function, optionally passing it a font to be used for text rendering [3].

Then, after having performed any other initialization such as those required by the system API, the application enters its main event loop where (ideally) at each iteration it reacts to input events and ends up rendering a frame on the screen. Omitting the details, each iteration of the event loop consists of the following steps:

  1. The backend mirrors the input, i.e. it collects input information via the system API and relays such information to Nuklear.

  2. The frontend draws the GUI using Nuklear’s frontend API (window, layout, widgets, etc), possibly accessing input information via context methods and modifying the aspect of the GUI accordingly. Upon each call of its frontend API, Nuklear generates vertex data and abstract draw commands ('abstract' in the sense that they do not depend on any particular system API).

  3. The backend converts the vertex data to the format expected by the system API, possibly uploads it to the rendering device (e.g. the GPU), retrieves the list of abstract draw commands generated by Nuklear, and eventually renders the frame, by mapping the abstract draw commands to concrete system API calls (e.g. OpenGL draw commands).

Notice how the frontend is in charge only of drawing the GUI, which it does independently and without any knowledge of the system API being used to concretely draw it. This means that once a frontend is developed, it should be reusable without changes with different backends, i.e. with different system APIs or even on different systems.

Also notice that the frontend must redraw the GUI at every frame: nothing about the GUI itself (its layout, which widgets it contains, their state, etc.) is retained across frames by Nuklear nor by the GPU. This is what 'immediate mode' means. [4]

This also means that a backend for a particular system API is a fairly general piece of code that can be reused for different frontends, thus one need not rewrite a new one every time he/she writes an application. Moreover, the backend is not required to do any fancy or particularly complex graphics task: it is only required to mirror input information from the system API to Nuklear, and to draw concretely the vertices that Nuklear asks it to draw via its abstract commands (Nuklear takes care to pass to the backend vertex data that will result in the GUI as intended by the frontend, and the backend blindly draws it).

A GLFW+OpenGL backend is provided with MoonNuklear (moonnuklear/glbackend.lua). This backend is used in the examples and requires MoonGL and MoonGLFW.

The rest of this manual lists the MoonNuklear Lua bindings to the functions provided by Nuklear for the above operations. A few examples can be found in the examples/ directory of the repository, including portings to Lua of the original examples and of the comprehensive demo that come with Nuklear.

API bindings

Context

  • context = init([font])
    Create a context. If no font is passed, one must be set using style_set_font( ) before entering the event loop.
    Rfr: nk_init_default( ).

  • context = init_from_ptr(ptr) EXPERIMENTAL
    Create a context object associated to an already initialized Nuklear context.
    ptr: a Lua lightuserdata containing a pointer to an already initialized nk_context struct.
    How ptr is obtained is outside of the scope of MoonNuklear. An application using this function, however, should be compiled against the same Nuklear version as MoonNuklear (file src/nuklear/nuklear.h) and using the same switches (the NK_XXX defines in src/moonnuklear.h). See issue #12.
    Note that when such a context object is destroyed - either automatically or via the context:free( ) method - the underlying Nuklear context is not touched. That is, the user is in charge of calling nk_free(ptr) and freeing the memory pointed by ptr, if dynamically allocated.

  • context:free( )
    Destroy a context.
    Rfr: nk_free( ).

  • font = context:font( )
    Returns an handle to the font in use by the context.

Input mirroring

Updated input information must be provided to Nuklear at each frame, using the input_xxx( ) functions in a code section delimited by input_begin( ) and input_end( ). See also the Input section in the Nuklear documentation.

  • input_begin(context)
    input_end(context)
    Rfr: nk_input_begin( ), nk_input_end( ).

  • input_key(context, key, down)
    input_button(context, button, x, y, down)
    input_scroll(context, x, y)
    input_motion(context, x, y)
    input_mouse_pos(context, x, y) - Note1
    input_char(context, char)
    input_glyph(context, glyph)
    input_unicode(context, codepoint)
    Note1: unlike input_motion( ), input_mouse_pos( ) only sets the mouse position without updating delta and prev (used e.g. in mouse grabbing).
    Rfr: nk_input_xxx( ).

  • input_keys(context, keytable)
    This function can be used to mirror all the keys with a single call. Any missing field in the keytable defaults to false (i.e. key up).

Input queries

The following context methods can be used (usually by the frontend) to query mirrored input information relevant to the GUI.

  • boolean = context:is_mouse_down(button)
    boolean = context:is_mouse_pressed(button)
    boolean = context:is_mouse_released(button)
    boolean = context:mouse_clicked(button, rect)
    boolean = context:has_mouse_click(button)
    boolean = context:has_mouse_click_in_rect(button, rect)
    boolean = context:has_mouse_click_down_in_rect(button, rect, down)
    boolean = context:is_mouse_click_in_rect(button, rect)
    boolean = context:is_mouse_click_down_in_rect(button, rect, down)
    boolean = context:any_mouse_click_in_rect(rect)
    boolean = context:is_mouse_prev_hovering_rect(rect)
    boolean = context:is_mouse_hovering_rect(rect)
    x, y = context:mouse_pos( )
    x, y = context:mouse_prev( )
    dx, dy = context:mouse_delta( )
    dx, dy = context:mouse_scroll_delta( )
    boolean = context:mouse_grabbed( )
    boolean = context:mouse_grab( )
    boolean = context:mouse_ungrab( )
    boolean = context:is_key_pressed(key)
    boolean = context:is_key_released(key)
    boolean = context:is_key_down(key)
    Rfr: nk_input_xxx( ), nk_input.

Clipboard

The following methods can be used (in the backend) to connect the context with the system clipboard:

  • context:set_clipboard_paste(func)
    Sets func (a function) as the 'paste' callback for the context. The callback is executed as func(edit) and is expected to paste the current contents of the clipboard to the given edit.
    Rfr: nk_plugin_paste.

  • context:set_clipboard_copy(func)
    Sets func (a function) as the 'copy' callback for the context. The callback is executed as func(text), and is expected to copy the given text (a string) to the clipboard.
    Rfr: nk_plugin_copy.

Convert

The context methods that follow are used in the backend to control the conversion of vertex data and draw commands from the formats used internally by Nuklear to formats accessible by the particular system API in use.

See the Drawing section in the Nuklear documentation for more details.

  • convertresultflags = context:convert(cbuffer, vbuffer, ebuffer)
    Converts the data generated by the frontend drawings and stores the abstract draw commands in the given cbuffer, the vertex data in vbuffer, and the element indices data in ebuffer. The conversion is done according to the current 'convert configuration' for the context, that can be set with the context:config_xxxx( ) methods.
    Rfr: nk_convert( ).

  • {command} = context:commands( )
    {drawcommand} = context:draw_commands(cbuffer)
    These methods return the list of commands generated by context:convert( ). The backend is expected to translate these commands to system API calls and render them.
    Rfr: nk_foreach( ), nk_draw_foreach( ).

  • context:clear( )
    Clears the context's state. This method must be called at the end of each frame, after the converted commands have been rendered.
    (Also remember to clear the buffers passed to context:convert( )).
    Rfr: nk_clear( ).

  • context:config_reset( )
    context:config_global_alpha(float)
    context:config_line_aa(boolean)
    context:config_shape_aa(boolean)
    context:config_circle_segment_count(integer)
    context:config_arc_segment_count(integer)
    context:config_curve_segment_count(integer)
    context:config_null_texture(texid, uv)
    context:config_vertex_layout({drawvertexlayoutelement})
    context:config_vertex_size(integer)
    context:config_vertex_alignment(integer)
    Set the conversion parameters associated with the context.
    Rfr: nk_convert_config_t struct.

Windows and groups

Rfr: Window, Groups.

  • ok = window_begin(context, title, bounds, panelflags, [name])
    window_end(context)
    Begin/end drawing a window. Any other widget can be added only in the scope of a window, delimited by these two functions.
    The name optional argument (a string) is a unique name to identify the window.
    Calls of window_begin( ) can not be nested: to create windows inside windows, use groups.
    Rfr: nk_begin( ), nk_begin_titled( ), nk_end( ).
    [5]

  • ok = group_begin(context, title, panelflags, [name])
    group_end(context)
    Begin/end a new group of widgets. Requires previous layouting.
    The name optional argument (a string) is a unique name to identify the group.
    Rfr: nk_group_xxx( ).

  • ok = group_scrolled_begin(context, title, panelflags, offset)
    group_scrolled_end(context)
    Begin/end a new group with manual scrollbar handling and widgets displaced as specified by offset. Requires previous layouting.
    The title argument is used both to display in the header and as identifier (name) for the group.
    Rfr: nk_group_scrolled_xxx( ).

Basic usage of windows and groups
 if nk.window_begin(ctx, ...) then
     -- ... layout ...
     -- ... add widgets ...
     if nk.group_begin(ctx, ...) then
         -- ... add widgets (grouped) ...
         nk.group_end(ctx)
     end
 end
 nk.window_end(ctx)

 -- Note: window_end() must be called no matter what window_begin() returned,
 -- while group_end() must be called only if group_begin() succeeded.

The following functions can be used to get/set the properties of a window or group:

  • bounds = window_get_bounds(context)
    position = window_get_position(context)
    size = window_get_size(context)
    float = window_get_width(context)
    float = window_get_height(context)
    bounds = window_get_content_region(context)
    position = window_get_content_region_min(context)
    position = window_get_content_region_max(context)
    size = window_get_content_region_size(context)
    offset_x, offset_y = window_get_scroll(context)
    boolean = window_has_focus(context)
    boolean = window_is_hovered(context)
    boolean = window_is_any_hovered(context)
    boolean = window_is_collapsed(context, name)
    boolean = window_is_closed(context, name)
    boolean = window_is_hidden(context, name)
    boolean = window_is_active(context, name)
    boolean = item_is_any_active(context)
    window_set_bounds(context, name, bounds)
    window_set_position(context, name, position)
    window_set_size(context, name, size)
    window_set_focus(context, name)
    window_close(context, name)
    window_collapse(context, name, collapsestates)
    window_collapse_if(context, name, collapsestates, condition)
    window_show(context, name, showstates)
    window_show_if(context, name, showstates, condition)
    window_set_scroll(context, offset_x, offset_y)
    Rfr: nk_window_xxx( ).

  • offset_x, offset_y = group_get_scroll(context, title)
    group_set_scroll(context, title, offset_x, offset_y)
    Rfr: nk_group_xxx( ).

Layout

Rfr: Layouting.

Nuklear provides the following basic APIs to lay out widgets in windows (see also the layout.lua example):

  • layout_row_dynamic(context, height, columns)
    Widgets are drawn left to right in the slots of a row having the given height and columns slots of the same width. The width of the slots is dynamically adapted so that the row spans the whole window width. New rows are added as needed, i.e. as the number of widgets that are added exceeds the number of slots.
    Rfr: nk_layout_row_dynamic( ).

  • layout_row_static(context, height, width, columns)
    Widgets are drawn left to right in the slots of a row having the given height and columns slots of fixed width. New rows are added as needed.
    (Note that being the slots of fixed size, there either can be unused space on the right of a row, or the rightmost portion may not be drawn because it does not fit in the window).
    Rfr: nk_layout_row_static( ).

  • layout_row_begin(context, layoutformat, height, columns)
    layout_row_push(context, width|ratio)
    layout_row_end(context)
    Widgets are drawn left to right in the slots of a row having the given height and columns slots. The width of the slots is specified with layout_row_push( ) and can be changed from slot to slot, thus allowing for slots of different width in the same row. The slot width is specified directly or indirectly as ratio to the total width, depending on layoutformat being respectively 'static' or 'dynamic'.
    Rfr: nk_layout_row_xxx( ).

  • layout_row(context, layoutformat, height, {width|ratio})
    Widgets are drawn left to right in the slots of a row of the given height. The number and widths of the slots are specified by the last argument, which is an array of either widths or ratios to the total width, depending on layoutformat being respectively 'static' or 'dynamic'. New similarly sized rows are added as needed.
    Rfr: nk_layout_row( ).

  • layout_row_template_begin(context, height)
    layout_row_template_push_static(context, width)
    layout_row_template_push_dynamic(context)
    layout_row_template_push_variable(context, minwidth)
    layout_row_template_end(context)
    Widgets are drawn left to right in the slots of a row having the given height and slots whose number and widths are specified by a template. The template is recorded by calling a series of 'push' functions between the 'begin' and 'end' calls (the widths can be defined either as static, or as dynamic with/without a minimum value). New rows with the same template as added as needed.
    Rfr: nk_layout_row_template_xxx( ).

  • layout_space_begin(context, layoutformat, height, count)
    layout_space_push(context, bounds)
    layout_space_end(context)
    Widgets are drawn in the slots of a row having the given height and count slots. The bounds (position in local coordinates, and size) of each slot are specified with the 'push' function before adding the widget. The bounds are given either directly in pixels, or indirectly as ratios to the relevant totals, depending on layoutformat being respectively 'static' or 'dynamic'.
    Rfr: nk_layout_space_xxx( ).


A few utilities are provided to help in laying out widgets with the above APIs:

  • layout_set_min_row_height(context, height)
    layout_reset_min_row_height(context)
    Set the current minimum row height to a specified value, or reset it to font height.
    The actual height of a row depends on the height of the font being used, which Nuklear uses to determine a minimum row height. These functions allow to overridde this minimum, if needed, and to restore it.
    Rfr: nk_layout_set_min_row_height( ), nk_layout_reset_min_row_height( ).

  • ratio = layout_ratio_from_pixel(context, pixelwidth)
    Calculates window ratio from pixel size.
    Rfr: nk_layout_ratio_from_pixel( ).

  • bounds = layout_space_bounds(context)
    To be called after layout_space_begin( ), returns the bounds of the allocated space (position in screen coordinates, and size).
    Rfr: nk_layout_space_bounds( ).

  • vec2 = layout_space_to_screen(context, vec2)
    vec2 = layout_space_to_local(context, vec2)
    rect = layout_space_rect_to_screen(context, rect)
    rect = layout_space_rect_to_local(context, rect)
    To be called after layout_space_begin( ), these function convert a position or a rectangle from local coordinates to screen coordinates, or viceversa.
    Rfr: nk_layout_space_to_xxx( ), nk_layout_space_rect_to_xxx( ).

Widgets

  • widgetlayoutstatesflags, bounds = widget(context, bounds, [padding])
    bounds = widget_bounds(context)
    position = widget_position(context)
    size = widget_size(context)
    float = widget_width(context)
    float = widget_height(context)
    boolean = widget_is_hovered(context)
    boolean = widget_is_mouse_clicked(context, buttons)
    boolean = widget_has_mouse_click_down(context, buttons, boolean)
    spacing(context, columns)
    Rfr: nk_widget_xxx( ), nk_spacing( ).

button

chart

  • ok = chart_begin(context, charttype, count, min, max, [color, highlightcolor])
    chart_add_slot(context, charttype, count, min, max, [color, highlightcolor])
    charteventflags = chart_push(context, value, [slot=1])
    chart_end(context)
    slot: 1-based integer (the default slot is slot=1, subsequently added slots are 2, 3 and so on).
    Rfr: nk_chart_xxx( ).

  • plot(context, charttype, {value}, count, offset)
    plot_function(context, charttype, valuegetfunc, count, offset)
    The valuegetfunc callback (a Lua function) is executed as value = valuegetfunc(index) and is expected to return the value (number) corresponding to index (integer in the range offset+1 .. offset+count).
    Rfr: nk_plot_xxx( ).

check, checkbox

  • active = check(context, text, active)
    flags = check_flags(context, text, flags, value)
    Rfr: nk_check_xxx( ).

  • active = checkbox(context, text, active)
    flags = checkbox_flags(context, text, flags, value)
    Rfr: nk_checkbox_xxx( ).

color_picker

combo

  • selected = combo(context, {item}, selected, itemheight, size)
    selected = combo_callback(context, itemgetfunc, selected, count, itemheight, size)
    {item} is a list of string items, and selected is the 1-based index of the selected item in that list.
    The itemgetfunc callback (a Lua function) is executed as item = itemgetfunc(selected) and is expected to return the item (a string) corresponding to the selected argument.
    Rfr: nk_combo_xxx( ).

contextual

edit

  • text, widgetlayoutstatesflags = edit_string(context, editflags, text, max, [filter|filterfunc])
    edit_focus(context, editflags)
    edit_unfocus(context)
    The filterfunc callback (a Lua function) can be used to implement custom filters in Lua. It is executed as boolean = filterfunc(edit, codepoint), where edit is the edit associated with the context, and it is expected to return a boolean indicating whether the given codepoint is accepted by the filter or not.
    If neither filter nor filterfunc are given, the 'default' filter is used.
    Rfr: nk_textedit_xxx( ), nk_plugin_filter.

image

  • image(context, image)
    Rfr: nk_image( ).

label (text)

  • label(context, text, textalignflags, [color])
    label_wrap(context, text, [color])
    Rfr: nk_label_xxx( ), nk_text_xxx( ).

menu, menubar

  • menubar_begin(context)
    menubar_end(context)
    Rfr: nk_menubar_xxx( ).

option (radio)

  • active, changed = option(context, text, active)
    active, changed: boolean.
    Rfr: nk_option_xxx( ), nk_radio_xxx( ).

popup

  • ok = popup_begin(context, popuptype, text, windowflags, bounds)
    popup_close(context)
    popup_end(context)
    offset_x, offset_y = popup_get_scroll(context)
    popup_set_scroll(context, offset_x, offset_y)
    Rfr: nk_popup_xxx( ).

progress

  • value = progress(context, value, max, modify)
    Rfr: nk_progress( ).

property

  • value = property(context, text, min, value, max, step, incrperpixel)
    Rfr: nk_property_xxx( ).

selectable

  • selected, changed = selectable(context, [image|symboltype], text, textalignflags, selected)
    selected, changed: boolean.
    Rfr: nk_selectable_xxx( ).

slider

  • value = slider(context, min, value, max, step)
    Rfr: nk_slider_xxx( ).

tooltip

  • tooltip(context, text)

  • ok = tooltip_begin(context, width)
    tooltip_end(context)
    Rfr: nk_tooltip_xxx( ).

tree

Edit

  • edit = context:edit( )
    Returns an handle to the edit associated with the context.

  • edit:text(text)
    edit:delete(where, len)
    edit:delete_selection( )
    edit:select_all( )
    edit:cut( )
    edit:paste(text)
    edit:undo( )
    edit:redo( )
    Rfr: nk_textedit_xxx( ), nk_text_edit.

Canvas

  • canvas = window_get_canvas(context)
    Returns an handle to the canvas of the current window or group.
    Rfr: nk_window_get_canvas( ).

The following methods can be used to draw to the canvas:

  • canvas:stroke_line(x0, y0, x1, y1, linethickness, color)
    canvas:stroke_curve(ax, ay, ctrl0x, ctrl0y, ctrl1x, ctrl1y, bx, by, linethickness, color)
    canvas:stroke_rect(rect, rounding, linethickness, color)
    canvas:stroke_circle(rect, linethickness, color)
    canvas:stroke_arc(cx, cy, radius, amin, amax, linethickness, color)
    canvas:stroke_triangle(x0, y0, x1, y1, x2, y2, linethickness, color)
    canvas:stroke_polyline({vec2}, linethickness, color)
    canvas:stroke_polygon({vec2}, linethickness, color)

  • canvas:fill_rect(rect, rounding, color)
    canvas:fill_rect_multi_color(rect, leftcolor, topcolor, rightcolor, bottomcolor)
    canvas:fill_circle(rect, color)
    canvas:fill_arc(cx, cy, radius, amin, amax, color)
    canvas:fill_triangle(x0, y0, x1, y1, x2, y2, color)
    canvas:fill_polygon({vec2}, color)

  • canvas:draw_image(rect, image, color)
    canvas:draw_text(rect, text, bgcolor, fgcolor)

  • canvas:push_scissor(rect)
    Rfr: nk_stroke_xxx( ), nk_fill_xxx( ), etc.

Colors

Unless otherwise specified, colors are represented in MoonNuklear with the color type, which is an array of 4 numbers representing the normalized RGBA components. The utilities listed below can be used to convert to/from other formats.

Note also that whenever a color is expected by MoonNuklear, an array with less than 4 elements may be provided, with the four components defaulting to {0, 0, 0, 1} (e.g. passing {0.2, 0.3, 0.1} is the same as passing passing {0.2, 0.3, 0.1, 1.0}).

  • color = color_from_bytes(context, r, g, b, a)
    r, g, b, a = color_bytes(context, color)
    Convert RGBA 0-255 byte components to/from normalized RGBA components.

  • hsvacolor = rgba_to_hsva(context, color)
    color = hsva_to_rgba(context, hsvacolor)
    Convert HSVA components to/from normalized RGBA components.

Style

Font

Fonts in MoonNuklear are represented by font objects, that are created with the atlas:add( ) method during the font baking process, or injected using the following function:

  • font = font_from_ptr(ptr) EXPERIMENTAL
    Create a font object associated to an already baked Nuklear font.
    ptr: a Lua lightuserdata containing a pointer to an already baked nk_font struct.
    How ptr is obtained is outside of the scope of MoonNuklear. An application using this function, however, should be compiled against the same Nuklear version as MoonNuklear (file src/nuklear/nuklear.h) and using the same switches (the NK_XXX defines in src/moonnuklear.h). See issue #12.
    Note that when such a font object is destroyed - either automatically or via the font:free( ) method - the underlying Nuklear font is not touched (that is, the user is in charge of and freeing the memory pointed by ptr, if dynamically allocated).

Fonts have the the following methods:

  • height = font:height( )
    Returns the height of the given font.

  • width = font:width(height, text)
    Computes the width of the given string of text, using font with the given height.

  • fontglyph = font:find_glyph(codepoint)
    Returns the font metadata for the glyph with the given codepoint (or the metadata for the fallback_glyph, if codepoint is missing in the font).

  • {codepoint} = font:ranges( )
    Returns the codepoint ranges for the font.

Font baking

The font baking process creates an image containing the glyphs of one or more fonts (that is, a texture atlas), with the metadata needed to retrieve individual glyphs from the image and properly render them.

Fonts are loaded from TrueType (.ttf) files. Nuklear also embeds a default font (ProggyClean.ttf, by Tristan Grimmer).

To bake fonts, create an atlas object, call atlas:begin( ), add all your desired fonts with atlas:add( ), then call atlas:bake( ) to create the texture image, and finally call atlas:done( ) to complete the baking process.

  • atlas = font_atlas( )
    atlas:free( )
    Create/destroy a font atlas object.
    Rfr: nk_font_atlas_init_default( ), nk_font_atlas_clear( ).

  • atlas:begin( )
    Begin adding fonts to the atlas.
    Rfr: nk_font_atlas_begin( ).

  • font = atlas:add(height, [filename], [fontconfig])
    Creates a font object and adds it to the atlas.
    The font is created with the given height (in pixels) and loaded from the given filename (a .ttf file). If filename is not given, the default font is used.
    Rfr: nk_font_atlas_add_xxx( ).

  • data, width, height = atlas:bake(fontatlasformat)
    Performs the baking process, that creates an image with all the glyphs of the fonts previously added to the atlas.
    Returns the pixel data (binary string) for the created image, and its dimensions in pixels.
    The image should be used to create a texture with the specific system API being used.
    Rfr: nk_font_atlas_bake( ).

  • texid, uv = atlas:done(texid)
    Ends the baking process and returns the texture id and uv coords for a white pixel ('null texture'), as expected in the convert configuration.
    Notice that the method is called done because 'end' is a reserved keyword in Lua.
    Rfr: nk_font_atlas_end( ), nk_draw_null_texture.

  • atlas:cleanup( )
    Rfr: nk_font_atlas_cleanup( ).

  • font = atlas:default_font( )
    Returns the default font for the atlas, if it has one (otherwise returns nil).

  • cursor = atlas:cursor(stylecursor)
    Returns the cursor stored in the atlas at the stylecursor entry.

Buffer

Buffer objects are used in MoonNuklear only to store draw commands and vertex data generated by context:convert( ).

The memory area of a buffer object may be either dynamically allocated ('dynamic') or of fixed size ('fixed'). In the former case, the buffer memory is managed by Nuklear, while in the latter it must be provided and managed by the user.

  • buffer = new_buffer('dynamic')
    buffer = new_buffer('fixed', [ptr, size])
    The ptr parameter, if passed, must be a lightuserdata containing a valid pointer to size bytes of contiguous memory.
    If ptr and size are not provided here, they must be provided later (before using the buffer) by means of the buffer:init( ) method.
    Rfr: nk_buffer_init_default( ), nk_buffer_init_fixed( ).

  • buffer:init(ptr, size)
    Sets/modifies the ptr and size for 'fixed' buffers (see new_buffer( )).

  • ptr = buffer:ptr( )
    Returns a lightuserdata containing the raw pointer (void*) to the buffer’s memory.

  • buffer:clear( )
    clear_buffers(buffer1, buffer2, …​)
    Clears the buffer (or a list of buffers), resetting its internal state.

Important
The buffers passed to context:convert( ) must be cleared at the end of each frame, since - starting from version 4.00.0 - Nuklear no longer clears them automatically (see nuklear.h Changelog).
  • buffer:free(ptr)
    Deletes the buffer object and frees its memory, if the buffer is 'dynamic'.
    (This method doesn’t touch the ptr of 'fixed' buffers, i.e. any required free or unmap of the memory pointed to by ptr must be done by the user).

Image

An image object encapsulates information about an image or texture, with the sole purpose to pass it across the Nuklear API and back to the application. It may cointain either a texture id (integer) or a lightuserdata with image information opaque to Nuklear. It may also represent a portion of an image (i.e. a 'subimage').

  • image = new_image(id|ptr)
    image = new_subimage(id|ptr, w, h, subregion)
    image:free( )
    id, w, h: integer, ptr: lightuserdata containing image information opaque to Nuklear.
    Rfr: nk_image.

  • id|ptr, w, h, subregion = image:info( )
    If image is not a subimage, then only the id or ptr is returned.

Structs and types

  • color = {float}[4] (normalized RGBA components, see also the Colors section)

  • hsvacolor = {float}[4] (normalized HSVA components)

  • rect, bounds = {float}[4] (xywh)

  • vec2, position, size, padding = {float}[2] (xy or wh)

  • vec2i, point = {integer}[2] (xy)

  • styleitem = image|color|'hide' (Rfr: nk_style_item)

  • colortable = {
    text: color,
    window: color,
    header: color,
    border: color,
    button: color,
    button_hover: color,
    button_active: color,
    toggle: color,
    toggle_hover: color,
    toggle_cursor: color,
    select: color,
    select_active: color,
    slider: color,
    slider_cursor: color,
    slider_cursor_hover: color,
    slider_cursor_active: color,
    property: color,
    edit: color,
    edit_cursor: color,
    combo: color,
    chart: color,
    chart_color: color,
    chart_color_highlight: color,
    scrollbar: color,
    scrollbar_cursor: color,
    scrollbar_cursor_hover: color,
    scrollbar_cursor_active: color,
    tab_header: color,
    }

  • keytable = {
    shift: boolean,
    ctrl: boolean,
    del: boolean,
    enter: boolean,
    tab: boolean,
    backspace: boolean,
    copy: boolean,
    cut: boolean,
    paste: boolean,
    up: boolean,
    down: boolean,
    left: boolean,
    right: boolean,
    text_insert_mode: boolean,
    text_replace_mode: boolean,
    text_reset_mode: boolean,
    text_line_start: boolean,
    text_line_end: boolean,
    text_start: boolean,
    text_end: boolean,
    text_undo: boolean,
    text_redo: boolean,
    text_select_all: boolean,
    text_word_left: boolean,
    text_word_right: boolean,
    scroll_start: boolean,
    scroll_end: boolean,
    scroll_down: boolean,
    scroll_up: boolean,
    }

  • drawvertexlayoutelement = { attribute, format, offset }, where:
    attribute: drawvertexlayoutattribute,
    format: drawvertexlayoutformat,
    offset: integer (opt., defaults to 0)
    (Rfr: nk_draw_vertex_layout_element)

  • memorystatus = {
    size: integer,
    allocated: integer,
    needed: integer,
    calls: integer,
    ptr: lightuserdata (void*),
    } (Rfr: nk_memory_status)

  • fontglyph = {
    codepoint: integer,
    xadvance: float,
    x0, y0, x1, y1: float,
    u0, v0, u1, v1: float,
    w, h: float,
    } (Rfr: nk_font_glyph)

  • fontconfig = {
    coord_type: fontcoordtype (defaults to 'uv'),
    oversample_v: integer (defaults to 1),
    oversample_h: integer (defaults to 3),
    fallback_glyph: codepoint (defaults to 63, i.e. '?'),
    spacing; vec2 (defaults to {0, 0})
    ranges: {codepoint} (defaults to font_default_glyph_ranges( )),
    } (Rfr: nk_font_config)

  • {codepoint} = font_default_glyph_ranges( )
    {codepoint} = font_chinese_glyph_ranges( )
    {codepoint} = font_cyrillic_glyph_ranges( )
    {codepoint} = font_korean_glyph_ranges( )
    These functions return the codepoint ranges for some languages.


  • drawcommand = {
    elem_count: integer,
    clip_rect: rect,
    texture_id: integer,
    } (Rfr: nk_draw_command)


  • command = { type: commandtype, …​ type-dependent contents (see below) …​ } (Rfr: nk_command)
    Commands:
    { type='nop' }
    { type='scissor', x, y, w, h: integer }
    { type='line', line_thickness: integer, start: point, stop: point, color: color }
    { type='curve', line_thickness: integer, start: point, stop: point, ctrl: {point}[2], color: color }
    { type='rect', rounding: integer, line_thickness: integer, x, y, w, h: integer, color: color }
    { type='rect filled', rounding: integer, x, y, w, h: integer, color: color }
    { type='rect multi color', x, y, w, h: integer, left, top, bottom, right: color }
    { type='triangle', line_thickness: integer, a, b, c: point, color: color }
    { type='triangle filled', a, b, c: point, color: color }
    { type='circle', line_thickness: integer, x, y, w, h: integer, color: color }
    { type='circle filled', x, y, w, h: integer, color: color }
    { type='arc', line_thickness: integer, cx, cy: integer, r: integer, a: {float}[2], color: color }
    { type='arc filled', cx, cy: integer, r: integer, a: {float}[2], color: color }
    { type='polygon', line_thickness: integer, points: {point}, color: color }
    { type='polygon filled', points: {point}, color: color }
    { type='polyline', line_thickness: integer, points: {point}, color: color }
    { type='image', image: image, x, y, w, h: integer, color: color }
    { type='text', font: user_font, x, y, w, h: integer, background, foreground: color, text: string, }

Enums

Nuklear enums are mapped in MoonNuklear to sets of string literals (as is customary in Lua). Admitted literals are available in the nk table (e.g. nk.BUTTON_XXX for NK_BUTTON_XXX), and can also be inferred from the corresponding C enum names. For example, given the nk.BUTTON_XXX hint for the buttons enum type, the literals it admits are obtained by lowercasing the XXX part of the name and replacing any underscore with a space.

If needed, the following function can be used to obtain the list of literals admitted by a particular enum type.

  • {literal} = nk.enum(enumtype)
    Returns a table listing the literals admitted by enumtype (given as a string, e.g. 'buttons', 'colorformat', etc).

Below is the list of the enum types, each with its hint, the list of string values it admits (if not too long), and a reference to the original Nuklear enum type where to look for semantic and usage information.

For enum types denoting object info, the type of the info value is also listed.

allocationtype: nk.BUFFER_XXX (nk_allocation_type)
Values: 'fixed', 'dynamic'.

bufferallocationtype: nk.BUFFER_XXX (nk_buffer_allocation_type)
Values: 'front', 'back'.

buttonbehavior: nk.BUTTON_XXX (nk_button_behavior)
Values: 'default', 'repeater'.

buttons: nk.BUTTON_XXX (nk_buttons)
Values: 'left', 'middle', 'right', 'double'.

charttype: nk.CHART_XXX (nk_chart_type)
Values: 'lines', 'column'.

commandtype: nk.COMMAND_XXX (nk_command_type)
Values: 'nop', 'scissor', 'line', 'curve', 'rect', 'rect filled', 'rect multi color', 'circle', 'circle filled', 'arc', 'arc filled', 'triangle', 'triangle filled', 'polygon', 'polygon filled', 'polyline', 'text', 'image', 'custom'.

collapsestates: nk.XXX (nk_collapse_states)
Values: 'minimized', 'maximized'.

colorformat: nk.XXX (nk_color_format)
Values: 'rgb', 'rgba'.

drawliststroke: nk.STROKE_XXX (nk_draw_list_stroke)
Values: 'open', 'closed'.

drawvertexlayoutattribute: nk.VERTEX_XXX (nk_draw_vertex_layout_attribute)
Values: 'position', 'color', 'texcoord'.

drawvertexlayoutformat: nk.FORMAT_XXX (nk_draw_vertex_layout_format)
Values: 'char', 'short', 'int', 'uchar', 'ushort', 'uint', 'float', 'double', 'r8g8b8', 'r16g15b16', 'r32g32b32', 'r8g8b8a8', 'b8g8r8a8', 'r16g15b16a16', 'r32g32b32a32', 'r32g32b32a32 float', 'r32g32b32a32 double', 'rgb32', 'rgba32'.

filter: nk.filter_xxx (nk_filter_xxx)
Values: 'default', 'ascii', 'float', 'decimal', 'hex', 'oct', 'binary'.

fontatlasformat: nk.FONT_ATLAS_XXX (nk_font_atlas_format)
Values: 'alpha8', 'rgba32'.

fontcoordtype: nk.COORD_XXX (nk_font_coord_type)
Values: 'uv', 'pixel'.

heading: nk.XXX (nk_heading)
Values: 'up', 'right', 'down', 'left'.

keys: nk.KEY_XXX (nk_keys)
Values: 'none', 'shift', 'ctrl', 'del', 'enter', 'tab', 'backspace', 'copy', 'cut', 'paste', 'up', 'down', 'left', 'right', 'text insert mode', 'text replace mode', 'text reset mode', 'text line start', 'text line end', 'text start', 'text end', 'text undo', 'text redo', 'text select all', 'text word left', 'text word right', 'scroll start', 'scroll end', 'scroll down', 'scroll up'.

layoutformat: nk.XXX (nk_layout_format)
Values: 'dynamic', 'static'.

modify: nk.XXX (nk_modify)
Values: 'fixed', 'modifiable'.

orientation: nk.XXX (nk_orientation)
Values: 'vertical', 'horizontal'.

panelrowlayouttype: nk.LAYOUT_XXX (nk_panel_row_layout_type)
Values: 'dynamic fixed _', '_dynamic row', 'dynamic free', 'dynamic', 'static fixed', 'static row', 'static free', 'static', 'template'.

popuptype: nk.POPUP_XXX (nk_popup_type)
Values: 'static', 'dynamic'.

showstates: nk.XXX (nk_show_states)
Values: 'hidden', 'shown'.

stylecursor: nk.CURSOR_XXX (nk_style_cursor)
Values: 'arrow', 'text', 'move', 'resize vertical', 'resize horizontal', 'resize top left down right', 'resize top right down left'.

styleitemtype: nk.STYLE_ITEM_XXX (nk_style_item_type)
Values: 'color', 'image'.

symboltype: nk.SYMBOL_XXX (nk_symbol_type)
Values: 'none', 'x', 'underscore', 'circle solid', 'circle outline', 'rect solid', 'rect outline', 'triangle up', 'triangle down', 'triangle left', 'triangle right', 'plus', 'minus'.

texteditmode: nk.TEXT_EDIT_MODE_XXX (nk_text_edit_mode)
Values: 'view', 'insert', 'replace'.

textedittype: nk.TEXT_EDIT_XXX (nk_text_edit_type)
Values: 'single line', 'multi line'.

treetype: nk.TREE_XXX (nk_tree_type)
Values: 'node', 'tab'.

Flags

Flags in MoonNuklear functions and structs are always represented as plain integers, and encoded in the same way as the corresponding flags in the C Nuklear API.

The nk table contains the NK_XXX values, renamed as nk.XXX (e.g. nk.CHART_HOVERING, nk.CHART_CLICKED, etc.).

For each flags type (see the list below), a utility function is also available to map an integer code to a list of string literals, each corresponding to an individual bit set in the code, and viceversa to encode an integer value from the individual bits given as a list of string literals. The generic definition of such functions is the following, where xxxflags stands for charteventflags, convertresultflags, etc:

  • code = xxxflags(s1, s2, …​)
    s1, s2, …​ = xxxflags(code)
    Maps the integer code to/from the list of string values s1, s2, …​.

charteventflags: nk.CHART_XXX (nk_chart_event)
Values: 'hovering', 'clicked'.

convertresultflags: nk.CONVERT_XXX (nk_convert_result)
Values: 'success', 'invalid param', 'command buffer full', 'vertex buffer full', 'element buffer full'.

editeventsflags: nk.EDIT_XXX (nk_edit_events)
Values: 'active', 'inactive', 'activated', 'deactivated', 'commited'.

editflags: nk.EDIT_XXX (nk_edit_flags, nk_edit_types)
Values: 'default', 'read only', 'auto select', 'sig enter', 'allow tab', 'no cursor', 'selectable', 'clipboard', 'ctrl enter newline', 'no horizontal scroll', 'always insert mode', 'multiline', 'goto end on activate'.
Combination values: 'simple', 'field', 'box', 'editor'.

panelflags: nk.WINDOW_XXX (nk_panel_flags)
Values: 'border', 'movable', 'scalable', 'closable', 'minimizable', 'no scrollbar', 'title', 'scroll auto hide', 'background', 'scale left', 'no input'.

paneltypeflags: nk.PANEL_XXX (nk_panel_type, nk_panel_set)
Values: 'window', 'group', 'popup', 'contextual', 'combo', 'menu', 'tooltip'.
Combination values: 'set nonblock', 'set popup', 'set sub'.

styleheaderalignflags: nk.HEADER_XXX (nk_style_header_align)
Values: 'left', 'right'.

textalignflags: nk.TEXT_XXX (nk_text_align, nk_text_alignment)
Values: 'align left', 'align centered', 'align right', 'align top', 'align middle', 'align bottom'.
Combination values: 'left', 'centered', 'right'.

widgetlayoutstatesflags: nk.WIDGET_XXX (nk_widget_layout_states)
Values: 'invalid', 'valid', 'rom'.

widgetstatesflags: nk.WIDGET_STATE_XXX (nk_widget_states)
Values: 'modified', 'inactive', 'entered', 'hover', 'actived', 'left', 'hovered', 'active'.

windowflags: nk.WINDOW_XXX (nk_window_flags)
Values: 'private', 'dynamic', 'rom', 'not interactive', 'hidden', 'closed', 'minimized', 'remove rom'.

List of style fields

Listed in this section are the accessible style fields of a context, together with their type.

The string literal for each field corresponds to its name in the style field of the nk_context struct in C (for example, 'button.border' identifies the context→style.button.border field which is a float).

'button.border' : float
'button.rounding' : float
'contextual_button.border' : float
'contextual_button.rounding' : float
'menu_button.border' : float
'menu_button.rounding' : float
'checkbox.border' : float
'checkbox.spacing' : float
'option.border' : float
'option.spacing' : float
'selectable.rounding' : float
'slider.bar_height' : float
'slider.rounding' : float
'slider.inc_button.border' : float
'slider.inc_button.rounding' : float
'slider.dec_button.border' : float
'slider.dec_button.rounding' : float
'progress.rounding' : float
'progress.border' : float
'progress.cursor_rounding' : float
'progress.cursor_border' : float
'scrollh.border' : float
'scrollh.rounding' : float
'scrollh.border_cursor' : float
'scrollh.rounding_cursor' : float
'scrollv.border' : float
'scrollv.rounding' : float
'scrollv.border_cursor' : float
'scrollv.rounding_cursor' : float
'scrollh.inc_button.border' : float
'scrollh.inc_button.rounding' : float
'scrollh.dec_button.border' : float
'scrollh.dec_button.rounding' : float
'scrollv.inc_button.border' : float
'scrollv.inc_button.rounding' : float
'scrollv.dec_button.border' : float
'scrollv.dec_button.rounding' : float
'edit.row_padding' : float
'edit.cursor_size' : float
'edit.border' : float
'edit.rounding' : float
'edit.scrollbar.border' : float
'edit.scrollbar.rounding' : float
'edit.scrollbar.border_cursor' : float
'edit.scrollbar.rounding_cursor' : float
'edit.scrollbar.inc_button.border' : float
'edit.scrollbar.inc_button.rounding' : float
'edit.scrollbar.dec_button.border' : float
'edit.scrollbar.dec_button.rounding' : float
'property.border' : float
'property.rounding' : float
'property.dec_button.border' : float
'property.dec_button.rounding' : float
'property.inc_button.border' : float
'property.inc_button.rounding' : float
'property.edit.cursor_size' : float
'property.edit.border' : float
'property.edit.rounding' : float
'chart.border' : float
'chart.rounding' : float
'combo.border' : float
'combo.rounding' : float
'combo.button.border' : float
'combo.button.rounding' : float
'tab.indent' : float
'tab.border' : float
'tab.rounding' : float
'tab.tab_minimize_button.border' : float
'tab.tab_minimize_button.rounding' : float
'tab.tab_maximize_button.border' : float
'tab.tab_maximize_button.rounding' : float
'tab.node_minimize_button.border' : float
'tab.node_minimize_button.rounding' : float
'tab.node_maximize_button.border' : float
'tab.node_maximize_button.rounding' : float
'window.header.close_button.border' : float
'window.header.close_button.rounding' : float
'window.header.minimize_button.border' : float
'window.header.minimize_button.rounding' : float
'window.rounding' : float
'window.combo_border' : float
'window.contextual_border' : float
'window.menu_border' : float
'window.group_border' : float
'window.tooltip_border' : float
'window.popup_border' : float
'window.border' : float
'window.min_row_height_padding' : float
'text.padding' : vec2
'button.padding' : vec2
'button.image_padding' : vec2
'button.touch_padding' : vec2
'contextual_button.padding' : vec2
'contextual_button.touch_padding' : vec2
'menu_button.padding' : vec2
'menu_button.touch_padding' : vec2
'checkbox.padding' : vec2
'checkbox.touch_padding' : vec2
'option.padding' : vec2
'option.touch_padding' : vec2
'selectable.padding' : vec2
'selectable.touch_padding' : vec2
'slider.cursor_size' : vec2
'slider.padding' : vec2
'slider.spacing' : vec2
'slider.inc_button.padding' : vec2
'slider.inc_button.touch_padding' : vec2
'slider.dec_button.padding' : vec2
'slider.dec_button.touch_padding' : vec2
'progress.padding' : vec2
'scrollh.padding' : vec2
'scrollv.padding' : vec2
'scrollh.inc_button.padding' : vec2
'scrollh.inc_button.touch_padding' : vec2
'scrollh.dec_button.padding' : vec2
'scrollh.dec_button.touch_padding' : vec2
'scrollv.inc_button.padding' : vec2
'scrollv.inc_button.touch_padding' : vec2
'scrollv.dec_button.padding' : vec2
'scrollv.dec_button.touch_padding' : vec2
'edit.scrollbar_size' : vec2
'edit.padding' : vec2
'edit.scrollbar.padding' : vec2
'edit.scrollbar.inc_button.padding' : vec2
'edit.scrollbar.inc_button.touch_padding' : vec2
'edit.scrollbar.dec_button.padding' : vec2
'edit.scrollbar.dec_button.touch_padding' : vec2
'property.padding' : vec2
'property.dec_button.padding' : vec2
'property.dec_button.touch_padding' : vec2
'property.inc_button.padding' : vec2
'property.inc_button.touch_padding' : vec2
'property.edit.padding' : vec2
'chart.padding' : vec2
'combo.content_padding' : vec2
'combo.button_padding' : vec2
'combo.spacing' : vec2
'combo.button.padding' : vec2
'combo.button.touch_padding' : vec2
'tab.padding' : vec2
'tab.spacing' : vec2
'tab.tab_minimize_button.padding' : vec2
'tab.tab_minimize_button.touch_padding' : vec2
'tab.tab_maximize_button.padding' : vec2
'tab.tab_maximize_button.touch_padding' : vec2
'tab.node_minimize_button.padding' : vec2
'tab.node_minimize_button.touch_padding' : vec2
'tab.node_maximize_button.padding' : vec2
'tab.node_maximize_button.touch_padding' : vec2
'window.header.label_padding' : vec2
'window.header.padding' : vec2
'window.header.spacing' : vec2
'window.header.close_button.padding' : vec2
'window.header.close_button.touch_padding' : vec2
'window.header.minimize_button.padding' : vec2
'window.header.minimize_button.touch_padding' : vec2
'window.spacing' : vec2
'window.scrollbar_size' : vec2
'window.min_size' : vec2
'window.padding' : vec2
'window.group_padding' : vec2
'window.popup_padding' : vec2
'window.combo_padding' : vec2
'window.contextual_padding' : vec2
'window.menu_padding' : vec2
'window.tooltip_padding' : vec2
'button.text_alignment' : textalignflags
'contextual_button.text_alignment' : textalignflags
'menu_button.text_alignment' : textalignflags
'slider.inc_button.text_alignment' : textalignflags
'slider.dec_button.text_alignment' : textalignflags
'scrollh.inc_button.text_alignment' : textalignflags
'scrollh.dec_button.text_alignment' : textalignflags
'scrollv.inc_button.text_alignment' : textalignflags
'scrollv.dec_button.text_alignment' : textalignflags
'edit.scrollbar.inc_button.text_alignment' : textalignflags
'edit.scrollbar.dec_button.text_alignment' : textalignflags
'property.dec_button.text_alignment' : textalignflags
'property.inc_button.text_alignment' : textalignflags
'combo.button.text_alignment' : textalignflags
'tab.tab_minimize_button.text_alignment' : textalignflags
'tab.tab_maximize_button.text_alignment' : textalignflags
'tab.node_minimize_button.text_alignment' : textalignflags
'tab.node_maximize_button.text_alignment' : textalignflags
'window.header.close_button.text_alignment' : textalignflags
'window.header.minimize_button.text_alignment' : textalignflags
'window.header.align' : styleheaderalignflags 'text.color' : color
'button.border_color' : color
'button.text_background' : color
'button.text_normal' : color
'button.text_hover' : color
'button.text_active' : color
'contextual_button.border_color' : color
'contextual_button.text_background' : color
'contextual_button.text_normal' : color
'contextual_button.text_hover' : color
'contextual_button.text_active' : color
'menu_button.border_color' : color
'menu_button.text_background' : color
'menu_button.text_normal' : color
'menu_button.text_hover' : color
'menu_button.text_active' : color
'checkbox.text_background' : color
'checkbox.text_normal' : color
'checkbox.text_hover' : color
'checkbox.text_active' : color
'checkbox.border_color' : color
'option.text_background' : color
'option.text_normal' : color
'option.text_hover' : color
'option.text_active' : color
'option.border_color' : color
'selectable.text_normal' : color
'selectable.text_hover' : color
'selectable.text_pressed' : color
'selectable.text_normal_active' : color
'selectable.text_hover_active' : color
'selectable.text_pressed_active' : color
'slider.bar_normal' : color
'slider.bar_hover' : color
'slider.bar_active' : color
'slider.bar_filled' : color
'slider.inc_button.border_color' : color
'slider.inc_button.text_background' : color
'slider.inc_button.text_normal' : color
'slider.inc_button.text_hover' : color
'slider.inc_button.text_active' : color
'slider.dec_button.border_color' : color
'slider.dec_button.text_background' : color
'slider.dec_button.text_normal' : color
'slider.dec_button.text_hover' : color
'slider.dec_button.text_active' : color
'progress.border_color' : color
'progress.cursor_border_color' : color
'scrollh.border_color' : color
'scrollh.cursor_border_color' : color
'scrollv.border_color' : color
'scrollv.cursor_border_color' : color
'scrollh.inc_button.border_color' : color
'scrollh.inc_button.text_background' : color
'scrollh.inc_button.text_normal' : color
'scrollh.inc_button.text_hover' : color
'scrollh.inc_button.text_active' : color
'scrollh.dec_button.border_color' : color
'scrollh.dec_button.text_background' : color
'scrollh.dec_button.text_normal' : color
'scrollh.dec_button.text_hover' : color
'scrollh.dec_button.text_active' : color
'scrollv.inc_button.border_color' : color
'scrollv.inc_button.text_background' : color
'scrollv.inc_button.text_normal' : color
'scrollv.inc_button.text_hover' : color
'scrollv.inc_button.text_active' : color
'scrollv.dec_button.border_color' : color
'scrollv.dec_button.text_background' : color
'scrollv.dec_button.text_normal' : color
'scrollv.dec_button.text_hover' : color
'scrollv.dec_button.text_active' : color
'edit.cursor_normal' : color
'edit.cursor_hover' : color
'edit.cursor_text_normal' : color
'edit.cursor_text_hover' : color
'edit.border_color' : color
'edit.text_normal' : color
'edit.text_hover' : color
'edit.text_active' : color
'edit.selected_normal' : color
'edit.selected_hover' : color
'edit.selected_text_normal' : color
'edit.selected_text_hover' : color
'edit.scrollbar.border_color' : color
'edit.scrollbar.cursor_border_color' : color
'edit.scrollbar.inc_button.border_color' : color
'edit.scrollbar.inc_button.text_background' : color
'edit.scrollbar.inc_button.text_normal' : color
'edit.scrollbar.inc_button.text_hover' : color
'edit.scrollbar.inc_button.text_active' : color
'edit.scrollbar.dec_button.border_color' : color
'edit.scrollbar.dec_button.text_background' : color
'edit.scrollbar.dec_button.text_normal' : color
'edit.scrollbar.dec_button.text_hover' : color
'edit.scrollbar.dec_button.text_active' : color
'property.border_color' : color
'property.label_normal' : color
'property.label_hover' : color
'property.label_active' : color
'property.dec_button.border_color' : color
'property.dec_button.text_background' : color
'property.dec_button.text_normal' : color
'property.dec_button.text_hover' : color
'property.dec_button.text_active' : color
'property.inc_button.border_color' : color
'property.inc_button.text_background' : color
'property.inc_button.text_normal' : color
'property.inc_button.text_hover' : color
'property.inc_button.text_active' : color
'property.edit.border_color' : color
'property.edit.cursor_normal' : color
'property.edit.cursor_hover' : color
'property.edit.cursor_text_normal' : color
'property.edit.cursor_text_hover' : color
'property.edit.text_normal' : color
'property.edit.text_hover' : color
'property.edit.text_active' : color
'property.edit.selected_normal' : color
'property.edit.selected_hover' : color
'property.edit.selected_text_normal' : color
'property.edit.selected_text_hover' : color
'chart.border_color' : color
'chart.selected_color' : color
'chart.color' : color
'combo.border_color' : color
'combo.label_normal' : color
'combo.label_hover' : color
'combo.label_active' : color
'combo.button.border_color' : color
'combo.button.text_background' : color
'combo.button.text_normal' : color
'combo.button.text_hover' : color
'combo.button.text_active' : color
'tab.border_color' : color
'tab.text' : color
'tab.tab_minimize_button.border_color' : color
'tab.tab_minimize_button.text_background' : color
'tab.tab_minimize_button.text_normal' : color
'tab.tab_minimize_button.text_hover' : color
'tab.tab_minimize_button.text_active' : color
'tab.tab_maximize_button.border_color' : color
'tab.tab_maximize_button.text_background' : color
'tab.tab_maximize_button.text_normal' : color
'tab.tab_maximize_button.text_hover' : color
'tab.tab_maximize_button.text_active' : color
'tab.node_minimize_button.border_color' : color
'tab.node_minimize_button.text_background' : color
'tab.node_minimize_button.text_normal' : color
'tab.node_minimize_button.text_hover' : color
'tab.node_minimize_button.text_active' : color
'tab.node_maximize_button.border_color' : color
'tab.node_maximize_button.text_background' : color
'tab.node_maximize_button.text_normal' : color
'tab.node_maximize_button.text_hover' : color
'tab.node_maximize_button.text_active' : color
'window.header.label_normal' : color
'window.header.label_hover' : color
'window.header.label_active' : color
'window.header.close_button.border_color' : color
'window.header.close_button.text_background' : color
'window.header.close_button.text_normal' : color
'window.header.close_button.text_hover' : color
'window.header.close_button.text_active' : color
'window.header.minimize_button.border_color' : color
'window.header.minimize_button.text_background' : color
'window.header.minimize_button.text_normal' : color
'window.header.minimize_button.text_hover' : color
'window.header.minimize_button.text_active' : color
'window.background' : color
'window.border_color' : color
'window.popup_border_color' : color
'window.combo_border_color' : color
'window.contextual_border_color' : color
'window.menu_border_color' : color
'window.group_border_color' : color
'window.tooltip_border_color' : color
'button.normal' : styleitem
'button.hover' : styleitem
'button.active' : styleitem
'contextual_button.normal' : styleitem
'contextual_button.hover' : styleitem
'contextual_button.active' : styleitem
'menu_button.normal' : styleitem
'menu_button.hover' : styleitem
'menu_button.active' : styleitem
'checkbox.normal' : styleitem
'checkbox.hover' : styleitem
'checkbox.active' : styleitem
'checkbox.cursor_normal' : styleitem
'checkbox.cursor_hover' : styleitem
'option.normal' : styleitem
'option.hover' : styleitem
'option.active' : styleitem
'option.cursor_normal' : styleitem
'option.cursor_hover' : styleitem
'selectable.normal' : styleitem
'selectable.hover' : styleitem
'selectable.pressed' : styleitem
'selectable.normal_active' : styleitem
'selectable.hover_active' : styleitem
'selectable.pressed_active' : styleitem
'slider.normal' : styleitem
'slider.hover' : styleitem
'slider.active' : styleitem
'slider.cursor_normal' : styleitem
'slider.cursor_hover' : styleitem
'slider.cursor_active' : styleitem
'slider.inc_button.normal' : styleitem
'slider.inc_button.hover' : styleitem
'slider.inc_button.active' : styleitem
'slider.dec_button.normal' : styleitem
'slider.dec_button.hover' : styleitem
'slider.dec_button.active' : styleitem
'progress.normal' : styleitem
'progress.hover' : styleitem
'progress.active' : styleitem
'progress.cursor_normal' : styleitem
'progress.cursor_hover' : styleitem
'progress.cursor_active' : styleitem
'scrollh.normal' : styleitem
'scrollh.hover' : styleitem
'scrollh.active' : styleitem
'scrollh.cursor_normal' : styleitem
'scrollh.cursor_hover' : styleitem
'scrollh.cursor_active' : styleitem
'scrollv.normal' : styleitem
'scrollv.hover' : styleitem
'scrollv.active' : styleitem
'scrollv.cursor_normal' : styleitem
'scrollv.cursor_hover' : styleitem
'scrollv.cursor_active' : styleitem
'scrollh.inc_button.normal' : styleitem
'scrollh.inc_button.hover' : styleitem
'scrollh.inc_button.active' : styleitem
'scrollh.dec_button.normal' : styleitem
'scrollh.dec_button.hover' : styleitem
'scrollh.dec_button.active' : styleitem
'scrollv.inc_button.normal' : styleitem
'scrollv.inc_button.hover' : styleitem
'scrollv.inc_button.active' : styleitem
'scrollv.dec_button.normal' : styleitem
'scrollv.dec_button.hover' : styleitem
'scrollv.dec_button.active' : styleitem
'edit.normal' : styleitem
'edit.hover' : styleitem
'edit.active' : styleitem
'edit.scrollbar.normal' : styleitem
'edit.scrollbar.hover' : styleitem
'edit.scrollbar.active' : styleitem
'edit.scrollbar.cursor_normal' : styleitem
'edit.scrollbar.cursor_hover' : styleitem
'edit.scrollbar.cursor_active' : styleitem
'edit.scrollbar.inc_button.normal' : styleitem
'edit.scrollbar.inc_button.hover' : styleitem
'edit.scrollbar.inc_button.active' : styleitem
'edit.scrollbar.dec_button.normal' : styleitem
'edit.scrollbar.dec_button.hover' : styleitem
'edit.scrollbar.dec_button.active' : styleitem
'property.normal' : styleitem
'property.hover' : styleitem
'property.active' : styleitem
'property.dec_button.normal' : styleitem
'property.dec_button.hover' : styleitem
'property.dec_button.active' : styleitem
'property.inc_button.normal' : styleitem
'property.inc_button.hover' : styleitem
'property.inc_button.active' : styleitem
'property.edit.normal' : styleitem
'property.edit.hover' : styleitem
'property.edit.active' : styleitem
'chart.background' : styleitem
'combo.normal' : styleitem
'combo.hover' : styleitem
'combo.active' : styleitem
'combo.button.normal' : styleitem
'combo.button.hover' : styleitem
'combo.button.active' : styleitem
'tab.background' : styleitem
'tab.tab_minimize_button.normal' : styleitem
'tab.tab_minimize_button.hover' : styleitem
'tab.tab_minimize_button.active' : styleitem
'tab.tab_maximize_button.normal' : styleitem
'tab.tab_maximize_button.hover' : styleitem
'tab.tab_maximize_button.active' : styleitem
'tab.node_minimize_button.normal' : styleitem
'tab.node_minimize_button.hover' : styleitem
'tab.node_minimize_button.active' : styleitem
'tab.node_maximize_button.normal' : styleitem
'tab.node_maximize_button.hover' : styleitem
'tab.node_maximize_button.active' : styleitem
'window.header.normal' : styleitem
'window.header.hover' : styleitem
'window.header.active' : styleitem
'window.header.close_button.normal' : styleitem
'window.header.close_button.hover' : styleitem
'window.header.close_button.active' : styleitem
'window.header.minimize_button.normal' : styleitem
'window.header.minimize_button.hover' : styleitem
'window.header.minimize_button.active' : styleitem
'window.fixed_background' : styleitem
'window.scaler' : styleitem
'slider.show_buttons' : boolean
'scrollh.show_buttons' : boolean
'scrollv.show_buttons' : boolean
'edit.scrollbar.show_buttons' : boolean
'slider.inc_symbol' : symboltype
'slider.dec_symbol' : symboltype
'scrollh.dec_symbol' : symboltype
'scrollh.inc_symbol' : symboltype
'scrollv.dec_symbol' : symboltype
'scrollv.inc_symbol' : symboltype
'edit.scrollbar.dec_symbol' : symboltype
'edit.scrollbar.inc_symbol' : symboltype
'property.sym_left' : symboltype
'property.sym_right' : symboltype
'combo.sym_normal' : symboltype
'combo.sym_hover' : symboltype
'combo.sym_active' : symboltype
'tab.sym_minimize' : symboltype
'tab.sym_maximize' : symboltype
'window.header.close_symbol' : symboltype
'window.header.minimize_symbol' : symboltype
'window.header.maximize_symbol' : symboltype
Rfr: nk_context.style.


1. This manual is written in AsciiDoc, rendered with AsciiDoctor and a CSS from the AsciiDoctor Stylesheet Factory.
2. Of course an application may have many other important components. We are considering here only those related to GUI drawing via Nuklear.
3. A font for text rendering must eventually be provided, but this can be done either by passing it to init( ) as well as later during the initialization phase.
4. The biggest price to pay for this (at least in GPU rendering) is that vertex data must be uploaded to the GPU at every frame. While this may be prohibitive when rendering complex graphics scenes, it is usually acceptable for simple GUIs like those for which Nuklear is intended for.
5. The Lua bindings to the nk_begin( ) and nk_end( ) functions are named respectively window_begin( ) and window_end( ) with the 'window_' prefix mainly because 'end' is a reserved word in Lua.