Skip to main content

Toolkit

Trait Toolkit 

Source
pub trait Toolkit: Sized + 'static {
    type Handle: Clone + 'static;

Show 45 methods // Required methods fn realize( &mut self, kind: PieceKind, props: &dyn Any, id: NodeId, ) -> Self::Handle; fn update( &mut self, h: &Self::Handle, kind: PieceKind, patch: &dyn Any, anim: Option<&AnimSpec>, ); fn release(&mut self, h: Self::Handle); fn insert( &mut self, parent: &Self::Handle, child: &Self::Handle, index: usize, ); fn remove(&mut self, parent: &Self::Handle, child: &Self::Handle); fn move_child( &mut self, parent: &Self::Handle, child: &Self::Handle, to: usize, ); fn measure( &mut self, h: &Self::Handle, kind: PieceKind, p: Proposal, ) -> Size; fn set_frame( &mut self, h: &Self::Handle, frame: Rect, anim: Option<&AnimSpec>, ); fn set_event_sink(&mut self, sink: EventSink); // Provided methods fn capability(&self, _cap: Cap) -> Support { ... } fn set_opacity( &mut self, _h: &Self::Handle, _opacity: f64, _anim: Option<&AnimSpec>, ) { ... } fn set_transform( &mut self, _h: &Self::Handle, _t: Transform, _size: Size, _anim: Option<&AnimSpec>, ) { ... } fn set_selectable(&mut self, _h: &Self::Handle, _selectable: bool) { ... } fn set_scroll_content(&mut self, _h: &Self::Handle, _content: Size) { ... } fn scroll_to(&mut self, _h: &Self::Handle, _target: Rect, _animated: bool) { ... } fn scroll_offset(&mut self, _h: &Self::Handle) -> Point { ... } fn enable_gesture( &mut self, _h: &Self::Handle, _node: NodeId, _kind: GestureKind, ) { ... } fn focus(&mut self, _h: &Self::Handle, _node: NodeId, _focused: bool) { ... } fn attach_list(&mut self, _host: &Self::Handle, _source: ListSource) { ... } fn set_route(&mut self, _route: &str) { ... } fn set_app_menu(&mut self, _items: &[MenuItem]) { ... } fn set_context_menu( &mut self, _h: &Self::Handle, _node: NodeId, _items: &[MenuItem], ) { ... } fn set_toolbar(&mut self, _h: &Self::Handle, _items: &[ToolbarItem]) { ... } fn update_toolbar(&mut self, _h: &Self::Handle, _patch: &ToolbarPatch) { ... } fn supports_lifecycle(&self, phase: Lifecycle) -> bool { ... } fn set_a11y(&mut self, _h: &Self::Handle, _a11y: &A11yProps) { ... } fn read_a11y(&self, _h: &Self::Handle) -> A11ySnapshot { ... } fn replay(&mut self, _h: &Self::Handle, _ops: &[DrawOp], _size: Size) { ... } fn snapshot_window(&mut self) -> Result<Vec<u8>, String> { ... } fn ui_idle(&mut self) -> bool { ... } fn present(&mut self, _req: u64, _spec: &PresentSpec) { ... } fn dismiss(&mut self, _req: u64) { ... } fn open_url(&mut self, _url: &str) { ... } fn defer_system_gestures(&mut self, _edges: Edges) { ... } fn dark_mode(&mut self) -> bool { ... } fn set_appearance(&mut self, _dark: Option<bool>) { ... } fn on_suspend(&mut self) { ... } fn on_resume(&mut self) { ... } fn on_memory_warning(&mut self) { ... } fn adopt(&mut self, _raw: RawHandle) -> Self::Handle { ... } fn open_window( &mut self, _id: NodeId, _options: &WindowOptions, _kind: WindowKind, ) -> WindowOpenReply<Self::Handle> { ... } fn close_window(&mut self, _host: &Self::Handle) { ... } fn focus_window(&mut self, _host: &Self::Handle) { ... } fn set_window_title(&mut self, _host: &Self::Handle, _title: &str) { ... } fn snapshot_window_of( &mut self, _host: &Self::Handle, ) -> Result<Vec<u8>, String> { ... }
}

Required Associated Types§

Source

type Handle: Clone + 'static

Required Methods§

Source

fn realize( &mut self, kind: PieceKind, props: &dyn Any, id: NodeId, ) -> Self::Handle

Source

fn update( &mut self, h: &Self::Handle, kind: PieceKind, patch: &dyn Any, anim: Option<&AnimSpec>, )

Source

fn release(&mut self, h: Self::Handle)

Called from the turn-boundary release queue; backends may defer destruction further.

Source

fn insert(&mut self, parent: &Self::Handle, child: &Self::Handle, index: usize)

Source

fn remove(&mut self, parent: &Self::Handle, child: &Self::Handle)

Source

fn move_child(&mut self, parent: &Self::Handle, child: &Self::Handle, to: usize)

Source

fn measure(&mut self, h: &Self::Handle, kind: PieceKind, p: Proposal) -> Size

Source

fn set_frame(&mut self, h: &Self::Handle, frame: Rect, anim: Option<&AnimSpec>)

Source

fn set_event_sink(&mut self, sink: EventSink)

Provided Methods§

Source

fn capability(&self, _cap: Cap) -> Support

Source

fn set_opacity( &mut self, _h: &Self::Handle, _opacity: f64, _anim: Option<&AnimSpec>, )

Source

fn set_transform( &mut self, _h: &Self::Handle, _t: Transform, _size: Size, _anim: Option<&AnimSpec>, )

Source

fn set_selectable(&mut self, _h: &Self::Handle, _selectable: bool)

Source

fn set_scroll_content(&mut self, _h: &Self::Handle, _content: Size)

Source

fn scroll_to(&mut self, _h: &Self::Handle, _target: Rect, _animated: bool)

Source

fn scroll_offset(&mut self, _h: &Self::Handle) -> Point

Source

fn enable_gesture( &mut self, _h: &Self::Handle, _node: NodeId, _kind: GestureKind, )

Source

fn focus(&mut self, _h: &Self::Handle, _node: NodeId, _focused: bool)

Source

fn attach_list(&mut self, _host: &Self::Handle, _source: ListSource)

Source

fn set_route(&mut self, _route: &str)

Source

fn set_app_menu(&mut self, _items: &[MenuItem])

The application menu (macOS/Windows/Linux menu bar; the app-bar overflow on Android; the UIMenuBuilder main menu on iPadOS/Catalyst). Replaces any previous app menu.

Source

fn set_context_menu( &mut self, _h: &Self::Handle, _node: NodeId, _items: &[MenuItem], )

A context menu for h, shown on secondary-click (desktop) or long-press (mobile). Passing an empty slice removes it.

Source

fn set_toolbar(&mut self, _h: &Self::Handle, _items: &[ToolbarItem])

Install items as the window’s toolbar, replacing any previous one. An empty slice removes it. Items are identified by ToolbarItem::id; a backend that can reuse the native item already carrying an id should, so a replace does not drop the search field’s focus.

Source

fn update_toolbar(&mut self, _h: &Self::Handle, _patch: &ToolbarPatch)

Apply a targeted change to one live toolbar item — the path a bound signal writes through, so syncing a search field does not rebuild the bar. No-op if the item is not present.

Source

fn supports_lifecycle(&self, phase: Lifecycle) -> bool

Source

fn set_a11y(&mut self, _h: &Self::Handle, _a11y: &A11yProps)

Source

fn read_a11y(&self, _h: &Self::Handle) -> A11ySnapshot

Read a widget’s ACTUAL native accessibility properties for a11y_audit (§14.2) to diff against Day’s expectation. Default: unsupported (found = false) — the audit skips the node.

Source

fn replay(&mut self, _h: &Self::Handle, _ops: &[DrawOp], _size: Size)

Source

fn snapshot_window(&mut self) -> Result<Vec<u8>, String>

Source

fn ui_idle(&mut self) -> bool

Whether the UI has settled — no native transition (modal present/dismiss, nav push) still animating. The dayscript screenshot step polls this before capturing so shots never catch a half-faded dialog or half-pushed page. Backends without async transitions (or without a way to know) report true.

Source

fn present(&mut self, _req: u64, _spec: &PresentSpec)

Source

fn dismiss(&mut self, _req: u64)

Source

fn open_url(&mut self, _url: &str)

Open url in the platform’s default handler — the system browser for http(s), the mail client for mailto:, etc. Backs the link piece. Fire and forget: there is no result, and an unopenable URL is ignored. The default no-ops so a backend that hasn’t wired it up still compiles.

Source

fn defer_system_gestures(&mut self, _edges: Edges)

Ask the OS to require a second swipe for its edge gestures on edges (docs/cover.md) — the union requested by every mounted defers_system_gestures modifier, re-sent whenever that set changes (Edges::NONE when the last one unmounts). iOS defers the home indicator / notification edges; Android enters swipe-to-reveal immersive mode while non-empty. The default no-ops (desktop has no system edge gestures).

Source

fn dark_mode(&mut self) -> bool

Whether the platform is rendering in DARK appearance right now. Apps painting custom surfaces (opaque overlay panels, scrims) branch on this so their fills track the theme the DEFAULT text colors already follow — hardcoding either theme’s surface produces dark-on-dark or light-on-light text on the other. Queried at build time (a piece rebuilt after a theme change re-queries). The default honors a DAY_THEME launch override and otherwise answers light.

Source

fn set_appearance(&mut self, _dark: Option<bool>)

App-level appearance override: Some(true) forces dark, Some(false) forces light, None returns to following the system. Backends restyle their native widgets in place and answer the override from dark_mode; app-painted surfaces pick it up on their next rebuild. Cap::Appearance reports whether the backend honors this; the default ignores the call.

Source

fn on_suspend(&mut self)

Source

fn on_resume(&mut self)

Source

fn on_memory_warning(&mut self)

Source

fn adopt(&mut self, _raw: RawHandle) -> Self::Handle

Source

fn open_window( &mut self, _id: NodeId, _options: &WindowOptions, _kind: WindowKind, ) -> WindowOpenReply<Self::Handle>

Open a native OS window per options + kind: create and show the window, wire ITS events to idWindowResized (content size, points), WindowClosed (after the native close), WindowFocused (key/active changes) — and answer with its CONTENT container handle, the same contract as the ready root container. Backends whose window creation is asynchronous (a scene, an activity, an ability) answer WindowOpenReply::Pending and complete later through day_core::finish_window_open(id, raw, size) (the Toolkit::adopt seam). The default answers Unsupported — day-core then presents the content as a fullscreen cover in the primary window instead.

Source

fn close_window(&mut self, _host: &Self::Handle)

Close the native window whose CONTENT container is host (a handle open_window produced). Asynchronous: the platform confirms with Event::WindowClosed on the window’s root node, and day-core tears the subtree down THEN. Idempotent; unknown hosts are ignored. Never called with the primary window’s container.

Source

fn focus_window(&mut self, _host: &Self::Handle)

Bring the window whose CONTENT container is host to front and make it key/active — the focus half of open-or-focus singleton windows. Default no-op.

Source

fn set_window_title(&mut self, _host: &Self::Handle, _title: &str)

Retitle the window whose CONTENT container is host. Default no-op.

Source

fn snapshot_window_of( &mut self, _host: &Self::Handle, ) -> Result<Vec<u8>, String>

Snapshot the window whose CONTENT container is host (the dayscript screenshot step’s window: target). The default answers the primary snapshot, so backends that never open windows stay correct without changes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Day API ↩ Guides· daybrite.dev