App
At a glance
Section titled “At a glance”App :: struct($Model, $Msg: typeid) {...}Config :: struct {...}Key :: enum {...}Modifier :: enum {...}MouseButton :: enum {...}clipboard :: proc() -> stringcopy_to_clipboard :: proc(s: string)create_image :: proc(width, height: int, pixels: []Pixel) -> Imagedestroy_image :: proc(img: ^Image)embed :: proc(out: ^[dynamic]$To, model: ^$M, view: proc(m: ^M, out: ^[dynamic]$From))frame_time :: proc() -> f32key_pressed :: proc(key: Key) -> boolload_image :: proc(path: string) -> (Image, bool)modifiers :: proc() -> (m: bit_set[Modifier])now :: proc() -> f64quit :: proc()run :: proc(a: App($Model, $Msg), config := Config{})task :: proc(work: proc(data: $D) -> $M, data: D)tasks_running :: proc() -> intKILN_SNAPSHOT :: #config(KILN_SNAPSHOT, false)App :: struct($Model, $Msg: typeid) { init: proc() -> Model, update: proc(m: ^Model, msg: Msg), view: proc(m: ^Model, out: ^[dynamic]Msg), tick: proc(m: ^Model, dt: f32), // optional, called once per frame before the view}Source: kiln/app.odin:18
Config
Section titled “Config”Config :: struct { title: cstring, // default "App" width: i32, // default 1100 height: i32, // default 760 min_width: i32, // default 320 min_height: i32, // default 420 theme: Maybe(Theme), // default: Catppuccin Mocha scale: Scale, no_zoom_keys: bool, // disable Ctrl +/-/0
// Only used by snapshot builds (`-define:KILN_SNAPSHOT=true`): snapshot_setup: proc(model: rawptr), // called after `init` (the model as ^Model), e.g. to load test data snapshot_open: []string, // dialogs / drawers to show; each gets its own extra image per size snapshot_pointer: [2]f32, // pointer position in units, to capture a hover or tooltip (zero = outside) snapshot_clicks: [][2]f32, // left clicks in units before rendering, e.g. to open a popup}Window and look of the app. Zero values select the defaults.
| Field | Type | Notes |
|---|---|---|
title | cstring | default “App” |
width | i32 | default 1100 |
height | i32 | default 760 |
min_width | i32 | default 320 |
min_height | i32 | default 420 |
theme | Maybe(Theme) | default: Catppuccin Mocha |
scale | Scale | |
no_zoom_keys | bool | disable Ctrl +/-/0 |
snapshot_setup | proc(model: rawptr) | Only used by snapshot builds (-define:KILN_SNAPSHOT=true): called after init (the model as ^Model), e.g. to load test data |
snapshot_open | []string | dialogs / drawers to show; each gets its own extra image per size |
snapshot_pointer | [2]f32 | pointer position in units, to capture a hover or tooltip (zero = outside) |
snapshot_clicks | [][2]f32 | left clicks in units before rendering, e.g. to open a popup |
Source: kiln/app.odin:26
Key :: enum { Left, Right, Up, Down, Home, End, Page_Up, Page_Down, Backspace, Delete, Enter, Escape, Tab, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Equal, Minus, Zero,}Values: .Left, .Right, .Up, .Down, .Home, .End, .Page_Up, .Page_Down, .Backspace, .Delete, .Enter, .Escape, .Tab, .A, .B, .C, .D, .E, .F, .G, .H, .I, .J, .K, .L, .M, .N, .O, .P, .Q, .R, .S, .T, .U, .V, .W, .X, .Y, .Z, .Equal, .Minus, .Zero
Source: kiln/app.odin:105
Modifier
Section titled “Modifier”Modifier :: enum { Shift, Ctrl, // Ctrl, or Cmd on macOS}Values: .Shift, .Ctrl
Source: kiln/app.odin:84
MouseButton
Section titled “MouseButton”MouseButton :: enum { Left, Right,}Values: .Left, .Right
Source: kiln/app.odin:100
Procedures
Section titled “Procedures”clipboard
Section titled “clipboard”clipboard :: proc() -> stringThe text on the system clipboard, valid until the end of the frame.
| Returns | Type |
|---|---|
| #0 | string |
Source: kiln/app.odin:75
copy_to_clipboard
Section titled “copy_to_clipboard”copy_to_clipboard :: proc(s: string)Puts text on the system clipboard.
| Argument | Type | Default |
|---|---|---|
s | string | required |
Source: kiln/app.odin:70
create_image
Section titled “create_image”create_image :: proc(width, height: int, pixels: []Pixel) -> ImageCreates an image from RGBA pixels (row by row, top to bottom).
| Argument | Type | Default |
|---|---|---|
width | int | required |
height | int | required |
pixels | []Pixel | required |
| Returns | Type |
|---|---|
| #0 | Image |
Source: kiln/backend_raylib.odin:51
destroy_image
Section titled “destroy_image”destroy_image :: proc(img: ^Image)| Argument | Type | Default |
|---|---|---|
img | ^Image | required |
Source: kiln/backend_raylib.odin:88
embed :: proc(out: ^[dynamic]$To, model: ^$M, view: proc(m: ^M, out: ^[dynamic]$From))Runs the view of a sub-model and forwards its messages, converted to the parent’s message type:
kiln.embed(out, &m.todo, todo.view)| Argument | Type | Default |
|---|---|---|
out | ^[dynamic]$To | required |
model | ^$M | required |
view | proc(m: ^M, out: ^[dynamic]$From) | required |
Source: kiln/app.odin:46
frame_time
Section titled “frame_time”frame_time :: proc() -> f32Duration of the last frame in seconds.
| Returns | Type |
|---|---|
| #0 | f32 |
Source: kiln/app.odin:60
key_pressed
Section titled “key_pressed”key_pressed :: proc(key: Key) -> boolTrue if key was pressed (or auto-repeated) in this frame and no text field has the focus.
| Argument | Type | Default |
|---|---|---|
key | Key | required |
| Returns | Type |
|---|---|
| #0 | bool |
Source: kiln/app.odin:80
load_image
Section titled “load_image”load_image :: proc(path: string) -> (Image, bool)Loads an image file (PNG, JPG, …).
| Argument | Type | Default |
|---|---|---|
path | string | required |
| Returns | Type |
|---|---|
| #0 | Image |
| #1 | bool |
Source: kiln/backend_raylib.odin:63
modifiers
Section titled “modifiers”modifiers :: proc() -> (m: bit_set[Modifier])The modifier keys held down in this frame: if kiln.key_pressed(.Z) && .Ctrl in kiln.modifiers().
| Returns | Type |
|---|---|
m | bit_set[Modifier] |
Source: kiln/app.odin:90
now :: proc() -> f64Seconds since the app started.
| Returns | Type |
|---|---|
| #0 | f64 |
Source: kiln/app.odin:65
quit :: proc()Closes the window at the end of the current frame.
Source: kiln/app.odin:55
run :: proc(a: App($Model, $Msg), config := Config{})Opens the window and runs the app until the window is closed or quit is called.
kiln.run(kiln.App(Model, Msg){init = init, update = update, view = view}, {title = "Meine App"})| Argument | Type | Default |
|---|---|---|
a | App($Model, $Msg) | required |
config | Config | Config{} |
Source: kiln/backend_raylib.odin:16
task :: proc(work: proc(data: $D) -> $M, data: D)Starts work(data) on a worker thread. M is the app’s message type or a variant of it, at
any depth (the message type of an embedded module, or one of its variants), so modules can
start their own tasks.
| Argument | Type | Default |
|---|---|---|
work | proc(data: $D) -> $M | required |
data | D | required |
Source: kiln/task.odin:40
tasks_running
Section titled “tasks_running”tasks_running :: proc() -> intNumber of tasks that were started and whose message has not arrived yet, e.g. for a spinner.
| Returns | Type |
|---|---|
| #0 | int |
Source: kiln/task.odin:66
Constants
Section titled “Constants”KILN_SNAPSHOT
Section titled “KILN_SNAPSHOT”KILN_SNAPSHOT :: #config(KILN_SNAPSHOT, false)Build with -define:KILN_SNAPSHOT=true to render PNG snapshots instead of opening a window.
Source: kiln/app.odin:16