Skip to content

Gui

Immediate-mode GUI backed by Nuklear via a Vulkan backend. Call all GUI methods each frame from update(dt). All methods are static.

Returns: Booltrue if the window is visible. If false, skip content but still call endWindow().

Parameters: title (String), x/y/w/h (Num) — Position and size in pixels.

if (Gui.beginWindow("Settings", 10, 10, 300, 200)) {
Gui.layoutRowDynamic(22, 1)
Gui.label("Volume: %(volume)")
Gui.endWindow()
}

Gui.beginWindowEx(name, title, x, y, w, h, flags)

Section titled “Gui.beginWindowEx(name, title, x, y, w, h, flags)”

Extended window with a separate internal name (used by window-management functions) and flags (Num) for Nuklear NK_WINDOW_* flags.

End the current window. Must be called once per beginWindow/beginWindowEx.

MethodDescription
windowGetBounds()Returns [x, y, w, h] of the current window
windowGetContentRegion()Returns [x, y, w, h] of the usable content area
windowGetPosition()Returns [x, y]
windowGetSize()Returns [w, h]
windowGetScroll()Returns [xOffset, yOffset]
windowSetScroll(x, y)Set scroll position
windowSetFocus(name)Focus a named window
windowSetBounds(name, x, y, w, h)Reposition and resize a named window
windowSetPosition(name, x, y)Move a named window
windowCollapse(name, state)Collapse (1) or expand (0)
windowShow(name, state)Show (1) or hide (0)
windowClose(name)Close a named window
isWindowHovered()Bool — mouse is over the current window
isWindowFocused()Bool — current window has keyboard focus
isWindowCollapsed(name)Bool
isWindowClosed(name)Bool
isAnyWindowHovered()Bool — mouse is over any GUI window

Divide the row equally into cols dynamic columns at height pixels tall.

Gui.layoutRowDynamic(28, 4)
if (Gui.buttonLabel("7")) _calc.digit(7)
if (Gui.buttonLabel("8")) _calc.digit(8)

Gui.layoutRowStatic(height, itemWidth, cols)

Section titled “Gui.layoutRowStatic(height, itemWidth, cols)”

Fixed-width columns: each column is itemWidth pixels wide.

Gui.layoutRowBegin(format, height, cols) / Gui.layoutRowPush(value) / Gui.layoutRowEnd()

Section titled “Gui.layoutRowBegin(format, height, cols) / Gui.layoutRowPush(value) / Gui.layoutRowEnd()”

Manual column layout. format is 0 (static widths) or 1 (relative fractions). Push each column width/fraction with layoutRowPush then call layoutRowEnd.

Gui.layoutRowBegin(1, 30, 2) // ratio mode, 2 cols
Gui.layoutRowPush(0.3) // 30% wide
Gui.label("Name:")
Gui.layoutRowPush(0.7) // 70% wide
_name = Gui.editString(_name, 64)
Gui.layoutRowEnd()

layoutRowTemplateBegin(height) / layoutRowTemplatePushDynamic() / layoutRowTemplatePushVariable(minWidth) / layoutRowTemplatePushStatic(width) / layoutRowTemplateEnd() — Define column types in a template then repeat it.

layoutSpaceBegin(format, height, count) / layoutSpacePush(x, y, w, h) / layoutSpaceEnd() — Place each widget at an explicit rectangle within the layout space.

MethodDescription
layoutSetMinRowHeight(height)Set minimum row height
layoutResetMinRowHeight()Reset to default
layoutWidgetBounds()Returns [x, y, w, h] of next widget slot
spacing(cols)Skip cols layout cells

Draw a colored horizontal separator line. Colors are 0–255. rounded (Bool) — true for rounded ends, false for sharp.

Gui.separator(128, 128, 128, 60, true)

MethodDescription
All color parameters in label methods are 0–255 integers.
MethodDescription
label(text)Non-editable label (left-aligned)
labelColored(text, r, g, b, a)Colored label (colors 0–255)
labelWrap(text)Word-wrapping label
labelColoredWrap(text, r, g, b, a)Colored, wrapping label (colors 0–255)
labelAligned(text, align)Aligned label: 0x11 = left, 0x12 = centered, 0x14 = right
Gui.labelColored("ERROR: file not found", 255, 80, 80, 255)

MethodReturnsDescription
buttonLabel(text)BoolStandard text button
buttonColor(r, g, b, a)BoolSolid color button (colors 0–255)
buttonSymbol(symbol)BoolIcon-only button (Nuklear symbol constant)
buttonSymbolLabel(symbol, text, align)BoolIcon + label
buttonSetBehavior(behavior)0 = default (click), 1 = repeater (held fires every frame)
if (Gui.buttonLabel("Save")) saveGame()
if (Gui.buttonLabel("Quit")) quit()

Returns: Bool — New active state (toggle when clicked).

_fullscreen = Gui.checkbox("Fullscreen", _fullscreen)
if (_fullscreen != _prevFullscreen) {
Window.setFullscreen(_fullscreen)
}

Returns: Booltrue if this radio was just selected.


Gui.selectableLabel(text, align, selected)

Section titled “Gui.selectableLabel(text, align, selected)”

Returns: Bool — New selected state.


Returns: Num — New value after user interaction.

_volume = Gui.sliderFloat(0, _volume, 1, 0.01)
Audio.setVolume(_volume)

Returns: Num — New integer value.


Gui.knobFloat(min, value, max, step, zeroDir, deadZone)

Section titled “Gui.knobFloat(min, value, max, step, zeroDir, deadZone)”

Returns: Num — New value. zeroDir sets where “zero” appears on the knob dial (0 = up, 1 = right, 2 = down, 3 = left). deadZone is a small radian threshold around the zero to reduce jitter.

Gui.knobInt(min, value, max, step, zeroDir, deadZone)

Section titled “Gui.knobInt(min, value, max, step, zeroDir, deadZone)”

Returns: Num — New integer value.


Returns: Num — Updated value (unchanged unless modifiable is true). Displays a horizontal progress bar.

_progress = Gui.progress(_progress, 100, true)

Gui.propertyFloat(name, min, value, max, step, incPerPixel)

Section titled “Gui.propertyFloat(name, min, value, max, step, incPerPixel)”

Returns: Num — New value. Labeled numeric property with click-drag editing.

Gui.propertyInt(name, min, value, max, step, incPerPixel)

Section titled “Gui.propertyInt(name, min, value, max, step, incPerPixel)”

Returns: Num — New integer value.


Returns: String — Current (possibly edited) text. Pass the returned value back each frame.

_widthStr = Gui.editString(_widthStr, 8)

Returns: Booltrue if the last edit field was submitted (Enter or focus lost).

Gui.editStringFiltered(text, maxLen, filter)

Section titled “Gui.editStringFiltered(text, maxLen, filter)”

Returns: String — Text with a custom filter applied. filter is a string of allowed characters.

Give keyboard focus to the next edit widget.


Returns: List[r, g, b, a] (0–255). format is 0 for RGB, 1 for RGBA, 2 for HSV. Pass the returned values back as inputs next frame.

var result = Gui.colorPicker(_r, _g, _b, _a, 1)
_r = result[0]
_g = result[1]
_b = result[2]
_a = result[3]

if (Gui.comboBeginLabel(_items[_selected], 150, 200)) {
Gui.layoutRowDynamic(20, 1)
for (item in _items) {
if (Gui.comboItemLabel(item, 0)) _selected = _items.indexOf(item)
}
Gui.comboEnd()
}
MethodReturnsDescription
comboBeginLabel(label, w, h)BoolOpen a combo with a text label
comboBeginColor(r, g, b, a, w, h)BoolOpen a combo with a color swatch (colors 0–255)
comboBeginSymbol(symbol, w, h)BoolOpen a combo with an icon
comboItemLabel(text, align)BoolItem row; returns true when selected
comboItemSymbolLabel(symbol, text, align)BoolIcon + text item
comboClose()Close the combo programmatically
comboEnd()End combo; must be called if comboBegin* returned true

Groups are scrollable sub-regions inside a window.

if (Gui.beginGroup("Inventory", 0)) { // flags=0
// ...widgets...
Gui.endGroup()
}
MethodDescription
beginGroup(title, flags)Start a group with a title
beginGroupTitled(name, title, flags)Group with separate name and title
endGroup()End the current group
groupGetScroll(id)Returns [xOffset, yOffset] for a named group
groupSetScroll(id, x, y)Set scroll position of a named group

Gui.treePush(type, title, state) / Gui.treePop()

Section titled “Gui.treePush(type, title, state) / Gui.treePop()”

type: 0 = node (collapsible branch), 1 = tab (tab-style). state: 0 = minimized, 1 = maximized (initial open state). Returns Bool; call treePop() only if true.

if (Gui.treePush(0, "Options", 1)) {
Gui.layoutRowDynamic(20, 1)
_sound = Gui.checkbox("Sound", _sound)
Gui.treePop()
}

Popups are modal/non-modal overlay panels.

MethodReturnsDescription
popupBegin(type, title, flags, x, y, w, h)Booltype: 0=static (modal), 1=dynamic (non-modal)
popupClose()Close programmatically
popupEnd()End popup; only if popupBegin returned true
popupGetScroll()List [x, y]Current scroll

MethodDescription
tooltip(text)Show a simple text tooltip on hover
tooltipBegin(width)Begin a custom-content tooltip
tooltipEnd()End the tooltip

Gui.menubarBegin()
if (Gui.menuBeginLabel("File", 0, 120, 200)) {
Gui.layoutRowDynamic(25, 1)
if (Gui.menuItemLabel("New", 0)) newFile()
if (Gui.menuItemLabel("Save", 0)) saveFile()
Gui.menuClose()
Gui.menuEnd()
}
Gui.menubarEnd()
MethodReturnsDescription
menubarBegin() / menubarEnd()Wrap all menu items
menuBeginLabel(text, align, w, h)BoolOpen a menu
menuBeginSymbol(text, symbol, w, h)BoolOpen a menu with icon
menuItemLabel(text, align)BoolItem; true if selected
menuItemSymbolLabel(symbol, text, align)BoolIcon + text item
menuClose()Close menu programmatically
menuEnd()End menu

if (Gui.contextualBegin(0, 150, 200, mouseX, mouseY, 0, 0)) {
Gui.layoutRowDynamic(25, 1)
if (Gui.contextualItemLabel("Delete", 0)) deleteSelected()
Gui.contextualEnd()
}
MethodReturnsDescription
contextualBegin(flags, w, h, trigX, trigY, trigW, trigH)BoolOpen on right-click within trigger rect
contextualItemLabel(text, align)BoolItem; true if selected
contextualItemSymbolLabel(symbol, text, align)BoolIcon + text item
contextualClose()Close programmatically
contextualEnd()End contextual

Gui.chartBegin(0, _values.count, 0, 1) // 0 = line chart
for (v in _values) {
Gui.chartPush(v)
}
Gui.chartEnd()
MethodDescription
chartBegin(type, count, min, max)type: 0=lines, 1=column. count = number of data points
chartBeginColored(type, r, g, b, a, ar, ag, ab, aa, count, min, max)Same with custom main and highlight colors (0–255)
chartPush(value)Add one data point
chartEnd()End chart

MethodReturnsDescription
isWidgetHovered()BoolMouse over last drawn widget
isWidgetClicked(button)Boolbutton: 0=left, 1=middle, 2=right
widgetBounds()[x, y, w, h]Bounds of the last drawn widget
isAnyItemActive()BoolAny widget is being interacted with
widgetDisableBegin()Disable interaction for subsequent widgets
widgetDisableEnd()Re-enable interaction

Draw directly into the current window using Nuklear’s canvas commands. All coordinates are window-local. All color parameters are r, g, b, a in 0–255 integers.

MethodDescription
drawLine(x0, y0, x1, y1, thickness, r, g, b, a)Thick line segment
drawRect(x, y, w, h, rounding, thickness, r, g, b, a)Outlined rectangle (rounding = corner radius px)
drawRectFilled(x, y, w, h, rounding, r, g, b, a)Filled rectangle
drawCircle(x, y, w, h, thickness, r, g, b, a)Outlined ellipse
drawCircleFilled(x, y, w, h, r, g, b, a)Filled ellipse
drawTriangleFilled(x0, y0, x1, y1, x2, y2, r, g, b, a)Filled triangle
drawArc(cx, cy, radius, aMin, aMax, thickness, r, g, b, a)Arc stroke
drawArcFilled(cx, cy, radius, aMin, aMax, r, g, b, a)Filled arc/pie
drawText(x, y, w, h, text, r, g, b, a)Text at position
drawCurve(x0, y0, x1, y1, x2, y2, x3, y3, thickness, r, g, b, a)Cubic bezier curve
// Draw a health bar
Gui.drawRectFilled(10, 10, 200, 16, 2, 50, 50, 50, 255)
Gui.drawRectFilled(10, 10, 200 * (_health / 100), 16, 2, 30, 220, 60, 255)

MethodDescription
setTheme(name)"dark" or "light" — switch the built-in theme
setAccentColor(r, g, b)Override the primary accent color (0–255)
setRounding(pixels)Corner rounding for buttons and windows
setWindowAlpha(alpha)Window background opacity (0–1)
setFont(name, size)Switch to a loaded font by name at the given point size
setFontSize(size)Change size of the current font
loadFont(path, size, name)Load a TTF font from path, at size points, and register it as name
Gui.setTheme("dark")
Gui.setAccentColor(0, 122, 255) // 0-255
Gui.setRounding(4)
Gui.setWindowAlpha(0.9) // 0-1
Gui.loadFont("fonts/inter.ttf", 16, "inter")
Gui.setFont("inter", 16)

See Examples → GUI Overview for a minimal example, GUI Terminal for the in-game terminal and #!command attributes, and GUI Configurator for full Window API integration.