Files
kryon/docs/API.md
T
waozi b59623b410 Split the API reference into topic files
docs/API.md becomes a short index and its sections move verbatim into widget-package, control, motion, style, GTK theme, image, application, hosted-widget, host, game, audio, persistence, scene-rendering, painting and model references. The AVIF compression section joins BACKENDS.md and the renderer benchmark joins PERFORMANCE.md. The runnable HTML example leaves HTML_TO_KRYON.md for HTML_EXAMPLES.md, and cross links point at the new files. Every fact moves and nothing is dropped; the uncommitted Hosted widgets heading and SceneResizeOpaqueInto paragraph another lane left in API.md are kept. No stale claims were removed because every kept symbol still exists in the tree.
2026-11-22 14:56:25 -03:00

4.1 KiB

Kryon API

This reference covers 0.4.0 and Unreleased changes on master.

Kryon is an ordinary Ziran package. An application imports the modules it uses; no widget names are recognized by the Ziran compiler or .zx loader. The public package imports are declared in ziran.toml.

Reusable component sources are grouped under src/ui/<component>/; shared tree, input, theme, and paint infrastructure stays in src/ui/. Applications import only the packages they use. For example, use kryon/text, kryon/button, kryon/button_group, or kryon/progress_ring; checklist tasks and swipe actions are available from kryon/onboarding_checklist_task and kryon/swipe_props.

With KRYON_HOSTED_UI, the same named widget packages expose their hosted contracts. Retained-only components such as Page and Toast require a local tree. Hosted kryon/menu keeps the menu's props, types and state; its menu bar Draw comes only with a local tree. Pointer and keyboard sampling remain separate imports.

Rendering hosts that retain pixels can call CommitFrameDamaged(session) to commit the tree and compare paint while leaving changed commands queued. An unchanged result needs no raster work; a partial result supplies its damage rectangle. The host clears and clips that area before PaintFlushArea, or clears its whole surface before PaintFlush. EndFrameDamaged keeps its existing behavior of emitting a full repaint immediately.

frame_transition.FrameSurfaceCopy(surface) copies a borrowed retained frame into an owned surface before its target is reused. Capture before committing the destination frame, draw with FrameTransition, and call FrameSurfaceRelease when the transition ends. An invalid source or failed allocation returns an empty surface.

TreeSubmittedCount(session) and TreeSubmittedNodeAt(session, index) expose the current frame's submitted geometry while building. Native skins can paint retained controls from it while input continues using the committed tree.

Import Surface
app Window, Frame, and Run for a small executable application
text, button, image, page, ... One named package per widget, with Props, Draw, and widget-specific results
semantic Semantic kinds for document-oriented applications
PageRoute Browser route path, hash, and history (GetRoutePath, PushRoute, GetRouteOrigin, ...) for Canvas profiles
geometry, drawing_props, session, tree, surface, paint_queue, style, style_sheet, control_props, font_metrics, scroll, semantic, tree_input, widget_kind Building blocks for widget packages

Where to look

Topic File
Widget packages catalog WIDGET_PACKAGES.md
Buttons, cards, menus, lists and other controls WIDGET_CONTROLS.md
Timed, retained and widget motion MOTION.md
Style rules, clipboard integration and drag source STYLE_RULES.md
GTK3 theme rendering on Linux GTK_THEME.md
Image, tile map and shape rendering IMAGE_RENDERING.md
Applications, window hosts and input delivery APPS.md
Hosted widget packages (KRYON_HOSTED_UI) HOSTED_WIDGETS.md
Desktop ZX player, host parts, compiled canvas and Android frames APP_HOSTS.md
Game touch controls GAME_CONTROLS.md
Asset audio AUDIO.md
Document persistence and local notifications PERSISTENCE.md
Scene materials, GLSL translation and GPU rendering SCENE_RENDERING.md
Vector paths, text pixels, light cookies, grades and watercolor PAINTING.md
glTF 2.0 and VRM models MODELS.md
AVIF compression and RGBA previews BACKENDS.md
Renderer performance benchmark PERFORMANCE.md
HTML and CSS mapping HTML_TO_KRYON.md
Runnable HTML and CSS example HTML_EXAMPLES.md