Skip to main content

FrameScope

Struct FrameScope 

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

帧级无状态渲染上下文(供 Widget::render_once 与 div().child(cx, ...) 使用)。

Implementations§

Source§

impl FrameScope

Source

pub fn new() -> Self

创建默认帧级上下文。

Source

pub fn with_theme(theme: CoreTheme) -> Self

使用指定主题创建帧级上下文。

Source

pub fn ime_preedit(&self) -> Option<&str>

获取当前正在组合输入的 IME 预编辑字符串(无预编辑内容时返回 None)。

Source

pub const fn ime_preedit_state(&self) -> ImePreedit

获取当前帧上下文中的完整 IME 预编辑状态(含可选光标区间)。

Source

pub fn set_ime_preedit(&mut self, preedit: ImePreedit)

设置当前帧上下文中的 IME 预编辑状态(由引擎自动同步)。

Source

pub const fn safe_area(&self) -> SafeAreaInsets

获取当前屏幕安全区域内边距(状态栏、刘海屏、底部 Home Indicator)。

Source

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

设置当前屏幕安全区域内边距。

Source

pub const fn keyboard_inset(&self) -> i16

获取当前屏幕软键盘占用的底部像素高度(0 表示未弹出)。

Source

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

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

Source

pub fn read<'s, T: View>( &'s self, handle: Handle<T>, ) -> Option<PodReadGuard<'s, T>>

在渲染期安全读取另一个子视图/兄弟视图 Handle<T> 的只读状态,返回局部借用守卫 super::PodReadGuard。

守卫通过 Deref 将引用生命周期严格限制在守卫存活的局部作用域内(不可泄漏为 'a 存入 Element<'a>), 且在守卫析构前阻止目标槽位进入可变借用或 View::render。

Source

pub fn read_with<T: View, R>( &self, handle: Handle<T>, f: impl FnOnce(&T) -> R, ) -> Option<R>

在渲染期通过闭包安全读取另一个 Handle<T> 视图并提取计算结果。

Source

pub fn arena(&self) -> &ScratchArena

获取瞬态帧内存池引用。

Source

pub fn arena_mut(&mut self) -> &mut ScratchArena

获取可变帧内存池引用(用于帧开始时 rewind())。

Source

pub fn locale(&self) -> Locale

返回当前生效的语言区域(若渲染期调用了 Self::override_locale 则优先返回覆盖值)。

Source

pub fn text_direction(&self) -> TextDirection

返回当前语言的默认书写方向(Ltr 或 Rtl)。

Source

pub fn is_rtl(&self) -> bool

当前语言区域是否为从右到左(RTL)书写方向。

Source

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

设置帧级默认语言区域。

Source

pub fn override_locale(&self, locale: Locale)

在当前帧渲染期间覆盖活跃语言区域(与 Self::override_theme 对称,零可变别名风险)。

Source

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

注册静态零堆多语言词典集合。

Source

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

在当前帧渲染期间临时覆盖静态词典集合(例如根视图挂载应用级词典)。

Source

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

注册 std 运行时动态翻译目录(支持运行时热加载 JSON / key=value 语言包,优先于静态词典)。

Source

pub fn t<'a>(&'a self, key: &str) -> StrRef<'a>

翻译无参数文本键(未命中时回退键名本身;静态词典命中时零拷贝返回)。

Source

pub fn t_or<'a>(&'a self, key: &str, fallback: &'a str) -> StrRef<'a>

翻译无参数文本键,若未命中任何词典则返回显式默认值 fallback。

Source

pub fn t_args<'a>( &'a self, key: &str, args: &[(&str, I18nArg<'_>)], ) -> StrRef<'a>

翻译带命名/位置参数的文本键并在 ScratchArena 中零堆完成插值(如 cx.t_args("greeting", &[("name", "Velox".into())]))。

Source

pub fn t_plural<'a>(&'a self, key: &str, count: i64) -> StrRef<'a>

按 CLDR 复数规则翻译文本键并自动注入 {count} 参数(如 cx.t_plural("files", 3))。

Source

pub fn push_id(&self, seed: u32)

压入一层作用域 ID 种子(ImGui / egui 风格 Scoped ID Stack,最多支持 8 层嵌套)。

同一页面中多次复用相同子组件或列表项模板时,通过 push_id / with_id 自动隔离所有内部交互与动画 ID。

Source

pub fn pop_id(&self)

弹出当前最顶层的作用域 ID 种子(与 Self::push_id 配对使用)。

Source

pub fn with_id<'a, R>(&'a self, seed: u32, f: impl FnOnce(&'a Self) -> R) -> R

在指定作用域 ID 种子内执行渲染闭包,退出时自动弹栈恢复外层作用域。

Source

pub fn scoped_id(&self, local_id: u32) -> u32

基于当前作用域 ID 栈与局部 ID 派生全局唯一、不与用户显式 ID 撞车的稳定 u32 元素 ID。

Source

pub fn theme(&self) -> &CoreTheme

获取当前主题配色令牌。

Source

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

设置当前主题配色令牌。

Source

pub fn override_theme(&self, theme: CoreTheme)

在当前帧渲染期间覆盖活跃主题配色(分配在 ScratchArena 中,零可变别名风险)。

Source

pub fn current_pod(&self) -> PodId

获取当前正在渲染的 PodId。

Source

pub const fn now_ms(&self) -> u32

引擎单调动画时钟(毫秒,自引擎创建起按 step_frame_dt(dt) 累加,约 49 天回绕)。

配合 Tween / Presence 实现与帧率无关的自定义动画。

Source

pub fn set_now_ms(&mut self, now_ms: u32)

设置动画时钟(由引擎在每帧渲染前自动调用;自定义宿主或测试可手动设置)。

Source

pub fn request_frame(&self)

请求引擎在下一帧继续重新渲染(用于由 now_ms() 驱动的连续动画,如旋转加载指示器)。

Source

pub fn keep_animating(&self, running: bool) -> bool

若 running 为真则请求下一帧,并原样返回 running(便于 cx.keep_animating(tween.is_running(now)))。

Source

pub fn is_frame_requested(&self) -> bool

本帧渲染期间是否有视图请求了下一帧(request_frame() / keep_animating(true))。

Trait Implementations§

Source§

impl Default for FrameScope

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.