Skip to main content

WidgetSpec

Struct WidgetSpec 

Source
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: WidgetId

Unique widget identifier.

§kind: WidgetKind

The 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: bool

Container vertical scroll setting.

§container_scroll_horizontal: bool

Container 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: bool

Row drag source metadata: rows of this list/tree can be dragged out.

§row_drop_target: bool

Row drop target metadata: rows can be dropped onto this list/tree.

§file_drop_target: bool

File drop target metadata: external files can be dropped onto this widget.

§image_source: Option<String>

Optional image source metadata.

§image_fit: ImageFit

How 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: FileChooserMode

What 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: AccessibilitySpec

Portable 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: ToolbarOrientation

Toolbar 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: CalendarFirstDayOfWeek

First day of week convention.

§calendar_selection_mode: CalendarSelectionMode

Selection mode for calendar widgets.

§label_alignment: LabelAlignment

Text alignment for label widgets.

§label_wrap: LabelWrap

Text 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: bool

Monospace 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

Source

pub fn new(id: WidgetId, kind: WidgetKind) -> Self

Creates a new widget specification.

Container widgets default to vertical stacking.

Source

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.

Source

pub fn requires_property(&self, property: WidgetProperty) -> GuiResult<()>

Source

pub fn with_text(self, text: impl Into<String>) -> Self

Sets the widget text.

Source

pub fn with_completion_items(self, items: Vec<String>) -> Self

Sets completion/suggestion items for a TextInput.

Source

pub fn with_parent(self, parent: WidgetId) -> Self

Sets the parent widget identifier.

Source

pub fn with_container_direction(self, direction: ContainerDirection) -> Self

Sets container direction metadata.

Source

pub fn with_container_wrap(self, wrap: ContainerWrap) -> Self

Sets container wrap metadata.

Source

pub fn with_container_scroll(self, vertical: bool, horizontal: bool) -> Self

Enables/disables container scrolling metadata.

Source

pub fn with_container_gap(self, gap: i32) -> Self

Sets the uniform flow spacing between container children.

Source

pub fn with_container_padding(self, padding: i32) -> Self

Sets the uniform inset between the container edges and its flow children.

Source

pub fn with_size(self, width: i32, height: i32) -> Self

Sets preferred size metadata for a widget.

Source

pub fn with_position(self, x: i32, y: i32) -> Self

Sets preferred position metadata for a widget.

Source

pub fn with_data_list_items( self, items: impl IntoIterator<Item = String>, ) -> Self

Sets list items for WidgetKind::DataList.

Source

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.

Source

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.

Source

pub fn with_data_grid_rows( self, rows: impl IntoIterator<Item = Vec<String>>, ) -> Self

Sets row-major data for WidgetKind::DataGrid.

Source

pub fn with_tree_items(self, items: impl IntoIterator<Item = TreeItem>) -> Self

Sets hierarchical items for WidgetKind::TreeView.

Source

pub fn with_background_color(self, color: Color) -> Self

Sets optional background color metadata for a widget.

Source

pub fn with_alert_level(self, level: AlertLevel) -> Self

Sets alert severity metadata for WidgetKind::AlertDialog.

Source

pub fn with_checked(self, checked: bool) -> Self

Sets optional checked state metadata.

Source

pub fn with_enabled(self, enabled: bool) -> Self

Sets optional enabled/disabled state metadata.

Source

pub fn with_range(self, min: i32, max: i32) -> Self

Sets numeric range metadata.

Source

pub fn with_step(self, step: i32) -> Self

Sets numeric step metadata.

Source

pub fn with_value(self, value: i32) -> Self

Sets numeric value metadata.

Source

pub fn with_selected_indices( self, indices: impl IntoIterator<Item = usize>, ) -> Self

Sets multi-selection indices metadata.

Source

pub fn with_row_drag_source(self, enabled: bool) -> Self

Marks this widget’s rows as a drag source.

Source

pub fn with_row_drop_target(self, enabled: bool) -> Self

Marks this widget’s rows as a drop target.

Source

pub fn with_file_drop_target(self, enabled: bool) -> Self

Marks this widget as accepting external file drops from the OS shell.

Source

pub fn with_group_name(self, name: impl Into<String>) -> Self

Sets grouping metadata.

Source

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.

Source

pub fn with_selected_index(self, selected_index: usize) -> Self

Sets selected index metadata.

Source

pub fn with_image_source(self, source: impl Into<String>) -> Self

Sets image source metadata.

Source

pub fn with_image_fit(self, fit: ImageFit) -> Self

Sets how the image scales into its bounds.

Source

pub fn with_file_chooser_mode(self, mode: FileChooserMode) -> Self

Sets what the file chooser dialog lets the user pick.

Source

pub fn with_date_value(self, date: impl Into<String>) -> Self

Sets date metadata (YYYY-MM-DD).

Sets link URL metadata.

Source

pub fn with_tooltip(self, tooltip: impl Into<String>) -> Self

Sets tooltip text metadata.

Source

pub fn with_accessible_name(self, name: impl Into<String>) -> Self

Sets the accessible name announced by assistive technology.

Source

pub fn with_accessible_description(self, description: impl Into<String>) -> Self

Sets the accessible description announced after the name.

Source

pub fn with_focusable(self, focusable: bool) -> Self

Overrides whether the widget participates in keyboard focus; None (the default) uses the per-kind default.

Source

pub fn with_split_ratio(self, ratio: u8) -> Self

Sets split ratio metadata (0..=100).

Source

pub fn with_canvas_scene(self, scene: CanvasScene) -> Self

Sets the canvas drawing scene for WidgetKind::Canvas.

Source

pub fn with_canvas_surface(self, surface: CanvasSurface) -> Self

Sets the raster surface painted beneath the canvas scene.

Source

pub fn with_color_dialog_data(self, data: ColorDialogData) -> Self

Sets the colour-dialog preferences.

Source

pub fn with_font_dialog_data(self, data: FontDialogData) -> Self

Sets the font-dialog preferences.

Source

pub fn with_toolbar_items(self, items: Vec<ToolbarItem>) -> Self

Sets the toolbar rows.

Source

pub fn with_toolbar_orientation(self, orientation: ToolbarOrientation) -> Self

Sets the toolbar orientation.

Source

pub fn with_calendar_selected_dates( self, dates: impl IntoIterator<Item = CalendarDate>, ) -> Self

Sets the calendar selected dates.

Source

pub fn with_calendar_bounds( self, min: Option<CalendarDate>, max: Option<CalendarDate>, ) -> Self

Sets the calendar selectable min and max bounds.

Source

pub fn with_calendar_first_day_of_week( self, first_day: CalendarFirstDayOfWeek, ) -> Self

Sets the calendar first day of the week convention.

Source

pub fn with_calendar_selection_mode(self, mode: CalendarSelectionMode) -> Self

Sets the calendar selection mode.

Source

pub fn with_label_alignment(self, alignment: impl Into<LabelAlignment>) -> Self

Sets the label text alignment.

Source

pub fn with_label_wrap(self, wrap: impl Into<LabelWrap>) -> Self

Sets the label text wrap mode.

Source

pub fn with_label_wrap_mode(self, wrap: impl Into<LabelWrap>) -> Self

Sets the label text wrap mode, alias for Self::with_label_wrap.

Source

pub fn with_rich_text_runs( self, runs: impl IntoIterator<Item = TextRun>, ) -> Self

Sets the styled text runs for rich text widgets.

Source

pub fn with_rich_text_images( self, images: impl IntoIterator<Item = RichTextImage>, ) -> Self

Sets the inline images for rich text widgets.

Source

pub fn with_placeholder_text(self, text: impl Into<String>) -> Self

Sets the placeholder/hint text (TextInput).

Source

pub fn with_monospace(self, monospace: bool) -> Self

Sets monospace font rendering metadata.

Trait Implementations§

Source§

impl Clone for WidgetSpec

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WidgetSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for WidgetSpec

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for WidgetSpec

Auto Trait Implementations§

§

impl Forget for WidgetSpec

§

impl Freeze for WidgetSpec

§

impl Move for WidgetSpec

§

impl RefUnwindSafe for WidgetSpec

§

impl Send for WidgetSpec
where RawVecInner: Send, Arc<Vec<Vec<String>>>: Send, Arc<Vec<u8>>: Send,

§

impl Sync for WidgetSpec
where RawVecInner: Sync, Arc<Vec<Vec<String>>>: Sync, Arc<Vec<u8>>: Sync,

§

impl Unpin for WidgetSpec
where *const u8 is !null: Unpin, Arc<Vec<Vec<String>>>: Unpin, Arc<Vec<u8>>: Unpin,

§

impl UnsafeUnpin for WidgetSpec

§

impl UnwindSafe for WidgetSpec
where RawVecInner: UnwindSafe, Arc<Vec<Vec<String>>>: UnwindSafe, Arc<Vec<u8>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.