slint-ui
Version:
Slint is a declarative GUI toolkit to build native user interfaces for desktop and embedded applications.
627 lines (621 loc) • 29 kB
text/typescript
// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
// AUTO-GENERATED by api/node/build.rs from internal/common/enums.rs
// and internal/common/builtin_structs.rs. Do not edit.
import { DataTransfer } from "../../binding.cjs";
const _data = {
/**
* The enum reports what happened to the `PointerEventButton` in the event
*/
PointerEventKind: {
/**
* The action was cancelled.
*/
Cancel: "cancel",
/**
* The button was pressed.
*/
Down: "down",
/**
* The button was released.
*/
Up: "up",
/**
* The pointer has moved,
*/
Move: "move",
},
/**
* This enum describes the different types of buttons for a pointer event,
* typically on a mouse or a pencil.
*/
PointerEventButton: {
/**
* A button that is none of left, right, middle, back or forward. For example,
* this is used for the task button on a mouse with many buttons.
*/
Other: "other",
/**
* The left button.
*/
Left: "left",
/**
* The right button.
*/
Right: "right",
/**
* The center button.
*/
Middle: "middle",
/**
* The back button.
*/
Back: "back",
/**
* The forward button.
*/
Forward: "forward",
},
/**
* This enum represents the different values for the `accessible-role` property, used to describe the
* role of an element in the context of assistive technology such as screen readers.
*
* In addition to widget roles, this enum includes *landmark* roles (`banner`, `complementary`,
* `content-info`, `form`, `main`, `navigation`, `region`, `search`).
* Landmarks identify large content areas that screen reader users can jump between,
* giving the application a navigable structure similar to headings in a document.
* See [WAI-ARIA Landmark Regions](https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/)
* for guidance on when and how to use them.
*/
AccessibleRole: {
/**
* The element isn't accessible.
*/
None: "none",
/**
* The element is a `Button` or behaves like one.
*/
Button: "button",
/**
* The element is a `CheckBox` or behaves like one.
*/
Checkbox: "checkbox",
/**
* The element is a `ComboBox` or behaves like one.
*/
Combobox: "combobox",
/**
* The element is a `GroupBox` or behaves like one.
*/
Groupbox: "groupbox",
/**
* The element is an `Image` or behaves like one. This is automatically applied to `Image` elements.
*/
Image: "image",
/**
* The element is a `ListView` or behaves like one.
*/
List: "list",
/**
* The element is a `Slider` or behaves like one.
*/
Slider: "slider",
/**
* The element is a `SpinBox` or behaves like one.
*/
Spinbox: "spinbox",
/**
* The element is a `Tab` or behaves like one.
*/
Tab: "tab",
/**
* The element is similar to the tab bar in a `TabWidget`.
*/
TabList: "tab-list",
/**
* The element is a container for tab content.
*/
TabPanel: "tab-panel",
/**
* The role for a `Text` element. This is automatically applied to `Text` elements.
*/
Text: "text",
/**
* The role for a `TableView` or behaves like one.
*/
Table: "table",
/**
* The role for a TreeView or behaves like one. (Not provided yet)
*/
Tree: "tree",
/**
* The element is a `ProgressIndicator` or behaves like one.
*/
ProgressIndicator: "progress-indicator",
/**
* The role for widget with editable text such as a `LineEdit` or a `TextEdit`.
* This is automatically applied to `TextInput` elements.
*/
TextInput: "text-input",
/**
* The element is a `Switch` or behaves like one.
*/
Switch: "switch",
/**
* The element is an item in a `ListView`.
*/
ListItem: "list-item",
/**
* The element is a `RadioButton` or behaves like one.
*/
RadioButton: "radio-button",
/**
* The element is a container grouping related `RadioButton`s.
*/
RadioGroup: "radio-group",
/**
* Landmark: the header area of the application, typically containing a logo, title, or global navigation.
*/
Banner: "banner",
/**
* Landmark: a supporting section that complements the main content, such as a sidebar.
*/
Complementary: "complementary",
/**
* Landmark: information about the application or its content, typically at the bottom (e.g. status bar, copyright).
*/
ContentInfo: "content-info",
/**
* Landmark: a region containing input fields and controls for submitting information.
*/
Form: "form",
/**
* Landmark: the primary content of the application. Each view should have exactly one `main` landmark.
*/
Main: "main",
/**
* Landmark: a group of links or controls used for navigating the application.
*/
Navigation: "navigation",
/**
* Landmark: a generic section significant enough to be listed in a summary.
* Use a more specific landmark if one applies.
*/
Region: "region",
/**
* Landmark: a region containing controls for searching or filtering content.
*/
Search: "search",
},
/**
* This enum represents the different values of the `accessible-live-region` property.
* It indicates that an element is a live region whose content changes should be
* announced by assistive technologies.
*/
AccessibleLiveness: {
/**
* Use in regions that present information that is of low-importance to the user.
* Assistive technologies are expected to not announce changes unless the user explicitly asks for it.
*/
Off: "off",
/**
* Use in regions that present new information to users.
* Assistive technologies are expected to not interrupt the user to inform of changes to the live region.
*/
Polite: "polite",
/**
* Use in regions that present information that a user should know about right away.
* Assistive technologies are expected to announce to the user as soon as possible.
*/
Assertive: "assertive",
},
/**
* This enum represents the different values of the `sort-order` property.
* It's used to sort a `StandardTableView` by a column.
*/
SortOrder: {
/**
* The column is unsorted.
*/
Unsorted: "unsorted",
/**
* The column is sorted in ascending order.
*/
Ascending: "ascending",
/**
* The column is sorted in descending order.
*/
Descending: "descending",
},
/**
* Represents the orientation of an element or widget such as the `Slider`.
*/
Orientation: {
/**
* Element is oriented horizontally.
*/
Horizontal: "horizontal",
/**
* Element is oriented vertically.
*/
Vertical: "vertical",
},
/**
* This enum indicates the color scheme used by the widget style. Use this to explicitly switch
* between dark and light schemes, or choose Unknown to fall back to the system default.
*/
ColorScheme: {
/**
* The scheme is not known and a system wide setting configures this. This could mean that
* the widgets are shown in a dark or light scheme, but it could also be a custom color scheme.
*/
Unknown: "unknown",
/**
* The style chooses light colors for the background and dark for the foreground.
*/
Dark: "dark",
/**
* The style chooses dark colors for the background and light for the foreground.
*/
Light: "light",
},
/**
* This enum describes the action negotiated between the source of a drag (`DragArea`)
* and its target (`DropArea`) during a drag-and-drop operation. The source declares
* which actions it permits, the target picks one in its `can-drop` callback, and the
* chosen action is reported back to the source via `drag-finished` so that, for
* example, a `move` source can remove the original data. The same enum is used for
* drags that come from another application or window once native drag-and-drop is
* in play.
*/
DragAction: {
/**
* No action: the drag is rejected, no drop will be delivered.
*/
None: "none",
/**
* The data is copied to the target; the source retains it.
*/
Copy: "copy",
/**
* The data is moved to the target; the source should remove it once the
* operation completes.
*/
Move: "move",
/**
* A link to the source data is created at the target; neither side gives
* up ownership.
*/
Link: "link",
},
/**
* Build a value of this struct. Any field you omit takes a documented default,
* which lets Slint add fields later without breaking existing call-sites.
*
* The `KeyboardModifiers` struct provides booleans to indicate possible modifier keys on a keyboard, such as Shift, Control, etc.
* It is provided as part of `KeyEvent`'s `modifiers` field.
*
* Keyboard shortcuts on Apple platforms typically use the Command key (⌘), such as Command+C for "Copy". On other platforms
* the same shortcut is typically represented using Control+C. To make it easier to develop cross-platform applications, on macOS,
* Slint maps the Command key to the control modifier, and the Control key to the meta modifier.
*
* On Windows, the Windows key is mapped to the meta modifier.
*/
KeyboardModifiers: (props?: Partial<language.KeyboardModifiers>): language.KeyboardModifiers => Object.freeze({ alt: false, control: false, shift: false, meta: false, ...props }),
/**
* Build a value of this struct. Any field you omit takes a documented default,
* which lets Slint add fields later without breaking existing call-sites.
*
* Represents a Pointer event sent by the windowing system.
* This structure is passed to the `pointer-event` callback of the `TouchArea` element.
*/
PointerEvent: (props?: Partial<language.PointerEvent>): language.PointerEvent => Object.freeze({ button: "other", kind: "cancel", modifiers: _data.KeyboardModifiers(), touch_finger_id: 0, ...props }),
/**
* Build a value of this struct. Any field you omit takes a documented default,
* which lets Slint add fields later without breaking existing call-sites.
*
* Represents a Pointer scroll (or wheel) event sent by the windowing system.
* This structure is passed to the `scroll-event` callback of the `TouchArea` element.
*/
PointerScrollEvent: (props?: Partial<language.PointerScrollEvent>): language.PointerScrollEvent => Object.freeze({ delta_x: 0, delta_y: 0, modifiers: _data.KeyboardModifiers(), ...props }),
/**
* Build a value of this struct. Any field you omit takes a documented default,
* which lets Slint add fields later without breaking existing call-sites.
*
* This structure is generated and passed to the key press and release callbacks of the `FocusScope` element.
*/
KeyEvent: (props?: Partial<language.KeyEvent>): language.KeyEvent => Object.freeze({ text: "", modifiers: _data.KeyboardModifiers(), repeat: false, ...props }),
/**
* Build a value of this struct. Any field you omit takes a documented default,
* which lets Slint add fields later without breaking existing call-sites.
*
* This structure is passed to the callbacks of the `DropArea` element
*/
DropEvent: (props?: Partial<language.DropEvent>): language.DropEvent => Object.freeze({ data: new DataTransfer(), position: { x: 0, y: 0 }, proposed_action: "none", ...props }),
/**
* Build a value of this struct. Any field you omit takes a documented default,
* which lets Slint add fields later without breaking existing call-sites.
*
* Represents an item in a StandardListView and a StandardTableView.
*/
StandardListViewItem: (props?: Partial<language.StandardListViewItem>): language.StandardListViewItem => Object.freeze({ text: "", ...props }),
/**
* Build a value of this struct. Any field you omit takes a documented default,
* which lets Slint add fields later without breaking existing call-sites.
*
* This is used to define the column and the column header of a TableView
*/
TableColumn: (props?: Partial<language.TableColumn>): language.TableColumn => Object.freeze({ title: "", min_width: 0, horizontal_stretch: 0, sort_order: "unsorted", width: 0, ...props }),
} as const;
/**
* Built-in enums and structs from the Slint language.
* Enum values are accessed via `language.ColorScheme.Dark`; struct values via the
* factory call `language.PointerEvent({ button: … })`. Enum and struct types are
* available in type position as `language.ColorScheme` / `language.PointerEvent`.
*/
export const language = _data;
/** Named types for the enum values in {@link language} and the built-in language structs. */
// biome-ignore lint/style/useConst: declaration-merging namespace, type-only.
export namespace language {
/**
* The enum reports what happened to the `PointerEventButton` in the event
*
* Variants:
* - `language.PointerEventKind.Cancel` (`"cancel"`) — The action was cancelled.
* - `language.PointerEventKind.Down` (`"down"`) — The button was pressed.
* - `language.PointerEventKind.Up` (`"up"`) — The button was released.
* - `language.PointerEventKind.Move` (`"move"`) — The pointer has moved,
*/
export type PointerEventKind = (typeof _data.PointerEventKind)[keyof typeof _data.PointerEventKind];
/**
* This enum describes the different types of buttons for a pointer event,
* typically on a mouse or a pencil.
*
* Variants:
* - `language.PointerEventButton.Other` (`"other"`) — A button that is none of left, right, middle, back or forward. For example, this is used for the task button on a mouse with many buttons.
* - `language.PointerEventButton.Left` (`"left"`) — The left button.
* - `language.PointerEventButton.Right` (`"right"`) — The right button.
* - `language.PointerEventButton.Middle` (`"middle"`) — The center button.
* - `language.PointerEventButton.Back` (`"back"`) — The back button.
* - `language.PointerEventButton.Forward` (`"forward"`) — The forward button.
*/
export type PointerEventButton = (typeof _data.PointerEventButton)[keyof typeof _data.PointerEventButton];
/**
* This enum represents the different values for the `accessible-role` property, used to describe the
* role of an element in the context of assistive technology such as screen readers.
*
* In addition to widget roles, this enum includes *landmark* roles (`banner`, `complementary`,
* `content-info`, `form`, `main`, `navigation`, `region`, `search`).
* Landmarks identify large content areas that screen reader users can jump between,
* giving the application a navigable structure similar to headings in a document.
* See [WAI-ARIA Landmark Regions](https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/)
* for guidance on when and how to use them.
*
* Variants:
* - `language.AccessibleRole.None` (`"none"`) — The element isn't accessible.
* - `language.AccessibleRole.Button` (`"button"`) — The element is a `Button` or behaves like one.
* - `language.AccessibleRole.Checkbox` (`"checkbox"`) — The element is a `CheckBox` or behaves like one.
* - `language.AccessibleRole.Combobox` (`"combobox"`) — The element is a `ComboBox` or behaves like one.
* - `language.AccessibleRole.Groupbox` (`"groupbox"`) — The element is a `GroupBox` or behaves like one.
* - `language.AccessibleRole.Image` (`"image"`) — The element is an `Image` or behaves like one. This is automatically applied to `Image` elements.
* - `language.AccessibleRole.List` (`"list"`) — The element is a `ListView` or behaves like one.
* - `language.AccessibleRole.Slider` (`"slider"`) — The element is a `Slider` or behaves like one.
* - `language.AccessibleRole.Spinbox` (`"spinbox"`) — The element is a `SpinBox` or behaves like one.
* - `language.AccessibleRole.Tab` (`"tab"`) — The element is a `Tab` or behaves like one.
* - `language.AccessibleRole.TabList` (`"tab-list"`) — The element is similar to the tab bar in a `TabWidget`.
* - `language.AccessibleRole.TabPanel` (`"tab-panel"`) — The element is a container for tab content.
* - `language.AccessibleRole.Text` (`"text"`) — The role for a `Text` element. This is automatically applied to `Text` elements.
* - `language.AccessibleRole.Table` (`"table"`) — The role for a `TableView` or behaves like one.
* - `language.AccessibleRole.Tree` (`"tree"`) — The role for a TreeView or behaves like one. (Not provided yet)
* - `language.AccessibleRole.ProgressIndicator` (`"progress-indicator"`) — The element is a `ProgressIndicator` or behaves like one.
* - `language.AccessibleRole.TextInput` (`"text-input"`) — The role for widget with editable text such as a `LineEdit` or a `TextEdit`. This is automatically applied to `TextInput` elements.
* - `language.AccessibleRole.Switch` (`"switch"`) — The element is a `Switch` or behaves like one.
* - `language.AccessibleRole.ListItem` (`"list-item"`) — The element is an item in a `ListView`.
* - `language.AccessibleRole.RadioButton` (`"radio-button"`) — The element is a `RadioButton` or behaves like one.
* - `language.AccessibleRole.RadioGroup` (`"radio-group"`) — The element is a container grouping related `RadioButton`s.
* - `language.AccessibleRole.Banner` (`"banner"`) — Landmark: the header area of the application, typically containing a logo, title, or global navigation.
* - `language.AccessibleRole.Complementary` (`"complementary"`) — Landmark: a supporting section that complements the main content, such as a sidebar.
* - `language.AccessibleRole.ContentInfo` (`"content-info"`) — Landmark: information about the application or its content, typically at the bottom (e.g. status bar, copyright).
* - `language.AccessibleRole.Form` (`"form"`) — Landmark: a region containing input fields and controls for submitting information.
* - `language.AccessibleRole.Main` (`"main"`) — Landmark: the primary content of the application. Each view should have exactly one `main` landmark.
* - `language.AccessibleRole.Navigation` (`"navigation"`) — Landmark: a group of links or controls used for navigating the application.
* - `language.AccessibleRole.Region` (`"region"`) — Landmark: a generic section significant enough to be listed in a summary. Use a more specific landmark if one applies.
* - `language.AccessibleRole.Search` (`"search"`) — Landmark: a region containing controls for searching or filtering content.
*/
export type AccessibleRole = (typeof _data.AccessibleRole)[keyof typeof _data.AccessibleRole];
/**
* This enum represents the different values of the `accessible-live-region` property.
* It indicates that an element is a live region whose content changes should be
* announced by assistive technologies.
*
* Variants:
* - `language.AccessibleLiveness.Off` (`"off"`) — Use in regions that present information that is of low-importance to the user. Assistive technologies are expected to not announce changes unless the user explicitly asks for it.
* - `language.AccessibleLiveness.Polite` (`"polite"`) — Use in regions that present new information to users. Assistive technologies are expected to not interrupt the user to inform of changes to the live region.
* - `language.AccessibleLiveness.Assertive` (`"assertive"`) — Use in regions that present information that a user should know about right away. Assistive technologies are expected to announce to the user as soon as possible.
*/
export type AccessibleLiveness = (typeof _data.AccessibleLiveness)[keyof typeof _data.AccessibleLiveness];
/**
* This enum represents the different values of the `sort-order` property.
* It's used to sort a `StandardTableView` by a column.
*
* Variants:
* - `language.SortOrder.Unsorted` (`"unsorted"`) — The column is unsorted.
* - `language.SortOrder.Ascending` (`"ascending"`) — The column is sorted in ascending order.
* - `language.SortOrder.Descending` (`"descending"`) — The column is sorted in descending order.
*/
export type SortOrder = (typeof _data.SortOrder)[keyof typeof _data.SortOrder];
/**
* Represents the orientation of an element or widget such as the `Slider`.
*
* Variants:
* - `language.Orientation.Horizontal` (`"horizontal"`) — Element is oriented horizontally.
* - `language.Orientation.Vertical` (`"vertical"`) — Element is oriented vertically.
*/
export type Orientation = (typeof _data.Orientation)[keyof typeof _data.Orientation];
/**
* This enum indicates the color scheme used by the widget style. Use this to explicitly switch
* between dark and light schemes, or choose Unknown to fall back to the system default.
*
* Variants:
* - `language.ColorScheme.Unknown` (`"unknown"`) — The scheme is not known and a system wide setting configures this. This could mean that the widgets are shown in a dark or light scheme, but it could also be a custom color scheme.
* - `language.ColorScheme.Dark` (`"dark"`) — The style chooses light colors for the background and dark for the foreground.
* - `language.ColorScheme.Light` (`"light"`) — The style chooses dark colors for the background and light for the foreground.
*/
export type ColorScheme = (typeof _data.ColorScheme)[keyof typeof _data.ColorScheme];
/**
* This enum describes the action negotiated between the source of a drag (`DragArea`)
* and its target (`DropArea`) during a drag-and-drop operation. The source declares
* which actions it permits, the target picks one in its `can-drop` callback, and the
* chosen action is reported back to the source via `drag-finished` so that, for
* example, a `move` source can remove the original data. The same enum is used for
* drags that come from another application or window once native drag-and-drop is
* in play.
*
* Variants:
* - `language.DragAction.None` (`"none"`) — No action: the drag is rejected, no drop will be delivered.
* - `language.DragAction.Copy` (`"copy"`) — The data is copied to the target; the source retains it.
* - `language.DragAction.Move` (`"move"`) — The data is moved to the target; the source should remove it once the operation completes.
* - `language.DragAction.Link` (`"link"`) — A link to the source data is created at the target; neither side gives up ownership.
*/
export type DragAction = (typeof _data.DragAction)[keyof typeof _data.DragAction];
/**
* The `KeyboardModifiers` struct provides booleans to indicate possible modifier keys on a keyboard, such as Shift, Control, etc.
* It is provided as part of `KeyEvent`'s `modifiers` field.
*
* Keyboard shortcuts on Apple platforms typically use the Command key (⌘), such as Command+C for "Copy". On other platforms
* the same shortcut is typically represented using Control+C. To make it easier to develop cross-platform applications, on macOS,
* Slint maps the Command key to the control modifier, and the Control key to the meta modifier.
*
* On Windows, the Windows key is mapped to the meta modifier.
*/
export type KeyboardModifiers = {
/**
* Indicates the Alt key on a keyboard.
*/
alt: boolean;
/**
* Indicates the Control key on a keyboard, except on macOS, where it is the Command key (⌘).
*/
control: boolean;
/**
* Indicates the Shift key on a keyboard.
*/
shift: boolean;
/**
* Indicates the Control key on macos, and the Windows key on Windows.
*/
meta: boolean;
};
/**
* Represents a Pointer event sent by the windowing system.
* This structure is passed to the `pointer-event` callback of the `TouchArea` element.
*/
export type PointerEvent = {
/**
* The button that was pressed or released
*/
button: PointerEventButton;
/**
* The kind of the event
*/
kind: PointerEventKind;
/**
* The keyboard modifiers pressed during the event
*/
modifiers: KeyboardModifiers;
/**
* The unique ID of the touch point, indicating the finger ID. 0 means it's not a touch event (e.g., mouse).
*/
touch_finger_id: number;
};
/**
* Represents a Pointer scroll (or wheel) event sent by the windowing system.
* This structure is passed to the `scroll-event` callback of the `TouchArea` element.
*/
export type PointerScrollEvent = {
/**
* The amount of pixel in the horizontal direction
*/
delta_x: number;
/**
* The amount of pixel in the vertical direction
*/
delta_y: number;
/**
* The keyboard modifiers pressed during the event
*/
modifiers: KeyboardModifiers;
};
/**
* This structure is generated and passed to the key press and release callbacks of the `FocusScope` element.
*/
export type KeyEvent = {
/**
* The unicode representation of the key pressed.
*/
text: string;
/**
* The keyboard modifiers active at the time of the key press event.
*/
modifiers: KeyboardModifiers;
/**
* This field is set to true for key press events that are repeated,
* i.e. the key is held down. It's always false for key release events.
*/
repeat: boolean;
};
/**
* This structure is passed to the callbacks of the `DropArea` element
*/
export type DropEvent = {
/**
* The payload set on the source `DragArea`.
*/
data: DataTransfer;
/**
* The cursor position in the `DropArea`'s local coordinates.
*/
position: { x: number; y: number };
/**
* The action negotiated from current modifier state, clamped to the allowed set;
* when no modifier is pressed, the first allowed of move, copy, link.
* Updated on every `DragMove`. The target's `can-drop` callback can return this
* to honor the user's modifier choice, or override with any other allowed action.
*/
proposed_action: DragAction;
};
/**
* Represents an item in a StandardListView and a StandardTableView.
*/
export type StandardListViewItem = {
/**
* The text content of the item
*/
text: string;
};
/**
* This is used to define the column and the column header of a TableView
*/
export type TableColumn = {
/**
* The title of the column header
*/
title: string;
/**
* The minimum column width (logical length)
*/
min_width: number;
/**
* The horizontal column stretch
*/
horizontal_stretch: number;
/**
* Sorts the column
*/
sort_order: SortOrder;
/**
* the actual width of the column (logical length)
*/
width: number;
};
}