Expand description
mitsuami core: the retained node tree, styles and units, layout, accessibility model, control flow and the backend contract.
See docs/ARCHITECTURE.md
for the design.
Re-exports§
pub use a11y::A11yAction;pub use a11y::A11yNode;pub use a11y::A11yProps;pub use a11y::ActionError;pub use a11y::Role;pub use backend::Appearance;pub use backend::AvailableSpace;pub use backend::Backend;pub use backend::EventSink;pub use backend::Key;pub use backend::MeasureRequest;pub use backend::NativeState;pub use backend::PlatformMetrics;pub use backend::SyntheticInput;pub use backend::TestHooks;pub use command::Command;pub use command::EventValue;pub use command::PointerEvent;pub use command::PointerKind;pub use command::UiEvent;pub use draw::Canvas;pub use draw::Color;pub use draw::DisplayList;pub use draw::Path;pub use draw::Shape;pub use geometry::Insets;pub use geometry::Point;pub use geometry::Rect;pub use geometry::Size;pub use geometry::WindowSize;pub use style::Align;pub use style::Display;pub use style::FlexDirection;pub use style::GridPlacement;pub use style::Justify;pub use style::Style;pub use style::TextDirection;pub use style::Track;pub use style::repeat;pub use table::Sort;pub use table::Table;pub use table::TableColumn;pub use units::Length;pub use units::LengthExt;pub use units::Spacing;pub use mitsuami_reactive as reactive;pub use raw_window_handle;pub use unicode_segmentation;
Modules§
- a11y
- Accessibility model. Every node carries semantics from day one. The test driver uses the same roles, names and actions as assistive technology.
- backend
- The contract every platform backend implements.
- command
- The data flowing between the core and a backend.
- draw
- The drawn tier of custom widgets: a small, platform-neutral 2D API.
- geometry
- graphemes
- Text selections count grapheme clusters, what people see as one
character (
éwith a combining accent, a flag, a family emoji), so none is ever split. Backends get Unicode scalar values (chars). - l10n
- Localization, with Project Fluent.
- services
- Platform services: clipboard, dialogs, the menu bar, the trash, opening files in other apps, notifications, later launches of a single-instance app and the tray icon. Widgets’ context menus are made of the same menus.
- style
- Layout style: the CSS flexbox / grid property set, in abstract units.
- task
- Async on the UI thread: a small executor driven by
Ui::tick, timers on a swappable clock, and a bridge for work done on other threads. - units
- Abstract units, resolved to logical units at layout time.
Macros§
- find_
prop - Finds a prop by pattern in a prop list.
- t
- A message as a closure, for any text a view shows: it follows the app’s language, and the signals the arguments read.
- tr
- A message as a
String, now, for text that isn’t a view’s: an alert’s, a file name. Read in a closure or an effect, it follows the language there. Seet!.
Structs§
- Action
- An async operation and its state:
action. - AnyValue
- Any comparable, printable value: custom widget props and events.
- AnyView
- A type-erased
View. - AppInfo
- The app’s id, name and icon, which the platform shows in its task switcher, dock or taskbar, and uses to match the app’s windows to it. Each platform takes what it has a place for, and a packaged app’s own (a macOS bundle’s, an MSIX package’s) wins over what’s set here.
- Callback
- A component’s event, Vue’s
emit:on_change: Callback<f32>in a#[component]is set with@change=…and fired withon_change.call(v). The default does nothing. - CellKey
- A cell of a
Table: its row, and its column’s index. - Column
Data - A column of a
Table, as backends get it. - Column
Sort - The column a
Tableis sorted by, and which way, as its header shows. - Composed
- What a composed render gets: the props (reactive), a way to emit the widget’s events, and the accessible label the app gave the widget.
- Current
Window - The window whose content is being built: provided in each window’s
scope, so views can find the window they’re in (a modal
Windowbelongs to it, aToolbar’s items go in its toolbar). - Custom
- A custom widget in the view tree:
Custom::<Rating>::new(props), orRating::view(props)throughCustomView. - Custom
Props - The props of a custom widget, as carried by
Prop::Custom: the value plus the widget’s type-erased definition (semantics and renders). - Element
- A node description: kind, style, props (static or reactive), handlers,
semantics and children. Widgets wrap an
Elementand add typed methods. - File
Drop - Which files a node takes when they’re dropped on it: files with these
extensions (any file without a list), and folders if
folders. - For
- Keyed list rendering. Vue’s
v-forwith:key. - List
- A virtualised list of rows, shown by the platform’s own list control.
- List
Handle - Scrolls a
Listfrom code: create one, pass it toList::handle, and callscroll_to. - Modifiers
- The modifier keys held with an event.
metais Command on macOS, the Super (Windows) key elsewhere. - Native
AppInfo - What a window shows of the app, read back from the platform for tests.
- NodeId
- Stable identity of a node for the lifetime of a
Ui. - Node
Info - Snapshot of one native node, for inspection tools and tests.
- NodeRef
- A handle to the node a view builds, set with
.node_ref(…). It follows the node: a view built again (byShow,For) sets it again, and it’sNonewhile nothing is built. It also focuses the node from code (focus,select_text), and brings a window forward (present). - Opaque
- A platform-specific payload the core passes through without looking inside: a native render, a native view factory. Equal only to itself; printed as its label.
- Pixels
- An image in memory: rows of straight (not premultiplied) RGBA8, top
row first, drawn at
scalepixels to a point, so an image made at the window’s scale factor is shown pixel for pixel. - Renderer
- A widget’s renders on the current platform: native, drawn or composed.
The first one present is used: native, then drawn, then composed. The
others stay available (for headless tests,
.drawn(),.composed()). - Resource
- Data loaded asynchronously:
resourceorresource_on. - RowKey
- Identity of a row of a
List, stable while its item’s key stays in the data. Assigned by the core. - RowMoves
- Where rows dragged within a list can be dropped (
List::on_move): onto a row (into a group, say), between rows (to reorder them), or both. A drop on the list’s empty part is at its end, either way. - RowRender
- How a
Listrenders a row. - RunOptions
- How the app runs, beyond who it is: what
Appgives its backend’srun_with. - Show
- Renders
thenwhilewhenis true, otherwise the optional fallback. Vue’sv-if/v-else. Either is any children: a view, or a tuple of them, which take their places in the parent as if written there. Switching branches disposes the old branch’s nodes and reactive state. - Sidebar
Item Data - One item of a
Sidebar: its title, and the name of its icon in the platform’s own set (an SF Symbol, a symbolic theme icon, a Segoe Fluent Icons glyph), which platforms without it ignore. - Sidebar
Section Data - A group of a
Sidebar’s items, under a heading if it has a title. - Slot
- The children a component receives: what goes between its tags. Pass it
on as children (
Column::new().children(children)); it builds once. - Sort
- How a
Tableis sorted: by the column with this sort key, and which way. - Suggestion
- A suggestion of a
SearchInput: what it says, and a second line in the secondary style (a file’s folder, an author’s email). - Surface
Handle - A
GpuSurface’s native surface, for the app to present to with its own GPU API (wgpu, Vulkan, Metal, Direct3D), at its own pace and on its own thread. It implementsraw-window-handle’s traits, so wgpu takes it as is:instance.create_surface(handle.clone()). - Surface
Size - How large a
GpuSurfaceis, in the physical pixels a GPU surface on it should be configured with, and the scale they are at (pixels to a point). - Table
- A virtualised table: rows of cells under column headers, shown by the platform’s own table control.
- Table
Column - A column of a
Table: its header’s title, and the view each row shows in its cell. - Tree
- A virtualised tree of rows, shown by the platform’s own tree control, which draws the disclosures and indents the levels.
- Tree
Indent - How far a
Treeindents its rows’ content, as its platform draws it (TreeIndent): a row’s content is the rows’ width lessstart + per_level × depth. - TreeRow
- A row of a
Treethat shows, as backends get it: its place in the tree, and whether it opens. - Tweak
- Raw platform settings for a built-in widget
W: the escape hatch past its semantic props, for what only one platform has. Each backend makes them with itstweak(ortweak_with), which gets the native control itself; pick one per platform withplatform!: - Ui
- Handle to a UI instance: one backend, its windows and their node trees. Cheap to clone; all clones share the same state.
- Vector
Icon - An icon the app draws, as path data in the SVG path syntax (
M0 0L10 10Z, arcs too), which SVG files, XAML’s and Avalonia’s geometries and most icon sets use. A leadingF0(even-odd) orF1(non-zero), as XAML’s path data has, sets the fill rule; non-zero by default. - WeakUi
- Non-owning
Uihandle, for closures stored inside the tree itself.
Enums§
- AppIcon
- The app’s icon, decoded by the platform: PNG everywhere, other formats
where the platform reads them (an
.icofile on Windows, with its sizes). Give it large (256 or 512 pixels square): platforms scale it down. - Button
Role - What a button does in its window or dialog, which each platform shows and handles its own way. Platforms without an equivalent ignore it.
- Button
Style - How a button is drawn, mapped to each platform’s native look.
- Cursor
- The pointer’s cursor over a
GpuSurface, while it isn’t locked. - Document
Tabs Style - Where
DocumentTabsshow their tabs: in the window’s own chrome, or in the content where they’re declared. - File
Lookup - Where a
FileIcongets its icon. From disk, the platform reads the file or folder for its own icon; by name, nothing is read, as file managers show files that aren’t on disk (a download, an archive’s contents, a file only in an old revision). - Font
Weight - How heavy a
Text’s font is, in place of its text style’s weight. A platform whose font lacks one uses the nearest it has. - Header
Edge - Where a window’s header (
Prop::Header) meets what scrolls under it, where the platform blurs it there (AppKit’s scroll edge effect, macOS 26.1 and later). The others have no such edge, and ignore it. - Horizontal
Align - A
TextAlignthe core has resolved against the text’s direction, as backends get it. - Image
Fit - How an
Imagefills a frame the layout makes a different size from it. Only the fits every platform’s image view has; without one, each fits as it does by default. - Image
Source - What an
Imageshows. - Input
Purpose - What a
TextInputis for, which the platform uses as it uses one: to pick an on-screen keyboard, to offer autofill, to check what’s typed. Only the purposes every platform has. - KeyCode
- A key by where it is on the keyboard, whatever the layout says
it types: the W3C UI Events
codenames (KeyAis the key right of Caps Lock, also on an AZERTY keyboard). - Layout
Direction - Which way a native widget lays itself out, as backends get it: the core has resolved the node’s direction (its own, its parent’s, or the app’s language’s).
- List
Style - How a
Listsits in its surroundings, mapped to each platform’s native look. Choosing per platform is up to the app, withplatform!. - Modality
- What a modal
Windowblocks while it’s open, shown each platform’s way. - Mouse
Button - A pointer button, as the platform names it: the primary one is the left one for right-handed users.
- Native
Icon - Orientation
- Which way a
Slideror aSeparatorruns. Every platform has vertical sliders; larger values are up on all of them. - Path
Step - A step of an icon’s path, in points from the icon’s top left corner.
- Prop
- A property of a native widget. Which ones apply depends on the kind.
- RowDrop
- Where rows dragged within a list were dropped: onto a row, before one, or at the end (the list’s empty part).
- Scroll
Axes - Scrolling directions of a
ScrollView. - Scroll
Delta - How far a scroll went.
- Selection
Mode - How many rows of a
Listcan be selected. - Sort
Order - Which way a
Tableis sorted. - Surface
Input - Input on a
GpuSurfacethat takes it, reported asUiEvent::SurfaceInput. - System
Cursor - The platform cursors a
Cursor::Systemnames: the ones the platforms share, as CSS names them. - Tabs
Style - How a
Tabsshows its tabs, where the platform has more than one way (GNOME and KDE). The others show theirs, and ignore it. - Text
Align - Where a
Text’s lines go across its frame, in its reading direction:Startis the left in left-to-right text, the right in right-to-left. - Text
Style - Semantic text styles, mapped to each platform’s type ramp.
- Truncation
- Where a
Textcut off at its line limit puts its ellipsis: in place of its start, its middle (a path’s folders, keeping its file name) or its end. Start and end are the text’s, so in right-to-left text the start is on the right. Platforms that can’t put one there cut off the end, as their labels do. - Widget
Kind
Traits§
- Children
- Anything that can be a list of children: a view, a tuple of views, a
Vec, anOption, or(). - Custom
View Rating::view(props): shorthand forCustom::<Rating>::new(props).- Custom
Widget - The shared, platform-free definition of a custom widget.
- Drawn
- The drawn tier: measured, drawn and hit-tested in shared code.
- Element
Builder - Style, semantics and test hooks shared by every widget builder.
- Native
Surface - A backend’s native surface: what
raw-window-handledescribes for a GPU API to present to (anNSViewbacked by aCAMetalLayer, a Wayland surface, a child window). - Render
- Which render this platform uses. Implement it once, choosing per
platform with
platform!: - Store
- App-wide state, created once per app by
use_store. - View
- Something that can build itself into the node tree.
Functions§
- action
- Wraps
runso eachdispatchruns it as a task, tracking whether any ispendingand keeping thevalueof the latest one. - moved_
index - Where the item at
indexof a list is after the one atfrommoved toto:DocumentTabs’ chosen tab afterTabMoved. - node_
ref - Creates a
NodeRefowned by the current scope. - provide_
stores - Makes
use_storework in the current scope and below: the stores live as long as it.AppandTestAppcall it in their app scope. - resource
- Loads
fetch()now; again onResource::refetch. - resource_
on - Loads
fetch(source())now, and again whenever the signalssourcereads change. Vue’swatchplus a fetch; the future’s own reads aren’t tracked. - use_
size - The size of the node
noderefers to, like a container query. Zero while it refers to none, and until its first layout. - use_
store - The app’s instance of store
S, created on first use; or the oneprovided nearest to this scope, if any. - use_
viewport - The content size of the window the view is in, like a media query. Zero until its first layout.