Skip to main content

Crate mitsuami_widgets

Crate mitsuami_widgets 

Source
Expand description

Built-in widgets. Platform-free: each is an Element with typed props, events and accessibility defaults. Backends decide how they look.

Structs§

Button
Checkbox
Column
Vertical flex container. new() returns a Container: chain its methods, and the style setters of ElementBuilder.
Container
A layout host: flexbox (column by default) or grid.
DocumentTab
A tab of DocumentTabs: its title, and the value choosing it gives the tabs’ selection.
DocumentTabs
Tabs for the documents the app has open, as a browser’s or a terminal’s: the platform’s own (in the title bar on macOS, as Safari’s and Xcode’s, and on Windows; libadwaita’s tab bar on GNOME, a tab bar on KDE). The tabs have no pages: the app shows the chosen document itself, in one place, as a terminal draws its sessions on one surface.
FileIcon
A file’s or folder’s own icon, as the platform’s file manager shows it: an app’s own, a folder’s custom one, a document’s by its type (the icon theme’s on Linux). It’s a square as big as the platform’s small icons (16 points) unless icon_size says otherwise. With thumbnail, a preview of what’s in the file (a picture’s, a document’s first page) where the platform makes one. The file is read when it’s set. Its label is its accessible name; without one it’s decorative, as it usually sits beside the file’s name.
GpuSurface
A surface the app draws on with its own GPU API (wgpu, Vulkan, Metal, Direct3D), at its own pace and on its own thread, as it would draw on a window of its own: an NSView backed by a CAMetalLayer on AppKit. It has no natural size; the layout sizes it.
Grid
Grid container. new() returns a Container: chain its methods (columns, rows), and the style setters of ElementBuilder.
Group
A box around related content, as the platform groups it: an NSBox (its heading inside, at the top), libadwaita’s card under a heading, a Fluent card under a heading on Windows, a QQC2.GroupBox. The heading is optional; it names the group to assistive technology.
Icon
An icon from the platform’s own set, by its name there: an SF Symbol on macOS, a themed icon’s name on Linux (Adwaita’s symbolic ones on GNOME, Breeze’s on KDE), a Segoe Fluent Icons glyph on Windows. Names differ, so pick one per platform with platform!. Symbolic icons are drawn in the colour the platform gives icons, which follows dark mode. It’s as large as the platform makes icons unless icon_size says otherwise. Its label is its accessible name; without one it’s decorative.
Image
A picture, in the platform’s image view: from a file, or from pixels in memory. It’s as large as the image (in points: pixels over their scale) unless the layout sizes it; then fit says how it fills the frame, or the platform does as it does by default. Its label is its accessible name; without one it’s decorative.
MenuButton
A button that opens a menu of actions, as the platform makes one: a pull-down NSPopUpButton, a gtk::MenuButton, a DropDownButton, a QQC2.Button that opens a QQC2.Menu. Each draws its own arrow. The menu is built as a context menu is, and an item’s on_select runs when it’s chosen. It has no click of its own: clicking opens the menu.
NumberInput
A field for a whole number, with buttons that step it up and down, as the platform’s spin box shows it. Its label is its accessible name; show one beside it with a Text. Typing reports the number when the edit is done (Return, or leaving the field), as each platform commits one. Whole numbers in an i32, because Qt’s spin box holds an int.
PasswordInput
Single-line entry of a password: the platform’s password field, which hides the text as the platform does (bullets, and a button to show it where the platform has one) and never reads it out.
Progress
A progress bar, as the platform draws one: how far along a task is, from 0 to 1, or, until a value is given (or while indeterminate), an animated bar for work of unknown length. Its label is its accessible name.
RadioGroup
Radio buttons, one for each of its options, to choose one from: NSButtons of the radio type, RadioButtons, gtk::CheckButtons in a group, QQC2.RadioButtons. Down a column, as each platform stacks them. Its label is its accessible name; it isn’t drawn, so put a Text above it.
Row
Horizontal flex container. new() returns a Container: chain its methods, and the style setters of ElementBuilder.
ScrollView
A native scroll container. Its children go into a content box that keeps its natural size, so it can be larger than the scroll view.
SearchInput
Single-line entry of search text: the platform’s search field, with its search icon and clear button. on_search is called when the platform asks for a search, as its own apps search.
Select
A pop-up menu of text options to choose one from: NSPopUpButton, ComboBox, gtk::DropDown, QQC2.ComboBox. Its label is its accessible name; like a text field’s, it isn’t drawn, so put a Text next to it.
Separator
A line between groups of content, as the platform draws one: a separator NSBox, gtk::Separator, Kirigami.Separator, and on WinUI, which has no separator control, a Border in the divider brush, as Fluent apps draw one. Horizontal unless told otherwise, as thick as the platform makes it; its length is the layout’s, so it spans a column (or a row, vertical) that stretches its children, as they do by default.
Sidebar
The sidebar of the window it’s declared in: the list down its leading side that picks what the window shows, as in macOS’s System Settings and GNOME’s Settings (a source list on macOS, libadwaita’s navigation split view on GTK, a NavigationView’s pane on Windows, a first column of Kirigami’s page row on KDE). Declare it anywhere in the window’s content; it stays while it does.
SidebarItem
An item of a Sidebar: a title, the value choosing it gives the sidebar’s selection, and optionally an icon, a subtitle and a context menu.
SidebarSection
A group of a Sidebar’s items, under a heading.
Slider
A slider: a number in a range, as the platform’s slider shows it, horizontal or vertical. Its label is its accessible name. What its step does is the platform’s: AppKit shows it as tick marks the knob stops at, WinUI and GTK snap the user’s moves to it, and Qt moves by it from the keyboard.
Spinner
A spinner, as the platform draws one, for work of unknown length: a spinning NSProgressIndicator, gtk::Spinner, ProgressRing, QQC2.BusyIndicator. It spins while running (from the start, unless told otherwise), and shows nothing while stopped, keeping its place. Its label is its accessible name.
Switch
On/off switch. Most platforms draw no caption; the label is its accessible name.
Tab
A page of Tabs: its title, the value picking it gives the tabs’ selection, and what it shows, in a column.
Tabs
Pages, one shown at a time, with a tab for each to pick it: the platform’s own tab view (an NSTabView on macOS, a notebook on GTK, a selector bar over its pages on Windows, a tab bar on KDE). It’s for a fixed set of views, as in a settings window, not documents the user opens and closes.
Text
Static or reactive text.
TextArea
Text over many lines: the platform’s text area, whose lines wrap to its width and where Return starts a new line. It’s as tall as lines of the platform’s text, and scrolls past them.
TextInput
Single-line text entry.
ToggleButton
A button that stays pressed until it’s clicked again, as the platform makes one: an NSButton that pushes on and off, a gtk::ToggleButton, a ToggleButton, a checkable QQC2.Button. Its caption, icon and style are a Button’s; whether it’s pressed is checked, as a checkbox’s.
Toolbar
Items for the toolbar of the window it’s declared in: the bar across the top that shows the window’s title (the unified toolbar on macOS, GTK’s header bar, a command bar on WinUI, the page toolbar on KDE). Declare it anywhere in the window’s content; its items stay while it does.
Window
A window the app opens while it runs: shown while open is true, with its content built when it opens and disposed when it closes. Declare it anywhere in the tree, next to the state that opens it; it closes with the scope that declared it, and belongs to the window it’s declared in.

Traits§

DocumentTabsChildren
What DocumentTabs take as children: DocumentTabs, and tuples, Vecs and Options of them.
SidebarEntries
What a Sidebar takes as children: SidebarItems, SidebarSections, and tuples, Vecs and Options of them.
SidebarItems
What a SidebarSection takes as children: SidebarItems, and tuples, Vecs and Options of them.
TabsChildren
What Tabs take as children: Tabs, and tuples, Vecs and Options of them.