Skip to main content

VeloxEngine

Struct VeloxEngine 

Source
pub struct VeloxEngine { /* private fields */ }
Expand description

Velox 核心渲染与事件调度引擎。

Implementations§

Source§

impl VeloxEngine

Source

pub fn step_frame(&mut self) -> &[Region]

推进一帧动画时钟(默认 16ms),执行布局求解、过渡插值与前后帧对比,返回本帧脏矩形切片。

Source

pub fn step_frame_dt(&mut self, dt_ms: u16) -> &[Region]

按给定帧间隔 dt_ms(毫秒)执行一帧更新并返回合并后的脏矩形列表。

Source

pub fn hit_regions<'a>(&'a self) -> &'a [HitRegion<'a>]

获取当前帧已求解并缓存在 ScratchArena 中的交互命中区域切片(生命周期绑定 &self)。

Source

pub fn build_a11y_tree<'a, const CAP: usize>( &'a mut self, ) -> SmallVec<A11yNode<'a>, CAP>

构建当前帧的无障碍语义树(Accessibility Semantic Tree,兼容 AccessKit / AT-SPI 角色模型)。

Source

pub fn cached_draw_ops<'a>(&'a self) -> &'a [DrawOp<'a>]

获取当前帧已求解并缓存在 ScratchArena 中的扁平化 DrawOp 切片(供各类 Renderer 后端读取)。

Source

pub fn render_with_renderer<R: Renderer + ?Sized>( &mut self, renderer: &mut R, dt_ms: u16, ) -> (usize, usize)

推进一帧动画与布局求解(dt_ms),并将生成的 DrawOp 流与脏矩形列表提交给任意 Renderer 后端执行绘制。

Source

pub fn rasterize_region<P: PixelFormat>( &mut self, reg: Region, pixels: &mut [P], )

将指定区域 reg 内的绘制指令光栅化到全屏像素缓冲区 pixels 中。

Source

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

Source

pub fn dispatch_event(&mut self, event: InputEvent) -> bool

统一派发输入事件(支持 PointerDown / PointerMove / PointerUp / Scroll / KeyDown / KeyUp / ModifiersChanged)。

Source

pub fn ime_preedit(&self) -> &str

返回当前正在进行的 IME 预编辑(组合输入)字符串;未组合时返回空串 ""。

Source

pub const fn ime_preedit_state(&self) -> ImePreedit

返回当前完整的 IME 预编辑状态(含字节级光标选区区间)。

Source

pub const fn ime_enabled(&self) -> bool

返回系统 IME 会话当前是否处于激活态。

Source

pub fn dispatch_ime_preedit( &mut self, text: &str, cursor: Option<(usize, usize)>, ) -> bool

派发系统 IME 组合输入预编辑更新(如拼音 "zhongwen" 与候选光标区间)。

Source

pub fn dispatch_ime_commit(&mut self, text: &str) -> bool

派发系统 IME 最终提交的 UTF-8 文本(如 "中文"):自动清空预编辑状态并逐字符送入当前聚焦输入控件。

Source

pub fn focused_bounds(&self) -> Option<Region>

返回当前拥有焦点的可交互/文本输入区域(逻辑像素坐标),供桌面端 winit::Window::set_ime_cursor_area 将系统输入法候选框精确对齐至输入框位置。

Source

pub fn has_focused_text_input(&self) -> bool

判断当前焦点节点(或活跃热区)是否接受键盘文本输入。

Source

pub fn dispatch_navigate_back(&mut self) -> bool

派发系统级返回事件(Android 返回键 / iOS 左边缘右滑返回 / 浏览器后退): 优先调用当前活动树中注册了 .on_navigate_back(...) 的处理器;若无,则回退到屏幕中心右滑返回手势(SwipeDir::Right)。

Source

pub fn dispatch_key(&mut self, key: KeyCode) -> bool

派发物理按键、字符输入或旋转编码器按键事件(支持无触摸屏 MCU 的焦点切换、Enter 触发与聚焦输入框文本编辑)。

Source

pub fn dispatch_key_up(&mut self, _key: KeyCode) -> bool

派发键盘按键抬起事件。

Source§

impl VeloxEngine

Source

pub fn cursor_shape(&self) -> CursorShape

根据当前指针位置、按下/拖拽态与最顶层命中热区解析实时鼠标光标形状(严格遵守 occlude 遮罩阻断)。

Source

pub fn dispatch_pointer_down_with_kind( &mut self, px: i16, py: i16, kind: PointerKind, ) -> bool

以显式指针设备来源(PointerKind::Mouse / PointerKind::Touch / PointerKind::Pen)派发指针按下事件。

Source

pub fn dispatch_mouse_down(&mut self, px: i16, py: i16) -> bool

派发桌面鼠标左键按下事件(标记为 PointerKind::Mouse,禁用空白区域按住拖动画布滚动与边缘右滑返回)。

Source

pub fn dispatch_touch_down(&mut self, px: i16, py: i16) -> bool

派发触控屏手指按下事件(标记为 PointerKind::Touch,启用跟手拖拽滚动、惯性滚动与边缘右滑返回)。

Source

pub fn dispatch_pointer_down(&mut self, px: i16, py: i16) -> bool

派发指针/手指按下事件(激活 active_bg、捕获焦点与拖拽起点,直接复用缓存 HitRegion 切片避免重复整树排版)。

Source

pub fn dispatch_pointer_secondary_down(&mut self, px: i16, py: i16) -> bool

派发鼠标右键(次键)按下事件(命中注册了 .on_secondary_click(...) 的节点并触发回调)。

Source

pub fn dispatch_pointer_move(&mut self, px: i16, py: i16) -> bool

派发指针移动/拖拽事件(更新 hover_bg、触发 on_drag 滑块连续拖动或滚动容器跟手滑动,复用帧缓存热区)。

Source

pub fn dispatch_pointer_leave(&mut self) -> bool

派发指针离开表面事件(清除悬停坐标,并在离开 hover_bg 热区时标记局部重绘)。

Source

pub fn dispatch_pointer_up(&mut self, px: i16, py: i16) -> bool

派发指针/手指抬起事件(释放 active_bg、触发点击或启动惯性滑动衰减)。

Source

pub fn dispatch_swipe(&mut self, x: i16, y: i16, dir: SwipeDir) -> bool

派发指定坐标 (x, y) 处的 4 向滑动手势 SwipeDir。

Source

pub fn dispatch_click(&mut self, px: i16, py: i16) -> bool

派发屏幕坐标 (px, py) 的点击事件。若命中某个可点击元素则执行其回调并返回 true。

Source

pub fn scroll(&mut self, list_id: u32, delta_y: i16)

更新指定列表容器 ID 的垂直滚动偏移量并标记下一帧执行 Pass-4 快径重拍平。

Source§

impl VeloxEngine

Source

pub fn new(width: i16, height: i16) -> Self

创建指定屏幕宽高 (width, height) 的 Velox 核心引擎实例。

Source

pub fn init_at( slot: &mut MaybeUninit<Self>, width: i16, height: i16, ) -> &mut Self

在未初始化静态槽位中原地构造 VeloxEngine,彻底消除 MCU 上先在栈上构造再拷贝的峰值栈开销。

Source

pub fn try_insert_view<V: View>(&mut self, view: V) -> Option<Handle<V>>

尝试注册一个独立的子视图(不触发 panic);若 #![no_std] PodPool Slab 或槽位耗尽返回 None。

Source

pub const fn modifiers(&self) -> KeyModifiers

获取当前键盘修饰键状态。

Source

pub fn set_modifiers(&mut self, modifiers: KeyModifiers)

更新当前键盘修饰键状态。

Source

pub const fn gesture_config(&self) -> GestureConfig

获取或修改手势判定参数配置。

Source

pub fn set_gesture_config(&mut self, config: GestureConfig)

设置自定义手势判定参数配置。

Source

pub const fn pointer_kind(&self) -> PointerKind

获取当前活跃指针输入设备来源类型(PointerKind::Touch / PointerKind::Mouse / PointerKind::Pen)。

Source

pub fn set_pointer_kind(&mut self, kind: PointerKind)

设置当前指针输入设备来源类型(桌面平台应设为 PointerKind::Mouse,触屏设为 PointerKind::Touch)。

Source

pub const fn dropped_draw_ops_count(&self) -> u32

获取累计因超出 MAX_DRAW_OPS(no_std 下)而被截断的绘制指令数量(用于可观测容量监控)。

Source

pub const fn layout_solve_count(&self) -> u32

获取累计执行的完整布局求解次数(Pass 1~4,用于性能剖析与单帧条带缓存验证)。

Source

pub const fn partial_relayout_count(&self) -> u32

获取累计通过子视图布局隔离边界(Relayout Boundary)执行 $O(\text{dirty_pod})$ 原地局部重排(跳过全局 build_layout_tree 与全局 Pass 1~3)完成的帧计数。

Source

pub fn relayout_boundary_hits(&self) -> u32

获取累计命中子视图布局隔离边界(包含原地局部重排与跳过未脏 SubView 子树 Pass 1~3)的次数。

Source

pub const fn fast_paint_pass_count(&self) -> u32

获取累计通过 Pass-4-Only 快径(跳过 View::render() 与 Pass 1~3 水平/折行测量)完成的帧计数。

Source

pub fn subview_cache_hits(&self) -> u32

获取累计因 SubView 未脏而直接复用缓存 Element 跳过 View::render() 的命中次数。

Source

pub fn pod_render_count<V: View>(&self, handle: Handle<V>) -> u32

获取指定视图句柄自创建以来实际执行 View::render() 的次数。

Source

pub fn set_dpi_scale(&mut self, scale: i16)

设置物理像素 HiDPI 缩放倍率(默认 1,桌面端可设为 2 实现 2x Retina 矢量光栅化)。 设置 HiDPI 整数缩放倍率(如 1 / 2 / 3,同步更新精确浮点 scale_factor)。

Source

pub fn set_scale_factor(&mut self, scale_factor: f32)

设置精确分数 DPI 缩放因子(如 1.25 / 1.5 / 1.75 / 2.0,支持 Pixel Snapping)。

Source

pub const fn dpi_scale(&self) -> i16

获取当前整数 HiDPI 缩放倍率(兼容旧接口)。

Source

pub const fn scale_factor(&self) -> f32

获取当前精确分数 DPI 缩放因子(如 1.5)。

Source

pub const fn viewport_region(&self) -> Region

获取视口矩形区域。

Source

pub fn resize(&mut self, width: i16, height: i16)

调整视口尺寸(触发全屏重绘)。

Source

pub fn theme(&self) -> CoreTheme

返回当前引擎生效的全局主题配色(CoreTheme)。

Source

pub fn set_theme(&mut self, theme: CoreTheme)

设置全局主题配色。

Source

pub fn locale(&self) -> Locale

返回当前引擎生效的国际化语言区域(crate::i18n::Locale)。

Source

pub fn set_locale(&mut self, locale: Locale)

运行时热切换全局语言区域:同步刷新 FrameScope、失效布局缓存并标脏整棵视图树(零重启切换语言)。

Source

pub fn set_i18n_catalog(&mut self, catalog: &'static StaticCatalog)

注册静态零堆多语言词典集合并标记整棵视图树重绘。

Source

pub fn set_dynamic_catalog(&mut self, catalog: Arc<DynamicCatalog>)

注册运行时动态翻译目录(支持 JSON / key=value 语言包热加载)并标记整棵视图树重绘。

Source

pub const fn safe_area(&self) -> SafeAreaInsets

获取当前屏幕安全区域内边距。

Source

pub fn set_safe_area(&mut self, insets: SafeAreaInsets)

设置移动端/异形屏安全区域内边距并标记根视图重绘。

Source

pub const fn keyboard_inset(&self) -> i16

获取当前屏幕软键盘占用的底部像素高度。

Source

pub fn set_keyboard_inset(&mut self, height: i16)

设置屏幕软键盘占用的底部像素高度并标记根视图重绘。

Source

pub fn mount_root<V: View>(&mut self, view: V) -> Handle<V>

挂载根视图组件,返回其强类型句柄 Handle<V>。

Source

pub fn insert_view<V: View>(&mut self, view: V) -> Handle<V>

在 PodPool 中注册一个独立子视图,返回其句柄。

Source

pub fn remove_view<V: View>(&mut self, handle: Handle<V>) -> bool

销毁并移除一个子视图(调用其 Drop 并回收 PodPool 槽位与内存)。

Source

pub fn view_mut<V: View>(&mut self, handle: Handle<V>) -> Option<&mut V>

获取视图可变引用并自动标记该视图为脏。

Source

pub fn update_view<V: View, R>( &mut self, handle: Handle<V>, f: impl FnOnce(&mut V) -> R, ) -> Option<R>

通过闭包修改视图状态,仅在视图字段实际发生变更时自动标记该视图为脏。

Source

pub fn view<V: View>(&self, handle: Handle<V>) -> Option<&V>

获取视图只读引用。

Source

pub fn motion_mut(&mut self) -> &mut MotionCache

获取跨帧动画与滚动缓存池。

Source

pub const fn last_arena_used_bytes(&self) -> usize

获取最近一帧 ScratchArena 的峰值使用字节数。

Source

pub fn last_damage(&self) -> &[Region]

获取最近一次 step_frame_dt 合并生成的 8 槽位脏矩形列表(供模拟器脏矩形红框透视使用)。

Source

pub const fn focused_index(&self) -> Option<u16>

获取当前物理按键/旋钮聚焦的元素序号。

Source

pub const fn is_focus_visible(&self) -> bool

返回当前焦点是否处于键盘导航激活的可见焦点态(:focus-visible)。

Source

pub fn set_focused_index(&mut self, idx: Option<u16>)

设置当前物理按键/旋钮聚焦的元素序号。

Source

pub fn needs_redraw(&self) -> bool

是否存在待处理的脏视图、响应式信号更新、交互状态变更、就绪异步任务或正在进行中的过渡动画。

Source

pub const fn clock_ms(&self) -> u32

获取引擎单调动画时钟(毫秒)。

Source

pub fn with_scheduler(self, backend: Arc<dyn SchedulerBackend>) -> Self

注入自定义可插拔异步调度器后端(链式构建器),如 crate::async_rt::ManualScheduler 或第三方运行时适配器。

Source

pub fn set_scheduler(&mut self, backend: Arc<dyn SchedulerBackend>)

在运行时切换当前引擎所使用的底层可插拔异步调度器后端。

Source

pub fn scheduler_name(&self) -> &'static str

返回当前引擎所绑定异步调度器的名称(如 "velox-native-std" / "velox-manual")。

Source

pub fn scheduler_capabilities(&self) -> SchedulerCapabilities

返回当前引擎所绑定异步调度器的能力描述符。

Source

pub fn set_async_waker(&mut self, waker: impl Fn() + Send + Sync + 'static)

注入平台级异步唤醒回调(当后台线程池任务完成或定时器到期时触发事件循环零轮询唤醒)。

Source

pub fn poll_async_tasks(&mut self) -> bool

在 UI 主线程排空所有已就绪的前景异步协程与 defer 回调;返回是否至少推进了 1 项任务或回调。

Source

pub fn has_pending_async_tasks(&self) -> bool

是否存在立即待执行的前景就绪异步任务或 defer 回调。

Source

pub fn active_async_task_count(&self) -> usize

返回当前仍活跃挂载在前景执行器中的协程数量(用于监控与测试验证取消回收无泄漏)。

Source

pub fn spawn<T, F, Fut>(&mut self, f: F) -> Task<T> ⓘ
where T: 'static, F: FnOnce(AsyncApp) -> Fut, Fut: Future<Output = T> + 'static,

在 UI 主线程前景执行器上派生异步任务(闭包接收 crate::async_rt::AsyncApp)。

Source

pub fn spawn_for<V, T, F, Fut>(&mut self, handle: Handle<V>, f: F) -> Task<T> ⓘ
where V: View, T: 'static, F: FnOnce(Handle<V>, AsyncApp) -> Fut, Fut: Future<Output = T> + 'static,

在 UI 主线程前景执行器上为指定视图句柄派生绑定异步任务(闭包接收 (Handle<V>, AsyncApp))。

Source

pub fn background_spawn<T, Fut>(&self, fut: Fut) -> Task<T> ⓘ
where T: Send + 'static, Fut: Future<Output = T> + Send + 'static,

在后台常驻线程池中执行 CPU 密集型计算或阻塞 I/O,返回可 .await 的 crate::async_rt::Task<T>。

Source

pub fn background_executor(&self) -> BackgroundExecutor

获取绑定到当前引擎调度器后端的后台执行器句柄(用于 .spawn(...) / .timer(Duration))。

Source

pub fn timer(&self, duration: Duration) -> Timer ⓘ

创建由当前引擎调度器时钟驱动的非阻塞异步定时器。

Source

pub fn defer<F>(&mut self, f: F)
where F: FnOnce(&mut ActionScope<'_>) + 'static,

排入一个延迟到下次前景异步轮询执行的 UI 主线程回调。

Source

pub fn finish_animations(&mut self)

立即结束所有单次过渡动画并停留在目标状态(用于“减少动态效果”无障碍设置或测试快进)。

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> FluentBuilder for T

Source§

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

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.