raygui/controls
interactive GUI controls for use inside the raylib draw loop.
Since: Phase 1
make-text-buf
(make-text-buf [capacity : int])
allocate a mutable text buffer for a text-box control.
| capacity | maximum byte capacity including null terminator |
Opaque :int handle; pass to gui-text-box and free with free-text-buf.
(let [buf (make-text-buf 64)] ...)
Since: Phase 1
free-text-buf
(free-text-buf [buf : int])
release a buffer allocated by make-text-buf.
| buf | opaque handle returned by make-text-buf |
(free-text-buf buf)
Since: Phase 1
text-buf->cstr
(text-buf->cstr [buf : int])
read the current contents of a text buffer as :cstr.
| buf | opaque handle returned by make-text-buf |
A :cstr view into the buffer (valid while the buffer is alive).
(println (text-buf->cstr name-buf))
Since: Phase 1
gui-label
(gui-label [r : Rect text : cstr] :)
draw a text label (non-interactive).
| r | bounding Rect | |
| text | label text |
(gui-label (rect 10.0 10.0 200.0 20.0) "Speed:")
Since: Phase 1
gui-button
(gui-button [r : Rect text : cstr] :)
draw a button; returns 1 the frame it is clicked.
| r | bounding Rect | |
| text | button label |
1 if the button was clicked this frame, 0 otherwise.
(when (gui-button (rect 10.0 10.0 120.0 30.0) "Go!")
(println "clicked"))
Since: Phase 1
gui-label-button
(gui-label-button [r : Rect text : cstr] :)
draw a label that acts as a button.
| r | bounding Rect | |
| text | label text |
1 if clicked this frame, 0 otherwise.
(gui-label-button (rect 10.0 10.0 100.0 20.0) "Click me")
Since: Phase 1
gui-toggle
(gui-toggle [r : Rect text : cstr active : int] :)
draw a toggle button; returns its current active state.
| r | bounding Rect | |
| text | button label | |
| active | current toggle state (0 = off, 1 = on) |
New toggle state after this frame.
(set! muted (gui-toggle (rect 10.0 10.0 80.0 30.0) "Mute" muted))
Since: Phase 1
gui-toggle-group
(gui-toggle-group [r : Rect text : cstr active : int] :)
draw a row of mutually exclusive toggle buttons.
| r | bounding Rect for the entire group | |
| text | semicolon-separated list of button labels ("A;B;C") | |
| active | index of the currently selected button |
Index of the selected button after this frame.
(set! tab (gui-toggle-group (rect 10.0 10.0 240.0 30.0) "Red;Green;Blue" tab))
Since: Phase 1
gui-check-box
(gui-check-box [r : Rect text : cstr checked : int] :)
draw a checkbox; returns current checked state.
| r | bounding Rect | |
| text | label displayed next to the box | |
| checked | current checked state (0 = unchecked, 1 = checked) |
New checked state after this frame.
(set! enabled (gui-check-box (rect 10.0 80.0 20.0 20.0) "Enabled" enabled))
Since: Phase 1
gui-slider
(gui-slider [r : Rect lo : cstr hi : cstr val : float min : float max : float] :)
draw a horizontal slider; returns the current value.
| r | bounding Rect | |
| lo | label shown at the left (min) end | |
| hi | label shown at the right (max) end | |
| val | current slider value | |
| min | minimum value | |
| max | maximum value |
Updated float value after dragging.
(set! speed (gui-slider (rect 10.0 40.0 200.0 20.0) "0" "10" speed 0.0 10.0))
Since: Phase 1
gui-slider-bar
(gui-slider-bar [r : Rect lo : cstr hi : cstr val : float min : float max : float] :)
draw a filled slider bar; returns the current value.
| r | bounding Rect | |
| lo | left label | |
| hi | right label | |
| val | current value | |
| min | minimum value | |
| max | maximum value |
Updated float value.
(set! vol (gui-slider-bar (rect 10.0 40.0 200.0 20.0) "0" "100" vol 0.0 100.0))
Since: Phase 1
gui-progress-bar
(gui-progress-bar [r : Rect lo : cstr hi : cstr val : float min : float max : float] :)
draw a read-only progress bar.
| r | bounding Rect | |
| lo | left label | |
| hi | right label | |
| val | current progress value | |
| min | minimum value | |
| max | maximum value |
Current value (unchanged).
(gui-progress-bar (rect 10.0 60.0 200.0 20.0) "0" "100" progress 0.0 100.0)
Since: Phase 1
gui-text-box
(gui-text-box [r : Rect buf : int size : int edit : int] :)
draw a single-line text input box.
| r | bounding Rect | |
| buf | mutable text buffer handle (from make-text-buf) | |
| size | buffer capacity in bytes | |
| edit | current edit mode state (0 = inactive, 1 = active) |
New edit mode state (toggled when the user clicks or presses Enter).
(set! editing (gui-text-box (rect 10.0 10.0 200.0 30.0) name-buf 64 editing))
Since: Phase 1
gui-text-box-multi
(gui-text-box-multi [r : Rect buf : int size : int edit : int] :)
draw a multi-line text input box.
| r | bounding Rect | |
| buf | mutable text buffer handle (from make-text-buf) | |
| size | buffer capacity in bytes | |
| edit | current edit mode state |
New edit mode state.
(set! editing (gui-text-box-multi (rect 10.0 10.0 300.0 120.0) notes-buf 256 editing))
Since: Phase 3
gui-spinner
(gui-spinner [r : Rect text : cstr val : int min : int max : int edit : int] :)
draw a numeric spinner with increment/decrement buttons.
| r | bounding Rect | |
| text | label | |
| val | current integer value | |
| min | minimum value | |
| max | maximum value | |
| edit | current edit mode state |
Packed pair: fst = new edit mode, snd = new value.
(let [res (gui-spinner (rect 10.0 10.0 120.0 30.0) "Speed" speed 0 20 speed-edit)]
(set! speed-edit (pair-fst res))
(set! speed (pair-snd res)))
Since: Phase 3
gui-value-box
(gui-value-box [r : Rect text : cstr val : int min : int max : int edit : int] :)
draw a numeric value box (type-in field).
| r | bounding Rect | |
| text | label | |
| val | current integer value | |
| min | minimum value | |
| max | maximum value | |
| edit | current edit mode state |
Packed pair: fst = new edit mode, snd = new value.
(let [res (gui-value-box (rect 10.0 10.0 120.0 30.0) "Count" count 0 100 count-edit)]
(set! count-edit (pair-fst res))
(set! count (pair-snd res)))
Since: Phase 3
gui-combo-box
(gui-combo-box [r : Rect text : cstr active : int] :)
draw a combo box (click to cycle through items).
| r | bounding Rect | |
| text | semicolon-separated item list ("Item1;Item2;Item3") | |
| active | index of the currently selected item |
Index of the selected item after this frame.
(set! mode (gui-combo-box (rect 10.0 10.0 150.0 30.0) "Linear;Ease;Bounce" mode))
Since: Phase 3
gui-dropdown-box
(gui-dropdown-box [r : Rect text : cstr active : int edit : int] :)
draw a dropdown box; expands when clicked.
| r | bounding Rect | |
| text | semicolon-separated item list | |
| active | index of the currently selected item | |
| edit | current open/close state (0 = closed, 1 = open) |
New edit (open) state after this frame.
(set! dd-open (gui-dropdown-box (rect 10.0 10.0 150.0 30.0) "A;B;C" dd-sel dd-open))
Since: Phase 3
gui-list-view
(gui-list-view [r : Rect text : cstr scroll : int active : int] :)
draw a scrollable list box.
| r | bounding Rect | |
| text | semicolon-separated item list | |
| scroll | current scroll offset (pixels) | |
| active | index of the selected item (-1 = none) |
Index of the newly selected item, or -1 if none.
(set! sel (gui-list-view (rect 10.0 10.0 200.0 120.0) "Apple;Banana;Cherry" 0 sel))
Since: Phase 3
gui-list-view-ex
(gui-list-view-ex [r : Rect text : cstr count : int scroll : int active : int focus : int] :)
draw a list box with per-item control.
| r | bounding Rect | |
| text | semicolon-separated item list | |
| count | number of items in the list | |
| scroll | current scroll offset | |
| active | index of the selected item | |
| focus | index of the focused item |
Index of the selected item after this frame.
Since: Phase 3
gui-color-picker
(gui-color-picker [r : Rect text : cstr color : int] :)
draw a full color picker (hue ring + HSV square).
| r | bounding Rect | |
| text | label | |
| color | current color as packed RGBA int (0xRRGGBBAA) |
New packed RGBA color.
(set! col (gui-color-picker (rect 10.0 10.0 200.0 200.0) "Color" col))
Since: Phase 3
gui-color-bar-alpha
(gui-color-bar-alpha [r : Rect text : cstr alpha : float] :)
draw an alpha channel bar.
| r | bounding Rect | |
| text | label | |
| alpha | current alpha (0.0 to 1.0) |
Updated alpha value.
Since: Phase 3
gui-color-bar-hue
(gui-color-bar-hue [r : Rect text : cstr value : float] :)
draw a hue selector bar.
| r | bounding Rect | |
| text | label | |
| value | current hue (0.0 to 360.0) |
Updated hue value.
Since: Phase 3
gui-message-box
(gui-message-box [r : Rect title : cstr message : cstr buttons : cstr] :)
draw a modal message dialog.
| r | bounding Rect | |
| title | dialog title | |
| message | message body text | |
| buttons | semicolon-separated button labels ("OK;Cancel") |
Index of the clicked button (0-based), or -1 if none clicked.
(let [btn (gui-message-box (rect 200.0 150.0 300.0 150.0) "Confirm" "Exit?" "Yes;No")]
(when (= btn 0) (close-window)))
Since: Phase 3
gui-text-input-box
(gui-text-input-box [r : Rect title : cstr message : cstr buttons : cstr buf : int size : int secret : int] :)
draw a modal text input dialog.
| r | bounding Rect | |
| title | dialog title | |
| message | prompt message | |
| buttons | semicolon-separated button labels | |
| buf | mutable text buffer handle (from make-text-buf) | |
| size | buffer capacity in bytes | |
| secret | 1 to hide typed characters (password mode) |
Index of the clicked button, or -1 if none clicked.
Since: Phase 3
gui-grid
(gui-grid [r : Rect text : cstr spacing : float divs : int] :)
draw a grid and return the hovered cell as a packed int.
| r | bounding Rect | |
| text | grid label | |
| spacing | cell size in pixels | |
| divs | number of subdivisions per cell |
Packed (row << 32 | col) of the hovered cell, or -1 if none.
Since: Phase 3