Updated Documentation (markdown)

Kevin Harrison 2016-12-03 14:16:28 -05:00
parent b9a864b83e
commit b467f87c00

@ -56,83 +56,83 @@ Draw the UI. Call this once every [love.draw](https://love2d.org/wiki/love.draw)
## Update ## Update
#### nk.frame_begin() #### nk.frameBegin()
Begin a new frame for the UI. Call this once every [love.update](https://love2d.org/wiki/love.update), before other UI calls. Begin a new frame for the UI. Call this once every [love.update](https://love2d.org/wiki/love.update), before other UI calls.
#### nk.frame_end() #### nk.frameEnd()
End the current frame. Call this once every [love.update](https://love2d.org/wiki/love.update), after other UI calls. End the current frame. Call this once every [love.update](https://love2d.org/wiki/love.update), after other UI calls.
*** ***
## Window ## Window
#### open = nk.window_begin(title, x, y, width, height, [flags](#flags)...) #### open = nk.windowBegin(title, x, y, width, height, [flags](#flags)...)
#### open = nk.window_begin(name, title, x, y, width, height, [flags](#flags)...) #### open = nk.windowBegin(name, title, x, y, width, height, [flags](#flags)...)
Create or update a window with the given `name`. The `name` is a unique identifier used internally to differentiate between windows. If unspecified, the `name` defaults to the `title`. The `x`, `y`, `width`, and `height` parameters describe the window's initial bounds. All additional arguments are interpreted as window [flags](#flags). Create or update a window with the given `name`. The `name` is a unique identifier used internally to differentiate between windows. If unspecified, the `name` defaults to the `title`. The `x`, `y`, `width`, and `height` parameters describe the window's initial bounds. All additional arguments are interpreted as window [flags](#flags).
Returns `true` if the window is open and `false` if it is closed or collapsed. Returns `true` if the window is open and `false` if it is closed or collapsed.
#### nk.window_end() #### nk.windowEnd()
End a window. This must always be called after `nk.window_begin`, regardless of whether or not the window is open. End a window. This must always be called after `nk.windowBegin`, regardless of whether or not the window is open.
#### x, y, width, height = nk.window_get_bounds() #### x, y, width, height = nk.windowGetBounds()
Return the bounds of the current window. Return the bounds of the current window.
#### x, y = nk.window_get_position() #### x, y = nk.windowGetPosition()
Return the position of the current window. Return the position of the current window.
#### width, height = nk.window_get_size() #### width, height = nk.windowGetSize()
Return the size of the current window. Return the size of the current window.
#### x, y, width, height = nk.window_get_content_region() #### x, y, width, height = nk.windowGetContentRegion()
Return the bounds of the current window's content region. Return the bounds of the current window's content region.
#### focused = nk.window_has_focus() #### focused = nk.windowHasFocus()
Return `true` if the current window is focused, and `false` otherwise. Return `true` if the current window is focused, and `false` otherwise.
#### collapsed = nk.window_is_collapsed(name) #### collapsed = nk.windowIsCollapsed(name)
Return 'true' if the given window is collapsed, and `false` otherwise. Return 'true' if the given window is collapsed, and `false` otherwise.
#### hidden = nk.window_is_hidden(name) #### hidden = nk.windowIsHidden(name)
Return 'true' if the given window is hidden, and `false` otherwise. Return 'true' if the given window is hidden, and `false` otherwise.
#### active = nk.window_is_active(name) #### active = nk.windowIsActive(name)
Return `true` if the given window is active, and `false` otherwise. Return `true` if the given window is active, and `false` otherwise.
#### hovered = nk.window_is_hovered() #### hovered = nk.windowIsHovered()
Return `true` if the current window is hovered by the mouse, and `false` otherwise. Return `true` if the current window is hovered by the mouse, and `false` otherwise.
#### hovered = nk.window_is_any_hovered() #### hovered = nk.windowIsAnyHovered()
Return `true` if any window is hovered by the mouse, and `false` otherwise. Return `true` if any window is hovered by the mouse, and `false` otherwise.
#### active = nk.item_is_any_active() #### active = nk.itemIsAnyActive()
Return `true` if any item is active, and `false` otherwise. Return `true` if any item is active, and `false` otherwise.
#### nk.window_set_bounds(x, y, width, height) #### nk.windowSetBounds(x, y, width, height)
Set the bounds of the current window. Set the bounds of the current window.
#### nk.window_set_position(x, y) #### nk.windowSetPosition(x, y)
Set the position of the current window. Set the position of the current window.
#### nk.window_set_size(width, height) #### nk.windowSetSize(width, height)
Set the size of the current window. Set the size of the current window.
#### nk.window_set_focus(name) #### nk.windowSetFocus(name)
Focus on the given window. Focus on the given window.
#### nk.window_close(name) #### nk.windowClose(name)
Close the given window. Close the given window.
#### nk.window_collapse(name) #### nk.windowCollapse(name)
Collapse the given window. Collapse the given window.
#### nk.window_expand(name) #### nk.windowExpand(name)
Expand the given window. Expand the given window.
#### nk.window_show(name) #### nk.windowShow(name)
Show the given window. Show the given window.
#### nk.window_hide(name) #### nk.windowHide(name)
Hide the given window. Hide the given window.
### Flags ### Flags
@ -169,66 +169,66 @@ Keep the window behind all other windows.
## Layout ## Layout
#### nk.layout_row('dynamic', height, cols) #### nk.layoutRow('dynamic', height, cols)
#### nk.layout_row('dynamic', height, ratios) #### nk.layoutRow('dynamic', height, ratios)
#### nk.layout_row('static', height, item_width, cols) #### nk.layoutRow('static', height, itemWidth, cols)
#### nk.layout_row('static', height, sizes) #### nk.layoutRow('static', height, sizes)
Adopt a row layout for the proceeding widgets. Adopt a row layout for the proceeding widgets.
If the layout is `'dynamic'`, the row height and columns must be specified. If `cols` is a number, it specifies the number of equally sized columns to divide the row into. If there is a `ratios` table instead, the table is treated as an array of ratios from 0 to 1. Each ratio describes the width of the column with respect to the total row width. If the layout is `'dynamic'`, the row height and columns must be specified. If `cols` is a number, it specifies the number of equally sized columns to divide the row into. If there is a `ratios` table instead, the table is treated as an array of ratios from 0 to 1. Each ratio describes the width of the column with respect to the total row width.
If the layout is `'static'`, there must either be `item_width` and `cols` parameters describing the number of fixed-width columns to divide the row into, or there must be a `sizes` table, which is an array of fixed widths for the columns. If the layout is `'static'`, there must either be `itemWidth` and `cols` parameters describing the number of fixed-width columns to divide the row into, or there must be a `sizes` table, which is an array of fixed widths for the columns.
Examples: Examples:
```lua ```lua
-- Create a row which is 30 pixels high and is divided into 3 equally sized columns. -- Create a row which is 30 pixels high and is divided into 3 equally sized columns.
nk.layout_row('dynamic', 30, 3) nk.layoutRow('dynamic', 30, 3)
-- Create a row which is 25 pixels high and divided into two columns with a size ratio of 1:3. -- Create a row which is 25 pixels high and divided into two columns with a size ratio of 1:3.
nk.layout_row('dynamic', 25, {0.25, 0.75}) nk.layoutRow('dynamic', 25, {0.25, 0.75})
-- Create a row which is 120 pixels high and is divided into 3 columns, each of width 20. -- Create a row which is 120 pixels high and is divided into 3 columns, each of width 20.
nk.layout_row('static', 120, 20, 3) nk.layoutRow('static', 120, 20, 3)
-- Create a row which is 40 pixels high and is divided into two columns, one 20 pixels wide and the other 30 pixels. -- Create a row which is 40 pixels high and is divided into two columns, one 20 pixels wide and the other 30 pixels.
nk.layout_row('static', 40, {20, 30}) nk.layoutRow('static', 40, {20, 30})
``` ```
#### nk.layout_row_begin('dynamic'/'static', height, cols) #### nk.layoutRowBegin('dynamic'/'static', height, cols)
Adopt a row layout of the specified format type, height, and column count. Before each proceeding widget, call `nk.layout_row_push` to set the column size. Don't forget to end the layout with `nk.layout_row_end`. Adopt a row layout of the specified format type, height, and column count. Before each proceeding widget, call `nk.layoutRowPush` to set the column size. Don't forget to end the layout with `nk.layoutRowEnd`.
#### nk.layout_row_push(ratio) #### nk.layoutRowPush(ratio)
#### nk.layout_row_push(size) #### nk.layoutRowPush(size)
Specify the width of the next widget in a row layout started with `nk.layout_row_begin`. If the layout is dynamic, the width is specified as a ratio of the total row width from 0 to 1. If the layout is static, the width is specified as a number of pixels. Specify the width of the next widget in a row layout started with `nk.layoutRowBegin`. If the layout is dynamic, the width is specified as a ratio of the total row width from 0 to 1. If the layout is static, the width is specified as a number of pixels.
#### nk.layout_row_end() #### nk.layoutRowEnd()
Call after `nk.layout_row_begin` in order to properly end the row layout. Call after `nk.layoutRowBegin` in order to properly end the row layout.
#### nk.layout_space_begin('dynamic'/'static', height, widget_count) #### nk.layoutSpaceBegin('dynamic'/'static', height, widgetCount)
Start a space layout with the given height and widget count. Call `nk.layout_space_push` before each proceeding widget and `nk.layout_space_end` after the layout is finished. Start a space layout with the given height and widget count. Call `nk.layoutSpacePush` before each proceeding widget and `nk.layoutSpaceEnd` after the layout is finished.
#### nk.layout_space_push(x, y, width, height) #### nk.layoutSpacePush(x, y, width, height)
Specify the bounds of a widget in a space layout. If the layout is dynamic, the bounds are specified as ratios from 0 to 1 of the total width and height of the space layout. If the layout is static, the bounds are pixel valued offsets from the beginning of the layout. Specify the bounds of a widget in a space layout. If the layout is dynamic, the bounds are specified as ratios from 0 to 1 of the total width and height of the space layout. If the layout is static, the bounds are pixel valued offsets from the beginning of the layout.
#### nk.layout_space_end() #### nk.layoutSpaceEnd()
End a space layout. End a space layout.
#### x, y, width, height = nk.layout_space_bounds() #### x, y, width, height = nk.layoutSpaceBounds()
Return the bounds of the current space layout. Return the bounds of the current space layout.
#### x, y nk.layout_space_to_screen(x, y) #### x, y nk.layoutSpaceToScreen(x, y)
Convert a space layout local position to global screen position. Convert a space layout local position to global screen position.
#### x, y = nk.layout_space_to_local(x, y) #### x, y = nk.layoutSpaceToLocal(x, y)
Convert a global screen position to space layout local position. Convert a global screen position to space layout local position.
#### x, y, width, height = nk.layout_space_rect_to_screen(x, y, width, height) #### x, y, width, height = nk.layoutSpaceRectToScreen(x, y, width, height)
Convert space layout local bounds to global screen bounds. Convert space layout local bounds to global screen bounds.
#### x, y, width, height = nk.layout_space_rect_to_local(x, y, width, height) #### x, y, width, height = nk.layoutSpaceRectToLocal(x, y, width, height)
Convert global screen bounds to space layout local bounds. Convert global screen bounds to space layout local bounds.
#### ratio = nk.layout_ratio_from_pixel(pixel_width) #### ratio = nk.layoutRatioFromPixel(pixelWidth)
Convert a pixel width to a ratio suitable for a dynamic layout. Convert a pixel width to a ratio suitable for a dynamic layout.
*** ***
@ -237,65 +237,65 @@ Convert a pixel width to a ratio suitable for a dynamic layout.
### Groups ### Groups
#### open = nk.group_begin(title, [flags](#flags)...) #### open = nk.groupBegin(title, [flags](#flags)...)
Start a group. Groups can have titles and scrollbars just like windows. Start a group. Groups can have titles and scrollbars just like windows.
Return `true` if the group is open and `false` otherwise. Return `true` if the group is open and `false` otherwise.
Call `nk.group_end` at the end of a group if it's open. Call `nk.groupEnd` at the end of a group if it's open.
#### nk.group_end() #### nk.groupEnd()
End a group. Remember to call this whenever the group is open. End a group. Remember to call this whenever the group is open.
### Trees ### Trees
#### open = nk.tree_push('node'/'tab', title) #### open = nk.treePush('node'/'tab', title)
#### open = nk.tree_push('node'/'tab', title, image) #### open = nk.treePush('node'/'tab', title, image)
#### open = nk.tree_push('node'/'tab', title, image, 'collapsed'/'expanded') #### open = nk.treePush('node'/'tab', title, image, 'collapsed'/'expanded')
Start a tree. The resulting item is either a `'node'` or a `'tab'`, with the idea being that nodes are a level below tabs. Optionally specify an image (default is none) or a starting state (default is `'collapsed'`). Start a tree. The resulting item is either a `'node'` or a `'tab'`, with the idea being that nodes are a level below tabs. Optionally specify an image (default is none) or a starting state (default is `'collapsed'`).
Return `true` if the item is expanded, and `false` if it is collapsed. Return `true` if the item is expanded, and `false` if it is collapsed.
Remember to call `nk.tree_pop` if the item is open. Remember to call `nk.treePop` if the item is open.
#### nk.tree_pop() #### nk.treePop()
Ends a tree. Call this at the end of an open tree item. Ends a tree. Call this at the end of an open tree item.
### Popups ### Popups
#### open = nk.popup_begin('dynamic'/'static', title, x, y, width, height, [flags](#flags)...) #### open = nk.popupBegin('dynamic'/'static', title, x, y, width, height, [flags](#flags)...)
Start a popup with the given size and [flags](#flags). Bounds can be given as either dynamic ratios or static pixel counts. Start a popup with the given size and [flags](#flags). Bounds can be given as either dynamic ratios or static pixel counts.
Return `true` if the popup is open, and `false` otherwise. Return `true` if the popup is open, and `false` otherwise.
Call `nk.popup_end` to end the popup if it is open. Call `nk.popupEnd` to end the popup if it is open.
#### nk.popup_close() #### nk.popupClose()
Close the current popup. Close the current popup.
#### nk.popup_end() #### nk.popupEnd()
End a popup. Be sure to call this when ending an open popup. End a popup. Be sure to call this when ending an open popup.
### Context Menus ### Context Menus
#### open = nk.contextual_begin(width, height, trigger_x, trigger_y, trigger_width, trigger_height, [flags](#flags)...) #### open = nk.contextualBegin(width, height, triggerX, triggerY, triggerWidth, triggerHeight, [flags](#flags)...)
Set up a context menu of the given size and trigger bounds. Also takes window [flags](#flags). Set up a context menu of the given size and trigger bounds. Also takes window [flags](#flags).
Return `true` if the context menu is open, and `false` otherwise. Return `true` if the context menu is open, and `false` otherwise.
#### activated = nk.contextual_item(text) #### activated = nk.contextualItem(text)
#### activated = nk.contextual_item(text, [symbol](#symbols)/image) #### activated = nk.contextualItem(text, [symbol](#symbols)/image)
#### activated = nk.contextual_item(text, [symbol](#symbols)/image, [align](#alignment)) #### activated = nk.contextualItem(text, [symbol](#symbols)/image, [align](#alignment))
Add an item to a context menu. Optionally specify a [symbol](#symbols) type, image, and/or [alignment](#alignment). Add an item to a context menu. Optionally specify a [symbol](#symbols) type, image, and/or [alignment](#alignment).
Return `true` if the item is activated, and `false` otherwise. Return `true` if the item is activated, and `false` otherwise.
Call `nk.contextual_end` at the end of an open context menu. Call `nk.contextualEnd` at the end of an open context menu.
#### nk.contextual_close() #### nk.contextualClose()
Close the current context menu. Close the current context menu.
#### nk.contextual_end() #### nk.contextualEnd()
End the current context menu. Be sure to call this at the end of an open context menu. End the current context menu. Be sure to call this at the end of an open context menu.
### Tooltips ### Tooltips
@ -303,43 +303,43 @@ End the current context menu. Be sure to call this at the end of an open context
#### nk.tooltip(text) #### nk.tooltip(text)
Show a tooltip with the given text. Show a tooltip with the given text.
#### open = nk.tooltip_begin(width) #### open = nk.tooltipBegin(width)
Start a tooltip with the given width. Start a tooltip with the given width.
Return `true` if the tooltip is open, and `false` otherwise. Return `true` if the tooltip is open, and `false` otherwise.
Be sure to call `nk.tooltip_end` at the end of an open tooltip. Be sure to call `nk.tooltipEnd` at the end of an open tooltip.
#### nk.tooltip_end() #### nk.tooltipEnd()
End a tooltip previously started with `nk.tooltip_begin`. Call this at the end of every open tooltip. End a tooltip previously started with `nk.tooltipBegin`. Call this at the end of every open tooltip.
### Menus ### Menus
#### nk.menubar_begin() #### nk.menubarBegin()
Start a menu bar. Menu bars stay at the top of a window even when scrolling. Call `nk.menubar_end` to end one. Start a menu bar. Menu bars stay at the top of a window even when scrolling. Call `nk.menubarEnd` to end one.
#### nk.menubar_end() #### nk.menubarEnd()
Ends a menu bar. Always call this at the end of a menu bar started with `nk.menubar_begin`. Ends a menu bar. Always call this at the end of a menu bar started with `nk.menubarBegin`.
#### open = nk.menu_begin(title, [symbol](#symbols)/image, width, height) #### open = nk.menuBegin(title, [symbol](#symbols)/image, width, height)
#### open = nk.menu_begin(title, [symbol](#symbols)/image, width, height, [align](#alignment)) #### open = nk.menuBegin(title, [symbol](#symbols)/image, width, height, [align](#alignment))
Start a menu of the given title and size. Optionally specify a [symbol](#symbols), image, and/or [alignment](#alignment). Start a menu of the given title and size. Optionally specify a [symbol](#symbols), image, and/or [alignment](#alignment).
Return `true` if the menu is open, and `false` otherwise. Return `true` if the menu is open, and `false` otherwise.
Be sure to call `nk.menu_end` when ending open menus. Be sure to call `nk.menuEnd` when ending open menus.
#### activated = nk.menu_item(title) #### activated = nk.menuItem(title)
#### activated = nk.menu_item(title, [symbol](#symbols)/image) #### activated = nk.menuItem(title, [symbol](#symbols)/image)
#### activated = nk.menu_item(title, [symbol](#symbols)/image, [align](#alignment)) #### activated = nk.menuItem(title, [symbol](#symbols)/image, [align](#alignment))
Add a menu item to the current menu. Optionally specify a [symbol](#symbols), image, and/or [alignment](#alignment). Add a menu item to the current menu. Optionally specify a [symbol](#symbols), image, and/or [alignment](#alignment).
Return `true` if the menu item is activated, and `false` otherwise. Return `true` if the menu item is activated, and `false` otherwise.
#### nk.menu_close() #### nk.menuClose()
Close the current menu. Close the current menu.
#### nk.menu_end() #### nk.menuEnd()
End the current menu. Always call this at the end of any open menu. End the current menu. Always call this at the end of any open menu.
### General ### General
@ -360,23 +360,23 @@ Add a button with a title and/or a [color](#colors), [symbol](#symbols), or imag
Return `true` if activated, and `false` otherwise. Return `true` if activated, and `false` otherwise.
#### nk.button_set_behavior('default'/'repeater') #### nk.buttonSetBehavior('default'/'repeater')
Sets whether a button is activated once per click (`'default'`) or every frame held down (`'repeater'`). Sets whether a button is activated once per click (`'default'`) or every frame held down (`'repeater'`).
#### nk.button_push_behavior('default'/'repeater') #### nk.buttonPushBehavior('default'/'repeater')
Push button behavior. Push button behavior.
#### nk.button_pop_behavior() #### nk.buttonPopBehavior()
Pop button behavior. Pop button behavior.
#### active = nk.checkbox(text, active) #### active = nk.checkbox(text, active)
#### changed = nk.checkbox(text, value_table) #### changed = nk.checkbox(text, valueTable)
Add a checkbox with the given title. Either specify a boolean state `active`, in which case the function returns the new state, or specify a table with a boolean field called `value`, in which case the value is updated and the function returns `true` on toggled, and `false` otherwise. Add a checkbox with the given title. Either specify a boolean state `active`, in which case the function returns the new state, or specify a table with a boolean field called `value`, in which case the value is updated and the function returns `true` on toggled, and `false` otherwise.
#### selection = nk.radio(text, selection) #### selection = nk.radio(text, selection)
#### selection = nk.radio(name, text, selection) #### selection = nk.radio(name, text, selection)
#### changed = nk.radio(text, value_table) #### changed = nk.radio(text, valueTable)
#### changed = nk.radio(name, text, value_table) #### changed = nk.radio(name, text, valueTable)
Add a radio button with the given name and/or title. The title is displayed to the user while the name is used to report which button is selected. By default, the name is the same as the title. Add a radio button with the given name and/or title. The title is displayed to the user while the name is used to report which button is selected. By default, the name is the same as the title.
If called with a string `selection`, the function returns the new `selection`, which should be the `name` of a radio button. If called with a table that has a string field `value`, the `value` gets updated and the function returns `true` on selection change and `false` otherwise. If called with a string `selection`, the function returns the new `selection`, which should be the `name` of a radio button. If called with a table that has a string field `value`, the `value` gets updated and the function returns `true` on selection change and `false` otherwise.
@ -384,104 +384,104 @@ If called with a string `selection`, the function returns the new `selection`, w
#### selected = nk.selectable(text, selected) #### selected = nk.selectable(text, selected)
#### selected = nk.selectable(text, image, selected) #### selected = nk.selectable(text, image, selected)
#### selected = nk.selectable(text, image, [align](#alignment), selected) #### selected = nk.selectable(text, image, [align](#alignment), selected)
#### changed = nk.selectable(text, value_table) #### changed = nk.selectable(text, valueTable)
#### changed = nk.selectable(text, image, value_table) #### changed = nk.selectable(text, image, valueTable)
#### changed = nk.selectable(text, image, [align](#alignment), value_table) #### changed = nk.selectable(text, image, [align](#alignment), valueTable)
Add a selectable item with the given text and/or image and [alignment](#alignment). Add a selectable item with the given text and/or image and [alignment](#alignment).
If given a boolean `selected`, return the new state of `selected`. If given a table with a boolean field named `value` instead, the field gets updated and the function returns `true` on a change and `false` otherwise. If given a boolean `selected`, return the new state of `selected`. If given a table with a boolean field named `value` instead, the field gets updated and the function returns `true` on a change and `false` otherwise.
#### current = nk.slider(min, current, max, step) #### current = nk.slider(min, current, max, step)
#### changed = nk.slider(min, value_table, max, step) #### changed = nk.slider(min, valueTable, max, step)
Add a slider widget with the given range and step size. Add a slider widget with the given range and step size.
If given a number `current`, return the new `current` value. If given a table with a number field named `value` instead, the field gets updated and the function returns `true` on a change and `false` otherwise. If given a number `current`, return the new `current` value. If given a table with a number field named `value` instead, the field gets updated and the function returns `true` on a change and `false` otherwise.
#### current = nk.progress(current, max) #### current = nk.progress(current, max)
#### current = nk.progress(current, max, modifiable) #### current = nk.progress(current, max, modifiable)
#### changed nk.progress(value_table, max) #### changed nk.progress(valueTable, max)
#### changed = nk.progress(value_table, max, modifiable) #### changed = nk.progress(valueTable, max, modifiable)
Add a progress widget, optionally making it modifiable. Add a progress widget, optionally making it modifiable.
If given a number `current`, return the new `current` value. If given a table with a number field named `value` instead, the field gets updated and the function returns `true` on a change and `false` otherwise. If given a number `current`, return the new `current` value. If given a table with a number field named `value` instead, the field gets updated and the function returns `true` on a change and `false` otherwise.
#### [color](#colors) = nk.color_picker([color](#colors)) #### [color](#colors) = nk.colorPicker([color](#colors))
#### [color](#colors) = nk.color_picker([color](#colors), 'RGB'/'RGBA') #### [color](#colors) = nk.colorPicker([color](#colors), 'RGB'/'RGBA')
#### changed = nk.color_picker(value_table) #### changed = nk.colorPicker(valueTable)
#### changed = nk.color_picker(value_table, 'RGB'/'RGBA') #### changed = nk.colorPicker(valueTable, 'RGB'/'RGBA')
Add a color picker widget, optionally specifying format (default 'RGB', no alpha). Add a color picker widget, optionally specifying format (default 'RGB', no alpha).
If given a `[color](#colors)` string, return the new `[color](#colors)`. If given a table with a [color](#colors) string field named `value` instead, the field gets updated and the function returns `true` on change and `false` otherwise. If given a `[color](#colors)` string, return the new `[color](#colors)`. If given a table with a [color](#colors) string field named `value` instead, the field gets updated and the function returns `true` on change and `false` otherwise.
#### current = nk.property(name, min, current, max, step, inc_per_pixel) #### current = nk.property(name, min, current, max, step, incPerPixel)
#### changed = nk.property(name, min, value_table, max, step, inc_per_pixel) #### changed = nk.property(name, min, valueTable, max, step, incPerPixel)
Add a property widget, which is a named number variable. Specify the range, step, and sensitivity. Add a property widget, which is a named number variable. Specify the range, step, and sensitivity.
If given a number `current`, return the new `current`. If given a table with a number field named `value` instead, the field gets updated and the function returns `true` on change and `false` otherwise. If given a number `current`, return the new `current`. If given a table with a number field named `value` instead, the field gets updated and the function returns `true` on change and `false` otherwise.
#### state, changed = nk.edit('simple'/'field'/'box', value_table) #### state, changed = nk.edit('simple'/'field'/'box', valueTable)
Add an editable text field widget. The first argument defines the type of editor to use: single line 'simple' and 'field', or multi-line 'box'. The `value_table` should be a table with a string field named `value`. The field gets updated and the function returns the edit state (one of 'commited'/'activated'/'deactivated'/'active'/'inactive') followed by `true` if the text changed or `false` if the text remained the same. Add an editable text field widget. The first argument defines the type of editor to use: single line 'simple' and 'field', or multi-line 'box'. The `valueTable` should be a table with a string field named `value`. The field gets updated and the function returns the edit state (one of 'commited'/'activated'/'deactivated'/'active'/'inactive') followed by `true` if the text changed or `false` if the text remained the same.
#### index = nk.combobox(index, items) #### index = nk.combobox(index, items)
#### index = nk.combobox(index, items, item_height) #### index = nk.combobox(index, items, itemHeight)
#### index = nk.combobox(index, items, item_height, width) #### index = nk.combobox(index, items, itemHeight, width)
#### index = nk.combobox(index, items, item_height, width, height) #### index = nk.combobox(index, items, itemHeight, width, height)
#### changed = nk.combobox(value_table, items) #### changed = nk.combobox(valueTable, items)
#### changed = nk.combobox(value_table, items, item_height) #### changed = nk.combobox(valueTable, items, itemHeight)
#### changed = nk.combobox(value_table, items, item_height, width) #### changed = nk.combobox(valueTable, items, itemHeight, width)
#### changed = nk.combobox(value_table, items, item_height, width, height) #### changed = nk.combobox(valueTable, items, itemHeight, width, height)
Add a drop-down combobox widget. `items` should be an array of strings. `item_height` defaults to the widget height, `width` defaults to widget width, and `height` defaults to a sensible value based on `item_height`. Add a drop-down combobox widget. `items` should be an array of strings. `itemHeight` defaults to the widget height, `width` defaults to widget width, and `height` defaults to a sensible value based on `itemHeight`.
If a number `index` is specified, then the function returns the new selected `index`. If a table with a number field `value` is given instead, then the field gets updated with the currently selected index and the function returns `true` on change and `false` otherwise. If a number `index` is specified, then the function returns the new selected `index`. If a table with a number field `value` is given instead, then the field gets updated with the currently selected index and the function returns `true` on change and `false` otherwise.
#### open = nk.combobox_begin(text) #### open = nk.comboboxBegin(text)
#### open = nk.combobox_begin(text, [color](#colors)/[symbol](#symbols)/image) #### open = nk.comboboxBegin(text, [color](#colors)/[symbol](#symbols)/image)
#### open = nk.combobox_begin(text, [color](#colors)/[symbol](#symbols)/image, width) #### open = nk.comboboxBegin(text, [color](#colors)/[symbol](#symbols)/image, width)
#### open = nk.combobox_begin(text, [color](#colors)/[symbol](#symbols)/image, width, height) #### open = nk.comboboxBegin(text, [color](#colors)/[symbol](#symbols)/image, width, height)
Start a combobox widget. This form gives complete control over the drop-down list (it's treated like a new window). [Color](#colors)/[symbol](#symbols)/image defaults to none, while width and height default to sensible values based on widget bounds. Start a combobox widget. This form gives complete control over the drop-down list (it's treated like a new window). [Color](#colors)/[symbol](#symbols)/image defaults to none, while width and height default to sensible values based on widget bounds.
Remember to call `nk.combobox_end` if the combobox is open. Remember to call `nk.comboboxEnd` if the combobox is open.
#### activated = nk.combobox_item(text, [symbol](#symbols)/image, [align](#alignment)) #### activated = nk.comboboxItem(text, [symbol](#symbols)/image, [align](#alignment))
#### activated = nk.combobox_item(text, [symbol](#symbols)/image) #### activated = nk.comboboxItem(text, [symbol](#symbols)/image)
#### activated = nk.combobox_item(text) #### activated = nk.comboboxItem(text)
Add a combobox item, optionally specifying a [symbol](#symbols), image, and/or [alignment](#alignment). Add a combobox item, optionally specifying a [symbol](#symbols), image, and/or [alignment](#alignment).
Return `true` if the item is activated, and `false` otherwise. Return `true` if the item is activated, and `false` otherwise.
#### nk.combobox_close() #### nk.comboboxClose()
Close the current combobox. Close the current combobox.
#### nk.combobox_end() #### nk.comboboxEnd()
End the current combobox. Always call this at the end of open comboboxes. End the current combobox. Always call this at the end of open comboboxes.
### Utilities ### Utilities
#### x, y, width, height = nk.widget_bounds() #### x, y, width, height = nk.widgetBounds()
Return the bounds of the current widget. Return the bounds of the current widget.
#### x, y = nk.widget_position() #### x, y = nk.widgetPosition()
Return the position of the current widget. Return the position of the current widget.
#### width, height = nk.widget_size() #### width, height = nk.widgetSize()
Return the size of the current widget. Return the size of the current widget.
#### width = nk.widget_width() #### width = nk.widgetWidth()
Return the width of the current widget. Return the width of the current widget.
#### height = nk.widget_height() #### height = nk.widgetHeight()
Return the height of the current widget. Return the height of the current widget.
#### hovered = nk.widget_is_hovered() #### hovered = nk.widgetIsHovered()
Return `true` if the widget is hovered by the mouse, and `false` otherwise. Return `true` if the widget is hovered by the mouse, and `false` otherwise.
#### clicked = nk.widget_is_mouse_clicked() #### clicked = nk.widgetIsMouseClicked()
#### clicked = nk.widget_is_mouse_clicked(button) #### clicked = nk.widgetIsMouseClicked(button)
Return `true` if the widget was just clicked by the given mouse button ('left'/'right'/'middle', defaults to 'left'), and `false` otherwise. Return `true` if the widget was just clicked by the given mouse button ('left'/'right'/'middle', defaults to 'left'), and `false` otherwise.
#### has_click = nk.widget_has_mouse_click() #### hasClick = nk.widgetHasMouseClick()
#### has_click = nk.widget_has_mouse_click(button) #### hasClick = nk.widgetHasMouseClick(button)
#### has_click = nk.widget_has_mouse_click(button, down) #### hasClick = nk.widgetHasMouseClick(button, down)
Returns `true` if the given mouse button is in the given state on the current widget, and `false` otherwise. `button` defaults to 'left', and `down` defaults to `true`. Returns `true` if the given mouse button is in the given state on the current widget, and `false` otherwise. `button` defaults to 'left', and `down` defaults to `true`.
#### nk.spacing(cols) #### nk.spacing(cols)
@ -522,29 +522,29 @@ Some widgets accept alignment arguments for text, symbols, and/or images. Here i
### Colors ### Colors
Some styles and widgets accept a "color string" parameter. This is a string of the format '#RRGGBB' or '#RRGGBBAA', where RR, GG, BB, and AA are each a byte in hexadecimal. Either use these strings directly or convert to and from the string format via the following functions. Some styles and widgets accept a "color string" parameter. This is a string of the format '#RRGGBB' or '#RRGGBBAA', where RR, GG, BB, and AA are each a byte in hexadecimal. Either use these strings directly or convert to and from the string format via the following functions.
#### color = nk.color_rgba(r, g, b) #### color = nk.colorRGBA(r, g, b)
#### color = nk.color_rgba(r, g, b, a) #### color = nk.colorRGBA(r, g, b, a)
Construct a color string from the given components (each from 0 to 255). Alpha (`a`) defaults to 255. Construct a color string from the given components (each from 0 to 255). Alpha (`a`) defaults to 255.
#### color = nk.color_hsva(h, s, v) #### color = nk.colorHSVA(h, s, v)
#### color = nk.color_hsva(h, s, v, a) #### color = nk.colorHSVA(h, s, v, a)
Construct a color string from the given components (each from 0 to 255). Alpha (`a`) defaults to 255. Construct a color string from the given components (each from 0 to 255). Alpha (`a`) defaults to 255.
#### r, g, b, a = nk.color_parse_rgba(color) #### r, g, b, a = nk.colorParseRGBA(color)
Split a color string into its number components. Split a color string into its number components.
#### h, s, v, a = nk.color_parse_hsva(color) #### h, s, v, a = nk.colorParseHSVA(color)
Split a color string into its number components. Split a color string into its number components.
#### nk.style_default() #### nk.styleDefault()
Reset color styles to their default values. Reset color styles to their default values.
#### nk.style_load_colors(color_table) #### nk.styleLoadColors(colorTable)
Load a color table for quick color styling. Load a color table for quick color styling.
Below is the default color table. Custom color tables must provide all of the same fields. Below is the default color table. Custom color tables must provide all of the same fields.
```lua ```lua
local color_table = { local colorTable = {
['text'] = '#afafaf', ['text'] = '#afafaf',
['window'] = '#2d2d2d', ['window'] = '#2d2d2d',
['header'] = '#282828', ['header'] = '#282828',
@ -580,17 +580,17 @@ local color_table = {
For finer-grained control over styles, including custom image-based skinning, Nuklear provides a wide arrangement of style items. For finer-grained control over styles, including custom image-based skinning, Nuklear provides a wide arrangement of style items.
#### nk.style_set_font(font) #### nk.styleSetFont(font)
Set the current font. Set the current font.
See [LÖVE Font](https://love2d.org/wiki/Font). See [LÖVE Font](https://love2d.org/wiki/Font).
#### nk.style_push(style) #### nk.stylePush(style)
Push any number of [style items](#style-items) onto the style stack. Push any number of [style items](#style-items) onto the style stack.
Example (see [skin.lua](https://github.com/keharriso/love-nuklear/blob/master/example/skin.lua)): Example (see [skin.lua](https://github.com/keharriso/love-nuklear/blob/master/example/skin.lua)):
```lua ```lua
nk.style_push { nk.stylePush {
['text'] = { ['text'] = {
['color'] = '#000000' ['color'] = '#000000'
}, },
@ -606,7 +606,7 @@ nk.style_push {
} }
``` ```
#### nk.style_pop() #### nk.stylePop()
Pop the most recently pushed style. Pop the most recently pushed style.
### Style Items ### Style Items