pub struct WidgetSpec {Show 62 fields
pub id: WidgetId,
pub kind: WidgetKind,
pub text: Option<String>,
pub text_selection: Option<(usize, usize)>,
pub completion_items: Vec<String>,
pub placeholder_text: Option<String>,
pub parent: Option<WidgetId>,
pub container_direction: Option<ContainerDirection>,
pub container_wrap: Option<ContainerWrap>,
pub container_scroll_vertical: bool,
pub container_scroll_horizontal: bool,
pub container_gap: Option<i32>,
pub container_padding: Option<i32>,
pub size: Option<(i32, i32)>,
pub position: Option<(i32, i32)>,
pub data_list_items: Vec<String>,
pub list_columns: Vec<ColumnSpec>,
pub list_rows: Vec<Vec<String>>,
pub data_grid_rows: Arc<Vec<Vec<String>>>,
pub tree_items: Vec<TreeItem>,
pub background_color: Option<Color>,
pub alert_level: Option<AlertLevel>,
pub checked: Option<bool>,
pub enabled: Option<bool>,
pub range: Option<(i32, i32)>,
pub step: Option<i32>,
pub value: Option<i32>,
pub group_name: Option<String>,
pub tab_items: Vec<String>,
pub selected_index: Option<usize>,
pub selected_indices: Vec<usize>,
pub row_drag_source: bool,
pub row_drop_target: bool,
pub file_drop_target: bool,
pub image_source: Option<String>,
pub image_fit: ImageFit,
pub icon: Option<IconRole>,
pub file_chooser_mode: FileChooserMode,
pub date_value: Option<String>,
pub link_url: Option<String>,
pub tooltip: Option<String>,
pub accessibility: AccessibilitySpec,
pub focusable: Option<bool>,
pub split_ratio: Option<u8>,
pub canvas_scene: Option<CanvasScene>,
pub canvas_surface: Option<CanvasSurface>,
pub color_dialog_data: Option<ColorDialogData>,
pub font_dialog_data: Option<FontDialogData>,
pub toolbar_items: Vec<ToolbarItem>,
pub toolbar_orientation: ToolbarOrientation,
pub calendar_selected_dates: Vec<CalendarDate>,
pub calendar_min_date: Option<CalendarDate>,
pub calendar_max_date: Option<CalendarDate>,
pub calendar_first_day_of_week: CalendarFirstDayOfWeek,
pub calendar_selection_mode: CalendarSelectionMode,
pub label_alignment: LabelAlignment,
pub label_wrap: LabelWrap,
pub rich_text_runs: Vec<TextRun>,
pub rich_text_images: Vec<RichTextImage>,
pub monospace: bool,
pub font: Option<FontDescriptor>,
pub row_icons: Vec<Option<IconRole>>,
}Expand description
In-memory widget description shared between Ui and backends.
Fields§
§id: WidgetIdUnique widget identifier.
kind: WidgetKindThe type of widget to create.
text: Option<String>Optional display text or initial value.
text_selection: Option<(usize, usize)>Optional text selection range in characters (start inclusive, end
exclusive) for TextInput/TextArea.
completion_items: Vec<String>Completion/suggestion items for a TextInput.
The shared model keeps the full item list; lanes filter it for the current text (case-insensitive prefix by default) and own their popup. Empty means completion is off.
placeholder_text: Option<String>Optional placeholder/hint text (TextInput).
parent: Option<WidgetId>Parent widget, if attached.
container_direction: Option<ContainerDirection>Container orientation (only meaningful for WidgetKind::Container).
container_wrap: Option<ContainerWrap>Container wrapping mode (Container, GroupBox, SplitPane).
container_scroll_vertical: boolContainer vertical scroll setting.
container_scroll_horizontal: boolContainer horizontal scroll setting.
container_gap: Option<i32>Uniform spacing between flow children in logical pixels
(Container, GroupBox); negatives clamp to 0.
container_padding: Option<i32>Uniform inset between the container edges and its flow children in
logical pixels (Container, GroupBox); negatives clamp to 0.
size: Option<(i32, i32)>Preferred widget size as (width, height) in logical pixels.
position: Option<(i32, i32)>Preferred widget position as (x, y) in logical pixels.
data_list_items: Vec<String>Rows/items for list widgets.
list_columns: Vec<ColumnSpec>Column headers for the columned list contract (ListView).
Empty keeps the shipped single-column row contract,
where rows come from Self::data_list_items.
list_rows: Vec<Vec<String>>Row cells aligned to Self::list_columns (ListView):
row r, cell c renders the header c with text
list_rows[r][c]. Missing trailing cells render empty and cells
beyond the column count are ignored.
data_grid_rows: Arc<Vec<Vec<String>>>Row-major cell values for data grid widgets.
Shared behind an Arc so the manager’s spec and the backend hold a
single resident allocation instead of each keeping a private copy.
tree_items: Vec<TreeItem>Hierarchical items for WidgetKind::TreeView.
background_color: Option<Color>Optional background color.
alert_level: Option<AlertLevel>Alert severity metadata (only meaningful for WidgetKind::AlertDialog).
checked: Option<bool>Optional checked state metadata.
enabled: Option<bool>Optional enabled/disabled state metadata.
range: Option<(i32, i32)>Optional numeric range metadata as (min, max).
step: Option<i32>Optional numeric step metadata.
value: Option<i32>Optional numeric value metadata.
group_name: Option<String>Optional grouping metadata (radio-like widgets).
tab_items: Vec<String>Optional tab labels metadata (WidgetKind::Tabs).
Tab strip height is dynamically resolved in layout passes from backend measurements or typography scaling, backed by a minimum floor to prevent collapse.
selected_index: Option<usize>Optional selected item index metadata.
selected_indices: Vec<usize>Optional multi-selection indices metadata (list/tree widgets).
row_drag_source: boolRow drag source metadata: rows of this list/tree can be dragged out.
row_drop_target: boolRow drop target metadata: rows can be dropped onto this list/tree.
file_drop_target: boolFile drop target metadata: external files can be dropped onto this widget.
image_source: Option<String>Optional image source metadata.
image_fit: ImageFitHow the image scales into its widget bounds.
icon: Option<IconRole>Optional stock-art icon role rendered beside the button label:
Button and FileChooserDialog only.
file_chooser_mode: FileChooserModeWhat the file chooser dialog lets the user pick.
date_value: Option<String>Optional date metadata (YYYY-MM-DD).
link_url: Option<String>Optional link URL metadata.
tooltip: Option<String>Optional tooltip text metadata.
accessibility: AccessibilitySpecPortable accessibility metadata: name, description, role.
focusable: Option<bool>Keyboard focusability override; None uses the per-kind
default from crate::focus::default_focusable.
split_ratio: Option<u8>Optional split ratio metadata (0..=100).
canvas_scene: Option<CanvasScene>Optional scene data for WidgetKind::Canvas.
canvas_surface: Option<CanvasSurface>Optional raster surface painted beneath the canvas scene.
color_dialog_data: Option<ColorDialogData>Portable colour-dialog preferences: initial colour, custom palette, and the full-mode/alpha requests.
font_dialog_data: Option<FontDialogData>Portable font-dialog preferences: initial descriptor, effects, and the size-range restriction.
toolbar_items: Vec<ToolbarItem>Portable toolbar rows: tools and separators, in display order. Ids are application-owned and survive rebuilds.
toolbar_orientation: ToolbarOrientationToolbar stacking orientation.
calendar_selected_dates: Vec<CalendarDate>Selected dates for calendar widgets.
calendar_min_date: Option<CalendarDate>Minimum selectable date.
calendar_max_date: Option<CalendarDate>Maximum selectable date.
calendar_first_day_of_week: CalendarFirstDayOfWeekFirst day of week convention.
calendar_selection_mode: CalendarSelectionModeSelection mode for calendar widgets.
label_alignment: LabelAlignmentText alignment for label widgets.
label_wrap: LabelWrapText wrap mode for label widgets.
rich_text_runs: Vec<TextRun>Styled text runs for rich text widgets.
rich_text_images: Vec<RichTextImage>Inline images for rich text widgets.
monospace: boolMonospace font rendering for text-bearing widgets.
font: Option<FontDescriptor>Explicit widget font descriptor (None follows theme/platform defaults).
row_icons: Vec<Option<IconRole>>Per-row stock-art icon roles for DataList and ListView controls.
Implementations§
Source§impl WidgetSpec
impl WidgetSpec
Sourcepub fn new(id: WidgetId, kind: WidgetKind) -> Self
pub fn new(id: WidgetId, kind: WidgetKind) -> Self
Creates a new widget specification.
Container widgets default to vertical stacking.
Sourcepub fn ensure_property(&self, property: WidgetProperty) -> GuiResult<()>
pub fn ensure_property(&self, property: WidgetProperty) -> GuiResult<()>
Rejects the property when this spec’s kind is outside its applicability row, returning the shared typed error.
Sourcepub fn requires_property(&self, property: WidgetProperty) -> GuiResult<()>
pub fn requires_property(&self, property: WidgetProperty) -> GuiResult<()>
Alias for Self::ensure_property.
Sourcepub fn with_completion_items(self, items: Vec<String>) -> Self
pub fn with_completion_items(self, items: Vec<String>) -> Self
Sets completion/suggestion items for a TextInput.
Sourcepub fn with_parent(self, parent: WidgetId) -> Self
pub fn with_parent(self, parent: WidgetId) -> Self
Sets the parent widget identifier.
Sourcepub fn with_container_direction(self, direction: ContainerDirection) -> Self
pub fn with_container_direction(self, direction: ContainerDirection) -> Self
Sets container direction metadata.
Sourcepub fn with_container_wrap(self, wrap: ContainerWrap) -> Self
pub fn with_container_wrap(self, wrap: ContainerWrap) -> Self
Sets container wrap metadata.
Sourcepub fn with_container_scroll(self, vertical: bool, horizontal: bool) -> Self
pub fn with_container_scroll(self, vertical: bool, horizontal: bool) -> Self
Enables/disables container scrolling metadata.
Sourcepub fn with_container_gap(self, gap: i32) -> Self
pub fn with_container_gap(self, gap: i32) -> Self
Sets the uniform flow spacing between container children.
Sourcepub fn with_container_padding(self, padding: i32) -> Self
pub fn with_container_padding(self, padding: i32) -> Self
Sets the uniform inset between the container edges and its flow children.
Sourcepub fn with_size(self, width: i32, height: i32) -> Self
pub fn with_size(self, width: i32, height: i32) -> Self
Sets preferred size metadata for a widget.
Sourcepub fn with_position(self, x: i32, y: i32) -> Self
pub fn with_position(self, x: i32, y: i32) -> Self
Sets preferred position metadata for a widget.
Sourcepub fn with_data_list_items(
self,
items: impl IntoIterator<Item = String>,
) -> Self
pub fn with_data_list_items( self, items: impl IntoIterator<Item = String>, ) -> Self
Sets list items for WidgetKind::DataList.
Sourcepub fn with_list_columns(
self,
columns: impl IntoIterator<Item = ColumnSpec>,
) -> Self
pub fn with_list_columns( self, columns: impl IntoIterator<Item = ColumnSpec>, ) -> Self
Sets column headers for the columned list contract (ListView);
an empty list keeps the single-column row contract.
Sourcepub fn with_list_rows(self, rows: impl IntoIterator<Item = Vec<String>>) -> Self
pub fn with_list_rows(self, rows: impl IntoIterator<Item = Vec<String>>) -> Self
Sets row cells for the columned list contract (ListView);
see Self::list_rows for the cell rule.
Sourcepub fn with_data_grid_rows(
self,
rows: impl IntoIterator<Item = Vec<String>>,
) -> Self
pub fn with_data_grid_rows( self, rows: impl IntoIterator<Item = Vec<String>>, ) -> Self
Sets row-major data for WidgetKind::DataGrid.
Sourcepub fn with_tree_items(self, items: impl IntoIterator<Item = TreeItem>) -> Self
pub fn with_tree_items(self, items: impl IntoIterator<Item = TreeItem>) -> Self
Sets hierarchical items for WidgetKind::TreeView.
Sourcepub fn with_background_color(self, color: Color) -> Self
pub fn with_background_color(self, color: Color) -> Self
Sets optional background color metadata for a widget.
Sourcepub fn with_alert_level(self, level: AlertLevel) -> Self
pub fn with_alert_level(self, level: AlertLevel) -> Self
Sets alert severity metadata for WidgetKind::AlertDialog.
Sourcepub fn with_checked(self, checked: bool) -> Self
pub fn with_checked(self, checked: bool) -> Self
Sets optional checked state metadata.
Sourcepub fn with_enabled(self, enabled: bool) -> Self
pub fn with_enabled(self, enabled: bool) -> Self
Sets optional enabled/disabled state metadata.
Sourcepub fn with_range(self, min: i32, max: i32) -> Self
pub fn with_range(self, min: i32, max: i32) -> Self
Sets numeric range metadata.
Sourcepub fn with_value(self, value: i32) -> Self
pub fn with_value(self, value: i32) -> Self
Sets numeric value metadata.
Sourcepub fn with_selected_indices(
self,
indices: impl IntoIterator<Item = usize>,
) -> Self
pub fn with_selected_indices( self, indices: impl IntoIterator<Item = usize>, ) -> Self
Sets multi-selection indices metadata.
Sourcepub fn with_row_drag_source(self, enabled: bool) -> Self
pub fn with_row_drag_source(self, enabled: bool) -> Self
Marks this widget’s rows as a drag source.
Sourcepub fn with_row_drop_target(self, enabled: bool) -> Self
pub fn with_row_drop_target(self, enabled: bool) -> Self
Marks this widget’s rows as a drop target.
Sourcepub fn with_file_drop_target(self, enabled: bool) -> Self
pub fn with_file_drop_target(self, enabled: bool) -> Self
Marks this widget as accepting external file drops from the OS shell.
Sourcepub fn with_group_name(self, name: impl Into<String>) -> Self
pub fn with_group_name(self, name: impl Into<String>) -> Self
Sets grouping metadata.
Sourcepub fn with_tab_items(self, items: impl IntoIterator<Item = String>) -> Self
pub fn with_tab_items(self, items: impl IntoIterator<Item = String>) -> Self
Sets tab labels metadata.
When rendered within a layout, tab strips automatically enforce a dynamic typography- and DPI-aware minimum height floor based on backend measurements (or falling back to 30.0pt), ensuring empty or short tab pages do not collapse the tab header strip.
Sourcepub fn with_selected_index(self, selected_index: usize) -> Self
pub fn with_selected_index(self, selected_index: usize) -> Self
Sets selected index metadata.
Sourcepub fn with_image_source(self, source: impl Into<String>) -> Self
pub fn with_image_source(self, source: impl Into<String>) -> Self
Sets image source metadata.
Sourcepub fn with_image_fit(self, fit: ImageFit) -> Self
pub fn with_image_fit(self, fit: ImageFit) -> Self
Sets how the image scales into its bounds.
Sourcepub fn with_file_chooser_mode(self, mode: FileChooserMode) -> Self
pub fn with_file_chooser_mode(self, mode: FileChooserMode) -> Self
Sets what the file chooser dialog lets the user pick.
Sourcepub fn with_date_value(self, date: impl Into<String>) -> Self
pub fn with_date_value(self, date: impl Into<String>) -> Self
Sets date metadata (YYYY-MM-DD).
Sourcepub fn with_link_url(self, url: impl Into<String>) -> Self
pub fn with_link_url(self, url: impl Into<String>) -> Self
Sets link URL metadata.
Sourcepub fn with_tooltip(self, tooltip: impl Into<String>) -> Self
pub fn with_tooltip(self, tooltip: impl Into<String>) -> Self
Sets tooltip text metadata.
Sourcepub fn with_accessible_name(self, name: impl Into<String>) -> Self
pub fn with_accessible_name(self, name: impl Into<String>) -> Self
Sets the accessible name announced by assistive technology.
Sourcepub fn with_accessible_description(self, description: impl Into<String>) -> Self
pub fn with_accessible_description(self, description: impl Into<String>) -> Self
Sets the accessible description announced after the name.
Sourcepub fn with_focusable(self, focusable: bool) -> Self
pub fn with_focusable(self, focusable: bool) -> Self
Overrides whether the widget participates in keyboard focus;
None (the default) uses the per-kind default.
Sourcepub fn with_split_ratio(self, ratio: u8) -> Self
pub fn with_split_ratio(self, ratio: u8) -> Self
Sets split ratio metadata (0..=100).
Sourcepub fn with_canvas_scene(self, scene: CanvasScene) -> Self
pub fn with_canvas_scene(self, scene: CanvasScene) -> Self
Sets the canvas drawing scene for WidgetKind::Canvas.
Sourcepub fn with_canvas_surface(self, surface: CanvasSurface) -> Self
pub fn with_canvas_surface(self, surface: CanvasSurface) -> Self
Sets the raster surface painted beneath the canvas scene.
Sourcepub fn with_color_dialog_data(self, data: ColorDialogData) -> Self
pub fn with_color_dialog_data(self, data: ColorDialogData) -> Self
Sets the colour-dialog preferences.
Sourcepub fn with_font_dialog_data(self, data: FontDialogData) -> Self
pub fn with_font_dialog_data(self, data: FontDialogData) -> Self
Sets the font-dialog preferences.
Sourcepub fn with_toolbar_items(self, items: Vec<ToolbarItem>) -> Self
pub fn with_toolbar_items(self, items: Vec<ToolbarItem>) -> Self
Sets the toolbar rows.
Sourcepub fn with_toolbar_orientation(self, orientation: ToolbarOrientation) -> Self
pub fn with_toolbar_orientation(self, orientation: ToolbarOrientation) -> Self
Sets the toolbar orientation.
Sourcepub fn with_calendar_selected_dates(
self,
dates: impl IntoIterator<Item = CalendarDate>,
) -> Self
pub fn with_calendar_selected_dates( self, dates: impl IntoIterator<Item = CalendarDate>, ) -> Self
Sets the calendar selected dates.
Sourcepub fn with_calendar_bounds(
self,
min: Option<CalendarDate>,
max: Option<CalendarDate>,
) -> Self
pub fn with_calendar_bounds( self, min: Option<CalendarDate>, max: Option<CalendarDate>, ) -> Self
Sets the calendar selectable min and max bounds.
Sourcepub fn with_calendar_first_day_of_week(
self,
first_day: CalendarFirstDayOfWeek,
) -> Self
pub fn with_calendar_first_day_of_week( self, first_day: CalendarFirstDayOfWeek, ) -> Self
Sets the calendar first day of the week convention.
Sourcepub fn with_calendar_selection_mode(self, mode: CalendarSelectionMode) -> Self
pub fn with_calendar_selection_mode(self, mode: CalendarSelectionMode) -> Self
Sets the calendar selection mode.
Sourcepub fn with_label_alignment(self, alignment: impl Into<LabelAlignment>) -> Self
pub fn with_label_alignment(self, alignment: impl Into<LabelAlignment>) -> Self
Sets the label text alignment.
Sourcepub fn with_label_wrap(self, wrap: impl Into<LabelWrap>) -> Self
pub fn with_label_wrap(self, wrap: impl Into<LabelWrap>) -> Self
Sets the label text wrap mode.
Sourcepub fn with_label_wrap_mode(self, wrap: impl Into<LabelWrap>) -> Self
pub fn with_label_wrap_mode(self, wrap: impl Into<LabelWrap>) -> Self
Sets the label text wrap mode, alias for Self::with_label_wrap.
Sourcepub fn with_rich_text_runs(
self,
runs: impl IntoIterator<Item = TextRun>,
) -> Self
pub fn with_rich_text_runs( self, runs: impl IntoIterator<Item = TextRun>, ) -> Self
Sets the styled text runs for rich text widgets.
Sourcepub fn with_rich_text_images(
self,
images: impl IntoIterator<Item = RichTextImage>,
) -> Self
pub fn with_rich_text_images( self, images: impl IntoIterator<Item = RichTextImage>, ) -> Self
Sets the inline images for rich text widgets.
Sourcepub fn with_placeholder_text(self, text: impl Into<String>) -> Self
pub fn with_placeholder_text(self, text: impl Into<String>) -> Self
Sets the placeholder/hint text (TextInput).
Sourcepub fn with_monospace(self, monospace: bool) -> Self
pub fn with_monospace(self, monospace: bool) -> Self
Sets monospace font rendering metadata.