Skip to main content

Crate mitsuami_core

Crate mitsuami_core 

Source
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 and opening files in other apps. 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. See t!.

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 with on_change.call(v). The default does nothing.
CellKey
A cell of a Table: its row, and its column’s index.
ColumnData
A column of a Table, as backends get it.
ColumnSort
The column a Table is 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.
CurrentWindow
The window whose content is being built: provided in each window’s scope, so views can find the window they’re in (a modal Window belongs to it, a Toolbar’s items go in its toolbar).
Custom
A custom widget in the view tree: Custom::<Rating>::new(props), or Rating::view(props) through CustomView.
CustomProps
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 Element and add typed methods.
FileDrop
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-for with :key.
List
A virtualised list of rows, shown by the platform’s own list control.
ListHandle
Scrolls a List from code: create one, pass it to List::handle, and call scroll_to.
Modifiers
The modifier keys held with an event. meta is Command on macOS, the Super (Windows) key elsewhere.
NativeAppInfo
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.
NodeInfo
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 (by Show, For) sets it again, and it’s None while nothing is built. It also focuses the node from code (focus, select_text).
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 scale pixels 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: resource or resource_on.
RowKey
Identity of a row of a List, stable while its item’s key stays in the data. Assigned by the core.
RowRender
How a List renders a row.
Show
Renders then while when is true, otherwise the optional fallback. Vue’s v-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.
SidebarItemData
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.
SidebarSectionData
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 Table is sorted: by the column with this sort key, and which way.
SurfaceHandle
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 implements raw-window-handle’s traits, so wgpu takes it as is: instance.create_surface(handle.clone()).
SurfaceSize
How large a GpuSurface is, 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.
TableColumn
A column of a Table: its header’s title, and the view each row shows in its cell.
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 its tweak (or tweak_with), which gets the native control itself; pick one per platform with platform!:
Ui
Handle to a UI instance: one backend, its windows and their node trees. Cheap to clone; all clones share the same state.
WeakUi
Non-owning Ui handle, 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 .ico file on Windows, with its sizes). Give it large (256 or 512 pixels square): platforms scale it down.
ButtonRole
What a button does in its window or dialog, which each platform shows and handles its own way. Platforms without an equivalent ignore it.
ButtonStyle
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.
FontWeight
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.
HorizontalAlign
A TextAlign the core has resolved against the text’s direction, as backends get it.
ImageFit
How an Image fills 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.
ImageSource
What an Image shows.
InputPurpose
What a TextInput is 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 code names (KeyA is the key right of Caps Lock, also on an AZERTY keyboard).
LayoutDirection
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).
ListStyle
How a List sits in its surroundings, mapped to each platform’s native look. Choosing per platform is up to the app, with platform!.
Modality
What a modal Window blocks while it’s open, shown each platform’s way.
MouseButton
A pointer button, as the platform names it: the primary one is the left one for right-handed users.
NativeIcon
Orientation
Which way a Slider or a Separator runs. Every platform has vertical sliders; larger values are up on all of them.
Prop
A property of a native widget. Which ones apply depends on the kind.
ScrollAxes
Scrolling directions of a ScrollView.
ScrollDelta
How far a scroll went.
SelectionMode
How many rows of a List can be selected.
SortOrder
Which way a Table is sorted.
SurfaceInput
Input on a GpuSurface that takes it, reported as UiEvent::SurfaceInput.
TabsStyle
How a Tabs shows its tabs, where the platform has more than one way (GNOME and KDE). The others show theirs, and ignore it.
TextAlign
Where a Text’s lines go across its frame, in its reading direction: Start is the left in left-to-right text, the right in right-to-left.
TextStyle
Semantic text styles, mapped to each platform’s type ramp.
Truncation
Where a Text cut 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.
WidgetKind

Traits§

Children
Anything that can be a list of children: a view, a tuple of views, a Vec, an Option, or ().
CustomView
Rating::view(props): shorthand for Custom::<Rating>::new(props).
CustomWidget
The shared, platform-free definition of a custom widget.
Drawn
The drawn tier: measured, drawn and hit-tested in shared code.
ElementBuilder
Style, semantics and test hooks shared by every widget builder.
NativeSurface
A backend’s native surface: what raw-window-handle describes for a GPU API to present to (an NSView backed by a CAMetalLayer, 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 run so each dispatch runs it as a task, tracking whether any is pending and keeping the value of the latest one.
node_ref
Creates a NodeRef owned by the current scope.
provide_stores
Makes use_store work in the current scope and below: the stores live as long as it. App and TestApp call it in their app scope.
resource
Loads fetch() now; again on Resource::refetch.
resource_on
Loads fetch(source()) now, and again whenever the signals source reads change. Vue’s watch plus a fetch; the future’s own reads aren’t tracked.
use_size
The size of the node node refers 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 one provided 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.