Writing an app with JFLib (Rust)#
This guide is for developers and AI models writing desktop apps with JFLib. There are two ways to write one, and the code is the same in both:
- An app of your own, with the crate
jflib: one dependency, Cargo builds it, andcargo jflib(cargo install cargo-jflib) makes the project, runs its tests, reloads it while you edit, builds it for the browser, Android and macOS and packages it. Start withcargo jflib new NAME. - An app inside this repository (
apps/NAME), built bybuild_rs.py, which builds the library and every app of the repository through Cargo.
Where the two differ, this guide shows the crate way first. Look up functions in
API.md (generated from the sources), and look at apps/gallery for every control in
use. How widgets look is the business of the linked style (STYLES.md); packaging is in
PACKAGING.md, what the crates promise in VERSIONING.md. The
library itself is described in README.md.
The examples below were compiled and run against the library (R13); identifiers such as
ID_*, CMD_* and the fields of self are the example app's own.
Sections
- 1. Rules of the code base
- 2. Skeleton
- 3. The model: immediate mode
- 4. Layout
- 5. Widgets
- 6. Commands, menus, accelerators, popups
- 7. Dialogs, windows, title bar, files
- 8. Files, settings, images
- 9. Threads
- 10. Effects
- 11. Styles, theme, fonts
- 12. Testing -- always verify
- 13. Pitfalls
- 14. Plugins
- 15. Data views and app shells
- 16. Several programs per app, app-local crates
- 17. Network programs
- 18. Updates
- 19. Accessibility (screen readers)
- 20. Secrets (passwords, tokens, keys)
- 21. Desktop integration: keeping awake, autostart, taskbar, file types, recent files, monitors, global shortcuts, the screen
- 22. Diagrams: nodes, ports and edges
- 23. Consoles: ui.terminal
- 24. Multi-colour vector symbols
- 25. Event timeline and hex view
- 26. Command trees: base::cmdtree
- 27. Keyboard operation
- 28. Rich text and code editors: ui.richtext, ui.code_editor
- 29. Scripts: script (compiler and VM)
- 30. Live inspector
- 31. SVG images and the image viewer
- 32. Markdown / HTML viewer and lists with rows of different heights
- 33. Sound: streams, short sounds, the system's sounds
- 34. App themes and the style at run time
- 35. Windows inside an area, a taskbar and full screen
- 36. Sensors and location: plat::sensors
- 37. The finger
- 38. Phones and tablets
- 39. Games: pointer lock, raw mouse motion, key positions, game pads
- 40. PDF, tables, drawings and other files