pub struct HeadlessShell { /* private fields */ }Expand description
无窗口应用宿主。
Implementations§
Source§impl HeadlessShell
impl HeadlessShell
pub fn new(width: f32, height: f32) -> Self
pub fn with_metrics(metrics: ShellMetrics) -> Self
pub fn metrics(&self) -> ShellMetrics
pub fn now_ms(&self) -> u64
pub fn set_time(&self, now_ms: u64)
pub fn resize(&mut self, logical_size: Size, scale_factor: f32)
pub fn mount(&mut self, root: WidgetNode)
pub fn update(&mut self, root: WidgetNode)
Sourcepub fn dispatch_event(&mut self, event: &WidgetEvent)
pub fn dispatch_event(&mut self, event: &WidgetEvent)
注入指针/键盘/IME 事件;坐标取事件自带 position。
Sourcepub fn dispatch_event_at(&mut self, event: &WidgetEvent, position: Point)
pub fn dispatch_event_at(&mut self, event: &WidgetEvent, position: Point)
显式指定命中坐标(Scroll / 无坐标事件等)。
pub fn click(&mut self, position: Point)
pub fn key_down(&mut self, key: KeyCode)
pub fn key_down_with(&mut self, key: KeyCode, mods: KeyModifiers)
pub fn key_up(&mut self, key: KeyCode)
pub fn type_text(&mut self, text: &str)
pub fn ime_commit(&mut self, text: impl Into<String>)
Sourcepub fn dispatch_shell_event(&mut self, event: &ShellEvent)
pub fn dispatch_shell_event(&mut self, event: &ShellEvent)
注入平台无关事件——与桌面 Runner 走同一条 ShellEvent 管线。
Sourcepub fn frame(&mut self) -> &RgbaImage
pub fn frame(&mut self) -> &RgbaImage
执行一帧:统一帧管线(tick → build requests → overlay intent)→ paint → 软件光栅化。
Sourcepub fn frame_paint(&self) -> Option<&FramePaint>
pub fn frame_paint(&self) -> Option<&FramePaint>
最近一帧的 PaintList(需要检查绘制命令时使用)。
pub fn image(&self) -> Option<&RgbaImage>
pub fn pixel(&self, x: u32, y: u32) -> Option<[u8; 4]>
pub fn tree(&self) -> &ElementTree
pub fn tree_mut(&mut self) -> &mut ElementTree
pub fn overlay_count(&self) -> usize
pub fn element_bounds(&self, id: ElementId) -> Option<Rect>
Sourcepub fn a11y_snapshot(&self) -> Vec<(ElementId, SemanticsData)>
pub fn a11y_snapshot(&self) -> Vec<(ElementId, SemanticsData)>
无障碍语义快照(与 Runner 推送给 AccessKit 的数据同源)。
pub fn title(&self) -> String
pub fn ime_allowed(&self) -> bool
pub fn ime_cursor_area(&self) -> Option<Rect>
Trait Implementations§
Source§impl FrameHost for HeadlessShell
impl FrameHost for HeadlessShell
fn tree_mut(&mut self) -> &mut ElementTree
Source§fn wants_full_rebuild(&mut self, _viewport: Size) -> bool
fn wants_full_rebuild(&mut self, _viewport: Size) -> bool
本帧是否需要全树重建(宿主 peek 了全局信号等)。
Source§fn build_root(&mut self, _viewport: Size) -> Option<WidgetNode>
fn build_root(&mut self, _viewport: Size) -> Option<WidgetNode>
构建新的 widget 树。仅在需要 mount/update 时调用。
返回 None = 本帧不做全树重建(例如 headless 由调用方手动 mount)。
Source§fn take_pending_pointer(&mut self) -> Option<Point>
fn take_pending_pointer(&mut self) -> Option<Point>
取出合并到本帧派发的指针位置(如 CursorMoved 合并)。
Source§fn after_tick(&mut self, _now_ms: u64)
fn after_tick(&mut self, _now_ms: u64)
tick + build requests 之后、overlay/paint 之前的宿主钩子
(编辑器焦点移交、查找条同步等)。
Source§impl WindowShell for HeadlessShell
impl WindowShell for HeadlessShell
fn metrics(&self) -> ShellMetrics
fn request_redraw(&self)
fn set_title(&self, title: &str)
fn set_visible(&self, _visible: bool)
fn set_ime_allowed(&self, allowed: bool)
fn set_ime_cursor_area(&self, rect: Rect)
Auto Trait Implementations§
impl !Freeze for HeadlessShell
impl !RefUnwindSafe for HeadlessShell
impl !Send for HeadlessShell
impl !Sync for HeadlessShell
impl !UnwindSafe for HeadlessShell
impl Unpin for HeadlessShell
impl UnsafeUnpin for HeadlessShell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more