Skip to main content

MockBackend

Struct MockBackend 

Source
pub struct MockBackend {
Show 65 fields pub created: HashMap<WidgetId, WidgetSpec>, pub size_writes: HashMap<WidgetId, usize>, pub position_writes: HashMap<WidgetId, usize>, pub min_sizes: HashMap<WidgetId, (i32, i32)>, pub natural_size_probes: AtomicUsize, pub natural_sizes: bool, pub scroll_anchors: HashMap<WidgetId, usize>, pub visible_row_counts: HashMap<WidgetId, usize>, pub scroll_failures: HashMap<WidgetId, GuiError>, pub scroll_requests: Vec<(WidgetId, usize)>, pub selection_clears: Vec<WidgetId>, pub row_writes: HashMap<WidgetId, usize>, pub applied_row_ops: Vec<(WidgetId, Vec<RowOp>)>, pub shown: Vec<WidgetId>, pub focused: Option<WidgetId>, pub theme: Option<Theme>, pub theme_overrides: HashMap<WidgetId, Vec<ThemeOverride>>, pub spell_check: HashMap<WidgetId, bool>, pub user_text_selections: HashMap<WidgetId, (usize, usize)>, pub monospace: HashMap<WidgetId, bool>, pub color_dialog_results: HashMap<WidgetId, Option<Rgba>>, pub font_dialog_results: HashMap<WidgetId, Option<(FontDescriptor, FontEffects)>>, pub system_theme: Option<ThemeMode>, pub theme_capabilities: ThemeCapabilities, pub displays: Vec<DisplayInfo>, pub display_capabilities: DisplayCapabilities, pub gpu_surface_capabilities_override: Option<GpuSurfaceCapabilities>, pub gpu_fallbacks: HashMap<WidgetId, GpuDegradationPolicy>, pub events: VecDeque<UiEvent>, pub posted_accessible_notifications: Vec<(WidgetId, AccessibleNotification)>, pub modal_loops: Vec<MockModalFrame>, pub menus: HashMap<MenuId, Vec<MenuItemId>>, pub menu_shortcuts: HashMap<MenuItemId, String>, pub clipboard: Option<String>, pub clipboard_image: Option<ClipboardImage>, pub context_menus: HashMap<WidgetId, MenuId>, pub tray_icons: HashMap<TrayIconId, MockTrayIconState>, pub confirm_requests: Vec<(u64, String, String)>, pub file_dialog_requests: Vec<(u64, FileDialog)>, pub close_guards: HashMap<WidgetId, bool>, pub window_options: HashMap<WidgetId, WindowOptions>, pub window_capabilities_override: Option<WindowCapabilities>, pub window_effects: Vec<MockWindowEffect>, pub drag_source_options: HashMap<WidgetId, DragSourceOptions>, pub drag_target_options: HashMap<WidgetId, DragTargetOptions>, pub image_resources: HashMap<ImageResourceId, ImageData>, pub image_resource_capabilities_override: Option<ImageResourceCapabilities>, pub animation_resources: HashMap<AnimationResourceId, AnimationData>, pub active_animations: HashMap<WidgetId, MockAnimationState>, pub widget_image_resources: HashMap<WidgetId, ImageResourceId>, pub animation_finished_events: Vec<WidgetId>, pub drag_capabilities_override: Option<DragCapabilities>, pub timer_capabilities_override: Option<TimerCapabilities>, pub motion_capabilities_override: Option<MotionCapabilities>, pub menu_item_enabled: HashMap<MenuItemId, bool>, pub menu_item_text: HashMap<MenuItemId, String>, pub menu_submenu_slots: HashMap<MenuId, MenuItemId>, pub rich_text_images: HashMap<WidgetId, Vec<RichTextImage>>, pub last_canvas_scene: Option<CanvasScene>, pub last_canvas_surface: Option<CanvasSurface>, pub data_grid_row_heights: HashMap<(WidgetId, usize), i32>, pub data_grid_col_widths: HashMap<(WidgetId, usize), i32>, pub data_grid_models: HashMap<WidgetId, RetainedDataGridModel>, pub data_grid_selections: HashMap<WidgetId, Vec<(usize, usize)>>, pub app_data_dir: Option<PathBuf>, /* private fields */
}

Fields§

§created: HashMap<WidgetId, WidgetSpec>§size_writes: HashMap<WidgetId, usize>

Per-widget count of set_size geometry applications (layout-bound assertions); the values themselves still land on created exactly as before.

§position_writes: HashMap<WidgetId, usize>

Per-widget count of set_position geometry applications.

§min_sizes: HashMap<WidgetId, (i32, i32)>

Layout size floors recorded by set_min_size, so a portable test can assert the shared API forwards the floor to the backend that owns its automatic layout. An absent entry means “no minimum”.

§natural_size_probes: AtomicUsize

natural_size probe count. Mock never measures, so the return value stays None - this counter is pure instrumentation for the layout invalidation-bound tests.

§natural_sizes: bool

Opt-in deterministic natural sizes (found while dogfooding): when true, natural_size reports a fixed per-kind size (see MockBackend::mock_natural_size) so layouts can be asserted headlessly. Off by default, so existing Mock layouts are unchanged.

§scroll_anchors: HashMap<WidgetId, usize>

Fixture anchor index per keyed row widget (visible_anchor_index); an absent entry means “no observable scroll position”.

§visible_row_counts: HashMap<WidgetId, usize>

Number of rows visible from the fixture anchor, for follow-tail tests.

§scroll_failures: HashMap<WidgetId, GuiError>

Injected failures for keyed-row scroll restoration.

§scroll_requests: Vec<(WidgetId, usize)>

scroll_to_row calls recorded in order.

§selection_clears: Vec<WidgetId>

Widget ids passed to clear_selection, in call order.

§row_writes: HashMap<WidgetId, usize>

Per-widget count of set_data_list_items/set_data_grid_rows applications (keyed no-op assertions).

§applied_row_ops: Vec<(WidgetId, Vec<RowOp>)>

Row operations passed to apply_row_delta, in call order.

§shown: Vec<WidgetId>§focused: Option<WidgetId>

Widget that currently holds keyboard focus.

§theme: Option<Theme>

Active theme recorded by set_theme.

§theme_overrides: HashMap<WidgetId, Vec<ThemeOverride>>

Per-widget theme overrides recorded by set_theme_override.

§spell_check: HashMap<WidgetId, bool>

Native spell-check flags recorded by set_spell_check.

§user_text_selections: HashMap<WidgetId, (usize, usize)>

Inject a live mouse/caret selection in character offsets. When absent, text_selection reports unsupported, leaving model-only tests unchanged.

§monospace: HashMap<WidgetId, bool>

Monospace font rendering flag recorded by set_monospace.

§color_dialog_results: HashMap<WidgetId, Option<Rgba>>

Colour-dialog outcomes injected by inject_color_dialog_result; an absent entry means “cancelled” so activation stays deterministic without a fixture.

§font_dialog_results: HashMap<WidgetId, Option<(FontDescriptor, FontEffects)>>

Font-dialog outcomes injected by inject_font_dialog_result; an absent entry means “cancelled”.

§system_theme: Option<ThemeMode>

System light/dark preference injected by inject_system_theme_mode; None models “unknown / no detection”.

§theme_capabilities: ThemeCapabilities

Detection capability flags reported by theme_capabilities.

§displays: Vec<DisplayInfo>

Display fixture reported by displays; empty until a fixture calls set_displays.

§display_capabilities: DisplayCapabilities

Display capability flags reported by display_capabilities.

§gpu_surface_capabilities_override: Option<GpuSurfaceCapabilities>

Optional GPU capability profile; the default is the fully enabled deterministic Mock profile.

§gpu_fallbacks: HashMap<WidgetId, GpuDegradationPolicy>

Degraded Vulkan canvas policies recorded by create_gpu_fallback.

§events: VecDeque<UiEvent>§posted_accessible_notifications: Vec<(WidgetId, AccessibleNotification)>

Accessibility notification requests made by Ui, in call order.

§modal_loops: Vec<MockModalFrame>

Stack of open scripted modal loops; empty outside a modal operation, where delivery is the plain FIFO events queue. While a frame is open its script takes over delivery and events stays parked, modelling a nested OS message pump.

§menus: HashMap<MenuId, Vec<MenuItemId>>§menu_shortcuts: HashMap<MenuItemId, String>§clipboard: Option<String>§clipboard_image: Option<ClipboardImage>

Image returned by paste_image_from_clipboard (tests).

§context_menus: HashMap<WidgetId, MenuId>§tray_icons: HashMap<TrayIconId, MockTrayIconState>

Active system tray icons registered with this backend.

§confirm_requests: Vec<(u64, String, String)>

Requests recorded by show_confirm_dialog: (token, title, message).

§file_dialog_requests: Vec<(u64, FileDialog)>

Requests recorded by show_file_dialog (found while dogfooding): (token, request). Answer one with MockBackend::inject_file_dialog_result.

§close_guards: HashMap<WidgetId, bool>

Per-window close-request interception flags; a guarded window reports CloseRequested instead of WindowClosed.

§window_options: HashMap<WidgetId, WindowOptions>

Window options recorded by the extended-window contract.

§window_capabilities_override: Option<WindowCapabilities>

Explicit fixture override; None selects Mock’s verified v0 profile.

§window_effects: Vec<MockWindowEffect>

Non-blocking show/hide effects requested by the last lifecycle calls.

§drag_source_options: HashMap<WidgetId, DragSourceOptions>

Drag-and-drop source and target configurations, kept separate from row drags.

§drag_target_options: HashMap<WidgetId, DragTargetOptions>§image_resources: HashMap<ImageResourceId, ImageData>

Loaded typed RGBA8 image resources.

§image_resource_capabilities_override: Option<ImageResourceCapabilities>

Capability override for typed image-resource refusal fixtures.

§animation_resources: HashMap<AnimationResourceId, AnimationData>

Loaded animation resources.

§active_animations: HashMap<WidgetId, MockAnimationState>

Active animated image playback state per Image widget.

§widget_image_resources: HashMap<WidgetId, ImageResourceId>

Currently displayed image resource per Image widget.

§animation_finished_events: Vec<WidgetId>

Recorded finished animation events for finite loop count completions.

§drag_capabilities_override: Option<DragCapabilities>

Capability override for typed-refusal fixtures.

§timer_capabilities_override: Option<TimerCapabilities>

Capability override for timer refusal fixtures.

§motion_capabilities_override: Option<MotionCapabilities>

Capability override for typed motion-refusal fixtures.

§menu_item_enabled: HashMap<MenuItemId, bool>

Menu-item enable state recorded by set_menu_item_enabled.

§menu_item_text: HashMap<MenuItemId, String>

Live menu-item labels: set at creation, replaced by set_menu_item_text, dropped with the item.

§menu_submenu_slots: HashMap<MenuId, MenuItemId>

Row slot minted for each submenu by the shared model, so submenu rows live in the same ordered list as items without sharing their id space.

§rich_text_images: HashMap<WidgetId, Vec<RichTextImage>>

Inline images recorded by .

§last_canvas_scene: Option<CanvasScene>§last_canvas_surface: Option<CanvasSurface>

Last surface recorded by set_canvas_surface.

§data_grid_row_heights: HashMap<(WidgetId, usize), i32>

Per-row height overrides recorded by set_data_grid_row_height; absent rows keep the backend default.

§data_grid_col_widths: HashMap<(WidgetId, usize), i32>

Per-column width overrides recorded by set_data_grid_col_width.

§data_grid_models: HashMap<WidgetId, RetainedDataGridModel>

Virtual data-grid models retained per widget by set_data_grid_model. The Mock keeps the boxed model itself and never expands it into WidgetSpec::data_grid_rows, so a fixture can prove a virtual grid stayed virtual.

§data_grid_selections: HashMap<WidgetId, Vec<(usize, usize)>>

Cell selections recorded by set_data_grid_selection.

§app_data_dir: Option<PathBuf>

Optional per-instance override returned by Backend::data_dir so concurrent tests isolate persisted state outside std::env::temp_dir().

Implementations§

Source§

impl MockBackend

Source

pub fn with_natural_sizes() -> Self

A Mock backend whose leaves report deterministic natural sizes, so Ui::compute_layout produces realistic, assertable geometry headlessly (rows as tall as their tallest control, text-sized buttons, …).

use native_gui_core::ui::Ui;
use native_gui_core::widgets::{ContainerDirection, WidgetKind};
use native_gui_mock::MockBackend;

let mut ui = Ui::new(MockBackend::with_natural_sizes());
let window = ui.create(WidgetKind::Window, Some("w")).unwrap();
let column = ui.create(WidgetKind::Container, None).unwrap();
ui.set_container_direction(column, ContainerDirection::Vertical).unwrap();
let row = ui.create(WidgetKind::Container, None).unwrap();
ui.set_container_direction(row, ContainerDirection::Horizontal).unwrap();
let ok = ui.create(WidgetKind::Button, Some("OK")).unwrap();
ui.attach(window, column).unwrap();
ui.attach(column, row).unwrap();
ui.attach(row, ok).unwrap();
ui.set_layout_root(window).unwrap();
ui.compute_layout(window, 400.0, 300.0).unwrap();
assert_eq!(ui.layout_rect(row).unwrap().height, 32.0);
Source

pub fn with_data_dir(self, dir: impl Into<PathBuf>) -> Self

Overrides Backend::data_dir with an isolated test directory so concurrent tests do not share persistence files under std::env::temp_dir().

Source

pub fn mock_natural_size(spec: &WidgetSpec) -> Option<(i32, i32)>

The deterministic natural size Mock reports for spec when MockBackend::natural_sizes is on: 8 px per character of text plus window decorations, and fixed sizes for editors, lists and canvases. Containers and windows report None (they are measured from their children).

Source

pub fn set_image_resource_capabilities( &mut self, capabilities: ImageResourceCapabilities, )

Overrides typed image-resource support for refusal tests.

Source

pub fn set_natural_size_override( &mut self, widget_id: WidgetId, size: (i32, i32), )

Overrides the natural size reported for widget_id.

Source

pub fn image_resource(&self, resource: ImageResourceId) -> Option<&ImageData>

Looks up the pixels retained for a live image resource.

Source

pub fn load_animation_resource( &mut self, data: &AnimationData, ) -> GuiResult<AnimationResourceId>

Loads a pre-decoded animated image resource into this backend.

Source

pub fn release_animation_resource( &mut self, id: AnimationResourceId, ) -> GuiResult<()>

Releases a loaded animated image resource from this backend.

Source

pub fn animation_resource( &self, id: AnimationResourceId, ) -> Option<&AnimationData>

Looks up a loaded animation resource.

Source

pub fn decode_animation_resource( &mut self, _bytes: &[u8], ) -> GuiResult<AnimationResourceId>

Rejects encoded animation blobs with the typed gate animation_decode.

Source

pub fn set_image_animation( &mut self, widget_id: WidgetId, animation: Option<AnimationResourceId>, ) -> GuiResult<()>

Assigns an animated image resource to an Image widget and autoplays from frame 0.

Passing None stops and clears any active animation on the widget.

Source

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

Restarts playback of an assigned animation from frame 0.

Source

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

Stops playback and resets the displayed frame to frame 0.

Source

pub fn widget_current_image_resource( &self, widget_id: WidgetId, ) -> Option<ImageResourceId>

Returns the currently displayed image resource for an Image widget.

Source

pub fn widget_animation_state( &self, widget_id: WidgetId, ) -> Option<&MockAnimationState>

Returns the animation playback state for an Image widget.

Source

pub fn animation_finished_events(&self) -> &[WidgetId]

Returns recorded animation finished events.

Source

pub fn take_animation_finished_events(&mut self) -> Vec<WidgetId>

Takes recorded animation finished events, draining the buffer.

Source

pub fn set_motion_capabilities(&mut self, capabilities: MotionCapabilities)

Overrides motion support for typed-refusal tests.

Source

pub fn set_timer_capabilities(&mut self, capabilities: TimerCapabilities)

Overrides the timer capability profile for refusal tests.

Source

pub fn now(&self) -> Duration

Current virtual time. It advances only through advance_time or deterministic wait_event auto-advance.

Source

pub fn advance_time(&mut self, amount: Duration) -> GuiResult<()>

Advances virtual time and services all due timers without sleeping.

Source

pub fn set_window_capabilities(&mut self, capabilities: WindowCapabilities)

Overrides the extended-window capability profile for typed-gate tests.

Source

pub fn set_drag_capabilities(&mut self, capabilities: DragCapabilities)

Overrides text/custom-MIME support for typed-gate tests.

Source

pub fn mock_start_drag(&mut self, source: WidgetId) -> GuiResult<DragSessionId>

Starts a scripted drag-and-drop session from a configured source.

Source

pub fn mock_drag_enter( &mut self, session: DragSessionId, target: WidgetId, position: (i32, i32), ) -> GuiResult<bool>

Scripts entry onto a target, emitting its compatible offered MIME types.

Source

pub fn mock_drag_move( &mut self, session: DragSessionId, target: WidgetId, position: (i32, i32), ) -> bool

Scripts pointer motion over the active drag target.

Source

pub fn mock_drag_exit( &mut self, session: DragSessionId, target: WidgetId, ) -> bool

Scripts leaving the current target without ending the drag session.

Source

pub fn mock_drag_drop( &mut self, session: DragSessionId, target: WidgetId, position: (i32, i32), payload: DragPayload, ) -> GuiResult<bool>

Scripts a compatible drop and ends the session exactly once.

Source

pub fn mock_cancel_drag( &mut self, session: DragSessionId, reason: DropCancelReason, ) -> bool

Cancels the matching live session once; stale ids return false.

Source

pub fn inject_popup_dismissal( &mut self, widget_id: WidgetId, reason: PopupDismissReason, ) -> bool

Injects one user- or OS-initiated popup dismissal.

A popup session can be dismissed only once; the return value is false for a stale or already-ended session.

Source

pub fn inject_window_closed(&mut self, widget_id: WidgetId)

Injects an owner-window close after dismissing its active popups.

Source

pub fn set_gpu_surface_capabilities( &mut self, capabilities: GpuSurfaceCapabilities, )

Replaces the default GPU capability profile for a deterministic test.

Source

pub fn push_event(&mut self, event: UiEvent)

Queues an event for the outer (flat) pump.

While a scripted modal loop is open the queue is parked: the nested pump serves only its script, and pushed events are delivered once the loop closes. Outside a modal loop delivery is the usual FIFO order.

Source

pub fn begin_modal_loop(&mut self)

Opens a scripted modal loop: a nested pump frame whose script takes over event delivery until Self::end_modal_loop.

Frames nest, so a loop opened from inside another loop’s handler models a dialog raised by a modal operation; the innermost frame owns delivery until it closes. Prefer driving loops through Ui::run_modal_loop, which pairs the frame with re-entrant dispatch of its script.

Source

pub fn script_modal_event(&mut self, event: UiEvent) -> bool

Scripts one event for the innermost open modal loop, in delivery order. Returns false when no loop is open: injection reaches only a running pump, so a fixture must call Self::begin_modal_loop first.

Source

pub fn end_modal_loop(&mut self) -> Vec<UiEvent>

Closes the innermost modal loop and returns the scripted events its pump never delivered. Closing with no loop open is a no-op that returns nothing.

Source

pub fn modal_loop_depth(&self) -> usize

Depth of the open modal-loop stack (0 = no modal operation running).

Source

pub fn modal_loop_open(&self) -> bool

Whether a modal loop is currently running.

Source

pub fn last_canvas_scene(&self) -> Option<&CanvasScene>

Source

pub fn last_canvas_surface(&self) -> Option<&CanvasSurface>

Surface most recently recorded by set_canvas_surface.

Source

pub fn data_grid_model(&self, widget_id: WidgetId) -> Option<&dyn DataGridModel>

Virtual data-grid model retained for widget_id, or None when the widget was never given one. The Mock retains the model the manager handed to set_data_grid_model verbatim - it is never materialised into rows - so fixtures can read its shape back.

Source

pub fn data_grid_model_row_count(&self, widget_id: WidgetId) -> Option<usize>

Row count of the retained virtual model, or None when the widget has no model.

Source

pub fn data_grid_model_col_count(&self, widget_id: WidgetId) -> Option<usize>

Column count of the retained virtual model, or None when the widget has no model.

Source

pub fn data_grid_model_is_row_resident( &self, widget_id: WidgetId, row: usize, ) -> Option<bool>

Residency of one row of the retained virtual model, or None when the widget has no model. Uses the defaulted DataGridModel::is_row_resident hook, so an eager model reports true for every row while a windowed model reports whether the row’s payload has been delivered.

Source

pub fn data_grid_selection( &self, widget_id: WidgetId, ) -> Option<&[(usize, usize)]>

Cell selection recorded by set_data_grid_selection.

Source

pub fn inject_system_theme_mode(&mut self, mode: ThemeMode)

Injects the reported OS light/dark preference.

The Mock never reads the operating system. Fixtures call this to model a system transition: the mode becomes readable through system_theme_mode, the detection capability flags switch to native_gui_core::ThemeCapabilities::all, and the matching UiEvent::ThemeChanged is queued for the event loop.

Source

pub fn set_displays(&mut self, displays: Vec<DisplayInfo>)

Installs the display fixture reported by displays.

The Mock never reads the operating system. Fixtures call this with a deterministic multi-display set; the enumeration capability flag switches on so display_capabilities stays consistent with the data.

Source

pub fn set_display_capabilities(&mut self, capabilities: DisplayCapabilities)

Sets the display capability flags directly.

Lets fixtures model hostile lanes (data present but enumeration advertised as unsupported, or the reverse).

Source

pub fn inject_display_change(&mut self, display: DisplayInfo)

Injects a DPI/monitor transition.

Models the platform event behind a display change: the event support flag switches on and the matching UiEvent::DisplayChanged is queued for the event loop with display as the fresh payload.

Source

pub fn inject_close_request(&mut self, widget_id: WidgetId)

Injects an OS close request for a window.

Models the platform message behind the X button/Alt+F4; guarded windows answer with UiEvent::CloseRequested through the event loop.

Source

pub fn inject_color_dialog_result( &mut self, widget_id: WidgetId, result: Option<Rgba>, )

Injects the outcome of an activated colour dialog.

The Mock never opens a native chooser. Fixtures call this to script exactly what the user did: Some(color) accepts that colour (the activation emits a ColorChanged preview first, then ColorSelected { color: Some(..) }), and None models cancel (one ColorSelected { color: None }, with the stored initial colour untouched). An activation with no injected result is a cancel.

Source

pub fn inject_font_dialog_result( &mut self, widget_id: WidgetId, result: Option<(FontDescriptor, FontEffects)>, )

Injects the outcome of an activated font dialog.

Same scripted contract as Self::inject_color_dialog_result: with Some((descriptor, effects)) the activation emits a FontChanged preview (the descriptor’s size clamped to the configured range) and then FontSelected { selection: Some(..) }; None models cancel with a single FontSelected { selection: None } and the stored initial descriptor untouched. An activation with no injected result cancels.

Source

pub fn inject_suggestion_selected( &mut self, widget_id: WidgetId, text: impl Into<String>, ) -> GuiResult<()>

Injects an accepted completion suggestion for a TextInput (completion fixture).

Models the native popup committing text: the matching UiEvent::SuggestionSelected is queued, and the shared model does not rewrite spec.text — the application applies the accepted text through native_gui_core::Ui::set_text. Widgets that are not TextInputs refuse with the shared typed error instead of producing a popup event.

Source

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

Injects a completion-popup dismissal (completion fixture): the popup closed without acceptance (Escape, blur, or a click elsewhere).

Source

pub fn inject_file_dialog_result( &mut self, token: u64, paths: Vec<PathBuf>, ) -> GuiResult<()>

Answers a pending Ui::show_file_dialog request as the user would: queues UiEvent::FileDialogResponse with paths (pass an empty vector to simulate Cancel). Unknown or already-answered tokens are refused, so a test cannot answer a dialog the app never opened.

Source

pub fn inject_split_pane_moved( &mut self, widget_id: WidgetId, position: i32, extent: i32, ) -> GuiResult<()>

Injects a divider movement on a SplitPane widget.

Validates that widget_id exists and is a SplitPane, then queues UiEvent::SplitPaneMoved.

Source

pub fn click_tool( &mut self, widget_id: WidgetId, tool_id: ToolId, ) -> GuiResult<()>

Simulates a user click on a toolbar tool.

Applies the shared native_gui_core::toolbar::click_tool rules to the stored rows and queues the resulting event: a plain tool reports ToolActivated, a dropdown tool ToolDropdown, a checkable tool one ToolToggled per changed tool (radio exclusivity can uncheck one peer), and a disabled or hidden tool consumes the click silently — exactly like the native controls.

Source

pub fn hover_tool( &mut self, widget_id: WidgetId, tool_id: Option<ToolId>, ) -> GuiResult<()>

Simulates the pointer entering (Some) or leaving (None) a toolbar tool.

Source

pub fn context_tool( &mut self, widget_id: WidgetId, tool_id: ToolId, ) -> GuiResult<()>

Simulates a right-click on a toolbar tool, asking for a context menu.

Source

pub fn click_calendar_date( &mut self, widget_id: WidgetId, date: CalendarDate, ) -> GuiResult<()>

Simulates a user click on a calendar date.

Source

pub fn navigate_calendar_month( &mut self, widget_id: WidgetId, year: i32, month: u32, ) -> GuiResult<()>

Simulates navigating a calendar to a different month/year.

Trait Implementations§

Source§

impl Backend for MockBackend

Source§

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

Records the layout size floor forwarded by Ui::set_min_size. Mock owns no layout, so the floor is stored only for contract assertions and (0, 0) clears it.

Source§

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

The Mock reports the scale of the display fixture (primary, else the first display) so the physical-to-logical pointer projection is deterministic under test. With no fixture it reports 1.0, the identity — the Mock emits logical coordinates, so a delivered native_gui_core::UiEvent::PointerMove passes through unchanged.

A fixture whose scale_factor is above 1.0 makes the Mock simulate a physical-pixel lane (Win32 under Per-Monitor v2): a pushed pointer event then arrives divided by that scale, exactly as it would on a scaled display.

Source§

type NativeHandle = usize

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

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

Returns the backend’s short identifier (e.g. “mock”, “win32”, “gtk”, “cocoa”).
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. Read more
Source§

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

Releases an image resource previously loaded into this backend.
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. Read more
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 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 window_capabilities(&self) -> WindowCapabilities

Reports the window features this backend can apply exactly. Read more
Source§

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

Applies options to an existing top-level window. Read more
Source§

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

Hides a popup without synthesizing a user-dismissal event.
Source§

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

Source§

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

Creates a native widget from a shared specification. Read more
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. Read more
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 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 }.
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 set_close_guard( &mut self, widget_id: WidgetId, guarded: bool, ) -> GuiResult<()>

Enables or disables close-request interception for a window. Read more
Source§

fn set_menu_item_enabled( &mut self, item_id: MenuItemId, enabled: bool, ) -> GuiResult<()>

Enables or disables a menu item. Read more
Source§

fn set_menu_item_text( &mut self, item_id: MenuItemId, text: &str, ) -> GuiResult<()>

Relabels an existing menu item. Read more
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_text(&mut self, widget_id: WidgetId, text: &str) -> GuiResult<()>

Sets text/value-like content for a widget.
Source§

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

Sets horizontal alignment for a Label. Read more
Source§

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

Sets line wrapping for a Label. Read more
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. Read more
Source§

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

Sets the completion/suggestion item list for a TextInput. Read more
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_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 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_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_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_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_file_drop_target( &mut self, widget_id: WidgetId, enabled: bool, ) -> GuiResult<()>

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

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

Sets preferred dimensions for widgets.
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_data_list_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()>

Sets items for a data list widget.
Source§

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

Sets column headers for the columned list contract. Read more
Source§

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

Sets row cells for the columned list contract. Read more
Source§

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

Clears the native selection of a row widget. Read more
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. Read more
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. Read more
Source§

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

Sets page labels for a tabs widget. Read more
Source§

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

Applies incremental row operations to a row widget. Read more
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). Read more
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 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 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_image_fit(&mut self, widget_id: WidgetId, fit: ImageFit) -> GuiResult<()>

Sets how an image scales into its bounds. Read more
Source§

fn set_file_chooser_mode( &mut self, widget_id: WidgetId, mode: FileChooserMode, ) -> GuiResult<()>

Sets what a FileChooserDialog lets the user pick. Read more
Source§

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

Sets the stock-art icon rendered beside a button’s label. Read more
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_wrap( &mut self, widget_id: WidgetId, wrap: ContainerWrap, ) -> GuiResult<()>

Sets wrap behavior 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 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_scene( &mut self, widget_id: WidgetId, scene: &CanvasScene, ) -> GuiResult<()>

Sets the scene content for a WidgetKind::Canvas widget.
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 native_handle(&self, widget_id: WidgetId) -> GuiResult<Self::NativeHandle>

Source§

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

Returns backend-native handle information for a Metal canvas widget.
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 set_font_dialog_data( &mut self, widget_id: WidgetId, data: &FontDialogData, ) -> GuiResult<()>

Applies font-dialog preferences to a live FontDialog. Read more
Source§

fn set_color_dialog_data( &mut self, widget_id: WidgetId, data: &ColorDialogData, ) -> GuiResult<()>

Applies colour-dialog preferences to a live ColorDialog. Read more
Source§

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

Replaces the tools of a Toolbar widget. Read more
Source§

fn set_toolbar_orientation( &mut self, widget_id: WidgetId, orientation: ToolbarOrientation, ) -> GuiResult<()>

Sets the orientation of a Toolbar widget. Read more
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 data_dir(&self) -> GuiResult<PathBuf>

Returns the platform-specific application data directory.
Source§

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

Writes text to the platform clipboard. Read more
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 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 set_tooltip(&mut self, widget_id: WidgetId, text: &str) -> GuiResult<()>

Sets tooltip text for a widget.
Source§

fn set_accessible_name( &mut self, widget_id: WidgetId, name: &str, ) -> GuiResult<()>

Applies an accessible name to a widget. Read more
Source§

fn set_accessible_description( &mut self, widget_id: WidgetId, description: &str, ) -> GuiResult<()>

Applies an accessible description to a widget. Read more
Source§

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

Posts a dynamic accessibility update for a widget. Read more
Source§

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

Moves keyboard focus to a widget. Read more
Source§

fn set_focusable( &mut self, widget_id: WidgetId, focusable: bool, ) -> GuiResult<()>

Applies the focusable flag so native traversal can honor the override. Read more
Source§

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

Applies a resolved theme so native controls can restyle. Read more
Source§

fn set_theme_override( &mut self, widget_id: WidgetId, theme_override: ThemeOverride, ) -> GuiResult<()>

Applies a per-widget theme override. Read more
Source§

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

Clears the per-widget theme overrides. Read more
Source§

fn theme_capabilities(&self) -> ThemeCapabilities

Reports the backend’s system light/dark detection support. Read more
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. Read more
Source§

fn display_capabilities(&self) -> DisplayCapabilities

Reports the lane’s display-metric support. Read more
Source§

fn gpu_surface_capabilities(&self) -> GpuSurfaceCapabilities

Reports host GPU surface and degradation support. Read more
Source§

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

Enumerates connected displays. Read more
Source§

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

Returns a thread-safe callback that wakes this backend’s event loop. Read more
Source§

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

Blocks until the next UI event is available. Read more
Source§

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

Blocks until the next UI event is available and returns it.
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 create_tray_icon(&mut self, spec: &TrayIconSpec) -> GuiResult<TrayIconId>

Creates a native system tray icon from a specification. Read more
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. Read more
Source§

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

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

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

Applies computed layout dimensions and GTK-style expansion semantics. Read more
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. Read more
Source§

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

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, ) -> Result<AdvancedHostCapabilities, GuiError>

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

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

Applies a computed layout position. Read more
Source§

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

Reparents an existing child to a new parent.
Source§

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

Native close simulation (E2E).
Source§

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

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

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

Source§

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

Source§

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

Source§

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

Source§

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

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. Read more
Source§

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

Resolves an OS-native stock icon for a role and DPI variant. Read more
Source§

fn primary_display(&self) -> Result<Option<DisplayInfo>, GuiError>

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

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

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

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

Sets the minimum dimensions for a top-level window. Read more
Source§

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

Sets whether a top-level window can be resized by the user. Read more
Source§

impl Debug for MockBackend

Source§

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

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

impl Default for MockBackend

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl TextMeasure for MockBackend

Source§

fn measure_text( &self, widget_id: WidgetId, known_dimensions: Size<Option<f32>>, available_space: Size<AvailableSpace>, ) -> Option<Size<f32>>

Measures the logical dimensions of a text-bearing widget given the available space (TEXT-004).

Auto Trait Implementations§

§

impl !Freeze for MockBackend

§

impl !RefUnwindSafe for MockBackend

§

impl !Send for MockBackend

§

impl !Sync for MockBackend

§

impl !UnwindSafe for MockBackend

§

impl Forget for MockBackend

§

impl Move for MockBackend

§

impl Unpin for MockBackend
where *const u8 is !null: Unpin, Arc<Vec<Vec<String>>>: Unpin, Arc<Vec<u8>>: Unpin, Align8<usize>: Unpin, &'static str: Unpin, Box<dyn DataGridModel>: Unpin, Arc<Atomic<bool>>: Unpin, Arc<(Mutex<()>, Condvar)>: Unpin,

§

impl UnsafeUnpin for MockBackend
where *const u8 is !null: UnsafeUnpin, PhantomData<(WidgetId, WidgetSpec)>: UnsafeUnpin, PhantomData<(WidgetId, usize)>: UnsafeUnpin, PhantomData<(WidgetId, (i32, i32))>: UnsafeUnpin, Align8<usize>: UnsafeUnpin, PhantomData<(WidgetId, GuiError)>: UnsafeUnpin, PhantomData<WidgetId>: UnsafeUnpin, PhantomData<(WidgetId, Vec<RowOp>)>: UnsafeUnpin, PhantomData<(WidgetId, Vec<ThemeOverride>)>: UnsafeUnpin, PhantomData<(WidgetId, bool)>: UnsafeUnpin, PhantomData<(WidgetId, (usize, usize))>: UnsafeUnpin, PhantomData<(WidgetId, Option<Rgba>)>: UnsafeUnpin, PhantomData<(WidgetId, Option<(FontDescriptor, FontEffects)>)>: UnsafeUnpin, PhantomData<DisplayInfo>: UnsafeUnpin, PhantomData<(WidgetId, GpuDegradationPolicy)>: UnsafeUnpin, PhantomData<UiEvent>: UnsafeUnpin, PhantomData<(WidgetId, AccessibleNotification)>: UnsafeUnpin, PhantomData<MockModalFrame>: UnsafeUnpin, PhantomData<(MenuId, Vec<MenuItemId>)>: UnsafeUnpin, PhantomData<(MenuItemId, String)>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<(WidgetId, MenuId)>: UnsafeUnpin, PhantomData<(TrayIconId, MockTrayIconState)>: UnsafeUnpin, PhantomData<(u64, String, String)>: UnsafeUnpin, PhantomData<(u64, FileDialog)>: UnsafeUnpin, PhantomData<(WidgetId, WindowOptions)>: UnsafeUnpin, PhantomData<(WidgetId, ())>: UnsafeUnpin, PhantomData<MockWindowEffect>: UnsafeUnpin, PhantomData<(WidgetId, DragSourceOptions)>: UnsafeUnpin, PhantomData<(WidgetId, DragTargetOptions)>: UnsafeUnpin, PhantomData<(ImageResourceId, ImageData)>: UnsafeUnpin, PhantomData<(AnimationResourceId, AnimationData)>: UnsafeUnpin, PhantomData<(WidgetId, MockAnimationState)>: UnsafeUnpin, PhantomData<(WidgetId, ImageResourceId)>: UnsafeUnpin, PhantomData<DragPayloadKind>: UnsafeUnpin, PhantomData<(TimerId, MockTimer)>: UnsafeUnpin, PhantomData<(TimerId, (Option<(WidgetId, TimerStopPolicy)>, usize))>: UnsafeUnpin, PhantomData<(MenuItemId, bool)>: UnsafeUnpin, PhantomData<(MenuId, MenuItemId)>: UnsafeUnpin, PhantomData<(WidgetId, Vec<RichTextImage>)>: UnsafeUnpin, PhantomData<CanvasPrimitive>: UnsafeUnpin, *const ArcInner<Vec<u8>> is !null: UnsafeUnpin, PhantomData<ArcInner<Vec<u8>>>: UnsafeUnpin, PhantomData<((WidgetId, usize), i32)>: UnsafeUnpin, PhantomData<(WidgetId, RetainedDataGridModel)>: UnsafeUnpin, PhantomData<(WidgetId, Vec<(usize, usize)>)>: UnsafeUnpin, *const ArcInner<Atomic<bool>> is !null: UnsafeUnpin, PhantomData<ArcInner<Atomic<bool>>>: UnsafeUnpin, *const ArcInner<(Mutex<()>, Condvar)> is !null: UnsafeUnpin, PhantomData<ArcInner<(Mutex<()>, Condvar)>>: UnsafeUnpin,

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> 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, 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.