nuklear

Nuklear immediate-mode GUI library bindings for Kit

Files

FileDescription
.editorconfigEditor formatting configuration
.gitignoreGit ignore rules for build artifacts and dependencies
.tool-versionsasdf tool versions (Zig, Kit)
LICENSEMIT license file
README.mdThis file
c/kit_nuklear.cC FFI wrapper, SDL renderer, and command-buffer accessors
c/kit_nuklear.hC header for the FFI wrapper
c/nuklear.hVendored Nuklear single-header library
docs/screenshots/PNG screenshots of each example, embedded in the Screenshots section
examples/chart.kitLine / column chart demo with hover & click events
examples/color-picker.kitColor picker, hex parsing, HSV→RGB ramp
examples/combo.kitCombo box variants, selectable list, tree node
examples/custom-canvas.kitStroke / fill primitives on the window canvas
examples/demo.kitWidget demo with buttons, sliders, progress, checkbox, options
examples/edit.kitText input fields with filters and event flags
examples/knobs-symbols.kitKnobs, symbol buttons, disabled-widget blocks
examples/layout-templates.kitlayout-row-template-*, layout-space, properties
examples/popup-menu.kitMenubar, popup, contextual menu, custom tooltip
examples/sdl-demo.kitSDL integration demo with input forwarding
examples/simple.kitMinimal SDL-backed Nuklear example
examples/style-themes.kitTheme switching and per-slot style overrides
kit.tomlPackage manifest with metadata, native build settings, and tasks
src/nuklear.kitEntry point — re-export hub that aggregates every topic module below
src/context.kitinit, free, clear
src/window.kitWindow flags, text alignment, begin?/end, window queries
src/layout.kitlayout-row-*, layout-space-*, widget bounds, widget-disable-*, spacing
src/widget.kitLabels, buttons, symbols, check/option/selectable, sliders, knobs, properties, groups, tree
src/chart.kitLine / column charts and chart event flags
src/input.kitinput-* event feeders, input queries, mouse-button and key constants
src/draw.kitrender-sdl, command iteration, stroke-* / fill-* canvas primitives
src/menu.kitPopups, tooltips, menus, combos, contextual (right-click) menus
src/edit.kitText input — edit-buffer-*, edit flags, input filters
src/style.kitColor utilities (color-pack, hex, HSV), style slots, built-in themes
tests/module-structure.test.kitExport and constant tests across every category
tests/nuklear.test.kitImport smoke test

Dependencies

No Kit package dependencies.

Native dependencies:

DependencyPurpose
SDL2Windowing and renderer integration for examples and render-sdl
SDL2_ttfFont initialization used by the C wrapper

Install native dependencies on macOS:

brew install sdl2 sdl2_ttf

Install native dependencies on Ubuntu:

sudo apt-get install libsdl2-dev libsdl2-ttf-dev

Installation

kit add gitlab.com/kit-lang/packages/kit-nuklear.git

Usage

import Kit.Nuklear as Nk
import Kit.SDL as SDL

main = fn =>
  match SDL.init
    | Ok _ ->
      defer SDL.quit
      match SDL.create-window "Nuklear App" 640 480
        | Ok window ->
          defer SDL.destroy-window window
          match SDL.create-renderer window
            | Ok renderer ->
              defer SDL.destroy-renderer renderer

              ctx = Nk.init 65536
              defer Nk.free ctx

              Nk.input-begin ctx
              # Feed SDL events here with Nk.input-motion, Nk.input-button,
              # Nk.input-scroll, Nk.input-key, Nk.input-char/unicode.
              Nk.input-end ctx

              flags = Int.bit-or (Nk.flag-border) (Nk.flag-title)
              if Nk.begin? ctx "Demo" 50.0 50.0 240.0 160.0 flags then
                Nk.layout-row-dynamic ctx 30.0 1
                Nk.label ctx "Hello from Nuklear" Nk.text-centered
                if Nk.button-label? ctx "Click me" then
                  println "Button clicked"
                else
                  no-op
                Nk.end ctx
              else
                Nk.end ctx

              SDL.set-draw-color renderer 30 30 30 255
              SDL.clear renderer
              Nk.render-sdl ctx renderer.ptr
              SDL.present renderer
              Nk.clear ctx
            | Err err -> println "Renderer error: ${err}"
        | Err err -> println "Window error: ${err}"
    | Err err -> println "SDL init error: ${err}"

main

API Overview

Context management

  • init, free, clear

Window

  • begin?, end
  • Existence / state: window-is-closed?, window-is-hidden?, window-is-collapsed?, window-is-active?, window-is-any-hovered?, window-has-focus?, window-is-hovered?, item-is-any-active?
  • Manipulation: window-close, window-collapse, window-show, window-set-position, window-set-size, window-set-focus
  • Queries: window-get-x, window-get-y, window-get-width, window-get-height, window-content-{x,y,width,height}, window-get-scroll-{x,y}, window-set-scroll

Layout

  • Rows: layout-row-dynamic, layout-row-static, layout-row-begin, layout-row-push, layout-row-end, spacing
  • Templates: layout-row-template-begin, layout-row-template-push-{dynamic,variable,static}, layout-row-template-end
  • Free positioning: layout-space-begin, layout-space-push, layout-space-end
  • Min row height: layout-set-min-row-height, layout-reset-min-row-height
  • Visual rule: rule-horizontal

Widget queries

  • Geometry: widget-bounds-{x,y,w,h}, widget-{width,height}, widget-position-{x,y}
  • State: widget-is-hovered?, widget-is-mouse-clicked?
  • Disabling: widget-disable-begin, widget-disable-end

Text / labels

  • label, label-colored, label-wrap, label-colored-wrap, text

Buttons

  • button-label?, button-text?, button-color?, button-symbol?, button-symbol-label?, button-set-behavior

Symbolssymbol-{none,x,underscore,circle-solid,circle-outline,rect-solid,rect-outline,triangle-up,triangle-down,triangle-left,triangle-right,triangle-up-outline,triangle-down-outline,triangle-left-outline,triangle-right-outline,plus,minus}

Checkboxes / options / selectable

  • check-label?, option-label?, selectable-label?

Sliders, progress, knobs, properties

  • slide-float, slide-int, prog, knob-float, knob-int, propertyi, propertyf
  • Knob headings: heading-{up,right,down,left}

Color picker & utilities

  • color-picker
  • Pack / unpack: color-pack, color-r, color-g, color-b, color-a
  • Hex: color-from-hex-rgb, color-from-hex-rgba
  • Spaces: hsv-to-rgb, rgb-to-hsv

Groups

  • group-begin?, group-begin-titled?, group-end
  • Scrolled groups (caller-owned offset): scroll-create, scroll-free, scroll-get-x, scroll-get-y, scroll-set, group-scrolled-begin?, group-scrolled-end

Treetree-push?, tree-push-id?, tree-pop, tree-{node,tab}, minimized/maximized, show/hidden

Chartchart-begin?, chart-begin-colored?, chart-add-slot, chart-add-slot-colored, chart-push, chart-push-slot, chart-end, chart-{lines,column}, chart-event-{hovering,clicked}

Popup / tooltippopup-begin?, popup-close, popup-end, popup-{static,dynamic}, tooltip, tooltip-begin?, tooltip-end

Menu / menubarmenubar-begin, menubar-end, menu-begin-label?, menu-begin-symbol?, menu-begin-symbol-label?, menu-item-label?, menu-item-symbol-label?, menu-close, menu-end

Combocombo-begin-{label,color,symbol,symbol-label}?, combo-item-label?, combo-item-symbol-label?, combo-close, combo-end

Contextual menucontextual-begin?, contextual-item-label?, contextual-item-symbol-label?, contextual-close, contextual-end

Edit (text input) — opaque buffer handle owned by the wrapper:

  • Lifecycle: edit-buffer-create, edit-buffer-free
  • Contents: edit-buffer-text, edit-buffer-len, edit-buffer-max, edit-buffer-set, edit-buffer-clear
  • Render: edit-buffer?, edit-focus, edit-unfocus
  • Modes: edit-{simple,field,box,editor}
  • Flag bits: edit-flag-{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}
  • Event bits (returned from edit-buffer?): edit-event-{active,inactive,activated,deactivated,commited}
  • Filters: filter-{default,ascii,float,decimal,hex,oct,binary}

Style / theming

  • style-default, style-set-theme, style-set-color, style-get-color
  • 32 color slots: color-{text,window,header,border,button,button-hover,button-active,toggle,toggle-hover,toggle-cursor,select,select-active,slider,slider-cursor,slider-cursor-hover,slider-cursor-active,property,edit,edit-cursor,combo,chart,chart-color,chart-color-highlight,scrollbar,scrollbar-cursor,scrollbar-cursor-hover,scrollbar-cursor-active,tab-header,knob,knob-cursor,knob-cursor-hover,knob-cursor-active}
  • Themes: theme-{default,white,red,blue,dark}

Input handling

  • Frame: input-begin, input-end
  • Events: input-motion, input-button, input-scroll, input-char, input-unicode, input-key
  • Queries: input-is-mouse-{hovering?,down?,pressed?,released?,click-in-rect?}, input-has-mouse-click-down-in-rect?, input-is-key-{pressed?,down?}, input-mouse-{x,y,delta-x,delta-y}
  • Mouse buttons: mouse-button-{left,middle,right,double}
  • Keys: key-{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-up,scroll-down}

Canvas drawing primitives (current window's command buffer)

  • Stroke: stroke-line, stroke-curve, stroke-rect, stroke-circle, stroke-arc, stroke-triangle
  • Fill: fill-rect, fill-circle, fill-arc, fill-triangle

Rendering

  • SDL2: render-sdl
  • Custom backend: command-begin, command-next, command-type, cmd-{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}, plus scalar accessors cmd-{type}-{x,y,w,h,…} and cmd-{type}-color for command-data extraction

Rendering Notes

Nuklear owns UI state and emits draw commands; it does not create windows or process platform events by itself. This package provides an SDL2 renderer helper (render-sdl) and lower-level command iteration for custom renderers.

Typical frame flow:

  1. Call input-begin
  2. Forward platform input events with input-motion, input-button, input-scroll, input-key, input-char/input-unicode
  3. Call input-end
  4. Build UI with begin?, layout calls, widgets, and end
  5. Render with render-sdl or iterate commands manually
  6. Call clear

Color convention

Widget colors are passed as four Byte channels (r, g, b, a). The color picker, command-iteration getters, and style-color APIs use a *packed* Int instead — a 32-bit value laid out as (r << 24) | (g << 16) | (b << 8) | a. Use color-pack / color-r / color-g / color-b / color-a to convert.

Screenshots

Captured from the compiled binaries (kit build examples/<name>.kit && ./<name>).

simple.kit — button, radio options, sliderdemo.kit — buttons, slider, progress, checkbox, options
!simple!demo
sdl-demo.kit — SDL integration with input forwardingedit.kit — text input, filters, multi-line editor
!sdl-demo!edit
combo.kit — combo variants, selectable list, treechart.kit — line, column, and multi-series charts
!combo!chart
popup-menu.kit — menubar, contextual menu, tooltip, popupcolor-picker.kit — picker, presets, hex parsing, HSV ramp
!popup-menu!color-picker
custom-canvas.kit — stroke/fill primitives on the window canvasknobs-symbols.kit — symbol buttons, knobs, disabled widgets
!custom-canvas!knobs-symbols
layout-templates.kit — row template, free positioning, propertiesstyle-themes.kit — theme switching and per-slot overrides
!layout-templates!style-themes

Development

Running Examples

Run examples with the interpreter:

kit run examples/simple.kit
kit run examples/demo.kit
kit run examples/edit.kit
kit run examples/combo.kit
kit run examples/chart.kit
kit run examples/popup-menu.kit
kit run examples/color-picker.kit
kit run examples/custom-canvas.kit
kit run examples/knobs-symbols.kit
kit run examples/layout-templates.kit
kit run examples/style-themes.kit

Compile any example to a native binary:

kit build examples/simple.kit && ./simple

Running Tests

kit test                  # all tests
kit test --coverage       # with coverage

Running kit dev

Standard development workflow (format, type check, test):

kit dev --no-spinner

This will:

  1. Verify the native library is current
  2. Check formatting
  3. Type check src/ (interactive examples are skipped here)
  4. Run tests with coverage

Running Parity

Check interpreter / build parity for examples:

kit parity --no-spinner --failures-only

Generating Documentation

kit doc

Note: Kit sources with doc comments (##) generate HTML in docs/*.html.

Cleaning Build Artifacts

kit task clean

Note: Defined in kit.toml.

Local Installation

kit install

This installs the package to ~/.kit/packages/@kit/nuklear/, making it available for import as Kit.Nuklear in other projects.

License

This package is released under the MIT License — see LICENSE for details.

The bundled c/nuklear.h library is public domain / MIT licensed by the Nuklear project.

Exported Functions & Types

chart-lines

Line chart type.

chart-column

Column (bar) chart type.

chart-event-hovering

Returned by chart-push when the data point is hovered.

chart-event-clicked

Returned by chart-push when the data point is clicked.

chart-begin?

Begin a chart with default colors.

Ptr -> Int -> Int -> Float -> Float -> Bool

chart-begin-colored?

Begin a chart with custom colors.

Ptr -> Int -> Byte -> Byte -> Byte -> Byte -> Byte -> Byte -> Byte -> Byte -> Int -> Float -> Float -> Bool

chart-add-slot

Add a chart slot (extra series) of the given type.

Ptr -> Int -> Int -> Float -> Float -> Unit

chart-add-slot-colored

Add a colored chart slot.

Ptr -> Int -> Byte -> Byte -> Byte -> Byte -> Byte -> Byte -> Byte -> Byte -> Int -> Float -> Float -> Unit

chart-push

Push a data point to the chart. Returns a bitmask of chart-event-hovering / chart-event-clicked.

Ptr -> Float -> Int

chart-push-slot

Push a data point to a specific slot.

Ptr -> Float -> Int -> Int

chart-end

End the current chart.

Ptr -> Unit

render-sdl

Render all Nuklear draw commands to an SDL renderer.

Ptr -> Ptr -> Unit

SDL.clear renderer
Nk.render-sdl ctx renderer.ptr
SDL.present renderer

command-begin

Get the first command in the buffer.

Ptr -> Ptr

command-next

Get the next command (or null if no more).

Ptr -> Ptr -> Ptr

command-type

Get the type of a command.

Ptr -> Int

cmd-nop

No-op command type constant.

cmd-scissor

Scissor (clip rect) command type.

cmd-line

Line stroke command type.

cmd-curve

Cubic Bezier curve stroke command type.

cmd-rect

Rectangle outline command type.

cmd-rect-filled

Filled rectangle command type.

cmd-rect-multi-color

Multi-color rectangle (gradient) command type.

cmd-circle

Circle outline command type.

cmd-circle-filled

Filled circle command type.

cmd-arc

Arc outline command type.

cmd-arc-filled

Filled arc command type.

cmd-triangle

Triangle outline command type.

cmd-triangle-filled

Filled triangle command type.

cmd-polygon

Polygon outline command type.

cmd-polygon-filled

Filled polygon command type.

cmd-polyline

Open polyline command type.

cmd-text

Text command type.

cmd-image

Image command type.

cmd-scissor-x

Get scissor x. Only valid when command-type is cmd-scissor.

Ptr -> Int

cmd-scissor-y

Scissor command field y.

Ptr -> Int

cmd-scissor-w

Scissor command field w.

Ptr -> Int

cmd-scissor-h

Scissor command field h.

Ptr -> Int

cmd-line-x0

Command field accessor: cmd-line-x0.

Ptr -> Int

cmd-line-y0

Command field accessor: cmd-line-y0.

Ptr -> Int

cmd-line-x1

Command field accessor: cmd-line-x1.

Ptr -> Int

cmd-line-y1

Command field accessor: cmd-line-y1.

Ptr -> Int

cmd-line-thickness

Command field accessor: cmd-line-thickness.

Ptr -> Int

cmd-line-color

Packed RGBA color of the line command.

Ptr -> Int

cmd-rect-x

Command field accessor: cmd-rect-x.

Ptr -> Int

cmd-rect-y

Command field accessor: cmd-rect-y.

Ptr -> Int

cmd-rect-w

Command field accessor: cmd-rect-w.

Ptr -> Int

cmd-rect-h

Command field accessor: cmd-rect-h.

Ptr -> Int

cmd-rect-rounding

Command field accessor: cmd-rect-rounding.

Ptr -> Int

cmd-rect-thickness

Command field accessor: cmd-rect-thickness.

Ptr -> Int

cmd-rect-color

Command field accessor: cmd-rect-color.

Ptr -> Int

cmd-rect-filled-x

Command field accessor: cmd-rect-filled-x.

Ptr -> Int

cmd-rect-filled-y

Command field accessor: cmd-rect-filled-y.

Ptr -> Int

cmd-rect-filled-w

Command field accessor: cmd-rect-filled-w.

Ptr -> Int

cmd-rect-filled-h

Command field accessor: cmd-rect-filled-h.

Ptr -> Int

cmd-rect-filled-rounding

Command field accessor: cmd-rect-filled-rounding.

Ptr -> Int

cmd-rect-filled-color

Command field accessor: cmd-rect-filled-color.

Ptr -> Int

cmd-circle-x

Command field accessor: cmd-circle-x.

Ptr -> Int

cmd-circle-y

Command field accessor: cmd-circle-y.

Ptr -> Int

cmd-circle-w

Command field accessor: cmd-circle-w.

Ptr -> Int

cmd-circle-h

Command field accessor: cmd-circle-h.

Ptr -> Int

cmd-circle-thickness

Command field accessor: cmd-circle-thickness.

Ptr -> Int

cmd-circle-color

Command field accessor: cmd-circle-color.

Ptr -> Int

cmd-circle-filled-x

Command field accessor: cmd-circle-filled-x.

Ptr -> Int

cmd-circle-filled-y

Command field accessor: cmd-circle-filled-y.

Ptr -> Int

cmd-circle-filled-w

Command field accessor: cmd-circle-filled-w.

Ptr -> Int

cmd-circle-filled-h

Command field accessor: cmd-circle-filled-h.

Ptr -> Int

cmd-circle-filled-color

Command field accessor: cmd-circle-filled-color.

Ptr -> Int

cmd-triangle-x0

Command field accessor: cmd-triangle-x0.

Ptr -> Int

cmd-triangle-y0

Command field accessor: cmd-triangle-y0.

Ptr -> Int

cmd-triangle-x1

Command field accessor: cmd-triangle-x1.

Ptr -> Int

cmd-triangle-y1

Command field accessor: cmd-triangle-y1.

Ptr -> Int

cmd-triangle-x2

Command field accessor: cmd-triangle-x2.

Ptr -> Int

cmd-triangle-y2

Command field accessor: cmd-triangle-y2.

Ptr -> Int

cmd-triangle-thickness

Command field accessor: cmd-triangle-thickness.

Ptr -> Int

cmd-triangle-color

Command field accessor: cmd-triangle-color.

Ptr -> Int

cmd-triangle-filled-x0

Command field accessor: cmd-triangle-filled-x0.

Ptr -> Int

cmd-triangle-filled-y0

Command field accessor: cmd-triangle-filled-y0.

Ptr -> Int

cmd-triangle-filled-x1

Command field accessor: cmd-triangle-filled-x1.

Ptr -> Int

cmd-triangle-filled-y1

Command field accessor: cmd-triangle-filled-y1.

Ptr -> Int

cmd-triangle-filled-x2

Command field accessor: cmd-triangle-filled-x2.

Ptr -> Int

cmd-triangle-filled-y2

Command field accessor: cmd-triangle-filled-y2.

Ptr -> Int

cmd-triangle-filled-color

Command field accessor: cmd-triangle-filled-color.

Ptr -> Int

cmd-text-x

Command field accessor: cmd-text-x.

Ptr -> Int

cmd-text-y

Command field accessor: cmd-text-y.

Ptr -> Int

cmd-text-w

Command field accessor: cmd-text-w.

Ptr -> Int

cmd-text-h

Command field accessor: cmd-text-h.

Ptr -> Int

cmd-text-string-ptr

Raw Ptr to the command's text. Combine with cmd-text-length for the slice.

Ptr -> Ptr

cmd-text-length

Command field accessor: cmd-text-length.

Ptr -> Int

cmd-text-color

Command field accessor: cmd-text-color.

Ptr -> Int

stroke-line

Stroke a line segment.

Ptr -> Float -> Float -> Float -> Float -> Float -> Byte -> Byte -> Byte -> Byte -> Unit

stroke-curve

Stroke a cubic Bezier curve.

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Byte -> Byte -> Byte -> Byte -> Unit

stroke-rect

Stroke a rectangle outline.

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Byte -> Byte -> Byte -> Byte -> Unit

stroke-circle

Stroke a circle outline (rectangle bounds).

Ptr -> Float -> Float -> Float -> Float -> Float -> Byte -> Byte -> Byte -> Byte -> Unit

stroke-arc

Stroke an arc.

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Byte -> Byte -> Byte -> Byte -> Unit

stroke-triangle

Stroke a triangle outline.

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Byte -> Byte -> Byte -> Byte -> Unit

fill-rect

Fill a rectangle.

Ptr -> Float -> Float -> Float -> Float -> Float -> Byte -> Byte -> Byte -> Byte -> Unit

fill-circle

Fill a circle (rectangle bounds).

Ptr -> Float -> Float -> Float -> Float -> Byte -> Byte -> Byte -> Byte -> Unit

fill-arc

Fill an arc.

Ptr -> Float -> Float -> Float -> Float -> Float -> Byte -> Byte -> Byte -> Byte -> Unit

fill-triangle

Fill a triangle.

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Byte -> Byte -> Byte -> Byte -> Unit

flag-border

Window has a visible border.

flag-movable

Window can be moved by dragging the header.

flag-scalable

Window can be resized by dragging the corner.

flag-closable

Window has a close button.

flag-minimizable

Window can be minimized.

flag-no-scrollbar

Window has no scrollbar.

flag-title

Window always shows the title bar.

flag-scroll-auto-hide

Window scrollbar fades when not in use.

flag-background

Window behaves like a background panel (always behind other windows).

flag-scale-left

Resize handle is on the left edge instead of the right.

flag-no-input

Window ignores input events.

text-left

Left-aligned text.

text-centered

Center-aligned text.

text-right

Right-aligned text.

text-align-top

Top-aligned text (combine with horizontal).

text-align-middle

Middle-aligned text (combine with horizontal).

text-align-bottom

Bottom-aligned text (combine with horizontal).

begin?

Begin a new window. Returns true if window is visible.

Parameters:

Ptr -> NonEmptyString -> Float -> Float -> Float -> Float -> Int -> Bool

flags = Nk.flag-border ||| Nk.flag-movable ||| Nk.flag-title
if Nk.begin? ctx "My Window" 50.0 50.0 200.0 200.0 flags then
  # ...
  Nk.end ctx

end

End the current window. Always call exactly once after begin?.

Ptr -> Unit

window-is-closed?

Check whether a window has been closed.

Ptr -> NonEmptyString -> Bool

window-is-hidden?

Check whether a window is hidden.

Ptr -> NonEmptyString -> Bool

window-is-collapsed?

Check whether a window is collapsed.

Ptr -> NonEmptyString -> Bool

window-is-active?

Check whether a named window is the active (focused) one.

Ptr -> NonEmptyString -> Bool

window-is-any-hovered?

Check whether any window is hovered.

Ptr -> Bool

window-close

Close a window by name.

Ptr -> NonEmptyString -> Unit

window-collapse

Collapse or expand a named window. Pass minimized or maximized.

Ptr -> NonEmptyString -> Int -> Unit

window-show

Show or hide a named window. Pass show or hidden.

Ptr -> NonEmptyString -> Int -> Unit

window-set-position

Set a named window's position.

Ptr -> NonEmptyString -> Float -> Float -> Unit

window-set-size

Set a named window's size.

Ptr -> NonEmptyString -> Float -> Float -> Unit

window-set-focus

Set focus to a named window.

Ptr -> NonEmptyString -> Unit

window-get-x

Get the current window's x coordinate.

Ptr -> Float

window-get-y

Get the current window's y coordinate.

Ptr -> Float

window-get-width

Get the current window's width.

Ptr -> Float

window-get-height

Get the current window's height.

Ptr -> Float

window-content-x

Get the x coordinate of the content region (inside padding/borders).

Ptr -> Float

window-content-y

Get the y coordinate of the content region.

Ptr -> Float

window-content-width

Get the width of the content region.

Ptr -> Float

window-content-height

Get the height of the content region.

Ptr -> Float

window-get-scroll-x

Get the current window's horizontal scroll offset.

Ptr -> Float

window-get-scroll-y

Get the current window's vertical scroll offset.

Ptr -> Float

window-set-scroll

Set the current window's scroll offset.

Ptr -> Int -> Int -> Unit

window-has-focus?

Check whether the current window has focus.

Ptr -> Bool

window-is-hovered?

Check whether the current window is hovered.

Ptr -> Bool

item-is-any-active?

Check whether any item is currently active.

Ptr -> Bool

Static popup type: fixed size.

Dynamic popup type: grows with content.

Begin a popup window.

Ptr -> Int -> NonEmptyString -> Int -> Float -> Float -> Float -> Float -> Bool

Close the current popup.

Ptr -> Unit

End a popup.

Ptr -> Unit

tooltip

Show a one-shot tooltip at the current widget position.

Ptr -> String -> Unit

tooltip-begin?

Begin a custom-content tooltip with the given width. Returns true if visible.

Ptr -> Float -> Bool

tooltip-end

End a custom-content tooltip.

Ptr -> Unit

Begin the menubar (call inside a window, before other widgets).

Ptr -> Int

End the menubar.

Ptr -> Unit

Begin a menu with a label. Returns true if open.

Ptr -> NonEmptyString -> Int -> Float -> Float -> Bool

Begin a menu shown as a symbol button.

Ptr -> NonEmptyString -> Int -> Float -> Float -> Bool

Begin a menu with both a symbol and a label.

Ptr -> NonEmptyString -> Int -> Int -> Float -> Float -> Bool

Add a menu item. Returns true if clicked.

Ptr -> NonEmptyString -> Int -> Bool

Add a menu item with a leading symbol.

Ptr -> Int -> NonEmptyString -> Int -> Bool

Close the current menu.

Ptr -> Unit

End the current menu.

Ptr -> Unit

combo-begin-label?

Begin a label-style combo box.

Ptr -> NonEmptyString -> Float -> Float -> Bool

combo-begin-color?

Begin a color-swatch combo box.

Ptr -> Byte -> Byte -> Byte -> Byte -> Float -> Float -> Bool

combo-begin-symbol?

Begin a symbol-only combo box.

Ptr -> Int -> Float -> Float -> Bool

combo-begin-symbol-label?

Begin a combo with both symbol and label.

Ptr -> NonEmptyString -> Int -> Float -> Float -> Bool

combo-item-label?

Add a combo item with a text label.

Ptr -> NonEmptyString -> Int -> Bool

combo-item-symbol-label?

Add a combo item with a leading symbol.

Ptr -> Int -> NonEmptyString -> Int -> Bool

combo-close

Close the current combo.

Ptr -> Unit

combo-end

End the current combo.

Ptr -> Unit

contextual-begin?

Begin a contextual menu triggered by right-clicking inside the trigger rect.

Ptr -> Int -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

contextual-item-label?

Add a contextual menu item.

Ptr -> NonEmptyString -> Int -> Bool

contextual-item-symbol-label?

Add a contextual menu item with a symbol.

Ptr -> Int -> NonEmptyString -> Int -> Bool

contextual-close

Close the current contextual menu.

Ptr -> Unit

contextual-end

End the current contextual menu.

Ptr -> Unit

init

Initialize a Nuklear context with the given memory size.

Parameters:

Returns:

PositiveInt -> Ptr

free

Free a Nuklear context and release all resources.

Ptr -> Unit

clear

Clear the command buffer. Call at the end of each frame after rendering.

Ptr -> Unit

layout-dynamic

Layout format: dynamic columns size proportionally to width.

layout-static

Layout format: static columns use fixed pixel widths.

layout-row-dynamic

Create a dynamic row with equally-sized columns.

Ptr -> Float -> Int -> Unit

layout-row-static

Create a static row with fixed-width columns.

Ptr -> Float -> Int -> Int -> Unit

layout-row-begin

Begin a custom row layout. Push widths with layout-row-push.

Ptr -> Int -> Float -> Int -> Unit

layout-row-push

Push a column width for the custom row layout.

Ptr -> Float -> Unit

layout-row-end

End the custom row layout.

Ptr -> Unit

layout-row-template-begin

Begin a row template, then push dynamic/variable/static widths.

Ptr -> Float -> Unit

Nk.layout-row-template-begin ctx 30.0
Nk.layout-row-template-push-static ctx 80.0   # label
Nk.layout-row-template-push-variable ctx 100.0  # min 100, grows
Nk.layout-row-template-push-dynamic ctx          # fills the rest
Nk.layout-row-template-end ctx

layout-row-template-push-dynamic

Push a dynamic column that grows with the window.

Ptr -> Unit

layout-row-template-push-variable

Push a variable-width column with a minimum size.

Ptr -> Float -> Unit

layout-row-template-push-static

Push a fixed-width column.

Ptr -> Float -> Unit

layout-row-template-end

End the row template.

Ptr -> Unit

layout-space-begin

Begin a free-positioning space layout.

Ptr -> Int -> Float -> Int -> Unit

Nk.layout-space-begin ctx Nk.layout-static 200.0 3
Nk.layout-space-push ctx 0.0 0.0 100.0 30.0
Nk.button-label? ctx "A"
Nk.layout-space-push ctx 100.0 40.0 100.0 30.0
Nk.button-label? ctx "B"
Nk.layout-space-end ctx

layout-space-push

Push a rect for the next widget in space layout.

Ptr -> Float -> Float -> Float -> Float -> Unit

layout-space-end

End the space layout.

Ptr -> Unit

layout-set-min-row-height

Force a minimum height for subsequent layout rows.

Ptr -> Float -> Unit

layout-reset-min-row-height

Restore the default minimum row height.

Ptr -> Unit

spacing

Insert cols empty spacing columns into the current row.

Ptr -> Int -> Unit

rule-horizontal

Draw a thin horizontal separator with the given color. rounded? enables rounded ends.

Ptr -> Byte -> Byte -> Byte -> Byte -> Bool -> Unit

widget-bounds-x

Get the x coordinate of the bounds for the next widget.

Ptr -> Float

widget-bounds-y

Get the y coordinate of the bounds for the next widget.

Ptr -> Float

widget-bounds-w

Get the width of the bounds for the next widget.

Ptr -> Float

widget-bounds-h

Get the height of the bounds for the next widget.

Ptr -> Float

widget-width

Get the width allocated for the next widget.

Ptr -> Float

widget-height

Get the height allocated for the next widget.

Ptr -> Float

widget-position-x

Get the x position of the next widget.

Ptr -> Float

widget-position-y

Get the y position of the next widget.

Ptr -> Float

widget-is-hovered?

Check whether the next widget is hovered.

Ptr -> Bool

widget-is-mouse-clicked?

Check whether the next widget was clicked with the given mouse button.

Ptr -> Int -> Bool

widget-disable-begin

Begin a disabled-widget block (subsequent widgets render greyed out and ignore input).

Ptr -> Unit

widget-disable-end

End a disabled-widget block.

Ptr -> Unit

label

Display a text label with the given alignment.

Ptr -> String -> Int -> Unit

label-colored

Display a colored text label.

Ptr -> String -> Int -> Byte -> Byte -> Byte -> Byte -> Unit

label-wrap

Display a label that wraps to multiple lines.

Ptr -> String -> Unit

label-colored-wrap

Display a wrapping label with a custom color.

Ptr -> String -> Byte -> Byte -> Byte -> Byte -> Unit

text

Display a substring of msg (length-bounded) with the given alignment.

Ptr -> String -> Int -> Int -> Unit

button-label?

Create a button with a text label. Returns true if clicked this frame.

Ptr -> NonEmptyString -> Bool

button-text?

Create a button showing the first len chars of title.

Ptr -> NonEmptyString -> Int -> Bool

button-color?

Create a colored button (no label). Returns true if clicked.

Ptr -> Byte -> Byte -> Byte -> Byte -> Bool

button-symbol?

Create a button showing a built-in symbol (symbol-x, symbol-plus, etc).

Ptr -> Int -> Bool

button-symbol-label?

Create a button with a symbol and a label.

Ptr -> Int -> NonEmptyString -> Int -> Bool

button-set-behavior

Set button click behavior: default (click on release) or repeater (held-down repeats).

Ptr -> Int -> Unit

button-behavior-default

Default button behavior: fire on release.

button-behavior-repeater

Repeater behavior: fire continuously while held.

symbol-none

Symbol: no glyph.

symbol-x

Symbol: "x" / close.

symbol-underscore

Symbol: underscore.

symbol-circle-solid

Symbol: filled circle.

symbol-circle-outline

Symbol: outlined circle.

symbol-rect-solid

Symbol: filled rectangle.

symbol-rect-outline

Symbol: outlined rectangle.

symbol-triangle-up

Symbol: upward filled triangle.

symbol-triangle-down

Symbol: downward filled triangle.

symbol-triangle-left

Symbol: leftward filled triangle.

symbol-triangle-right

Symbol: rightward filled triangle.

symbol-plus

Symbol: plus / add.

symbol-minus

Symbol: minus / remove.

symbol-triangle-up-outline

Symbol: upward outlined triangle.

symbol-triangle-down-outline

Symbol: downward outlined triangle.

symbol-triangle-left-outline

Symbol: leftward outlined triangle.

symbol-triangle-right-outline

Symbol: rightward outlined triangle.

check-label?

Create a checkbox. Returns the new state.

Ptr -> String -> Bool -> Bool

option-label?

Create a radio button option. Returns true if selected this frame.

Ptr -> String -> Bool -> Bool

selectable-label?

Create a selectable list item. Returns the new selected state.

Ptr -> String -> Int -> Bool -> Bool

slide-float

Float slider. Returns the new value.

Ptr -> Float -> Float -> Float -> Float -> Float

slide-int

Integer slider. Returns the new value.

Ptr -> Int -> Int -> Int -> Int -> Int

prog

Progress bar. Returns the new value (modifiable? makes it click-to-set).

Ptr -> Int -> Int -> Bool -> Int

knob-float

Knob (circular slider) for floats. Use heading-up, heading-right, etc. for zero direction.

Ptr -> Float -> Float -> Float -> Float -> Int -> Float -> Float

knob-int

Knob for integers.

Ptr -> Int -> Int -> Int -> Int -> Int -> Float -> Int

heading-up

Heading direction "up".

heading-right

Heading direction "right".

heading-down

Heading direction "down".

heading-left

Heading direction "left".

propertyi

Integer property (label + value + increment buttons).

Ptr -> NonEmptyString -> Int -> Int -> Int -> Int -> Float -> Int

propertyf

Float property (label + value + increment buttons).

Ptr -> NonEmptyString -> Float -> Float -> Float -> Float -> Float -> Float

group-begin?

Begin a group (scrollable sub-region). Returns true if visible.

Ptr -> NonEmptyString -> Int -> Bool

group-begin-titled?

Begin a group with a distinct id and visible title.

Ptr -> NonEmptyString -> NonEmptyString -> Int -> Bool

group-end

End the current group.

Ptr -> Unit

scroll-create

Allocate a scroll-offset handle for use with group-scrolled-begin?.

Unit -> Ptr

scroll-free

Free a scroll-offset handle.

Ptr -> Unit

scroll-get-x

Get the x offset of a scroll handle.

Ptr -> Int

scroll-get-y

Get the y offset of a scroll handle.

Ptr -> Int

scroll-set

Set a scroll handle's offsets.

Ptr -> Int -> Int -> Unit

group-scrolled-begin?

Begin a group whose scroll position is owned by the caller via a scroll handle.

Ptr -> Ptr -> NonEmptyString -> Int -> Bool

group-scrolled-end

End a scrolled group.

Ptr -> Unit

tree-node

Tree-node type (indented small node).

tree-tab

Tree-tab type (tab-style header).

minimized

Initial collapse state: minimized.

maximized

Initial collapse state: maximized.

show

Show state for window-show.

hidden

Hidden state for window-show.

tree-push?

Begin a tree node. Returns true if expanded.

Ptr -> Int -> NonEmptyString -> Int -> Bool

tree-push-id?

Begin a tree node with an explicit id (use when multiple siblings share a title).

Ptr -> Int -> NonEmptyString -> Int -> Int -> Bool

tree-pop

End a tree node.

Ptr -> Unit

edit-buffer-create

Allocate an edit buffer with the given maximum length (in bytes).

PositiveInt -> Ptr

edit-buffer-free

Free an edit buffer.

Ptr -> Unit

edit-buffer-text

Get the current text of an edit buffer as a Kit String.

Ptr -> String

edit-buffer-len

Get the current length of an edit buffer.

Ptr -> Int

edit-buffer-max

Get the maximum length of an edit buffer.

Ptr -> Int

edit-buffer-set

Overwrite an edit buffer with the given text.

Ptr -> String -> Unit

edit-buffer-clear

Clear an edit buffer's contents.

Ptr -> Unit

edit-buffer?

Render a text input bound to an edit buffer. Returns the bitmask of edit-event flags fired this frame (active/activated/deactivated/commited).

Ptr -> Ptr -> Int -> Int -> Int

events = Nk.edit-buffer? ctx my-buf (Nk.edit-field ||| Nk.edit-flag-sig-enter) Nk.filter-default
if Int.bit-and events Nk.edit-event-commited != 0 then
  submit (Nk.edit-buffer-text my-buf)

edit-simple

Edit-mode preset: single-line field with no scrollbar or selection.

edit-field

Edit-mode preset: single-line field (most common).

edit-box

Edit-mode preset: multi-line bordered box.

edit-editor

Edit-mode preset: full text editor.

edit-flag-read-only

Edit flag: read only.

edit-flag-auto-select

Edit flag: auto select.

edit-flag-sig-enter

Edit flag: sig enter.

edit-flag-allow-tab

Edit flag: allow tab.

edit-flag-no-cursor

Edit flag: no cursor.

edit-flag-selectable

Edit flag: selectable.

edit-flag-clipboard

Edit flag: clipboard.

edit-flag-ctrl-enter-newline

Edit flag: ctrl enter newline.

edit-flag-no-horizontal-scroll

Edit flag: no horizontal scroll.

edit-flag-always-insert-mode

Edit flag: always insert mode.

edit-flag-multiline

Edit flag: multiline.

edit-flag-goto-end-on-activate

Edit flag: goto end on activate.

edit-event-active

Edit event bit: the field is currently focused.

edit-event-inactive

Edit event bit: the field is not focused.

edit-event-activated

Edit event bit: the field just gained focus.

edit-event-deactivated

Edit event bit: the field just lost focus.

edit-event-commited

Edit event bit: the user pressed Enter (requires edit-flag-sig-enter).

filter-default

Input filter: accept all characters.

filter-ascii

Input filter: 7-bit ASCII only.

filter-float

Input filter: floats (digits + - . e).

filter-decimal

Input filter: signed decimal integers.

filter-hex

Input filter: hexadecimal digits.

filter-oct

Input filter: octal digits.

filter-binary

Input filter: binary digits.

edit-focus

Programmatically focus the next edit widget.

Ptr -> Int -> Unit

edit-unfocus

Remove focus from any edit widget.

Ptr -> Unit

input-begin

Begin input handling for the frame. Call before feeding events.

Ptr -> Unit

input-end

End input handling for the frame.

Ptr -> Unit

input-motion

Feed a mouse motion event.

Ptr -> Int -> Int -> Unit

input-button

Feed a mouse button event.

Ptr -> Int -> Int -> Int -> Bool -> Unit

input-scroll

Feed a scroll event.

Ptr -> Float -> Float -> Unit

input-char

Feed a single character of text input.

Ptr -> Int -> Unit

input-unicode

Feed a Unicode rune (text input above ASCII).

Ptr -> Int -> Unit

input-key

Feed a key event.

Ptr -> Int -> Bool -> Unit

input-is-mouse-hovering?

Check whether the mouse is currently hovering the given rect.

Ptr -> Float -> Float -> Float -> Float -> Bool

input-is-mouse-down?

Check whether a mouse button is currently held down.

Ptr -> Int -> Bool

input-is-mouse-pressed?

Check whether a mouse button transitioned to pressed this frame.

Ptr -> Int -> Bool

input-is-mouse-released?

Check whether a mouse button transitioned to released this frame.

Ptr -> Int -> Bool

input-is-mouse-click-in-rect?

Check whether a click started and ended within the rect.

Ptr -> Int -> Float -> Float -> Float -> Float -> Bool

input-has-mouse-click-down-in-rect?

Check whether the mouse currently has a click started in the rect with the given down state.

Ptr -> Int -> Float -> Float -> Float -> Float -> Bool -> Bool

input-is-key-pressed?

Check whether a key was pressed this frame.

Ptr -> Int -> Bool

input-is-key-down?

Check whether a key is currently held down.

Ptr -> Int -> Bool

input-mouse-x

Current mouse x coordinate.

Ptr -> Float

input-mouse-y

Current mouse y coordinate.

Ptr -> Float

input-mouse-delta-x

Change in mouse x since last frame.

Ptr -> Float

input-mouse-delta-y

Change in mouse y since last frame.

Ptr -> Float

mouse-button-left

Mouse button: primary (left) button.

mouse-button-middle

Mouse button: middle button.

mouse-button-right

Mouse button: secondary (right) button.

mouse-button-double

Pseudo-button representing a double-click.

key-none

Key id sentinel meaning "no key".

key-shift

Shift modifier.

key-ctrl

Control modifier (Cmd on macOS conventions).

key-del

Delete key (forward delete).

key-enter

Enter / Return key.

key-tab

Tab key.

key-backspace

Backspace key.

key-copy

Copy hotkey (typically Ctrl-C).

key-cut

Cut hotkey (typically Ctrl-X).

key-paste

Paste hotkey (typically Ctrl-V).

key-up

Up arrow key.

key-down

Down arrow key.

key-left

Left arrow key.

key-right

Right arrow key.

key-text-insert-mode

Text editor: switch to insert mode.

key-text-replace-mode

Text editor: switch to replace mode.

key-text-reset-mode

Text editor: reset to default editing mode.

key-text-line-start

Text editor: jump to start of line (Home).

key-text-line-end

Text editor: jump to end of line (End).

key-text-start

Text editor: jump to start of buffer.

key-text-end

Text editor: jump to end of buffer.

key-text-undo

Text editor: undo.

key-text-redo

Text editor: redo.

key-text-select-all

Text editor: select all.

key-text-word-left

Text editor: move one word left.

key-text-word-right

Text editor: move one word right.

key-scroll-start

Scrollable view: jump to top.

key-scroll-end

Scrollable view: jump to bottom.

key-scroll-up

Scrollable view: page up.

key-scroll-down

Scrollable view: page down.

color-picker

Show a color picker. Pass the current RGBA; returns the new packed color.

Ptr -> Byte -> Byte -> Byte -> Byte -> Int

color-from-hex-rgb

Parse "#rrggbb" or "rrggbb" into a packed color (alpha = 255).

String -> Int

color-from-hex-rgba

Parse "#rrggbbaa" or "rrggbbaa" into a packed color.

String -> Int

color-pack

Pack four byte channels into a single color int.

Byte -> Byte -> Byte -> Byte -> Int

color-r

Extract red channel from a packed color.

Int -> Int

color-g

Extract green channel from a packed color.

Int -> Int

color-b

Extract blue channel from a packed color.

Int -> Int

color-a

Extract alpha channel from a packed color.

Int -> Int

hsv-to-rgb

Convert HSV(A) (each 0–255) to a packed RGBA color.

Int -> Int -> Int -> Int -> Int

rgb-to-hsv

Convert RGB(A) (each 0–255) to a packed HSVA color.

Int -> Int -> Int -> Int -> Int

color-count

Total number of style color slots.

color-text

Style color slot: color-text.

color-window

Style color slot: color-window.

color-header

Style color slot: color-header.

color-border

Style color slot: color-border.

color-button

Style color slot: color-button.

color-button-hover

Style color slot: color-button-hover.

color-button-active

Style color slot: color-button-active.

color-toggle

Style color slot: color-toggle.

color-toggle-hover

Style color slot: color-toggle-hover.

color-toggle-cursor

Style color slot: color-toggle-cursor.

color-select

Style color slot: color-select.

color-select-active

Style color slot: color-select-active.

color-slider

Style color slot: color-slider.

color-slider-cursor

Style color slot: color-slider-cursor.

color-slider-cursor-hover

Style color slot: color-slider-cursor-hover.

color-slider-cursor-active

Style color slot: color-slider-cursor-active.

color-property

Style color slot: color-property.

color-edit

Style color slot: color-edit.

color-edit-cursor

Style color slot: color-edit-cursor.

color-combo

Style color slot: color-combo.

color-chart

Style color slot: color-chart.

color-chart-color

Style color slot: color-chart-color.

color-chart-color-highlight

Style color slot: color-chart-color-highlight.

color-scrollbar

Style color slot: color-scrollbar.

color-scrollbar-cursor

Style color slot: color-scrollbar-cursor.

color-scrollbar-cursor-hover

Style color slot: color-scrollbar-cursor-hover.

color-scrollbar-cursor-active

Style color slot: color-scrollbar-cursor-active.

color-tab-header

Style color slot: color-tab-header.

color-knob

Style color slot: color-knob.

color-knob-cursor

Style color slot: color-knob-cursor.

color-knob-cursor-hover

Style color slot: color-knob-cursor-hover.

color-knob-cursor-active

Style color slot: color-knob-cursor-active.

style-default

Reset to Nuklear's default style/theme.

Ptr -> Unit

style-set-color

Override a single style color (any other slots keep their current value).

Ptr -> Int -> Byte -> Byte -> Byte -> Byte -> Unit

style-get-color

Get the current packed RGBA color for the given style slot.

Ptr -> Int -> Int

theme-default

Theme id: the default dark grey theme.

theme-white

Theme id: bright/light grey.

theme-red

Theme id: dark with red accents.

theme-blue

Theme id: pastel blue.

theme-dark

Theme id: slate dark with blue accents.

style-set-theme

Apply a built-in theme to the context.

Ptr -> Int -> Unit