pub struct VeloxEngine { /* private fields */ }Expand description
Velox 核心渲染与事件调度引擎。
Implementations§
Source§impl VeloxEngine
impl VeloxEngine
Sourcepub fn step_frame(&mut self) -> &[Region]
pub fn step_frame(&mut self) -> &[Region]
推进一帧动画时钟(默认 16ms),执行布局求解、过渡插值与前后帧对比,返回本帧脏矩形切片。
Sourcepub fn step_frame_dt(&mut self, dt_ms: u16) -> &[Region]
pub fn step_frame_dt(&mut self, dt_ms: u16) -> &[Region]
按给定帧间隔 dt_ms(毫秒)执行一帧更新并返回合并后的脏矩形列表。
Sourcepub fn hit_regions<'a>(&'a self) -> &'a [HitRegion<'a>]
pub fn hit_regions<'a>(&'a self) -> &'a [HitRegion<'a>]
获取当前帧已求解并缓存在 ScratchArena 中的交互命中区域切片(生命周期绑定 &self)。
Sourcepub fn build_a11y_tree<'a, const CAP: usize>(
&'a mut self,
) -> SmallVec<A11yNode<'a>, CAP>
pub fn build_a11y_tree<'a, const CAP: usize>( &'a mut self, ) -> SmallVec<A11yNode<'a>, CAP>
构建当前帧的无障碍语义树(Accessibility Semantic Tree,兼容 AccessKit / AT-SPI 角色模型)。
Sourcepub fn cached_draw_ops<'a>(&'a self) -> &'a [DrawOp<'a>]
pub fn cached_draw_ops<'a>(&'a self) -> &'a [DrawOp<'a>]
Sourcepub fn render_with_renderer<R: Renderer + ?Sized>(
&mut self,
renderer: &mut R,
dt_ms: u16,
) -> (usize, usize)
pub fn render_with_renderer<R: Renderer + ?Sized>( &mut self, renderer: &mut R, dt_ms: u16, ) -> (usize, usize)
推进一帧动画与布局求解(dt_ms),并将生成的 DrawOp 流与脏矩形列表提交给任意 Renderer 后端执行绘制。
Sourcepub fn rasterize_region<P: PixelFormat>(
&mut self,
reg: Region,
pixels: &mut [P],
)
pub fn rasterize_region<P: PixelFormat>( &mut self, reg: Region, pixels: &mut [P], )
将指定区域 reg 内的绘制指令光栅化到全屏像素缓冲区 pixels 中。
Sourcepub fn rasterize_strip<P: PixelFormat>(
&mut self,
reg: Region,
origin_x: i16,
origin_y: i16,
stride: usize,
target: &mut [P],
)
pub fn rasterize_strip<P: PixelFormat>( &mut self, reg: Region, origin_x: i16, origin_y: i16, stride: usize, target: &mut [P], )
将指定区域 reg 光栅化到具有自定义起点 (origin_x, origin_y) 和行跨度 stride 的局部/条带缓冲区中。
若当前帧已通过 step_frame_dt 求解缓存,则直接零拷贝复用 ScratchArena 中的 DrawOp 切片,避免重复执行 View::render() 与布局求解。
Source§impl VeloxEngine
impl VeloxEngine
Sourcepub fn dispatch_event(&mut self, event: InputEvent) -> bool
pub fn dispatch_event(&mut self, event: InputEvent) -> bool
统一派发输入事件(支持 PointerDown / PointerMove / PointerUp / Scroll / KeyDown / KeyUp / ModifiersChanged)。
Sourcepub fn ime_preedit(&self) -> &str
pub fn ime_preedit(&self) -> &str
返回当前正在进行的 IME 预编辑(组合输入)字符串;未组合时返回空串 ""。
Sourcepub const fn ime_preedit_state(&self) -> ImePreedit
pub const fn ime_preedit_state(&self) -> ImePreedit
返回当前完整的 IME 预编辑状态(含字节级光标选区区间)。
Sourcepub const fn ime_enabled(&self) -> bool
pub const fn ime_enabled(&self) -> bool
返回系统 IME 会话当前是否处于激活态。
Sourcepub fn dispatch_ime_preedit(
&mut self,
text: &str,
cursor: Option<(usize, usize)>,
) -> bool
pub fn dispatch_ime_preedit( &mut self, text: &str, cursor: Option<(usize, usize)>, ) -> bool
派发系统 IME 组合输入预编辑更新(如拼音 "zhongwen" 与候选光标区间)。
Sourcepub fn dispatch_ime_commit(&mut self, text: &str) -> bool
pub fn dispatch_ime_commit(&mut self, text: &str) -> bool
派发系统 IME 最终提交的 UTF-8 文本(如 "中文"):自动清空预编辑状态并逐字符送入当前聚焦输入控件。
Sourcepub fn focused_bounds(&self) -> Option<Region>
pub fn focused_bounds(&self) -> Option<Region>
返回当前拥有焦点的可交互/文本输入区域(逻辑像素坐标),供桌面端 winit::Window::set_ime_cursor_area
将系统输入法候选框精确对齐至输入框位置。
Sourcepub fn has_focused_text_input(&self) -> bool
pub fn has_focused_text_input(&self) -> bool
判断当前焦点节点(或活跃热区)是否接受键盘文本输入。
派发系统级返回事件(Android 返回键 / iOS 左边缘右滑返回 / 浏览器后退):
优先调用当前活动树中注册了 .on_navigate_back(...) 的处理器;若无,则回退到屏幕中心右滑返回手势(SwipeDir::Right)。
Sourcepub fn dispatch_key(&mut self, key: KeyCode) -> bool
pub fn dispatch_key(&mut self, key: KeyCode) -> bool
派发物理按键、字符输入或旋转编码器按键事件(支持无触摸屏 MCU 的焦点切换、Enter 触发与聚焦输入框文本编辑)。
Sourcepub fn dispatch_key_up(&mut self, _key: KeyCode) -> bool
pub fn dispatch_key_up(&mut self, _key: KeyCode) -> bool
派发键盘按键抬起事件。
Source§impl VeloxEngine
impl VeloxEngine
Sourcepub fn cursor_shape(&self) -> CursorShape
pub fn cursor_shape(&self) -> CursorShape
根据当前指针位置、按下/拖拽态与最顶层命中热区解析实时鼠标光标形状(严格遵守 occlude 遮罩阻断)。
Sourcepub fn dispatch_pointer_down_with_kind(
&mut self,
px: i16,
py: i16,
kind: PointerKind,
) -> bool
pub fn dispatch_pointer_down_with_kind( &mut self, px: i16, py: i16, kind: PointerKind, ) -> bool
以显式指针设备来源(PointerKind::Mouse / PointerKind::Touch / PointerKind::Pen)派发指针按下事件。
Sourcepub fn dispatch_mouse_down(&mut self, px: i16, py: i16) -> bool
pub fn dispatch_mouse_down(&mut self, px: i16, py: i16) -> bool
派发桌面鼠标左键按下事件(标记为 PointerKind::Mouse,禁用空白区域按住拖动画布滚动与边缘右滑返回)。
Sourcepub fn dispatch_touch_down(&mut self, px: i16, py: i16) -> bool
pub fn dispatch_touch_down(&mut self, px: i16, py: i16) -> bool
派发触控屏手指按下事件(标记为 PointerKind::Touch,启用跟手拖拽滚动、惯性滚动与边缘右滑返回)。
Sourcepub fn dispatch_pointer_down(&mut self, px: i16, py: i16) -> bool
pub fn dispatch_pointer_down(&mut self, px: i16, py: i16) -> bool
派发指针/手指按下事件(激活 active_bg、捕获焦点与拖拽起点,直接复用缓存 HitRegion 切片避免重复整树排版)。
Sourcepub fn dispatch_pointer_secondary_down(&mut self, px: i16, py: i16) -> bool
pub fn dispatch_pointer_secondary_down(&mut self, px: i16, py: i16) -> bool
派发鼠标右键(次键)按下事件(命中注册了 .on_secondary_click(...) 的节点并触发回调)。
Sourcepub fn dispatch_pointer_move(&mut self, px: i16, py: i16) -> bool
pub fn dispatch_pointer_move(&mut self, px: i16, py: i16) -> bool
派发指针移动/拖拽事件(更新 hover_bg、触发 on_drag 滑块连续拖动或滚动容器跟手滑动,复用帧缓存热区)。
Sourcepub fn dispatch_pointer_leave(&mut self) -> bool
pub fn dispatch_pointer_leave(&mut self) -> bool
派发指针离开表面事件(清除悬停坐标,并在离开 hover_bg 热区时标记局部重绘)。
Sourcepub fn dispatch_pointer_up(&mut self, px: i16, py: i16) -> bool
pub fn dispatch_pointer_up(&mut self, px: i16, py: i16) -> bool
派发指针/手指抬起事件(释放 active_bg、触发点击或启动惯性滑动衰减)。
Sourcepub fn dispatch_swipe(&mut self, x: i16, y: i16, dir: SwipeDir) -> bool
pub fn dispatch_swipe(&mut self, x: i16, y: i16, dir: SwipeDir) -> bool
派发指定坐标 (x, y) 处的 4 向滑动手势 SwipeDir。
Sourcepub fn dispatch_click(&mut self, px: i16, py: i16) -> bool
pub fn dispatch_click(&mut self, px: i16, py: i16) -> bool
派发屏幕坐标 (px, py) 的点击事件。若命中某个可点击元素则执行其回调并返回 true。
Source§impl VeloxEngine
impl VeloxEngine
Sourcepub fn init_at(
slot: &mut MaybeUninit<Self>,
width: i16,
height: i16,
) -> &mut Self
pub fn init_at( slot: &mut MaybeUninit<Self>, width: i16, height: i16, ) -> &mut Self
在未初始化静态槽位中原地构造 VeloxEngine,彻底消除 MCU 上先在栈上构造再拷贝的峰值栈开销。
Sourcepub fn try_insert_view<V: View>(&mut self, view: V) -> Option<Handle<V>>
pub fn try_insert_view<V: View>(&mut self, view: V) -> Option<Handle<V>>
尝试注册一个独立的子视图(不触发 panic);若 #![no_std] PodPool Slab 或槽位耗尽返回 None。
Sourcepub const fn modifiers(&self) -> KeyModifiers
pub const fn modifiers(&self) -> KeyModifiers
获取当前键盘修饰键状态。
Sourcepub fn set_modifiers(&mut self, modifiers: KeyModifiers)
pub fn set_modifiers(&mut self, modifiers: KeyModifiers)
更新当前键盘修饰键状态。
Sourcepub const fn gesture_config(&self) -> GestureConfig
pub const fn gesture_config(&self) -> GestureConfig
获取或修改手势判定参数配置。
Sourcepub fn set_gesture_config(&mut self, config: GestureConfig)
pub fn set_gesture_config(&mut self, config: GestureConfig)
设置自定义手势判定参数配置。
Sourcepub const fn pointer_kind(&self) -> PointerKind
pub const fn pointer_kind(&self) -> PointerKind
获取当前活跃指针输入设备来源类型(PointerKind::Touch / PointerKind::Mouse / PointerKind::Pen)。
Sourcepub fn set_pointer_kind(&mut self, kind: PointerKind)
pub fn set_pointer_kind(&mut self, kind: PointerKind)
设置当前指针输入设备来源类型(桌面平台应设为 PointerKind::Mouse,触屏设为 PointerKind::Touch)。
Sourcepub const fn dropped_draw_ops_count(&self) -> u32
pub const fn dropped_draw_ops_count(&self) -> u32
获取累计因超出 MAX_DRAW_OPS(no_std 下)而被截断的绘制指令数量(用于可观测容量监控)。
Sourcepub const fn layout_solve_count(&self) -> u32
pub const fn layout_solve_count(&self) -> u32
获取累计执行的完整布局求解次数(Pass 1~4,用于性能剖析与单帧条带缓存验证)。
Sourcepub const fn partial_relayout_count(&self) -> u32
pub const fn partial_relayout_count(&self) -> u32
获取累计通过子视图布局隔离边界(Relayout Boundary)执行 $O(\text{dirty_pod})$ 原地局部重排(跳过全局 build_layout_tree 与全局 Pass 1~3)完成的帧计数。
Sourcepub fn relayout_boundary_hits(&self) -> u32
pub fn relayout_boundary_hits(&self) -> u32
获取累计命中子视图布局隔离边界(包含原地局部重排与跳过未脏 SubView 子树 Pass 1~3)的次数。
Sourcepub const fn fast_paint_pass_count(&self) -> u32
pub const fn fast_paint_pass_count(&self) -> u32
获取累计通过 Pass-4-Only 快径(跳过 View::render() 与 Pass 1~3 水平/折行测量)完成的帧计数。
Sourcepub fn subview_cache_hits(&self) -> u32
pub fn subview_cache_hits(&self) -> u32
获取累计因 SubView 未脏而直接复用缓存 Element 跳过 View::render() 的命中次数。
Sourcepub fn pod_render_count<V: View>(&self, handle: Handle<V>) -> u32
pub fn pod_render_count<V: View>(&self, handle: Handle<V>) -> u32
获取指定视图句柄自创建以来实际执行 View::render() 的次数。
Sourcepub fn set_dpi_scale(&mut self, scale: i16)
pub fn set_dpi_scale(&mut self, scale: i16)
设置物理像素 HiDPI 缩放倍率(默认 1,桌面端可设为 2 实现 2x Retina 矢量光栅化)。
设置 HiDPI 整数缩放倍率(如 1 / 2 / 3,同步更新精确浮点 scale_factor)。
Sourcepub fn set_scale_factor(&mut self, scale_factor: f32)
pub fn set_scale_factor(&mut self, scale_factor: f32)
设置精确分数 DPI 缩放因子(如 1.25 / 1.5 / 1.75 / 2.0,支持 Pixel Snapping)。
Sourcepub const fn scale_factor(&self) -> f32
pub const fn scale_factor(&self) -> f32
获取当前精确分数 DPI 缩放因子(如 1.5)。
Sourcepub const fn viewport_region(&self) -> Region
pub const fn viewport_region(&self) -> Region
获取视口矩形区域。
Sourcepub fn locale(&self) -> Locale
pub fn locale(&self) -> Locale
返回当前引擎生效的国际化语言区域(crate::i18n::Locale)。
Sourcepub fn set_locale(&mut self, locale: Locale)
pub fn set_locale(&mut self, locale: Locale)
运行时热切换全局语言区域:同步刷新 FrameScope、失效布局缓存并标脏整棵视图树(零重启切换语言)。
Sourcepub fn set_i18n_catalog(&mut self, catalog: &'static StaticCatalog)
pub fn set_i18n_catalog(&mut self, catalog: &'static StaticCatalog)
注册静态零堆多语言词典集合并标记整棵视图树重绘。
Sourcepub fn set_dynamic_catalog(&mut self, catalog: Arc<DynamicCatalog>)
pub fn set_dynamic_catalog(&mut self, catalog: Arc<DynamicCatalog>)
注册运行时动态翻译目录(支持 JSON / key=value 语言包热加载)并标记整棵视图树重绘。
Sourcepub const fn safe_area(&self) -> SafeAreaInsets
pub const fn safe_area(&self) -> SafeAreaInsets
获取当前屏幕安全区域内边距。
Sourcepub fn set_safe_area(&mut self, insets: SafeAreaInsets)
pub fn set_safe_area(&mut self, insets: SafeAreaInsets)
设置移动端/异形屏安全区域内边距并标记根视图重绘。
Sourcepub const fn keyboard_inset(&self) -> i16
pub const fn keyboard_inset(&self) -> i16
获取当前屏幕软键盘占用的底部像素高度。
Sourcepub fn set_keyboard_inset(&mut self, height: i16)
pub fn set_keyboard_inset(&mut self, height: i16)
设置屏幕软键盘占用的底部像素高度并标记根视图重绘。
Sourcepub fn mount_root<V: View>(&mut self, view: V) -> Handle<V>
pub fn mount_root<V: View>(&mut self, view: V) -> Handle<V>
挂载根视图组件,返回其强类型句柄 Handle<V>。
Sourcepub fn insert_view<V: View>(&mut self, view: V) -> Handle<V>
pub fn insert_view<V: View>(&mut self, view: V) -> Handle<V>
在 PodPool 中注册一个独立子视图,返回其句柄。
Sourcepub fn remove_view<V: View>(&mut self, handle: Handle<V>) -> bool
pub fn remove_view<V: View>(&mut self, handle: Handle<V>) -> bool
销毁并移除一个子视图(调用其 Drop 并回收 PodPool 槽位与内存)。
Sourcepub fn update_view<V: View, R>(
&mut self,
handle: Handle<V>,
f: impl FnOnce(&mut V) -> R,
) -> Option<R>
pub fn update_view<V: View, R>( &mut self, handle: Handle<V>, f: impl FnOnce(&mut V) -> R, ) -> Option<R>
通过闭包修改视图状态,仅在视图字段实际发生变更时自动标记该视图为脏。
Sourcepub fn motion_mut(&mut self) -> &mut MotionCache
pub fn motion_mut(&mut self) -> &mut MotionCache
获取跨帧动画与滚动缓存池。
Sourcepub const fn last_arena_used_bytes(&self) -> usize
pub const fn last_arena_used_bytes(&self) -> usize
获取最近一帧 ScratchArena 的峰值使用字节数。
Sourcepub fn last_damage(&self) -> &[Region]
pub fn last_damage(&self) -> &[Region]
获取最近一次 step_frame_dt 合并生成的 8 槽位脏矩形列表(供模拟器脏矩形红框透视使用)。
Sourcepub const fn focused_index(&self) -> Option<u16>
pub const fn focused_index(&self) -> Option<u16>
获取当前物理按键/旋钮聚焦的元素序号。
Sourcepub const fn is_focus_visible(&self) -> bool
pub const fn is_focus_visible(&self) -> bool
返回当前焦点是否处于键盘导航激活的可见焦点态(:focus-visible)。
Sourcepub fn set_focused_index(&mut self, idx: Option<u16>)
pub fn set_focused_index(&mut self, idx: Option<u16>)
设置当前物理按键/旋钮聚焦的元素序号。
Sourcepub fn needs_redraw(&self) -> bool
pub fn needs_redraw(&self) -> bool
是否存在待处理的脏视图、响应式信号更新、交互状态变更、就绪异步任务或正在进行中的过渡动画。
Sourcepub fn with_scheduler(self, backend: Arc<dyn SchedulerBackend>) -> Self
pub fn with_scheduler(self, backend: Arc<dyn SchedulerBackend>) -> Self
注入自定义可插拔异步调度器后端(链式构建器),如 crate::async_rt::ManualScheduler 或第三方运行时适配器。
Sourcepub fn set_scheduler(&mut self, backend: Arc<dyn SchedulerBackend>)
pub fn set_scheduler(&mut self, backend: Arc<dyn SchedulerBackend>)
在运行时切换当前引擎所使用的底层可插拔异步调度器后端。
Sourcepub fn scheduler_name(&self) -> &'static str
pub fn scheduler_name(&self) -> &'static str
返回当前引擎所绑定异步调度器的名称(如 "velox-native-std" / "velox-manual")。
Sourcepub fn scheduler_capabilities(&self) -> SchedulerCapabilities
pub fn scheduler_capabilities(&self) -> SchedulerCapabilities
返回当前引擎所绑定异步调度器的能力描述符。
Sourcepub fn set_async_waker(&mut self, waker: impl Fn() + Send + Sync + 'static)
pub fn set_async_waker(&mut self, waker: impl Fn() + Send + Sync + 'static)
注入平台级异步唤醒回调(当后台线程池任务完成或定时器到期时触发事件循环零轮询唤醒)。
Sourcepub fn poll_async_tasks(&mut self) -> bool
pub fn poll_async_tasks(&mut self) -> bool
在 UI 主线程排空所有已就绪的前景异步协程与 defer 回调;返回是否至少推进了 1 项任务或回调。
Sourcepub fn has_pending_async_tasks(&self) -> bool
pub fn has_pending_async_tasks(&self) -> bool
是否存在立即待执行的前景就绪异步任务或 defer 回调。
Sourcepub fn active_async_task_count(&self) -> usize
pub fn active_async_task_count(&self) -> usize
返回当前仍活跃挂载在前景执行器中的协程数量(用于监控与测试验证取消回收无泄漏)。
Sourcepub fn spawn<T, F, Fut>(&mut self, f: F) -> Task<T> ⓘ
pub fn spawn<T, F, Fut>(&mut self, f: F) -> Task<T> ⓘ
在 UI 主线程前景执行器上派生异步任务(闭包接收 crate::async_rt::AsyncApp)。
Sourcepub fn spawn_for<V, T, F, Fut>(&mut self, handle: Handle<V>, f: F) -> Task<T> ⓘ
pub fn spawn_for<V, T, F, Fut>(&mut self, handle: Handle<V>, f: F) -> Task<T> ⓘ
在 UI 主线程前景执行器上为指定视图句柄派生绑定异步任务(闭包接收 (Handle<V>, AsyncApp))。
Sourcepub fn background_spawn<T, Fut>(&self, fut: Fut) -> Task<T> ⓘ
pub fn background_spawn<T, Fut>(&self, fut: Fut) -> Task<T> ⓘ
在后台常驻线程池中执行 CPU 密集型计算或阻塞 I/O,返回可 .await 的 crate::async_rt::Task<T>。
Sourcepub fn background_executor(&self) -> BackgroundExecutor
pub fn background_executor(&self) -> BackgroundExecutor
获取绑定到当前引擎调度器后端的后台执行器句柄(用于 .spawn(...) / .timer(Duration))。
Sourcepub fn defer<F>(&mut self, f: F)where
F: FnOnce(&mut ActionScope<'_>) + 'static,
pub fn defer<F>(&mut self, f: F)where
F: FnOnce(&mut ActionScope<'_>) + 'static,
排入一个延迟到下次前景异步轮询执行的 UI 主线程回调。
Sourcepub fn finish_animations(&mut self)
pub fn finish_animations(&mut self)
立即结束所有单次过渡动画并停留在目标状态(用于“减少动态效果”无障碍设置或测试快进)。
Auto Trait Implementations§
impl !Freeze for VeloxEngine
impl !RefUnwindSafe for VeloxEngine
impl !Send for VeloxEngine
impl !Sync for VeloxEngine
impl !UnwindSafe for VeloxEngine
impl Forget for VeloxEngine
impl Move for VeloxEngine
impl Unpin for VeloxEngine
impl UnsafeUnpin for VeloxEngine
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FluentBuilder for T
impl<T> FluentBuilder for T
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
condition 为 true 时执行闭包修饰自身,否则原样返回。Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Self
fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
condition 在两个修饰分支之间二选一。Source§fn when_some<O>(
self,
option: Option<O>,
then: impl FnOnce(Self, O) -> Self,
) -> Self
fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self
option 为 Some(value) 时执行闭包修饰自身,否则原样返回。