Skip to content

App

App :: struct($Model, $Msg: typeid) {...}
Config :: struct {...}
Key :: enum {...}
Modifier :: enum {...}
MouseButton :: enum {...}
clipboard :: proc() -> string
copy_to_clipboard :: proc(s: string)
create_image :: proc(width, height: int, pixels: []Pixel) -> Image
destroy_image :: proc(img: ^Image)
embed :: proc(out: ^[dynamic]$To, model: ^$M, view: proc(m: ^M, out: ^[dynamic]$From))
frame_time :: proc() -> f32
key_pressed :: proc(key: Key) -> bool
load_image :: proc(path: string) -> (Image, bool)
modifiers :: proc() -> (m: bit_set[Modifier])
now :: proc() -> f64
quit :: proc()
run :: proc(a: App($Model, $Msg), config := Config{})
task :: proc(work: proc(data: $D) -> $M, data: D)
tasks_running :: proc() -> int
KILN_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 :: 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.

FieldTypeNotes
titlecstringdefault “App”
widthi32default 1100
heighti32default 760
min_widthi32default 320
min_heighti32default 420
themeMaybe(Theme)default: Catppuccin Mocha
scaleScale
no_zoom_keysbooldisable Ctrl +/-/0
snapshot_setupproc(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[]stringdialogs / drawers to show; each gets its own extra image per size
snapshot_pointer[2]f32pointer position in units, to capture a hover or tooltip (zero = outside)
snapshot_clicks[][2]f32left 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 :: enum {
Shift,
Ctrl, // Ctrl, or Cmd on macOS
}

Values: .Shift, .Ctrl

Source: kiln/app.odin:84

MouseButton :: enum {
Left,
Right,
}

Values: .Left, .Right

Source: kiln/app.odin:100

clipboard :: proc() -> string

The text on the system clipboard, valid until the end of the frame.

ReturnsType
#0string

Source: kiln/app.odin:75

copy_to_clipboard :: proc(s: string)

Puts text on the system clipboard.

ArgumentTypeDefault
sstringrequired

Source: kiln/app.odin:70

create_image :: proc(width, height: int, pixels: []Pixel) -> Image

Creates an image from RGBA pixels (row by row, top to bottom).

ArgumentTypeDefault
widthintrequired
heightintrequired
pixels[]Pixelrequired
ReturnsType
#0Image

Source: kiln/backend_raylib.odin:51

destroy_image :: proc(img: ^Image)
ArgumentTypeDefault
img^Imagerequired

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)
ArgumentTypeDefault
out^[dynamic]$Torequired
model^$Mrequired
viewproc(m: ^M, out: ^[dynamic]$From)required

Source: kiln/app.odin:46

frame_time :: proc() -> f32

Duration of the last frame in seconds.

ReturnsType
#0f32

Source: kiln/app.odin:60

key_pressed :: proc(key: Key) -> bool

True if key was pressed (or auto-repeated) in this frame and no text field has the focus.

ArgumentTypeDefault
keyKeyrequired
ReturnsType
#0bool

Source: kiln/app.odin:80

load_image :: proc(path: string) -> (Image, bool)

Loads an image file (PNG, JPG, …).

ArgumentTypeDefault
pathstringrequired
ReturnsType
#0Image
#1bool

Source: kiln/backend_raylib.odin:63

modifiers :: proc() -> (m: bit_set[Modifier])

The modifier keys held down in this frame: if kiln.key_pressed(.Z) && .Ctrl in kiln.modifiers().

ReturnsType
mbit_set[Modifier]

Source: kiln/app.odin:90

now :: proc() -> f64

Seconds since the app started.

ReturnsType
#0f64

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"})
ArgumentTypeDefault
aApp($Model, $Msg)required
configConfigConfig{}

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.

ArgumentTypeDefault
workproc(data: $D) -> $Mrequired
dataDrequired

Source: kiln/task.odin:40

tasks_running :: proc() -> int

Number of tasks that were started and whose message has not arrived yet, e.g. for a spinner.

ReturnsType
#0int

Source: kiln/task.odin:66

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