Gui
Immediate-mode GUI backed by Nuklear via a Vulkan backend. Call all GUI methods each frame from update(dt). All methods are static.
Windows
Section titled “Windows”Gui.beginWindow(title, x, y, w, h)
Section titled “Gui.beginWindow(title, x, y, w, h)”Returns: Bool — true 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.
Gui.endWindow()
Section titled “Gui.endWindow()”End the current window. Must be called once per beginWindow/beginWindowEx.
Window management
Section titled “Window management”| Method | Description |
|---|---|
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 |
Layout
Section titled “Layout”Gui.layoutRowDynamic(height, cols)
Section titled “Gui.layoutRowDynamic(height, cols)”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 colsGui.layoutRowPush(0.3) // 30% wideGui.label("Name:")Gui.layoutRowPush(0.7) // 70% wide_name = Gui.editString(_name, 64)Gui.layoutRowEnd()Row template
Section titled “Row template”layoutRowTemplateBegin(height) / layoutRowTemplatePushDynamic() / layoutRowTemplatePushVariable(minWidth) / layoutRowTemplatePushStatic(width) / layoutRowTemplateEnd() — Define column types in a template then repeat it.
Space layout
Section titled “Space layout”layoutSpaceBegin(format, height, count) / layoutSpacePush(x, y, w, h) / layoutSpaceEnd() — Place each widget at an explicit rectangle within the layout space.
Other layout helpers
Section titled “Other layout helpers”| Method | Description |
|---|---|
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 |
Separator
Section titled “Separator”Gui.separator(r, g, b, a, rounded)
Section titled “Gui.separator(r, g, b, a, rounded)”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)Labels
Section titled “Labels”| Method | Description |
|---|---|
All color parameters in label methods are 0–255 integers. |
| Method | Description |
|---|---|
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)Buttons
Section titled “Buttons”| Method | Returns | Description |
|---|---|---|
buttonLabel(text) | Bool | Standard text button |
buttonColor(r, g, b, a) | Bool | Solid color button (colors 0–255) |
buttonSymbol(symbol) | Bool | Icon-only button (Nuklear symbol constant) |
buttonSymbolLabel(symbol, text, align) | Bool | Icon + label |
buttonSetBehavior(behavior) | — | 0 = default (click), 1 = repeater (held fires every frame) |
if (Gui.buttonLabel("Save")) saveGame()if (Gui.buttonLabel("Quit")) quit()Checkbox & radio
Section titled “Checkbox & radio”Gui.checkbox(label, active)
Section titled “Gui.checkbox(label, active)”Returns: Bool — New active state (toggle when clicked).
_fullscreen = Gui.checkbox("Fullscreen", _fullscreen)if (_fullscreen != _prevFullscreen) { Window.setFullscreen(_fullscreen)}Gui.radio(label, active)
Section titled “Gui.radio(label, active)”Returns: Bool — true if this radio was just selected.
Selectable
Section titled “Selectable”Gui.selectableLabel(text, align, selected)
Section titled “Gui.selectableLabel(text, align, selected)”Returns: Bool — New selected state.
Sliders
Section titled “Sliders”Gui.sliderFloat(min, value, max, step)
Section titled “Gui.sliderFloat(min, value, max, step)”Returns: Num — New value after user interaction.
_volume = Gui.sliderFloat(0, _volume, 1, 0.01)Audio.setVolume(_volume)Gui.sliderInt(min, value, max, step)
Section titled “Gui.sliderInt(min, value, max, step)”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.
Progress
Section titled “Progress”Gui.progress(current, max, modifiable)
Section titled “Gui.progress(current, max, modifiable)”Returns: Num — Updated value (unchanged unless modifiable is true). Displays a horizontal progress bar.
_progress = Gui.progress(_progress, 100, true)Property widgets
Section titled “Property widgets”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.
Edit / input
Section titled “Edit / input”Gui.editString(currentText, maxLen)
Section titled “Gui.editString(currentText, maxLen)”Returns: String — Current (possibly edited) text. Pass the returned value back each frame.
_widthStr = Gui.editString(_widthStr, 8)Gui.lastEditCommitted()
Section titled “Gui.lastEditCommitted()”Returns: Bool — true 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.
Gui.editFocus()
Section titled “Gui.editFocus()”Give keyboard focus to the next edit widget.
Color picker
Section titled “Color picker”Gui.colorPicker(r, g, b, a, format)
Section titled “Gui.colorPicker(r, g, b, a, format)”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]Combo / dropdown
Section titled “Combo / dropdown”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()}| Method | Returns | Description |
|---|---|---|
comboBeginLabel(label, w, h) | Bool | Open a combo with a text label |
comboBeginColor(r, g, b, a, w, h) | Bool | Open a combo with a color swatch (colors 0–255) |
comboBeginSymbol(symbol, w, h) | Bool | Open a combo with an icon |
comboItemLabel(text, align) | Bool | Item row; returns true when selected |
comboItemSymbolLabel(symbol, text, align) | Bool | Icon + text item |
comboClose() | — | Close the combo programmatically |
comboEnd() | — | End combo; must be called if comboBegin* returned true |
Groups
Section titled “Groups”Groups are scrollable sub-regions inside a window.
if (Gui.beginGroup("Inventory", 0)) { // flags=0 // ...widgets... Gui.endGroup()}| Method | Description |
|---|---|
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
Section titled “Popups”Popups are modal/non-modal overlay panels.
| Method | Returns | Description |
|---|---|---|
popupBegin(type, title, flags, x, y, w, h) | Bool | type: 0=static (modal), 1=dynamic (non-modal) |
popupClose() | — | Close programmatically |
popupEnd() | — | End popup; only if popupBegin returned true |
popupGetScroll() | List [x, y] | Current scroll |
Tooltips
Section titled “Tooltips”| Method | Description |
|---|---|
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()| Method | Returns | Description |
|---|---|---|
menubarBegin() / menubarEnd() | — | Wrap all menu items |
menuBeginLabel(text, align, w, h) | Bool | Open a menu |
menuBeginSymbol(text, symbol, w, h) | Bool | Open a menu with icon |
menuItemLabel(text, align) | Bool | Item; true if selected |
menuItemSymbolLabel(symbol, text, align) | Bool | Icon + text item |
menuClose() | — | Close menu programmatically |
menuEnd() | — | End menu |
Contextual (right-click) menus
Section titled “Contextual (right-click) menus”if (Gui.contextualBegin(0, 150, 200, mouseX, mouseY, 0, 0)) { Gui.layoutRowDynamic(25, 1) if (Gui.contextualItemLabel("Delete", 0)) deleteSelected() Gui.contextualEnd()}| Method | Returns | Description |
|---|---|---|
contextualBegin(flags, w, h, trigX, trigY, trigW, trigH) | Bool | Open on right-click within trigger rect |
contextualItemLabel(text, align) | Bool | Item; true if selected |
contextualItemSymbolLabel(symbol, text, align) | Bool | Icon + text item |
contextualClose() | — | Close programmatically |
contextualEnd() | — | End contextual |
Charts
Section titled “Charts”Gui.chartBegin(0, _values.count, 0, 1) // 0 = line chartfor (v in _values) { Gui.chartPush(v)}Gui.chartEnd()| Method | Description |
|---|---|
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 |
Widget utilities
Section titled “Widget utilities”| Method | Returns | Description |
|---|---|---|
isWidgetHovered() | Bool | Mouse over last drawn widget |
isWidgetClicked(button) | Bool | button: 0=left, 1=middle, 2=right |
widgetBounds() | [x, y, w, h] | Bounds of the last drawn widget |
isAnyItemActive() | Bool | Any widget is being interacted with |
widgetDisableBegin() | — | Disable interaction for subsequent widgets |
widgetDisableEnd() | — | Re-enable interaction |
Custom drawing
Section titled “Custom drawing”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.
| Method | Description |
|---|---|
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 barGui.drawRectFilled(10, 10, 200, 16, 2, 50, 50, 50, 255)Gui.drawRectFilled(10, 10, 200 * (_health / 100), 16, 2, 30, 220, 60, 255)Theme & style
Section titled “Theme & style”| Method | Description |
|---|---|
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-255Gui.setRounding(4)Gui.setWindowAlpha(0.9) // 0-1Gui.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.