Skip to main content

Crate nifty_runtime

Crate nifty_runtime 

Source
Expand description

Platform-independent core of the Nifty runtime: a retained tree of native widgets with flexbox layout, and the engine that keeps an app’s windows in step with its state. Each platform crate implements Backend with that OS’s widgets.

Modules§

backend 🔒
The contract each platform (AppKit, Win32, GTK) implements with its own native widgets.
coded 🔒
Enums compiled apps store by number.
dialog 🔒
File dialogs, shared by the interpreter and compiled apps. Code asks for one during an event; it is shown once the event has finished and the UI caught up, and the user’s answer comes back through the app’s waker, like a download’s reports.
download 🔒
What a download(…) call can bind, shared by the checker, which reads the call, and everything that runs it.
failure 🔒
Why running an app’s code can fail. The interpreter and compiled apps both report these, so an app fails the same way however it runs.
geometry 🔒
Geometry in logical points, origin top-left, y growing downward.
layout 🔒
Flexbox layout over native widgets: Taffy computes frames, the caller applies them.
menu 🔒
Menus and the keyboard shortcuts of their items, which every platform builds with its own menus.
path 🔒
Paths into a value, shared by the interpreter’s and compiled apps’ places.
paths 🔒
Paths as apps write them, shared by downloads and file dialogs.
reactive 🔒
Shows an app’s windows from templates and keeps them in step with its state.
state 🔒
Which app state a part of the UI reads, so it can be shown again when that state changes.
style 🔒
Appearance options shared by every backend.
ui 🔒
The retained UI that apps drive: create native widgets, arrange them, update them. Changes are laid out together when Ui::flush runs, once per event.

Structs§

AppTemplate
Everything an app shows: its windows, and the menus of its menu bar.
Dialogs
The dialogs an app has asked for, and the answers that have come back. T says where each answer goes, in whatever terms the app uses.
Engine
A running app: its logic, its windows, and what each widget shows.
FileDialog
A dialog as the platform shows it.
Frame
ImageSize
The size an image is shown at: a fixed width or height in points, or ImageSize::FIT for the image’s own. Fixing only one keeps the image’s shape. repr(C) because compiled apps store it as is.
LabelStyle
repr(C) because compiled apps store it as is.
Menu
A menu: its title, and its entries in order. A is what an item does: an action the app runs, or, as backends receive it, the number of the item.
MenuBar
The app’s menus, whose items run their actions with frame as their locals.
NoHomeFolder
Node
A widget, stack or spacer inside one window.
Point
Position
Where a new node goes: at index among the children of parent.
Shortcut
A keyboard shortcut: the platform’s command key, Cmd on macOS and Ctrl on Windows, with key, and Shift or Alt (Option on macOS) when set. repr(C) because compiled apps store it as is.
Shown
Part of what a region shows: templates, with frame as their locals.
Size
StackStyle
repr(C) because compiled apps store it as is.
StateId
One state declaration of the app, numbered in the order they are declared.
StateSet
States read by a dynamic part of the UI, sorted and without duplicates.
Ui
A shared handle to the app’s windows; clones refer to the same UI.
WindowId
WindowRequest
A request for the app’s window at window, its position among the app’s windows.
WindowTemplate
A window and the column it shows its content in.

Enums§

Align
Placement of children across a stack’s axis.
Axis
Backdrop
What a window is drawn on, in each platform’s own materials.
ButtonStyle
DialogKind
What a dialog asks the user to pick. Compiled code passes it to the runtime as a u32, which every platform’s C calling convention passes without widening.
DownloadCommand
What code asks of a running download, by its id. repr(u32) because compiled apps pass it to the runtime, which every platform’s C calling convention passes without widening.
DownloadField
A piece of state a download reports into. Compiled apps pass it to the runtime by its code.
Failure
Icon
Symbols from the platform’s own icon set: SF Symbols on macOS, Segoe Fluent Icons on Windows. Nothing is bundled with the app.
Justify
Distribution of children along a stack’s axis.
Key
A key a shortcut presses with the platform’s command key.
MenuEntry
Parent
Where a new widget goes: straight into a window’s content area, or into the content of a scroll area, which scrolls with it. Frames are relative to that parent’s content.
Picked
How a dialog closed.
ShortcutError
Why a shortcut can’t be read.
Step
One step from a value into part of it: a struct’s field, or a list’s item, by position.
Surface
What a stack is drawn on. Each surface is one native view behind the stack’s children, using the platform’s own materials and colors.
SystemCommand
The commands the system’s own menus and text fields take shortcuts for, which an app’s menus leave alone.
Template
One element of a window’s UI, before it is shown.
TextAlign
Placement of text within its frame.
TextColor
Semantic text colors, so text follows the system appearance and accent color.
TextStyle
The platform’s system text styles, so apps follow the system font and accessibility sizes.
ToggleStyle
How a control that turns a bool on and off looks.
Widget
WindowAction
What code asks of a window. repr(u32) because compiled apps pass it to the runtime, which every platform’s C calling convention passes without widening.

Constants§

ALT
MAX_CALL_DEPTH
How deeply functions may call each other before the app stops with an error. The interpreter takes roughly 10 KB of native stack per call in debug builds, so this stops runaway recursion well before a 2 MB thread stack overflows.
SHIFT
The modifiers a shortcut may add to the command key, as code writes them.

Traits§

Backend
Logic
The program behind an app’s UI. Templates hold its handles to values, bindings, actions and regions, and the engine asks it to evaluate them against a frame of locals.
ShowDialog
Shows file dialogs; every Backend is one, so code that isn’t generic over the backend can hold it as Rc<dyn ShowDialog>.
Waker
Asks the UI thread to run its wake handler; see Backend::waker.

Functions§

expand_home
path with a leading ~ standing for the user’s home folder.

Type Aliases§

ClickHandler
CloseHandler
Runs when the user asks to close a window.
DialogHandler
DropHandler
Runs with what the user dropped: a path for each file, an address for each link.
ErrorHandler
MenuHandler
Runs with the number of the menu item the user chose.
NumberHandler
ResizeHandler
Templates
TextHandler
ToggleHandler
WakeHandler
WindowCloseHandler
Decides what happens when the user asks to close a window.