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: AtomicUsizenatural_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: boolOpt-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: ThemeCapabilitiesDetection capability flags reported by theme_capabilities.
displays: Vec<DisplayInfo>Display fixture reported by displays; empty until a
fixture calls set_displays.
display_capabilities: DisplayCapabilitiesDisplay 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.
clipboard: Option<String>§clipboard_image: Option<ClipboardImage>Image returned by paste_image_from_clipboard (tests).
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 enable state recorded by set_menu_item_enabled.
Live menu-item labels: set at creation, replaced by
set_menu_item_text, dropped with the item.
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
impl MockBackend
Sourcepub fn with_natural_sizes() -> Self
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);Sourcepub fn with_data_dir(self, dir: impl Into<PathBuf>) -> Self
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().
Sourcepub fn mock_natural_size(spec: &WidgetSpec) -> Option<(i32, i32)>
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).
Sourcepub fn set_image_resource_capabilities(
&mut self,
capabilities: ImageResourceCapabilities,
)
pub fn set_image_resource_capabilities( &mut self, capabilities: ImageResourceCapabilities, )
Overrides typed image-resource support for refusal tests.
Sourcepub fn set_natural_size_override(
&mut self,
widget_id: WidgetId,
size: (i32, i32),
)
pub fn set_natural_size_override( &mut self, widget_id: WidgetId, size: (i32, i32), )
Overrides the natural size reported for widget_id.
Sourcepub fn image_resource(&self, resource: ImageResourceId) -> Option<&ImageData>
pub fn image_resource(&self, resource: ImageResourceId) -> Option<&ImageData>
Looks up the pixels retained for a live image resource.
Sourcepub fn load_animation_resource(
&mut self,
data: &AnimationData,
) -> GuiResult<AnimationResourceId>
pub fn load_animation_resource( &mut self, data: &AnimationData, ) -> GuiResult<AnimationResourceId>
Loads a pre-decoded animated image resource into this backend.
Sourcepub fn release_animation_resource(
&mut self,
id: AnimationResourceId,
) -> GuiResult<()>
pub fn release_animation_resource( &mut self, id: AnimationResourceId, ) -> GuiResult<()>
Releases a loaded animated image resource from this backend.
Sourcepub fn animation_resource(
&self,
id: AnimationResourceId,
) -> Option<&AnimationData>
pub fn animation_resource( &self, id: AnimationResourceId, ) -> Option<&AnimationData>
Looks up a loaded animation resource.
Sourcepub fn decode_animation_resource(
&mut self,
_bytes: &[u8],
) -> GuiResult<AnimationResourceId>
pub fn decode_animation_resource( &mut self, _bytes: &[u8], ) -> GuiResult<AnimationResourceId>
Rejects encoded animation blobs with the typed gate animation_decode.
Sourcepub fn set_image_animation(
&mut self,
widget_id: WidgetId,
animation: Option<AnimationResourceId>,
) -> GuiResult<()>
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.
Sourcepub fn start_image_animation(&mut self, widget_id: WidgetId) -> GuiResult<()>
pub fn start_image_animation(&mut self, widget_id: WidgetId) -> GuiResult<()>
Restarts playback of an assigned animation from frame 0.
Sourcepub fn stop_image_animation(&mut self, widget_id: WidgetId) -> GuiResult<()>
pub fn stop_image_animation(&mut self, widget_id: WidgetId) -> GuiResult<()>
Stops playback and resets the displayed frame to frame 0.
Sourcepub fn widget_current_image_resource(
&self,
widget_id: WidgetId,
) -> Option<ImageResourceId>
pub fn widget_current_image_resource( &self, widget_id: WidgetId, ) -> Option<ImageResourceId>
Returns the currently displayed image resource for an Image widget.
Sourcepub fn widget_animation_state(
&self,
widget_id: WidgetId,
) -> Option<&MockAnimationState>
pub fn widget_animation_state( &self, widget_id: WidgetId, ) -> Option<&MockAnimationState>
Returns the animation playback state for an Image widget.
Sourcepub fn animation_finished_events(&self) -> &[WidgetId]
pub fn animation_finished_events(&self) -> &[WidgetId]
Returns recorded animation finished events.
Sourcepub fn take_animation_finished_events(&mut self) -> Vec<WidgetId>
pub fn take_animation_finished_events(&mut self) -> Vec<WidgetId>
Takes recorded animation finished events, draining the buffer.
Sourcepub fn set_motion_capabilities(&mut self, capabilities: MotionCapabilities)
pub fn set_motion_capabilities(&mut self, capabilities: MotionCapabilities)
Overrides motion support for typed-refusal tests.
Sourcepub fn set_timer_capabilities(&mut self, capabilities: TimerCapabilities)
pub fn set_timer_capabilities(&mut self, capabilities: TimerCapabilities)
Overrides the timer capability profile for refusal tests.
Sourcepub fn now(&self) -> Duration
pub fn now(&self) -> Duration
Current virtual time. It advances only through advance_time or
deterministic wait_event auto-advance.
Sourcepub fn advance_time(&mut self, amount: Duration) -> GuiResult<()>
pub fn advance_time(&mut self, amount: Duration) -> GuiResult<()>
Advances virtual time and services all due timers without sleeping.
Sourcepub fn set_window_capabilities(&mut self, capabilities: WindowCapabilities)
pub fn set_window_capabilities(&mut self, capabilities: WindowCapabilities)
Overrides the extended-window capability profile for typed-gate tests.
Sourcepub fn set_drag_capabilities(&mut self, capabilities: DragCapabilities)
pub fn set_drag_capabilities(&mut self, capabilities: DragCapabilities)
Overrides text/custom-MIME support for typed-gate tests.
Sourcepub fn mock_start_drag(&mut self, source: WidgetId) -> GuiResult<DragSessionId>
pub fn mock_start_drag(&mut self, source: WidgetId) -> GuiResult<DragSessionId>
Starts a scripted drag-and-drop session from a configured source.
Sourcepub fn mock_drag_enter(
&mut self,
session: DragSessionId,
target: WidgetId,
position: (i32, i32),
) -> GuiResult<bool>
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.
Sourcepub fn mock_drag_move(
&mut self,
session: DragSessionId,
target: WidgetId,
position: (i32, i32),
) -> bool
pub fn mock_drag_move( &mut self, session: DragSessionId, target: WidgetId, position: (i32, i32), ) -> bool
Scripts pointer motion over the active drag target.
Sourcepub fn mock_drag_exit(
&mut self,
session: DragSessionId,
target: WidgetId,
) -> bool
pub fn mock_drag_exit( &mut self, session: DragSessionId, target: WidgetId, ) -> bool
Scripts leaving the current target without ending the drag session.
Sourcepub fn mock_drag_drop(
&mut self,
session: DragSessionId,
target: WidgetId,
position: (i32, i32),
payload: DragPayload,
) -> GuiResult<bool>
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.
Sourcepub fn mock_cancel_drag(
&mut self,
session: DragSessionId,
reason: DropCancelReason,
) -> bool
pub fn mock_cancel_drag( &mut self, session: DragSessionId, reason: DropCancelReason, ) -> bool
Cancels the matching live session once; stale ids return false.
Sourcepub fn inject_popup_dismissal(
&mut self,
widget_id: WidgetId,
reason: PopupDismissReason,
) -> bool
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.
Sourcepub fn inject_window_closed(&mut self, widget_id: WidgetId)
pub fn inject_window_closed(&mut self, widget_id: WidgetId)
Injects an owner-window close after dismissing its active popups.
Sourcepub fn set_gpu_surface_capabilities(
&mut self,
capabilities: GpuSurfaceCapabilities,
)
pub fn set_gpu_surface_capabilities( &mut self, capabilities: GpuSurfaceCapabilities, )
Replaces the default GPU capability profile for a deterministic test.
Sourcepub fn push_event(&mut self, event: UiEvent)
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.
Sourcepub fn begin_modal_loop(&mut self)
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.
Sourcepub fn script_modal_event(&mut self, event: UiEvent) -> bool
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.
Sourcepub fn end_modal_loop(&mut self) -> Vec<UiEvent>
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.
Sourcepub fn modal_loop_depth(&self) -> usize
pub fn modal_loop_depth(&self) -> usize
Depth of the open modal-loop stack (0 = no modal operation running).
Sourcepub fn modal_loop_open(&self) -> bool
pub fn modal_loop_open(&self) -> bool
Whether a modal loop is currently running.
pub fn last_canvas_scene(&self) -> Option<&CanvasScene>
Sourcepub fn last_canvas_surface(&self) -> Option<&CanvasSurface>
pub fn last_canvas_surface(&self) -> Option<&CanvasSurface>
Surface most recently recorded by set_canvas_surface.
Sourcepub fn data_grid_model(&self, widget_id: WidgetId) -> Option<&dyn DataGridModel>
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.
Sourcepub fn data_grid_model_row_count(&self, widget_id: WidgetId) -> Option<usize>
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.
Sourcepub fn data_grid_model_col_count(&self, widget_id: WidgetId) -> Option<usize>
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.
Sourcepub fn data_grid_model_is_row_resident(
&self,
widget_id: WidgetId,
row: usize,
) -> Option<bool>
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.
Sourcepub fn data_grid_selection(
&self,
widget_id: WidgetId,
) -> Option<&[(usize, usize)]>
pub fn data_grid_selection( &self, widget_id: WidgetId, ) -> Option<&[(usize, usize)]>
Cell selection recorded by set_data_grid_selection.
Sourcepub fn inject_system_theme_mode(&mut self, mode: ThemeMode)
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.
Sourcepub fn set_displays(&mut self, displays: Vec<DisplayInfo>)
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.
Sourcepub fn set_display_capabilities(&mut self, capabilities: DisplayCapabilities)
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).
Sourcepub fn inject_display_change(&mut self, display: DisplayInfo)
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.
Sourcepub fn inject_close_request(&mut self, widget_id: WidgetId)
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.
Sourcepub fn inject_color_dialog_result(
&mut self,
widget_id: WidgetId,
result: Option<Rgba>,
)
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.
Sourcepub fn inject_font_dialog_result(
&mut self,
widget_id: WidgetId,
result: Option<(FontDescriptor, FontEffects)>,
)
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.
Sourcepub fn inject_suggestion_selected(
&mut self,
widget_id: WidgetId,
text: impl Into<String>,
) -> GuiResult<()>
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.
Sourcepub fn inject_suggestion_dismissed(
&mut self,
widget_id: WidgetId,
) -> GuiResult<()>
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).
Sourcepub fn inject_file_dialog_result(
&mut self,
token: u64,
paths: Vec<PathBuf>,
) -> GuiResult<()>
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.
Sourcepub fn inject_split_pane_moved(
&mut self,
widget_id: WidgetId,
position: i32,
extent: i32,
) -> GuiResult<()>
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.
Sourcepub fn click_tool(
&mut self,
widget_id: WidgetId,
tool_id: ToolId,
) -> GuiResult<()>
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.
Sourcepub fn hover_tool(
&mut self,
widget_id: WidgetId,
tool_id: Option<ToolId>,
) -> GuiResult<()>
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.
Sourcepub fn context_tool(
&mut self,
widget_id: WidgetId,
tool_id: ToolId,
) -> GuiResult<()>
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.
Sourcepub fn click_calendar_date(
&mut self,
widget_id: WidgetId,
date: CalendarDate,
) -> GuiResult<()>
pub fn click_calendar_date( &mut self, widget_id: WidgetId, date: CalendarDate, ) -> GuiResult<()>
Simulates a user click on a calendar date.
Simulates navigating a calendar to a different month/year.
Trait Implementations§
Source§impl Backend for MockBackend
impl Backend for MockBackend
Source§fn set_min_size(
&mut self,
widget_id: WidgetId,
width: i32,
height: i32,
) -> GuiResult<()>
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
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
type NativeHandle = usize
Source§fn backend_name(&self) -> &'static str
fn backend_name(&self) -> &'static str
Source§fn image_resource_capabilities(&self) -> ImageResourceCapabilities
fn image_resource_capabilities(&self) -> ImageResourceCapabilities
Source§fn load_image_resource(
&mut self,
resource: ImageResourceId,
data: &ImageData,
) -> GuiResult<()>
fn load_image_resource( &mut self, resource: ImageResourceId, data: &ImageData, ) -> GuiResult<()>
Source§fn release_image_resource(&mut self, resource: ImageResourceId) -> GuiResult<()>
fn release_image_resource(&mut self, resource: ImageResourceId) -> GuiResult<()>
Source§fn timer_capabilities(&self) -> TimerCapabilities
fn timer_capabilities(&self) -> TimerCapabilities
Source§fn motion_capabilities(&self) -> MotionCapabilities
fn motion_capabilities(&self) -> MotionCapabilities
Source§fn start_timer(&mut self, timer: TimerId, spec: TimerSpec) -> GuiResult<()>
fn start_timer(&mut self, timer: TimerId, spec: TimerSpec) -> GuiResult<()>
Ui-allocated id.Source§fn start_widget_timer(
&mut self,
timer: TimerId,
widget_id: WidgetId,
spec: TimerSpec,
stop_policy: TimerStopPolicy,
) -> GuiResult<()>
fn start_widget_timer( &mut self, timer: TimerId, widget_id: WidgetId, spec: TimerSpec, stop_policy: TimerStopPolicy, ) -> GuiResult<()>
Source§fn drag_capabilities(&self) -> DragCapabilities
fn drag_capabilities(&self) -> DragCapabilities
Source§fn set_drag_source_options(
&mut self,
widget_id: WidgetId,
options: &DragSourceOptions,
) -> GuiResult<()>
fn set_drag_source_options( &mut self, widget_id: WidgetId, options: &DragSourceOptions, ) -> GuiResult<()>
Source§fn set_drag_target_options(
&mut self,
widget_id: WidgetId,
options: &DragTargetOptions,
) -> GuiResult<()>
fn set_drag_target_options( &mut self, widget_id: WidgetId, options: &DragTargetOptions, ) -> GuiResult<()>
Source§fn window_capabilities(&self) -> WindowCapabilities
fn window_capabilities(&self) -> WindowCapabilities
Source§fn set_window_options(
&mut self,
widget_id: WidgetId,
options: &WindowOptions,
) -> GuiResult<()>
fn set_window_options( &mut self, widget_id: WidgetId, options: &WindowOptions, ) -> GuiResult<()>
Source§fn dismiss_popup(&mut self, widget_id: WidgetId) -> GuiResult<()>
fn dismiss_popup(&mut self, widget_id: WidgetId) -> GuiResult<()>
fn e2e_poll_event(&mut self) -> GuiResult<Option<UiEvent>>
Source§fn create_widget(&mut self, spec: &WidgetSpec) -> GuiResult<()>
fn create_widget(&mut self, spec: &WidgetSpec) -> GuiResult<()>
parent_id. Read moreSource§fn show_confirm_dialog(
&mut self,
token: u64,
title: &str,
message: &str,
) -> GuiResult<()>
fn show_confirm_dialog( &mut self, token: u64, title: &str, message: &str, ) -> GuiResult<()>
UiEvent::DialogResponse { token, confirmed }.Source§fn show_file_dialog(
&mut self,
token: u64,
request: &FileDialog,
) -> GuiResult<()>
fn show_file_dialog( &mut self, token: u64, request: &FileDialog, ) -> GuiResult<()>
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<()>
fn set_close_guard( &mut self, widget_id: WidgetId, guarded: bool, ) -> GuiResult<()>
index inside an existing menu; an index past the end
appends.Source§fn set_text(&mut self, widget_id: WidgetId, text: &str) -> GuiResult<()>
fn set_text(&mut self, widget_id: WidgetId, text: &str) -> GuiResult<()>
Source§fn set_label_alignment(
&mut self,
widget_id: WidgetId,
alignment: LabelAlignment,
) -> GuiResult<()>
fn set_label_alignment( &mut self, widget_id: WidgetId, alignment: LabelAlignment, ) -> GuiResult<()>
Label. Read moreSource§fn set_label_wrap(
&mut self,
widget_id: WidgetId,
wrap: LabelWrap,
) -> GuiResult<()>
fn set_label_wrap( &mut self, widget_id: WidgetId, wrap: LabelWrap, ) -> GuiResult<()>
Label. Read moreSource§fn text_selection(&self, widget_id: WidgetId) -> GuiResult<(usize, usize)>
fn text_selection(&self, widget_id: WidgetId) -> GuiResult<(usize, usize)>
Source§fn set_text_selection(
&mut self,
widget_id: WidgetId,
start: usize,
end: usize,
) -> GuiResult<()>
fn set_text_selection( &mut self, widget_id: WidgetId, start: usize, end: usize, ) -> GuiResult<()>
Source§fn set_text_completion_items(
&mut self,
widget_id: WidgetId,
items: &[String],
) -> GuiResult<()>
fn set_text_completion_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()>
TextInput. Read moreSource§fn set_placeholder_text(
&mut self,
widget_id: WidgetId,
text: &str,
) -> GuiResult<()>
fn set_placeholder_text( &mut self, widget_id: WidgetId, text: &str, ) -> GuiResult<()>
Source§fn set_monospace(
&mut self,
widget_id: WidgetId,
monospace: bool,
) -> GuiResult<()>
fn set_monospace( &mut self, widget_id: WidgetId, monospace: bool, ) -> GuiResult<()>
Source§fn set_font(
&mut self,
widget_id: WidgetId,
font: Option<&FontDescriptor>,
) -> GuiResult<()>
fn set_font( &mut self, widget_id: WidgetId, font: Option<&FontDescriptor>, ) -> GuiResult<()>
None clears back to the active theme font).Source§fn set_row_icons(
&mut self,
widget_id: WidgetId,
icons: &[Option<IconRole>],
) -> GuiResult<()>
fn set_row_icons( &mut self, widget_id: WidgetId, icons: &[Option<IconRole>], ) -> GuiResult<()>
DataList, ListView).Source§fn set_spell_check(
&mut self,
widget_id: WidgetId,
enabled: bool,
) -> GuiResult<()>
fn set_spell_check( &mut self, widget_id: WidgetId, enabled: bool, ) -> GuiResult<()>
Source§fn set_rich_text_runs(
&mut self,
widget_id: WidgetId,
runs: &[TextRun],
) -> GuiResult<()>
fn set_rich_text_runs( &mut self, widget_id: WidgetId, runs: &[TextRun], ) -> GuiResult<()>
Source§fn set_rich_text_images(
&mut self,
widget_id: WidgetId,
images: &[RichTextImage],
) -> GuiResult<()>
fn set_rich_text_images( &mut self, widget_id: WidgetId, images: &[RichTextImage], ) -> GuiResult<()>
Source§fn set_checked(&mut self, widget_id: WidgetId, checked: bool) -> GuiResult<()>
fn set_checked(&mut self, widget_id: WidgetId, checked: bool) -> GuiResult<()>
Source§fn set_value(&mut self, widget_id: WidgetId, value: i32) -> GuiResult<()>
fn set_value(&mut self, widget_id: WidgetId, value: i32) -> GuiResult<()>
Source§fn set_range(
&mut self,
widget_id: WidgetId,
min: i32,
max: i32,
) -> GuiResult<()>
fn set_range( &mut self, widget_id: WidgetId, min: i32, max: i32, ) -> GuiResult<()>
Source§fn set_step(&mut self, widget_id: WidgetId, step: i32) -> GuiResult<()>
fn set_step(&mut self, widget_id: WidgetId, step: i32) -> GuiResult<()>
Source§fn set_selected_index(
&mut self,
widget_id: WidgetId,
index: usize,
) -> GuiResult<()>
fn set_selected_index( &mut self, widget_id: WidgetId, index: usize, ) -> GuiResult<()>
Source§fn set_selected_indices(
&mut self,
widget_id: WidgetId,
indices: &[usize],
) -> GuiResult<()>
fn set_selected_indices( &mut self, widget_id: WidgetId, indices: &[usize], ) -> GuiResult<()>
Source§fn set_row_drag(
&mut self,
widget_id: WidgetId,
source: bool,
target: bool,
) -> GuiResult<()>
fn set_row_drag( &mut self, widget_id: WidgetId, source: bool, target: bool, ) -> GuiResult<()>
Source§fn set_file_drop_target(
&mut self,
widget_id: WidgetId,
enabled: bool,
) -> GuiResult<()>
fn set_file_drop_target( &mut self, widget_id: WidgetId, enabled: bool, ) -> GuiResult<()>
Source§fn set_size(
&mut self,
widget_id: WidgetId,
width: i32,
height: i32,
) -> GuiResult<()>
fn set_size( &mut self, widget_id: WidgetId, width: i32, height: i32, ) -> GuiResult<()>
Source§fn set_combo_box_items(
&mut self,
widget_id: WidgetId,
_items: &[String],
) -> GuiResult<()>
fn set_combo_box_items( &mut self, widget_id: WidgetId, _items: &[String], ) -> GuiResult<()>
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<()>
fn set_data_list_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()>
Source§fn set_list_columns(
&mut self,
widget_id: WidgetId,
columns: &[ColumnSpec],
) -> GuiResult<()>
fn set_list_columns( &mut self, widget_id: WidgetId, columns: &[ColumnSpec], ) -> GuiResult<()>
Source§fn set_list_rows(
&mut self,
widget_id: WidgetId,
rows: &[Vec<String>],
) -> GuiResult<()>
fn set_list_rows( &mut self, widget_id: WidgetId, rows: &[Vec<String>], ) -> GuiResult<()>
Source§fn clear_selection(&mut self, widget_id: WidgetId) -> GuiResult<()>
fn clear_selection(&mut self, widget_id: WidgetId) -> GuiResult<()>
Source§fn visible_anchor_index(&self, widget_id: WidgetId) -> GuiResult<Option<usize>>
fn visible_anchor_index(&self, widget_id: WidgetId) -> GuiResult<Option<usize>>
"scroll_anchor").Source§fn scroll_to_row(&mut self, widget_id: WidgetId, index: usize) -> GuiResult<()>
fn scroll_to_row(&mut self, widget_id: WidgetId, index: usize) -> GuiResult<()>
index is its topmost visible row. Read moreSource§fn rows_end_visible(&self, widget_id: WidgetId) -> GuiResult<bool>
fn rows_end_visible(&self, widget_id: WidgetId) -> GuiResult<bool>
true when the lane can observe the
scroll position and the bottom-most row lies inside the viewport. Read moreSource§fn set_tab_items(
&mut self,
widget_id: WidgetId,
items: &[String],
) -> GuiResult<()>
fn set_tab_items( &mut self, widget_id: WidgetId, items: &[String], ) -> GuiResult<()>
Source§fn apply_row_delta(
&mut self,
widget_id: WidgetId,
ops: &[RowOp],
) -> GuiResult<()>
fn apply_row_delta( &mut self, widget_id: WidgetId, ops: &[RowOp], ) -> GuiResult<()>
Source§fn set_data_grid_rows(
&mut self,
widget_id: WidgetId,
rows: Arc<Vec<Vec<String>>>,
) -> GuiResult<()>
fn set_data_grid_rows( &mut self, widget_id: WidgetId, rows: Arc<Vec<Vec<String>>>, ) -> GuiResult<()>
Source§fn set_data_grid_model(
&mut self,
widget_id: WidgetId,
model: Box<dyn DataGridModel>,
) -> GuiResult<()>
fn set_data_grid_model( &mut self, widget_id: WidgetId, model: Box<dyn DataGridModel>, ) -> GuiResult<()>
Source§fn set_data_grid_row_height(
&mut self,
widget_id: WidgetId,
row: usize,
height: i32,
) -> GuiResult<()>
fn set_data_grid_row_height( &mut self, widget_id: WidgetId, row: usize, height: i32, ) -> GuiResult<()>
Source§fn set_data_grid_col_width(
&mut self,
widget_id: WidgetId,
col: usize,
width: i32,
) -> GuiResult<()>
fn set_data_grid_col_width( &mut self, widget_id: WidgetId, col: usize, width: i32, ) -> GuiResult<()>
Source§fn set_data_grid_frozen_panes(
&mut self,
widget_id: WidgetId,
_rows: usize,
_cols: usize,
) -> GuiResult<()>
fn set_data_grid_frozen_panes( &mut self, widget_id: WidgetId, _rows: usize, _cols: usize, ) -> GuiResult<()>
Source§fn set_data_grid_selection(
&mut self,
widget_id: WidgetId,
selection: &[(usize, usize)],
) -> GuiResult<()>
fn set_data_grid_selection( &mut self, widget_id: WidgetId, selection: &[(usize, usize)], ) -> GuiResult<()>
Source§fn set_tree_items(
&mut self,
widget_id: WidgetId,
items: &[TreeItem],
) -> GuiResult<()>
fn set_tree_items( &mut self, widget_id: WidgetId, items: &[TreeItem], ) -> GuiResult<()>
Source§fn set_position(&mut self, widget_id: WidgetId, x: i32, y: i32) -> GuiResult<()>
fn set_position(&mut self, widget_id: WidgetId, x: i32, y: i32) -> GuiResult<()>
Source§fn natural_size(&self, widget_id: WidgetId) -> Option<(i32, i32)>
fn natural_size(&self, widget_id: WidgetId) -> Option<(i32, i32)>
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<()>
fn set_background_color( &mut self, widget_id: WidgetId, color: Color, ) -> GuiResult<()>
Source§fn set_alert_level(
&mut self,
widget_id: WidgetId,
level: AlertLevel,
) -> GuiResult<()>
fn set_alert_level( &mut self, widget_id: WidgetId, level: AlertLevel, ) -> GuiResult<()>
Source§fn set_image_source(
&mut self,
widget_id: WidgetId,
source: &str,
) -> GuiResult<()>
fn set_image_source( &mut self, widget_id: WidgetId, source: &str, ) -> GuiResult<()>
Source§fn set_image_fit(&mut self, widget_id: WidgetId, fit: ImageFit) -> GuiResult<()>
fn set_image_fit(&mut self, widget_id: WidgetId, fit: ImageFit) -> GuiResult<()>
Source§fn set_file_chooser_mode(
&mut self,
widget_id: WidgetId,
mode: FileChooserMode,
) -> GuiResult<()>
fn set_file_chooser_mode( &mut self, widget_id: WidgetId, mode: FileChooserMode, ) -> GuiResult<()>
FileChooserDialog lets the user pick. Read moreSource§fn set_icon(
&mut self,
widget_id: WidgetId,
icon: Option<IconRole>,
) -> GuiResult<()>
fn set_icon( &mut self, widget_id: WidgetId, icon: Option<IconRole>, ) -> GuiResult<()>
Source§fn set_date_value(
&mut self,
widget_id: WidgetId,
iso_date: &str,
) -> GuiResult<()>
fn set_date_value( &mut self, widget_id: WidgetId, iso_date: &str, ) -> GuiResult<()>
YYYY-MM-DD) for date-capable widgets.Source§fn set_link_url(&mut self, widget_id: WidgetId, url: &str) -> GuiResult<()>
fn set_link_url(&mut self, widget_id: WidgetId, url: &str) -> GuiResult<()>
Source§fn set_container_direction(
&mut self,
widget_id: WidgetId,
direction: ContainerDirection,
) -> GuiResult<()>
fn set_container_direction( &mut self, widget_id: WidgetId, direction: ContainerDirection, ) -> GuiResult<()>
Source§fn set_container_wrap(
&mut self,
widget_id: WidgetId,
wrap: ContainerWrap,
) -> GuiResult<()>
fn set_container_wrap( &mut self, widget_id: WidgetId, wrap: ContainerWrap, ) -> GuiResult<()>
Source§fn set_container_scroll(
&mut self,
widget_id: WidgetId,
vertical: bool,
horizontal: bool,
) -> GuiResult<()>
fn set_container_scroll( &mut self, widget_id: WidgetId, vertical: bool, horizontal: bool, ) -> GuiResult<()>
Source§fn set_container_gap(&mut self, widget_id: WidgetId, gap: i32) -> GuiResult<()>
fn set_container_gap(&mut self, widget_id: WidgetId, gap: i32) -> GuiResult<()>
Source§fn set_container_padding(
&mut self,
widget_id: WidgetId,
padding: i32,
) -> GuiResult<()>
fn set_container_padding( &mut self, widget_id: WidgetId, padding: i32, ) -> GuiResult<()>
Source§fn draw_demo_cube(&mut self, widget_id: WidgetId) -> GuiResult<()>
fn draw_demo_cube(&mut self, widget_id: WidgetId) -> GuiResult<()>
Source§fn create_gpu_fallback(
&mut self,
spec: &WidgetSpec,
policy: GpuDegradationPolicy,
) -> GuiResult<()>
fn create_gpu_fallback( &mut self, spec: &WidgetSpec, policy: GpuDegradationPolicy, ) -> GuiResult<()>
Source§fn set_canvas_scene(
&mut self,
widget_id: WidgetId,
scene: &CanvasScene,
) -> GuiResult<()>
fn set_canvas_scene( &mut self, widget_id: WidgetId, scene: &CanvasScene, ) -> GuiResult<()>
WidgetKind::Canvas widget.Source§fn set_canvas_surface(
&mut self,
widget_id: WidgetId,
surface: &CanvasSurface,
) -> GuiResult<()>
fn set_canvas_surface( &mut self, widget_id: WidgetId, surface: &CanvasSurface, ) -> GuiResult<()>
WidgetKind::Canvas scene.
Backends without an implementation return a typed error.fn native_handle(&self, widget_id: WidgetId) -> GuiResult<Self::NativeHandle>
Source§fn metal_canvas_handle(
&self,
widget_id: WidgetId,
) -> GuiResult<MetalCanvasHandle>
fn metal_canvas_handle( &self, widget_id: WidgetId, ) -> GuiResult<MetalCanvasHandle>
Source§fn add_child(&mut self, parent: WidgetId, child: WidgetId) -> GuiResult<()>
fn add_child(&mut self, parent: WidgetId, child: WidgetId) -> GuiResult<()>
Source§fn remove(&mut self, widget_id: WidgetId) -> GuiResult<()>
fn remove(&mut self, widget_id: WidgetId) -> GuiResult<()>
Source§fn set_enabled(&mut self, widget_id: WidgetId, enabled: bool) -> GuiResult<()>
fn set_enabled(&mut self, widget_id: WidgetId, enabled: bool) -> GuiResult<()>
Source§fn activate(&mut self, widget_id: WidgetId) -> GuiResult<()>
fn activate(&mut self, widget_id: WidgetId) -> GuiResult<()>
Source§fn set_font_dialog_data(
&mut self,
widget_id: WidgetId,
data: &FontDialogData,
) -> GuiResult<()>
fn set_font_dialog_data( &mut self, widget_id: WidgetId, data: &FontDialogData, ) -> GuiResult<()>
FontDialog. Read moreSource§fn set_color_dialog_data(
&mut self,
widget_id: WidgetId,
data: &ColorDialogData,
) -> GuiResult<()>
fn set_color_dialog_data( &mut self, widget_id: WidgetId, data: &ColorDialogData, ) -> GuiResult<()>
ColorDialog. Read moreSource§fn set_toolbar_items(
&mut self,
widget_id: WidgetId,
items: &[ToolbarItem],
) -> GuiResult<()>
fn set_toolbar_items( &mut self, widget_id: WidgetId, items: &[ToolbarItem], ) -> GuiResult<()>
Toolbar widget. Read moreSource§fn set_toolbar_orientation(
&mut self,
widget_id: WidgetId,
orientation: ToolbarOrientation,
) -> GuiResult<()>
fn set_toolbar_orientation( &mut self, widget_id: WidgetId, orientation: ToolbarOrientation, ) -> GuiResult<()>
Toolbar widget. Read moreSource§fn set_calendar_selected_dates(
&mut self,
widget_id: WidgetId,
dates: &[CalendarDate],
) -> GuiResult<()>
fn set_calendar_selected_dates( &mut self, widget_id: WidgetId, dates: &[CalendarDate], ) -> GuiResult<()>
Source§fn set_calendar_bounds(
&mut self,
widget_id: WidgetId,
min_date: Option<CalendarDate>,
max_date: Option<CalendarDate>,
) -> GuiResult<()>
fn set_calendar_bounds( &mut self, widget_id: WidgetId, min_date: Option<CalendarDate>, max_date: Option<CalendarDate>, ) -> GuiResult<()>
Source§fn set_calendar_first_day_of_week(
&mut self,
widget_id: WidgetId,
first_day: CalendarFirstDayOfWeek,
) -> GuiResult<()>
fn set_calendar_first_day_of_week( &mut self, widget_id: WidgetId, first_day: CalendarFirstDayOfWeek, ) -> GuiResult<()>
Source§fn set_calendar_selection_mode(
&mut self,
widget_id: WidgetId,
mode: CalendarSelectionMode,
) -> GuiResult<()>
fn set_calendar_selection_mode( &mut self, widget_id: WidgetId, mode: CalendarSelectionMode, ) -> GuiResult<()>
Source§fn data_dir(&self) -> GuiResult<PathBuf>
fn data_dir(&self) -> GuiResult<PathBuf>
Source§fn set_clipboard_text(&mut self, text: &str) -> GuiResult<()>
fn set_clipboard_text(&mut self, text: &str) -> GuiResult<()>
Source§fn paste_image_from_clipboard(&mut self) -> GuiResult<Option<ClipboardImage>>
fn paste_image_from_clipboard(&mut self) -> GuiResult<Option<ClipboardImage>>
Source§fn clipboard_text(&mut self) -> GuiResult<Option<String>>
fn clipboard_text(&mut self) -> GuiResult<Option<String>>
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<()>
fn set_tooltip(&mut self, widget_id: WidgetId, text: &str) -> GuiResult<()>
Source§fn set_accessible_name(
&mut self,
widget_id: WidgetId,
name: &str,
) -> GuiResult<()>
fn set_accessible_name( &mut self, widget_id: WidgetId, name: &str, ) -> GuiResult<()>
Source§fn set_accessible_description(
&mut self,
widget_id: WidgetId,
description: &str,
) -> GuiResult<()>
fn set_accessible_description( &mut self, widget_id: WidgetId, description: &str, ) -> GuiResult<()>
Source§fn post_accessible_notification(
&mut self,
widget_id: WidgetId,
notification: AccessibleNotification,
) -> GuiResult<()>
fn post_accessible_notification( &mut self, widget_id: WidgetId, notification: AccessibleNotification, ) -> GuiResult<()>
Source§fn set_focus(&mut self, widget_id: WidgetId) -> GuiResult<()>
fn set_focus(&mut self, widget_id: WidgetId) -> GuiResult<()>
Source§fn set_focusable(
&mut self,
widget_id: WidgetId,
focusable: bool,
) -> GuiResult<()>
fn set_focusable( &mut self, widget_id: WidgetId, focusable: bool, ) -> GuiResult<()>
Source§fn set_theme(&mut self, theme: &Theme) -> GuiResult<()>
fn set_theme(&mut self, theme: &Theme) -> GuiResult<()>
Source§fn set_theme_override(
&mut self,
widget_id: WidgetId,
theme_override: ThemeOverride,
) -> GuiResult<()>
fn set_theme_override( &mut self, widget_id: WidgetId, theme_override: ThemeOverride, ) -> GuiResult<()>
Source§fn clear_theme_overrides(&mut self, widget_id: WidgetId) -> GuiResult<()>
fn clear_theme_overrides(&mut self, widget_id: WidgetId) -> GuiResult<()>
Source§fn theme_capabilities(&self) -> ThemeCapabilities
fn theme_capabilities(&self) -> ThemeCapabilities
Source§fn system_theme_mode(&self) -> Option<ThemeMode>
fn system_theme_mode(&self) -> Option<ThemeMode>
None means unknown or unsupported. Read moreSource§fn display_capabilities(&self) -> DisplayCapabilities
fn display_capabilities(&self) -> DisplayCapabilities
Source§fn gpu_surface_capabilities(&self) -> GpuSurfaceCapabilities
fn gpu_surface_capabilities(&self) -> GpuSurfaceCapabilities
Source§fn wake_handle(&self) -> Option<Arc<dyn Fn() + Send + Sync>>
fn wake_handle(&self) -> Option<Arc<dyn Fn() + Send + Sync>>
Source§fn poll_event(&mut self) -> GuiResult<Option<UiEvent>>
fn poll_event(&mut self) -> GuiResult<Option<UiEvent>>
Source§fn wait_event(&mut self) -> GuiResult<UiEvent>
fn wait_event(&mut self) -> GuiResult<UiEvent>
Source§fn capture_window_rgba(
&self,
widget_id: WidgetId,
include_decorations: bool,
) -> GuiResult<(u32, u32, Vec<u8>)>
fn capture_window_rgba( &self, widget_id: WidgetId, include_decorations: bool, ) -> GuiResult<(u32, u32, Vec<u8>)>
Source§fn capture_widget_rgba(
&self,
widget_id: WidgetId,
) -> GuiResult<(u32, u32, Vec<u8>)>
fn capture_widget_rgba( &self, widget_id: WidgetId, ) -> GuiResult<(u32, u32, Vec<u8>)>
Source§fn native_read_text(&self, widget_id: WidgetId) -> GuiResult<Option<String>>
fn native_read_text(&self, widget_id: WidgetId) -> GuiResult<Option<String>>
Source§fn native_read_checked(&self, widget_id: WidgetId) -> GuiResult<Option<bool>>
fn native_read_checked(&self, widget_id: WidgetId) -> GuiResult<Option<bool>>
Source§fn native_type_text(&self, widget_id: WidgetId, _text: &str) -> GuiResult<bool>
fn native_type_text(&self, widget_id: WidgetId, _text: &str) -> GuiResult<bool>
Source§fn create_tray_icon(&mut self, spec: &TrayIconSpec) -> GuiResult<TrayIconId>
fn create_tray_icon(&mut self, spec: &TrayIconSpec) -> GuiResult<TrayIconId>
Source§fn destroy_tray_icon(&mut self, id: TrayIconId) -> GuiResult<()>
fn destroy_tray_icon(&mut self, id: TrayIconId) -> GuiResult<()>
Source§fn set_tray_icon_tooltip(
&mut self,
id: TrayIconId,
tooltip: &str,
) -> GuiResult<()>
fn set_tray_icon_tooltip( &mut self, id: TrayIconId, tooltip: &str, ) -> GuiResult<()>
Source§fn set_tray_icon_visible(
&mut self,
id: TrayIconId,
visible: bool,
) -> GuiResult<()>
fn set_tray_icon_visible( &mut self, id: TrayIconId, visible: bool, ) -> GuiResult<()>
Source§fn set_tray_icon_icon(
&mut self,
id: TrayIconId,
icon_bytes: Option<Vec<u8>>,
) -> GuiResult<()>
fn set_tray_icon_icon( &mut self, id: TrayIconId, icon_bytes: Option<Vec<u8>>, ) -> GuiResult<()>
Source§fn set_drop_target(
&mut self,
widget_id: WidgetId,
enabled: bool,
) -> Result<(), GuiError>
fn set_drop_target( &mut self, widget_id: WidgetId, enabled: bool, ) -> Result<(), GuiError>
Source§fn set_layout_size(
&mut self,
widget_id: WidgetId,
width: i32,
height: i32,
expand_width: bool,
expand_height: bool,
) -> Result<(), GuiError>
fn set_layout_size( &mut self, widget_id: WidgetId, width: i32, height: i32, expand_width: bool, expand_height: bool, ) -> Result<(), GuiError>
Source§fn min_compressed_size(&self, widget_id: WidgetId) -> Option<(i32, i32)>
fn min_compressed_size(&self, widget_id: WidgetId) -> Option<(i32, i32)>
(width, height) in logical pixels, a visible leaf
may be compressed to when its window is too small for its natural
content. Read moreSource§fn apply_flow_padding(
&mut self,
widget_id: WidgetId,
padding: [i32; 4],
) -> Result<(), GuiError>
fn apply_flow_padding( &mut self, widget_id: WidgetId, padding: [i32; 4], ) -> Result<(), GuiError>
[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>
fn host_advanced_control( &mut self, host: WidgetId, family: AdvancedFamily, ) -> Result<AdvancedHostCapabilities, GuiError>
host and reports the
runtime capability record for that family. Read moreSource§fn set_layout_position(
&mut self,
widget_id: WidgetId,
x: i32,
y: i32,
) -> Result<(), GuiError>
fn set_layout_position( &mut self, widget_id: WidgetId, x: i32, y: i32, ) -> Result<(), GuiError>
Source§fn reparent(
&mut self,
child: WidgetId,
new_parent: WidgetId,
) -> Result<(), GuiError>
fn reparent( &mut self, child: WidgetId, new_parent: WidgetId, ) -> Result<(), GuiError>
Source§fn native_close(&self, _widget_id: WidgetId) -> Result<bool, GuiError>
fn native_close(&self, _widget_id: WidgetId) -> Result<bool, GuiError>
Source§fn e2e_capability(
&self,
_widget_id: WidgetId,
_operation: Operation,
) -> Result<Capability, GuiError>
fn e2e_capability( &self, _widget_id: WidgetId, _operation: Operation, ) -> Result<Capability, GuiError>
fn e2e_click(&mut self, _widget_id: WidgetId) -> Result<(), GuiError>
fn e2e_type_text( &mut self, _widget_id: WidgetId, _text: &str, ) -> Result<(), GuiError>
fn e2e_check( &mut self, _widget_id: WidgetId, _checked: bool, ) -> Result<(), GuiError>
fn e2e_text(&self, _widget_id: WidgetId) -> Result<String, GuiError>
fn e2e_checked(&self, _widget_id: WidgetId) -> Result<bool, GuiError>
Source§fn system_high_contrast(&self) -> bool
fn system_high_contrast(&self) -> bool
Source§fn art_capabilities(&self) -> ArtCapabilities
fn art_capabilities(&self) -> ArtCapabilities
Source§fn native_stock_icon(
&self,
role: IconRole,
size: IconSize,
) -> Result<StockIcon, GuiError>
fn native_stock_icon( &self, role: IconRole, size: IconSize, ) -> Result<StockIcon, GuiError>
Source§fn primary_display(&self) -> Result<Option<DisplayInfo>, GuiError>
fn primary_display(&self) -> Result<Option<DisplayInfo>, GuiError>
Backend::displays.