Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: TextMeasure {
    type NativeHandle;

Show 160 methods // Required methods fn create_widget(&mut self, spec: &WidgetSpec) -> GuiResult<()>; fn create_menu(&mut self, menu_id: MenuId) -> GuiResult<()>; fn add_submenu( &mut self, parent_id: MenuId, submenu_id: MenuId, slot_id: MenuItemId, text: &str, ) -> GuiResult<()>; fn create_menu_item( &mut self, menu_id: MenuId, item_id: MenuItemId, text: &str, shortcut: Option<&str>, ) -> GuiResult<()>; fn attach_menu_to_window( &mut self, window_id: WidgetId, menu_id: MenuId, ) -> GuiResult<()>; fn attach_context_menu( &mut self, widget_id: WidgetId, menu_id: MenuId, ) -> GuiResult<()>; fn set_text(&mut self, widget_id: WidgetId, text: &str) -> GuiResult<()>; fn set_checked( &mut self, widget_id: WidgetId, checked: bool, ) -> GuiResult<()>; fn set_value(&mut self, widget_id: WidgetId, value: i32) -> GuiResult<()>; fn set_range( &mut self, widget_id: WidgetId, min: i32, max: i32, ) -> GuiResult<()>; fn set_step(&mut self, widget_id: WidgetId, step: i32) -> GuiResult<()>; fn set_selected_index( &mut self, widget_id: WidgetId, index: usize, ) -> GuiResult<()>; fn set_tab_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()>; fn set_selected_indices( &mut self, widget_id: WidgetId, indices: &[usize], ) -> GuiResult<()>; fn set_row_drag( &mut self, widget_id: WidgetId, source: bool, target: bool, ) -> GuiResult<()>; fn set_size( &mut self, widget_id: WidgetId, width: i32, height: i32, ) -> GuiResult<()>; fn set_data_list_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()>; fn set_data_grid_rows( &mut self, widget_id: WidgetId, rows: Arc<Vec<Vec<String>>>, ) -> GuiResult<()>; fn set_data_grid_model( &mut self, widget_id: WidgetId, model: Box<dyn DataGridModel>, ) -> GuiResult<()>; fn set_data_grid_row_height( &mut self, widget_id: WidgetId, row: usize, height: i32, ) -> GuiResult<()>; fn set_data_grid_col_width( &mut self, widget_id: WidgetId, col: usize, width: i32, ) -> GuiResult<()>; fn set_data_grid_frozen_panes( &mut self, widget_id: WidgetId, rows: usize, cols: usize, ) -> GuiResult<()>; fn set_data_grid_selection( &mut self, widget_id: WidgetId, selection: &[(usize, usize)], ) -> GuiResult<()>; fn set_tree_items( &mut self, widget_id: WidgetId, items: &[TreeItem], ) -> GuiResult<()>; fn set_position( &mut self, widget_id: WidgetId, x: i32, y: i32, ) -> GuiResult<()>; fn set_background_color( &mut self, widget_id: WidgetId, color: Color, ) -> GuiResult<()>; fn set_alert_level( &mut self, widget_id: WidgetId, level: AlertLevel, ) -> GuiResult<()>; fn set_image_source( &mut self, widget_id: WidgetId, source: &str, ) -> GuiResult<()>; fn set_date_value( &mut self, widget_id: WidgetId, iso_date: &str, ) -> GuiResult<()>; fn set_link_url(&mut self, widget_id: WidgetId, url: &str) -> GuiResult<()>; fn set_container_direction( &mut self, widget_id: WidgetId, direction: ContainerDirection, ) -> GuiResult<()>; fn set_container_scroll( &mut self, widget_id: WidgetId, vertical: bool, horizontal: bool, ) -> GuiResult<()>; fn set_container_gap( &mut self, widget_id: WidgetId, gap: i32, ) -> GuiResult<()>; fn set_container_padding( &mut self, widget_id: WidgetId, padding: i32, ) -> GuiResult<()>; fn draw_demo_cube(&mut self, widget_id: WidgetId) -> GuiResult<()>; fn set_canvas_scene( &mut self, widget_id: WidgetId, scene: &CanvasScene, ) -> GuiResult<()>; fn native_handle( &self, widget_id: WidgetId, ) -> GuiResult<Self::NativeHandle>; fn add_child(&mut self, parent: WidgetId, child: WidgetId) -> GuiResult<()>; fn show(&mut self, widget_id: WidgetId) -> GuiResult<()>; fn hide(&mut self, widget_id: WidgetId) -> GuiResult<()>; fn remove(&mut self, widget_id: WidgetId) -> GuiResult<()>; fn set_enabled( &mut self, widget_id: WidgetId, enabled: bool, ) -> GuiResult<()>; fn activate(&mut self, widget_id: WidgetId) -> GuiResult<()>; fn data_dir(&self) -> GuiResult<PathBuf>; fn set_tooltip(&mut self, widget_id: WidgetId, text: &str) -> GuiResult<()>; fn poll_event(&mut self) -> GuiResult<Option<UiEvent>>; fn wait_event(&mut self) -> GuiResult<UiEvent>; fn show_confirm_dialog( &mut self, token: u64, title: &str, message: &str, ) -> GuiResult<()>; // Provided methods fn set_label_alignment( &mut self, widget_id: WidgetId, alignment: LabelAlignment, ) -> GuiResult<()> { ... } fn set_label_wrap( &mut self, widget_id: WidgetId, wrap: LabelWrap, ) -> GuiResult<()> { ... } fn text_selection(&self, _widget_id: WidgetId) -> GuiResult<(usize, usize)> { ... } fn set_text_selection( &mut self, widget_id: WidgetId, start: usize, end: usize, ) -> GuiResult<()> { ... } fn set_text_completion_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()> { ... } fn drag_capabilities(&self) -> DragCapabilities { ... } fn set_drag_source_options( &mut self, widget_id: WidgetId, options: &DragSourceOptions, ) -> GuiResult<()> { ... } fn set_drag_target_options( &mut self, widget_id: WidgetId, options: &DragTargetOptions, ) -> GuiResult<()> { ... } fn set_file_drop_target( &mut self, widget_id: WidgetId, enabled: bool, ) -> GuiResult<()> { ... } fn set_drop_target( &mut self, widget_id: WidgetId, enabled: bool, ) -> GuiResult<()> { ... } fn set_min_size( &mut self, widget_id: WidgetId, width: i32, height: i32, ) -> GuiResult<()> { ... } fn set_layout_size( &mut self, widget_id: WidgetId, width: i32, height: i32, expand_width: bool, expand_height: bool, ) -> GuiResult<()> { ... } fn natural_size(&self, widget_id: WidgetId) -> Option<(i32, i32)> { ... } fn min_compressed_size(&self, widget_id: WidgetId) -> Option<(i32, i32)> { ... } fn apply_flow_padding( &mut self, widget_id: WidgetId, padding: [i32; 4], ) -> GuiResult<()> { ... } fn host_advanced_control( &mut self, host: WidgetId, family: AdvancedFamily, ) -> GuiResult<AdvancedHostCapabilities> { ... } fn set_combo_box_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()> { ... } fn set_list_columns( &mut self, widget_id: WidgetId, columns: &[ColumnSpec], ) -> GuiResult<()> { ... } fn set_list_rows( &mut self, widget_id: WidgetId, rows: &[Vec<String>], ) -> GuiResult<()> { ... } fn clear_selection(&mut self, widget_id: WidgetId) -> GuiResult<()> { ... } fn visible_anchor_index( &self, widget_id: WidgetId, ) -> GuiResult<Option<usize>> { ... } fn scroll_to_row( &mut self, widget_id: WidgetId, index: usize, ) -> GuiResult<()> { ... } fn rows_end_visible(&self, widget_id: WidgetId) -> GuiResult<bool> { ... } fn apply_row_delta( &mut self, widget_id: WidgetId, ops: &[RowOp], ) -> GuiResult<()> { ... } fn set_layout_position( &mut self, widget_id: WidgetId, x: i32, y: i32, ) -> GuiResult<()> { ... } fn image_resource_capabilities(&self) -> ImageResourceCapabilities { ... } fn load_image_resource( &mut self, _resource: ImageResourceId, _data: &ImageData, ) -> GuiResult<()> { ... } fn release_image_resource( &mut self, _resource: ImageResourceId, ) -> GuiResult<()> { ... } fn set_image_fit( &mut self, _widget_id: WidgetId, _fit: ImageFit, ) -> GuiResult<()> { ... } fn set_file_chooser_mode( &mut self, _widget_id: WidgetId, _mode: FileChooserMode, ) -> GuiResult<()> { ... } fn set_icon( &mut self, _widget_id: WidgetId, _icon: Option<IconRole>, ) -> GuiResult<()> { ... } fn set_color_dialog_data( &mut self, _widget_id: WidgetId, _data: &ColorDialogData, ) -> GuiResult<()> { ... } fn set_font_dialog_data( &mut self, _widget_id: WidgetId, _data: &FontDialogData, ) -> GuiResult<()> { ... } fn set_toolbar_items( &mut self, _widget_id: WidgetId, _items: &[ToolbarItem], ) -> GuiResult<()> { ... } fn set_toolbar_orientation( &mut self, _widget_id: WidgetId, _orientation: ToolbarOrientation, ) -> GuiResult<()> { ... } fn set_calendar_selected_dates( &mut self, _widget_id: WidgetId, _dates: &[CalendarDate], ) -> GuiResult<()> { ... } fn set_calendar_bounds( &mut self, _widget_id: WidgetId, _min_date: Option<CalendarDate>, _max_date: Option<CalendarDate>, ) -> GuiResult<()> { ... } fn set_calendar_first_day_of_week( &mut self, _widget_id: WidgetId, _first_day: CalendarFirstDayOfWeek, ) -> GuiResult<()> { ... } fn set_calendar_selection_mode( &mut self, _widget_id: WidgetId, _mode: CalendarSelectionMode, ) -> GuiResult<()> { ... } fn set_container_wrap( &mut self, widget_id: WidgetId, wrap: ContainerWrap, ) -> GuiResult<()> { ... } fn create_gpu_fallback( &mut self, _spec: &WidgetSpec, _policy: GpuDegradationPolicy, ) -> GuiResult<()> { ... } fn set_canvas_surface( &mut self, _widget_id: WidgetId, _surface: &CanvasSurface, ) -> GuiResult<()> { ... } fn metal_canvas_handle( &self, _widget_id: WidgetId, ) -> GuiResult<MetalCanvasHandle> { ... } fn reparent( &mut self, child: WidgetId, new_parent: WidgetId, ) -> GuiResult<()> { ... } fn backend_name(&self) -> &'static str { ... } fn capture_window_rgba( &self, _widget_id: WidgetId, _include_decorations: bool, ) -> GuiResult<(u32, u32, Vec<u8>)> { ... } fn capture_widget_rgba( &self, _widget_id: WidgetId, ) -> GuiResult<(u32, u32, Vec<u8>)> { ... } fn native_read_text( &self, _widget_id: WidgetId, ) -> GuiResult<Option<String>> { ... } fn native_read_checked( &self, _widget_id: WidgetId, ) -> GuiResult<Option<bool>> { ... } fn native_click(&self, _widget_id: WidgetId) -> GuiResult<bool> { ... } fn native_type_text( &self, _widget_id: WidgetId, _text: &str, ) -> GuiResult<bool> { ... } fn native_close(&self, _widget_id: WidgetId) -> GuiResult<bool> { ... } fn e2e_capability( &self, _widget_id: WidgetId, _operation: Operation, ) -> GuiResult<Capability> { ... } fn e2e_click(&mut self, _widget_id: WidgetId) -> GuiResult<()> { ... } fn e2e_type_text( &mut self, _widget_id: WidgetId, _text: &str, ) -> GuiResult<()> { ... } fn e2e_check( &mut self, _widget_id: WidgetId, _checked: bool, ) -> GuiResult<()> { ... } fn e2e_text(&self, _widget_id: WidgetId) -> GuiResult<String> { ... } fn e2e_checked(&self, _widget_id: WidgetId) -> GuiResult<bool> { ... } fn e2e_poll_event(&mut self) -> GuiResult<Option<UiEvent>> { ... } fn set_clipboard_text(&mut self, _text: &str) -> GuiResult<()> { ... } fn clipboard_text(&mut self) -> GuiResult<Option<String>> { ... } fn paste_image_from_clipboard( &mut self, ) -> GuiResult<Option<ClipboardImage>> { ... } fn set_accessible_name( &mut self, _widget_id: WidgetId, _name: &str, ) -> GuiResult<()> { ... } fn set_accessible_description( &mut self, _widget_id: WidgetId, _description: &str, ) -> GuiResult<()> { ... } fn post_accessible_notification( &mut self, widget_id: WidgetId, notification: AccessibleNotification, ) -> GuiResult<()> { ... } fn set_focus(&mut self, _widget_id: WidgetId) -> GuiResult<()> { ... } fn set_focusable( &mut self, _widget_id: WidgetId, _focusable: bool, ) -> GuiResult<()> { ... } fn set_theme(&mut self, _theme: &Theme) -> GuiResult<()> { ... } fn set_theme_override( &mut self, _widget_id: WidgetId, _theme_override: ThemeOverride, ) -> GuiResult<()> { ... } fn clear_theme_overrides(&mut self, _widget_id: WidgetId) -> GuiResult<()> { ... } fn theme_capabilities(&self) -> ThemeCapabilities { ... } fn system_theme_mode(&self) -> Option<ThemeMode> { ... } fn system_high_contrast(&self) -> bool { ... } fn art_capabilities(&self) -> ArtCapabilities { ... } fn native_stock_icon( &self, role: IconRole, size: IconSize, ) -> GuiResult<StockIcon> { ... } fn display_capabilities(&self) -> DisplayCapabilities { ... } fn gpu_surface_capabilities(&self) -> GpuSurfaceCapabilities { ... } fn displays(&self) -> GuiResult<Vec<DisplayInfo>> { ... } fn primary_display(&self) -> GuiResult<Option<DisplayInfo>> { ... } fn widget_scale_factor(&self, _widget_id: WidgetId) -> f64 { ... } fn wake_handle(&self) -> Option<Arc<dyn Fn() + Send + Sync>> { ... } fn show_file_dialog( &mut self, token: u64, request: &FileDialog, ) -> GuiResult<()> { ... } fn native_window_handle( &self, window_id: WidgetId, ) -> GuiResult<NativeWindowHandle> { ... } fn set_close_guard( &mut self, _widget_id: WidgetId, _guarded: bool, ) -> GuiResult<()> { ... } fn window_capabilities(&self) -> WindowCapabilities { ... } fn set_window_options( &mut self, widget_id: WidgetId, options: &WindowOptions, ) -> GuiResult<()> { ... } fn dismiss_popup(&mut self, widget_id: WidgetId) -> GuiResult<()> { ... } fn timer_capabilities(&self) -> TimerCapabilities { ... } fn motion_capabilities(&self) -> MotionCapabilities { ... } fn start_timer(&mut self, timer: TimerId, spec: TimerSpec) -> GuiResult<()> { ... } fn start_widget_timer( &mut self, timer: TimerId, widget_id: WidgetId, spec: TimerSpec, stop_policy: TimerStopPolicy, ) -> GuiResult<()> { ... } fn cancel_timer(&mut self, timer: TimerId) -> GuiResult<()> { ... } fn set_menu_item_enabled( &mut self, _item_id: MenuItemId, _enabled: bool, ) -> GuiResult<()> { ... } fn set_menu_item_text( &mut self, _item_id: MenuItemId, _text: &str, ) -> GuiResult<()> { ... } fn insert_menu_item( &mut self, _menu_id: MenuId, _item_id: MenuItemId, _index: usize, _text: &str, _shortcut: Option<&str>, ) -> GuiResult<()> { ... } fn remove_menu_item(&mut self, _item_id: MenuItemId) -> GuiResult<()> { ... } fn remove_submenu(&mut self, _submenu_id: MenuId) -> GuiResult<()> { ... } fn set_window_min_size( &mut self, _widget_id: WidgetId, _w: u32, _h: u32, ) -> GuiResult<()> { ... } fn set_resizable( &mut self, _widget_id: WidgetId, _resizable: bool, ) -> GuiResult<()> { ... } fn set_placeholder_text( &mut self, _widget_id: WidgetId, _text: &str, ) -> GuiResult<()> { ... } fn set_rich_text_runs( &mut self, _widget_id: WidgetId, _runs: &[TextRun], ) -> GuiResult<()> { ... } fn set_rich_text_images( &mut self, _widget_id: WidgetId, _images: &[RichTextImage], ) -> GuiResult<()> { ... } fn set_spell_check( &mut self, _widget_id: WidgetId, _enabled: bool, ) -> GuiResult<()> { ... } fn set_monospace( &mut self, _widget_id: WidgetId, _monospace: bool, ) -> GuiResult<()> { ... } fn set_font( &mut self, _widget_id: WidgetId, _font: Option<&FontDescriptor>, ) -> GuiResult<()> { ... } fn set_row_icons( &mut self, _widget_id: WidgetId, _icons: &[Option<IconRole>], ) -> GuiResult<()> { ... } fn create_tray_icon( &mut self, _spec: &TrayIconSpec, ) -> GuiResult<TrayIconId> { ... } fn destroy_tray_icon(&mut self, _id: TrayIconId) -> GuiResult<()> { ... } fn set_tray_icon_tooltip( &mut self, _id: TrayIconId, _tooltip: &str, ) -> GuiResult<()> { ... } fn set_tray_icon_menu( &mut self, _id: TrayIconId, _menu: Option<MenuId>, ) -> GuiResult<()> { ... } fn set_tray_icon_visible( &mut self, _id: TrayIconId, _visible: bool, ) -> GuiResult<()> { ... } fn set_tray_icon_icon( &mut self, _id: TrayIconId, _icon_bytes: Option<Vec<u8>>, ) -> GuiResult<()> { ... }
}
Expand description

Backend contract implemented by platform-specific renderers.

§Method Groups

The trait carries 162 items: 160 methods declared here, the inherited TextMeasure::measure_text supertrait method, and the Self::NativeHandle associated type. They fall into seventeen subsystems; the groups are stable, and a new method joins an existing group or argues for a new one (see docs/guides/backend-development.md section 10 for the expansion governance and Chapter 17 of the book for the narrative walkthrough).

GroupItemsCovers
Lifecycle & hierarchy8create, attach child, reparent, show/hide, remove, enable, activate
Menus & menu items10menu structure, attachment, item enablement/labels, dynamic insert/remove
Text & input properties12text, label alignment/wrap, text selection, completion, placeholder, rich-text runs/images, monospace, explicit font, live selection readback, native spell checking
Value & selection properties8checked, value/range/step, tab labels, selected index/indices, link URL
Layout, containers & flow13size/min size/layout size, natural size, compressed-size floor, position, flow padding, container direction/wrap/scroll/gap/padding
Collections, grids & trees18list items, runtime combo-box items, list columns/rows, per-row art-provider icons, selection clearing, anchor/scroll/end visibility, row drag, grid rows/model/metrics/selection, row deltas, tree items
Calendar & date5selected dates, bounds, first day of week, selection mode, date value
Presentation & tool strips10background, tooltip, alert level, image source/fit, toolbar items/orientation, typed image resources
System tray & status icons6tray icon lifecycle, pixels, tooltip, context menu, visibility
Dialogs & windowing11confirm dialog, function-style file dialog, close guard, file-chooser mode, color/font dialog data, window min size/resizable, extended window capabilities/options, popup dismissal
Clipboard, drops & data directory9clipboard text/image, paste image, app data directory, file/URL/text drop targets, MIME drag capabilities/source/target options
Focus & accessibility5focus/focusable, accessible name/description, post notification
Theming & stock art9theme apply/override/capabilities, system mode/high contrast, stock-art icon set/query, art capabilities
Events, tasks & lane introspection10event polling/blocking, wake hook, advanced-control hosting, backend name, timer and motion capabilities/start/scoped start/cancel
Canvas, GPU & displays10scenes/surfaces, demo cube, GPU fallback/surface capabilities, display capabilities/enumeration/scale
Native handles & text measurement4Vulkan-canvas native handle and its associated type, top-level window handle, inherited measure_text
Screenshot & E2E adapters14window/widget capture, native readbacks and simulated input, E2E capability/actions/poll

§Maintenance

The counts are verified mechanically - from the repository root:

python -c "import re;s=open('crates/native-gui-core/src/ui.rs',encoding='utf-8').read();b=s.split('\npub trait Backend: TextMeasure {',1)[1].split('\n}\n',1)[0];t=s.split('\npub trait TextMeasure {',1)[1].split('\n}\n',1)[0];f=lambda x:len(re.findall(r'(?m)^    (?:unsafe )?fn \w+',x));a=len(re.findall(r'(?m)^    type \w+',b));print('Backend %d fns + %d assoc type + %d supertrait fn = %d trait items'%(f(b),a,f(t),f(b)+a+f(t)))"

It must print Backend 160 fns + 1 assoc type + 1 supertrait fn = 162 trait items; adding, removing, or renaming a method updates this inventory (count and table) in the same commit - see “Backend work” in CONTRIBUTING.md.

§Operational contract (Pre / Post / Inv)

Every method obeys the same operational semantics; the deterministic contract tests in tests/functional_flow.rs and the unit tests in this module pin them:

  • Pre-conditions. The widget id names a live widget; a kind-restricted operation is offered only when the kind is inside the property’s WidgetProperty::applicable_kinds row; validated values reject before any mutation (min <= max, positive sizes/steps, finite canvas extents, start <= end).
  • Post-conditions. A successful call mirrors the new value on the shared WidgetSpec exactly once and forwards the same value to the native control; an unrelated widget and unrelated native handles are never touched. A refused call is transactional: the shared spec and the backend record are byte-identical to the pre-call state.
  • Invariants. Parent links form a strict acyclic forest (single parentage); WidgetIds are monotonic and never reused, including after removal; a removed widget takes its whole subtree with it (Ui::remove); and the shared spec stays in exact sync with the native value the backend reports (the Mock lane asserts full spec equality).

§FFI memory boundary and ownership

Chapter 17’s first structural invariant (lossless strings, bounded closures) is asserted here so every lane implements the same seam; the digest lives in docs/reference/architecture.md:

  • String encodings. Every &str/String crossing this trait is Rust UTF-8, and a lane transcodes it losslessly to its native format at the call site: Win32 builds UTF-16 (NUL-terminated) buffers through its to_wide helper, GTK consumes UTF-8 through gtk-rs (which owns the native conversion), and Cocoa builds NSStrings from UTF-8. Borrowed text is strictly call-scoped: a lane must copy whatever it retains, no borrowed pointer outlives the call, and the WidgetSpec on the shared side stays the authoritative text.
  • Closure lifetimes. The trait takes and retains no closures. Application callbacks are 'static values registered on Ui (Ui::on_window_close, Ui::on_window_resize, Ui::on_menu_item_selected, the run_until_closed* handlers), owned by the Ui and dispatched from its staged event pump - never invoked directly inside a native signal handler. A lane that reaches a native event loop bridges through state owned for the widget’s lifetime (GTK Rc<RefCell<...>> captures, Win32 window properties plus WM_BRIDGED_* messages), so the native loop can never dispatch into freed application state and no application closure is stored in a WNDPROC or a native delegate.
  • Ownership and release. Ui owns the widget tree and every value through WidgetSpec; a lane’s per-widget state is an implementation record keyed by WidgetId (never a second source of truth, see the coherence invariant above), and every remove path releases the native handles, models, brushes, and parked properties it allocated.

Required Associated Types§

Source

type NativeHandle

Returns backend-native handle information for a Vulkan canvas widget.

Required Methods§

Source

fn create_widget(&mut self, spec: &WidgetSpec) -> GuiResult<()>

Creates a native widget from a shared specification.

spec is borrowed for the duration of the call: the lane copies every value it retains (strings included - see the trait’s FFI memory boundary section), while Ui keeps owning the authoritative spec.

Source

fn create_menu(&mut self, menu_id: MenuId) -> GuiResult<()>

Creates a native menu container.

Source

fn add_submenu( &mut self, parent_id: MenuId, submenu_id: MenuId, slot_id: MenuItemId, text: &str, ) -> GuiResult<()>

Creates a submenu under parent_id.

slot_id names the submenu’s row inside the parent’s ordered list; it is minted from the item-id space so a submenu row can never be mistaken for a real item, and lanes that record order (Mock) store it next to the items.

Source

fn create_menu_item( &mut self, menu_id: MenuId, item_id: MenuItemId, text: &str, shortcut: Option<&str>, ) -> GuiResult<()>

Creates a native menu item under an existing menu.

Source

fn attach_menu_to_window( &mut self, window_id: WidgetId, menu_id: MenuId, ) -> GuiResult<()>

Attaches a menu to a window.

Source

fn attach_context_menu( &mut self, widget_id: WidgetId, menu_id: MenuId, ) -> GuiResult<()>

Attaches a menu as a right-click context menu on a widget.

Source

fn set_text(&mut self, widget_id: WidgetId, text: &str) -> GuiResult<()>

Sets text/value-like content for a widget.

Source

fn set_checked(&mut self, widget_id: WidgetId, checked: bool) -> GuiResult<()>

Sets checked state for check-capable widgets.

Source

fn set_value(&mut self, widget_id: WidgetId, value: i32) -> GuiResult<()>

Sets numeric value for value-capable widgets.

Source

fn set_range( &mut self, widget_id: WidgetId, min: i32, max: i32, ) -> GuiResult<()>

Sets numeric range for widgets supporting min/max semantics.

Source

fn set_step(&mut self, widget_id: WidgetId, step: i32) -> GuiResult<()>

Sets numeric step for widgets supporting step semantics.

Source

fn set_selected_index( &mut self, widget_id: WidgetId, index: usize, ) -> GuiResult<()>

Sets selected index for widgets exposing item/page selection.

Source

fn set_tab_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()>

Sets page labels for a tabs widget.

Labels follow the attached pages in attach order. Backends relabel pages they have already applied (Win32 strip items, GTK notebook pages, Cocoa tab-view items) and use the labels for pages attached later; pages without a label keep the backend placeholder header.

Source

fn set_selected_indices( &mut self, widget_id: WidgetId, indices: &[usize], ) -> GuiResult<()>

Sets multiple selected indices for multi-select list/tree widgets.

Source

fn set_row_drag( &mut self, widget_id: WidgetId, source: bool, target: bool, ) -> GuiResult<()>

Enables/disables row drag-source and drop-target behavior on a row widget.

Source

fn set_size( &mut self, widget_id: WidgetId, width: i32, height: i32, ) -> GuiResult<()>

Sets preferred dimensions for widgets.

Source

fn set_data_list_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()>

Sets items for a data list widget.

Source

fn set_data_grid_rows( &mut self, widget_id: WidgetId, rows: Arc<Vec<Vec<String>>>, ) -> GuiResult<()>

Sets row-major cell data for a data grid widget (legacy string matrix).

The matrix is shared as one Arc between the manager’s spec and the backend, so neither keeps a private resident copy.

Source

fn set_data_grid_model( &mut self, widget_id: WidgetId, model: Box<dyn DataGridModel>, ) -> GuiResult<()>

Sets a virtual data model for a data grid widget.

Source

fn set_data_grid_row_height( &mut self, widget_id: WidgetId, row: usize, height: i32, ) -> GuiResult<()>

Sets the height of a specific row in a data grid widget.

Source

fn set_data_grid_col_width( &mut self, widget_id: WidgetId, col: usize, width: i32, ) -> GuiResult<()>

Sets the width of a specific column in a data grid widget.

Source

fn set_data_grid_frozen_panes( &mut self, widget_id: WidgetId, rows: usize, cols: usize, ) -> GuiResult<()>

Sets the number of frozen rows and columns in a data grid widget.

Source

fn set_data_grid_selection( &mut self, widget_id: WidgetId, selection: &[(usize, usize)], ) -> GuiResult<()>

Sets the selected cells for a DataGrid.

Source

fn set_tree_items( &mut self, widget_id: WidgetId, items: &[TreeItem], ) -> GuiResult<()>

Sets hierarchical items for a tree view widget.

Source

fn set_position(&mut self, widget_id: WidgetId, x: i32, y: i32) -> GuiResult<()>

Sets preferred position for widgets.

Source

fn set_background_color( &mut self, widget_id: WidgetId, color: Color, ) -> GuiResult<()>

Sets background color for a widget.

Source

fn set_alert_level( &mut self, widget_id: WidgetId, level: AlertLevel, ) -> GuiResult<()>

Sets alert severity for an alert dialog widget.

Source

fn set_image_source( &mut self, widget_id: WidgetId, source: &str, ) -> GuiResult<()>

Sets image source for image-capable widgets.

Source

fn set_date_value( &mut self, widget_id: WidgetId, iso_date: &str, ) -> GuiResult<()>

Sets date value (YYYY-MM-DD) for date-capable widgets.

Sets URL for link-capable widgets.

Source

fn set_container_direction( &mut self, widget_id: WidgetId, direction: ContainerDirection, ) -> GuiResult<()>

Sets stacking direction for container widgets.

Source

fn set_container_scroll( &mut self, widget_id: WidgetId, vertical: bool, horizontal: bool, ) -> GuiResult<()>

Sets scroll capability for container widgets.

Source

fn set_container_gap(&mut self, widget_id: WidgetId, gap: i32) -> GuiResult<()>

Sets the uniform spacing between a flow container’s children.

Source

fn set_container_padding( &mut self, widget_id: WidgetId, padding: i32, ) -> GuiResult<()>

Sets the uniform inset between a container’s edges and its children.

Source

fn draw_demo_cube(&mut self, widget_id: WidgetId) -> GuiResult<()>

Draws a built-in colored 3D cube demo into a Vulkan canvas widget.

Source

fn set_canvas_scene( &mut self, widget_id: WidgetId, scene: &CanvasScene, ) -> GuiResult<()>

Sets the scene content for a WidgetKind::Canvas widget.

Source

fn native_handle(&self, widget_id: WidgetId) -> GuiResult<Self::NativeHandle>

Source

fn add_child(&mut self, parent: WidgetId, child: WidgetId) -> GuiResult<()>

Adds a child widget to a parent widget.

Source

fn show(&mut self, widget_id: WidgetId) -> GuiResult<()>

Makes a widget visible.

Source

fn hide(&mut self, widget_id: WidgetId) -> GuiResult<()>

Hides a widget without removing it.

Source

fn remove(&mut self, widget_id: WidgetId) -> GuiResult<()>

Removes a widget and its native counterpart.

Source

fn set_enabled(&mut self, widget_id: WidgetId, enabled: bool) -> GuiResult<()>

Enables or disables a widget.

Source

fn activate(&mut self, widget_id: WidgetId) -> GuiResult<()>

Programmatically activates a clickable widget, as if it were clicked.

Source

fn data_dir(&self) -> GuiResult<PathBuf>

Returns the platform-specific application data directory.

Source

fn set_tooltip(&mut self, widget_id: WidgetId, text: &str) -> GuiResult<()>

Sets tooltip text for a widget.

Source

fn poll_event(&mut self) -> GuiResult<Option<UiEvent>>

Blocks until the next UI event is available.

Unlike poll_event, this parks the thread inside the platform’s event system instead of busy-polling.

Source

fn wait_event(&mut self) -> GuiResult<UiEvent>

Blocks until the next UI event is available and returns it.

Source

fn show_confirm_dialog( &mut self, token: u64, title: &str, message: &str, ) -> GuiResult<()>

Shows a modal Yes/No confirm dialog; the answer is delivered as UiEvent::DialogResponse { token, confirmed }.

Provided Methods§

Source

fn set_label_alignment( &mut self, widget_id: WidgetId, alignment: LabelAlignment, ) -> GuiResult<()>

Sets horizontal alignment for a Label.

Lanes without a native alignment mapping report the typed label_alignment capability error.

Source

fn set_label_wrap( &mut self, widget_id: WidgetId, wrap: LabelWrap, ) -> GuiResult<()>

Sets line wrapping for a Label.

Lanes without the requested wrapping behavior report the typed label_wrap capability error.

Source

fn text_selection(&self, _widget_id: WidgetId) -> GuiResult<(usize, usize)>

Reads the native text selection as ordered Unicode character offsets. Unlike WidgetSpec’s last programmatic selection, this reflects mouse selection and caret navigation in the live text control.

Source

fn set_text_selection( &mut self, widget_id: WidgetId, start: usize, end: usize, ) -> GuiResult<()>

Selects a character range (start inclusive, end exclusive) in a text control.

Backends without a native text-selection mapping report GuiError::UnsupportedWidget instead of silently dropping the call, so per-lane coverage stays accurate.

Source

fn set_text_completion_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()>

Sets the completion/suggestion item list for a TextInput.

items is the full suggestion list; lanes filter it for the current text (case-insensitive prefix by default) and own their popup. Backends without a completion mapping report GuiError::UnsupportedCapability with the "text_completion" identifier instead of silently ignoring the request.

Source

fn drag_capabilities(&self) -> DragCapabilities

Reports support for the additive text/custom-MIME drag surface.

Source

fn set_drag_source_options( &mut self, widget_id: WidgetId, options: &DragSourceOptions, ) -> GuiResult<()>

Configures text/custom-MIME payloads offered by a source.

Source

fn set_drag_target_options( &mut self, widget_id: WidgetId, options: &DragTargetOptions, ) -> GuiResult<()>

Configures accepted payloads and the target’s requested drop effect.

Source

fn set_file_drop_target( &mut self, widget_id: WidgetId, enabled: bool, ) -> GuiResult<()>

Enables/disables accepting external file drops from the OS shell.

Source

fn set_drop_target( &mut self, widget_id: WidgetId, enabled: bool, ) -> GuiResult<()>

Enables/disables drop target support for files, URLs, and text.

Source

fn set_min_size( &mut self, widget_id: WidgetId, width: i32, height: i32, ) -> GuiResult<()>

Records a layout size floor for a widget.

Forwarded by Ui::set_min_size. Backends with a native flow layout consult the recorded minimum as a lower bound when they place auto-sized children, so a widget the app sized with a minimum never lays out smaller than that floor. Lanes that place every child from the shared computed layout keep this default no-op, because the shared layout pass already honours set_min_size; (0, 0) clears the floor.

Source

fn set_layout_size( &mut self, widget_id: WidgetId, width: i32, height: i32, expand_width: bool, expand_height: bool, ) -> GuiResult<()>

Applies computed layout dimensions and GTK-style expansion semantics.

Backends with native flow layouts can use the expansion flags while retaining set_size’s explicit-size behavior. The default preserves existing backend behavior.

Source

fn natural_size(&self, widget_id: WidgetId) -> Option<(i32, i32)>

Natural (preferred) size of a leaf widget, when the backend can measure it. Ui::compute_layout seeds layout leaf styles with this so auto-sized rows and labels get real heights instead of measuring zero; None keeps the node’s flex style untouched.

Source

fn min_compressed_size(&self, widget_id: WidgetId) -> Option<(i32, i32)>

Smallest size, (width, height) in logical pixels, a visible leaf may be compressed to when its window is too small for its natural content.

Ui::compute_layout resets every non-root min_size to the app’s own minimum so natural sizes stay a shrinkable basis and rows compress to the window. That suits lanes that can paint a control at any size. A lane with quantized geometry (the TUI cell grid paints every widget in whole cells) returns a floor here so compressed siblings cannot land on the same cells and overprint each other or lose their labels. The height floor always applies; the width floor applies only in row parents, the same rule that seeds a leaf’s natural width. None (the default) keeps the shrink-to-zero behaviour.

Source

fn apply_flow_padding( &mut self, widget_id: WidgetId, padding: [i32; 4], ) -> GuiResult<()>

Mirrors a declarative container’s flexbox padding ([top, right, bottom, left], logical pixels) onto lanes whose containers lay their children out natively (GTK boxes). Lanes that place children from the computed layout already honour the computed layout style and keep this default no-op. The declarative gap is deliberately not mirrored: a native box cannot shrink controls below their native minimum, so a wide layout gap would push trailing controls out of their row; apps opt in with Ui::set_container_gap.

Source

fn host_advanced_control( &mut self, host: WidgetId, family: AdvancedFamily, ) -> GuiResult<AdvancedHostCapabilities>

Hosts an advanced-control family inside host and reports the runtime capability record for that family.

The default refuses with a typed error, so a lane never silently pretends to host a family; Mock and Win32 override this behind the family’s Cargo feature.

Source

fn set_combo_box_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()>

Replaces a ComboBox’s options after creation (found while dogfooding). Must not emit SelectionChanged. The default reports UnsupportedCapability("combo_box_items"); options given at creation (Ui::create_combo_box) work on every lane.

Source

fn set_list_columns( &mut self, widget_id: WidgetId, columns: &[ColumnSpec], ) -> GuiResult<()>

Sets column headers for the columned list contract.

The default reports the typed GuiError::UnsupportedCapability with the "list_view_columns" identifier, so a lane without a columned mapping fails loudly instead of silently rendering a flat list. Lanes override this when their mapping lands and must keep the documented cell rule (list_rows[r][c] under column c).

Source

fn set_list_rows( &mut self, widget_id: WidgetId, rows: &[Vec<String>], ) -> GuiResult<()>

Sets row cells for the columned list contract.

Same capability contract as Self::set_list_columns.

Source

fn clear_selection(&mut self, widget_id: WidgetId) -> GuiResult<()>

Clears the native selection of a row widget.

The default reports the typed GuiError::UnsupportedCapability with the "clear_selection" identifier, so Ui::clear_selection and a keyed apply that must drop a removed selection fail loudly instead of leaving the native selection out of sync with the model.

Source

fn visible_anchor_index(&self, widget_id: WidgetId) -> GuiResult<Option<usize>>

Reports the index of the topmost visible row of a row widget, when the lane can observe its scroll position (capability "scroll_anchor").

Source

fn scroll_to_row(&mut self, widget_id: WidgetId, index: usize) -> GuiResult<()>

Scrolls a row widget so index is its topmost visible row.

Same capability contract as Self::visible_anchor_index: a lane that cannot restore the anchor reports the typed "scroll_anchor" refusal and the shared model skips re-anchoring instead of guessing.

Source

fn rows_end_visible(&self, widget_id: WidgetId) -> GuiResult<bool>

Reports whether the last row of a row widget is currently visible (follow-tail detection): true when the lane can observe the scroll position and the bottom-most row lies inside the viewport.

Same capability contract as Self::visible_anchor_index: a lane without the "scroll_anchor" capability reports the typed refusal, and a widget with no rows answers false (nothing is at the end).

Source

fn apply_row_delta( &mut self, widget_id: WidgetId, ops: &[RowOp], ) -> GuiResult<()>

Applies incremental row operations to a row widget.

Backends implement this to avoid full table reconstruction on single-cell edits, inserts, removes, or moves. The default implementation returns Err(GuiError::UnsupportedCapability("row_delta".to_owned())).

Source

fn set_layout_position( &mut self, widget_id: WidgetId, x: i32, y: i32, ) -> GuiResult<()>

Applies a computed layout position.

Backends with native flow containers may let those containers place children instead of translating the position into manual offsets. The default preserves existing backend behavior.

Source

fn image_resource_capabilities(&self) -> ImageResourceCapabilities

Reports support for bounded in-memory RGBA image resources.

Source

fn load_image_resource( &mut self, _resource: ImageResourceId, _data: &ImageData, ) -> GuiResult<()>

Loads a UI-allocated image resource into this backend.

The default refuses explicitly so a backend without a pixel provider never reports a success-shaped no-op.

Source

fn release_image_resource( &mut self, _resource: ImageResourceId, ) -> GuiResult<()>

Releases an image resource previously loaded into this backend.

Source

fn set_image_fit( &mut self, _widget_id: WidgetId, _fit: ImageFit, ) -> GuiResult<()>

Sets how an image scales into its bounds.

The default returns a typed capability error so a backend without an image surface never silently ignores the request.

Source

fn set_file_chooser_mode( &mut self, _widget_id: WidgetId, _mode: FileChooserMode, ) -> GuiResult<()>

Sets what a FileChooserDialog lets the user pick.

The default returns a typed capability error so a backend that cannot present a folder picker never silently shows the wrong dialog.

Source

fn set_icon( &mut self, _widget_id: WidgetId, _icon: Option<IconRole>, ) -> GuiResult<()>

Sets the stock-art icon rendered beside a button’s label.

None clears the icon. The default reports the typed unsupported error: a lane without a button-art mapping must refuse instead of silently leaving a text-only button behind.

Source

fn set_color_dialog_data( &mut self, _widget_id: WidgetId, _data: &ColorDialogData, ) -> GuiResult<()>

Applies colour-dialog preferences to a live ColorDialog.

The default reports the typed unsupported error: a lane that cannot present the native chooser must refuse instead of pretending the preferences took effect.

Source

fn set_font_dialog_data( &mut self, _widget_id: WidgetId, _data: &FontDialogData, ) -> GuiResult<()>

Applies font-dialog preferences to a live FontDialog.

The default reports the typed unsupported error: a lane that cannot present the native chooser must refuse instead of pretending the preferences took effect.

Source

fn set_toolbar_items( &mut self, _widget_id: WidgetId, _items: &[ToolbarItem], ) -> GuiResult<()>

Replaces the tools of a Toolbar widget.

The default reports the typed unsupported error: a lane that has not composed the native toolbar refuses instead of pretending the items took effect. GTK/Win32/Cocoa compositions land later.

Source

fn set_toolbar_orientation( &mut self, _widget_id: WidgetId, _orientation: ToolbarOrientation, ) -> GuiResult<()>

Sets the orientation of a Toolbar widget.

The default reports the typed unsupported error for the same reason as Backend::set_toolbar_items; a lane whose native control is horizontal-only reports UnsupportedCapability("toolbar_vertical") for a vertical request once its composition lands.

Source

fn set_calendar_selected_dates( &mut self, _widget_id: WidgetId, _dates: &[CalendarDate], ) -> GuiResult<()>

Sets selected dates for a calendar widget.

Source

fn set_calendar_bounds( &mut self, _widget_id: WidgetId, _min_date: Option<CalendarDate>, _max_date: Option<CalendarDate>, ) -> GuiResult<()>

Sets selectable bounds for a calendar widget.

Source

fn set_calendar_first_day_of_week( &mut self, _widget_id: WidgetId, _first_day: CalendarFirstDayOfWeek, ) -> GuiResult<()>

Sets the first day of the week convention for a calendar widget.

Source

fn set_calendar_selection_mode( &mut self, _widget_id: WidgetId, _mode: CalendarSelectionMode, ) -> GuiResult<()>

Sets the selection mode for a calendar widget.

Source

fn set_container_wrap( &mut self, widget_id: WidgetId, wrap: ContainerWrap, ) -> GuiResult<()>

Sets wrap behavior for container widgets.

Source

fn create_gpu_fallback( &mut self, _spec: &WidgetSpec, _policy: GpuDegradationPolicy, ) -> GuiResult<()>

Creates a backend-native degraded replacement for an unavailable Vulkan canvas. Backends must refuse rather than fabricate a fallback.

Source

fn set_canvas_surface( &mut self, _widget_id: WidgetId, _surface: &CanvasSurface, ) -> GuiResult<()>

Sets the raster surface painted beneath a WidgetKind::Canvas scene. Backends without an implementation return a typed error.

Source

fn metal_canvas_handle( &self, _widget_id: WidgetId, ) -> GuiResult<MetalCanvasHandle>

Returns backend-native handle information for a Metal canvas widget.

Source

fn reparent(&mut self, child: WidgetId, new_parent: WidgetId) -> GuiResult<()>

Reparents an existing child to a new parent.

Source

fn backend_name(&self) -> &'static str

Returns the backend’s short identifier (e.g. “mock”, “win32”, “gtk”, “cocoa”).

Source

fn capture_window_rgba( &self, _widget_id: WidgetId, _include_decorations: bool, ) -> GuiResult<(u32, u32, Vec<u8>)>

Captures a screenshot of the specified window as RGBA pixels.

Source

fn capture_widget_rgba( &self, _widget_id: WidgetId, ) -> GuiResult<(u32, u32, Vec<u8>)>

Captures a screenshot of the specified widget as RGBA pixels.

Source

fn native_read_text(&self, _widget_id: WidgetId) -> GuiResult<Option<String>>

Reads live text for a widget (E2E readback).

Source

fn native_read_checked(&self, _widget_id: WidgetId) -> GuiResult<Option<bool>>

Reads live checked state for a checkbox (E2E readback).

Source

fn native_click(&self, _widget_id: WidgetId) -> GuiResult<bool>

Native click simulation (E2E).

Source

fn native_type_text(&self, _widget_id: WidgetId, _text: &str) -> GuiResult<bool>

Native type text simulation (E2E).

Source

fn native_close(&self, _widget_id: WidgetId) -> GuiResult<bool>

Native close simulation (E2E).

Source

fn e2e_capability( &self, _widget_id: WidgetId, _operation: Operation, ) -> GuiResult<Capability>

Services a bounded native-work slice; unverified adapters refuse it.

Source

fn e2e_click(&mut self, _widget_id: WidgetId) -> GuiResult<()>

Source

fn e2e_type_text(&mut self, _widget_id: WidgetId, _text: &str) -> GuiResult<()>

Source

fn e2e_check(&mut self, _widget_id: WidgetId, _checked: bool) -> GuiResult<()>

Source

fn e2e_text(&self, _widget_id: WidgetId) -> GuiResult<String>

Source

fn e2e_checked(&self, _widget_id: WidgetId) -> GuiResult<bool>

Source

fn e2e_poll_event(&mut self) -> GuiResult<Option<UiEvent>>

Source

fn set_clipboard_text(&mut self, _text: &str) -> GuiResult<()>

Writes text to the platform clipboard.

Default: no-op — the Ui layer keeps an in-memory mirror so paste still works. Native backends override this with real OS clipboard writes (GTK today; Win32 tracked).

Source

fn clipboard_text(&mut self) -> GuiResult<Option<String>>

Reads text from the platform clipboard, when the backend can provide it synchronously. Ok(None) means “unavailable” — callers fall back to the Ui-level in-memory mirror.

Source

fn paste_image_from_clipboard(&mut self) -> GuiResult<Option<ClipboardImage>>

Reads an image from the platform clipboard, returning RGBA pixels and PNG bytes.

Source

fn set_accessible_name( &mut self, _widget_id: WidgetId, _name: &str, ) -> GuiResult<()>

Applies an accessible name to a widget.

Default: returns GuiError::UnsupportedCapability; a backend without a native accessibility bridge must not silently ignore the request. GTK, Win32 and Cocoa apply the model in their own bridges.

Source

fn set_accessible_description( &mut self, _widget_id: WidgetId, _description: &str, ) -> GuiResult<()>

Applies an accessible description to a widget.

Default: returns GuiError::UnsupportedCapability (see Backend::set_accessible_name).

Source

fn post_accessible_notification( &mut self, widget_id: WidgetId, notification: AccessibleNotification, ) -> GuiResult<()>

Posts a dynamic accessibility update for a widget.

The default is deliberately best-effort: some native controls announce programmatic updates themselves, and notification delivery is not a portable capability result. Backends may override this to post native assistive-technology notifications.

Source

fn set_focus(&mut self, _widget_id: WidgetId) -> GuiResult<()>

Moves keyboard focus to a widget.

Default: returns GuiError::UnsupportedCapability; a backend without a native focus mapping must not silently ignore the request. GTK/Win32/Cocoa application lands.

Source

fn set_focusable( &mut self, _widget_id: WidgetId, _focusable: bool, ) -> GuiResult<()>

Applies the focusable flag so native traversal can honor the override.

Default: returns GuiError::UnsupportedCapability (see Backend::set_focus).

Source

fn set_theme(&mut self, _theme: &Theme) -> GuiResult<()>

Applies a resolved theme so native controls can restyle.

Default: returns GuiError::UnsupportedCapability; a backend without a native theming mapping must not silently ignore the request. GTK/Win32/Cocoa application lands.

Source

fn set_theme_override( &mut self, _widget_id: WidgetId, _theme_override: ThemeOverride, ) -> GuiResult<()>

Applies a per-widget theme override.

Default: returns GuiError::UnsupportedCapability (see Backend::set_theme).

Source

fn clear_theme_overrides(&mut self, _widget_id: WidgetId) -> GuiResult<()>

Clears the per-widget theme overrides.

Default: returns GuiError::UnsupportedCapability (see Backend::set_theme).

Source

fn theme_capabilities(&self) -> ThemeCapabilities

Reports the backend’s system light/dark detection support.

Default: ThemeCapabilities::none — a capability query, so an safe default instead of the typed error used by setters.

Source

fn system_theme_mode(&self) -> Option<ThemeMode>

Returns the OS light/dark preference when the backend can detect it; None means unknown or unsupported.

Change notifications arrive as UiEvent::ThemeChanged.

Source

fn system_high_contrast(&self) -> bool

Returns whether the OS high-contrast accessibility mode is active.

Source

fn art_capabilities(&self) -> ArtCapabilities

Reports the lane’s native stock-art support.

The portable renderer (Ui::stock_icon) is library-owned art and is available on every backend; this describes the optional OS-native lookup served by Backend::native_stock_icon. Default: no native art, so the capability query stays accurate without a typed error.

Source

fn native_stock_icon( &self, role: IconRole, size: IconSize, ) -> GuiResult<StockIcon>

Resolves an OS-native stock icon for a role and DPI variant.

Default: returns GuiError::UnsupportedCapability — a lane without a native mapping must not fabricate art or return a placeholder. Apps that want platform-independent art use Ui::stock_icon instead.

Source

fn display_capabilities(&self) -> DisplayCapabilities

Reports the lane’s display-metric support.

Capability query: DisplayCapabilities::none is a safe default (no detection) instead of the typed error used by setters.

Source

fn gpu_surface_capabilities(&self) -> GpuSurfaceCapabilities

Reports host GPU surface and degradation support.

The default advertises no GPU integration. A capability means the backend can provide its documented host contract, not that a third-party renderer or device driver is installed.

Source

fn displays(&self) -> GuiResult<Vec<DisplayInfo>>

Enumerates connected displays.

Default: returns GuiError::UnsupportedCapability — a lane that cannot enumerate must not fabricate monitor geometry. DPI/monitor transitions arrive as UiEvent::DisplayChanged when Backend::display_capabilities advertises dpi_change_events.

Source

fn primary_display(&self) -> GuiResult<Option<DisplayInfo>>

Returns the primary display; derived from Backend::displays.

Source

fn widget_scale_factor(&self, _widget_id: WidgetId) -> f64

Reports the display scale factor (relative to 96 DPI) of the display hosting widget_id.

Ui uses the value to project incoming pointer input: a lane that receives physical pixels from the OS (Win32 under Per-Monitor v2) reports the window’s effective DPI divided by 96, and every UiEvent::PointerDown, UiEvent::PointerMove, and UiEvent::PointerUp the app observes has been divided by it, so a physical (125, 250) on a 125 % display arrives as the logical (100, 200) the layout engine lays the widget out against. Lanes that already receive logical coordinates (GTK4 gestures, Cocoa points) report 1.0, making the projection the identity.

Default: 1.0 — a neutral identity for a lane that does not report scaling, so the projection is a no-op rather than a guess. A lane must report 1.0 unless its pointer events really are in physical pixels.

Source

fn wake_handle(&self) -> Option<Arc<dyn Fn() + Send + Sync>>

Returns a thread-safe callback that wakes this backend’s event loop.

Ui::task_proxy embeds it into every UiProxy so a command posted from a worker thread promptly interrupts a blocked wait_event; the transport marker itself is an internal UiEvent::TasksPending that Ui consumes while draining. Backends without a wake hook return None (the default); queued commands then apply at the next organic event.

Source

fn show_file_dialog( &mut self, token: u64, request: &FileDialog, ) -> GuiResult<()>

Shows a native file dialog described by request (dogfood report #5). The answer must arrive later as UiEvent::FileDialogResponse { token, paths } (empty paths when cancelled). The default reports UnsupportedCapability("file_dialog"), so existing backends keep compiling; use the FileChooserDialog widget there.

Source

fn native_window_handle( &self, window_id: WidgetId, ) -> GuiResult<NativeWindowHandle>

Returns the platform handles of a realized top-level window (found while dogfooding).

The default reports UnsupportedCapability("native_window_handle"), so existing backends keep compiling. Backends return an error rather than a placeholder when the window is not realized yet.

Source

fn set_close_guard( &mut self, _widget_id: WidgetId, _guarded: bool, ) -> GuiResult<()>

Enables or disables close-request interception for a window.

While guarded, an OS close request (the X button, Alt+F4, the system menu) emits UiEvent::CloseRequested and the window stays open; the app approves a close by lifting the guard and removing the window. Default: GuiError::UnsupportedCapability — a lane without close interception must not silently close.

Source

fn window_capabilities(&self) -> WindowCapabilities

Reports the window features this backend can apply exactly.

Native backends default to no extended-window support until their implementation has runtime evidence.

Source

fn set_window_options( &mut self, widget_id: WidgetId, options: &WindowOptions, ) -> GuiResult<()>

Applies options to an existing top-level window.

The default permits the portable default options and refuses every extended behavior that a backend has not implemented.

Source

fn dismiss_popup(&mut self, widget_id: WidgetId) -> GuiResult<()>

Hides a popup without synthesizing a user-dismissal event.

Source

fn timer_capabilities(&self) -> TimerCapabilities

Reports timer operations implemented by this backend.

Source

fn motion_capabilities(&self) -> MotionCapabilities

Reports support for timer-driven motions.

Native backends without a motion implementation inherit an explicit false capability; Ui::start_motion then refuses with ui_motion.

Source

fn start_timer(&mut self, timer: TimerId, spec: TimerSpec) -> GuiResult<()>

Starts a one-shot or repeating timer with a Ui-allocated id.

Source

fn start_widget_timer( &mut self, timer: TimerId, widget_id: WidgetId, spec: TimerSpec, stop_policy: TimerStopPolicy, ) -> GuiResult<()>

Starts a timer whose lifecycle is tied to one widget.

Source

fn cancel_timer(&mut self, timer: TimerId) -> GuiResult<()>

Cancels a live timer id.

Source

fn set_menu_item_enabled( &mut self, _item_id: MenuItemId, _enabled: bool, ) -> GuiResult<()>

Enables or disables a menu item.

State-dependent commands (Undo, Redo, Clear) grey out instead of looking actionable. Default: GuiError::UnsupportedCapability — a lane without a mapping must not claim the item changed.

Source

fn set_menu_item_text( &mut self, _item_id: MenuItemId, _text: &str, ) -> GuiResult<()>

Relabels an existing menu item.

State-driven menus (recent-file lists, session lists, plugin menus) relabel rows in place instead of rebuilding the whole bar. Default: GuiError::UnsupportedCapability — a lane without a mapping must not pretend the label changed.

Source

fn insert_menu_item( &mut self, _menu_id: MenuId, _item_id: MenuItemId, _index: usize, _text: &str, _shortcut: Option<&str>, ) -> GuiResult<()>

Inserts a menu item at index inside an existing menu; an index past the end appends.

Source

fn remove_menu_item(&mut self, _item_id: MenuItemId) -> GuiResult<()>

Removes a menu item from its menu.

Source

fn remove_submenu(&mut self, _submenu_id: MenuId) -> GuiResult<()>

Detaches a submenu from its parent and drops it.

Source

fn set_window_min_size( &mut self, _widget_id: WidgetId, _w: u32, _h: u32, ) -> GuiResult<()>

Sets the minimum dimensions for a top-level window.

Backends without window minimum size support report GuiError::UnsupportedCapability.

Source

fn set_resizable( &mut self, _widget_id: WidgetId, _resizable: bool, ) -> GuiResult<()>

Sets whether a top-level window can be resized by the user.

Backends without resizable control report GuiError::UnsupportedCapability.

Source

fn set_placeholder_text( &mut self, _widget_id: WidgetId, _text: &str, ) -> GuiResult<()>

Sets placeholder/hint text on a text input widget.

Source

fn set_rich_text_runs( &mut self, _widget_id: WidgetId, _runs: &[TextRun], ) -> GuiResult<()>

Sets styled text runs for a rich text widget.

Source

fn set_rich_text_images( &mut self, _widget_id: WidgetId, _images: &[RichTextImage], ) -> GuiResult<()>

Sets inline images for a rich text widget.

Source

fn set_spell_check( &mut self, _widget_id: WidgetId, _enabled: bool, ) -> GuiResult<()>

Turns the text control’s built-in spell checking on or off (MD-PERF follow-up). Only flags the native control already provides are flipped; lanes without one report the typed unsupported error.

Source

fn set_monospace( &mut self, _widget_id: WidgetId, _monospace: bool, ) -> GuiResult<()>

Sets monospace font rendering for text-bearing widgets.

Source

fn set_font( &mut self, _widget_id: WidgetId, _font: Option<&FontDescriptor>, ) -> GuiResult<()>

Sets an explicit widget font descriptor (None clears back to the active theme font).

Source

fn set_row_icons( &mut self, _widget_id: WidgetId, _icons: &[Option<IconRole>], ) -> GuiResult<()>

Sets per-row stock-art icons for list controls (DataList, ListView).

Source

fn create_tray_icon(&mut self, _spec: &TrayIconSpec) -> GuiResult<TrayIconId>

Creates a native system tray icon from a specification.

Backends without system tray support return GuiError::UnsupportedCapability.

Source

fn destroy_tray_icon(&mut self, _id: TrayIconId) -> GuiResult<()>

Destroys a native system tray icon by id.

Source

fn set_tray_icon_tooltip( &mut self, _id: TrayIconId, _tooltip: &str, ) -> GuiResult<()>

Sets or updates the tooltip text for a system tray icon.

Source

fn set_tray_icon_menu( &mut self, _id: TrayIconId, _menu: Option<MenuId>, ) -> GuiResult<()>

Attaches or detaches a context menu for a system tray icon.

Source

fn set_tray_icon_visible( &mut self, _id: TrayIconId, _visible: bool, ) -> GuiResult<()>

Shows or hides a system tray icon.

Source

fn set_tray_icon_icon( &mut self, _id: TrayIconId, _icon_bytes: Option<Vec<u8>>, ) -> GuiResult<()>

Replaces the icon pixels of a system tray icon.

None restores the platform default image. The payload uses the same portable encoding as TrayIconSpec::icon_bytes; a backend that can create icons but cannot swap their pixels keeps this default and returns GuiError::UnsupportedCapability instead of reporting success for an icon it did not change.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§