pub struct FrameScope { /* private fields */ }Expand description
帧级无状态渲染上下文(供 Widget::render_once 与 div().child(cx, ...) 使用)。
Implementations§
Source§impl FrameScope
impl FrameScope
Sourcepub fn with_theme(theme: CoreTheme) -> Self
pub fn with_theme(theme: CoreTheme) -> Self
使用指定主题创建帧级上下文。
Sourcepub fn ime_preedit(&self) -> Option<&str>
pub fn ime_preedit(&self) -> Option<&str>
获取当前正在组合输入的 IME 预编辑字符串(无预编辑内容时返回 None)。
Sourcepub const fn ime_preedit_state(&self) -> ImePreedit
pub const fn ime_preedit_state(&self) -> ImePreedit
获取当前帧上下文中的完整 IME 预编辑状态(含可选光标区间)。
Sourcepub fn set_ime_preedit(&mut self, preedit: ImePreedit)
pub fn set_ime_preedit(&mut self, preedit: ImePreedit)
设置当前帧上下文中的 IME 预编辑状态(由引擎自动同步)。
Sourcepub const fn safe_area(&self) -> SafeAreaInsets
pub const fn safe_area(&self) -> SafeAreaInsets
获取当前屏幕安全区域内边距(状态栏、刘海屏、底部 Home Indicator)。
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
获取当前屏幕软键盘占用的底部像素高度(0 表示未弹出)。
Sourcepub fn set_keyboard_inset(&mut self, height: i16)
pub fn set_keyboard_inset(&mut self, height: i16)
设置当前屏幕软键盘占用的底部像素高度。
Sourcepub fn read<'s, T: View>(
&'s self,
handle: Handle<T>,
) -> Option<PodReadGuard<'s, T>>
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。
Sourcepub fn read_with<T: View, R>(
&self,
handle: Handle<T>,
f: impl FnOnce(&T) -> R,
) -> Option<R>
pub fn read_with<T: View, R>( &self, handle: Handle<T>, f: impl FnOnce(&T) -> R, ) -> Option<R>
在渲染期通过闭包安全读取另一个 Handle<T> 视图并提取计算结果。
Sourcepub fn arena(&self) -> &ScratchArena
pub fn arena(&self) -> &ScratchArena
获取瞬态帧内存池引用。
Sourcepub fn arena_mut(&mut self) -> &mut ScratchArena
pub fn arena_mut(&mut self) -> &mut ScratchArena
获取可变帧内存池引用(用于帧开始时 rewind())。
Sourcepub fn locale(&self) -> Locale
pub fn locale(&self) -> Locale
返回当前生效的语言区域(若渲染期调用了 Self::override_locale 则优先返回覆盖值)。
Sourcepub fn text_direction(&self) -> TextDirection
pub fn text_direction(&self) -> TextDirection
返回当前语言的默认书写方向(Ltr 或 Rtl)。
Sourcepub fn set_locale(&mut self, locale: Locale)
pub fn set_locale(&mut self, locale: Locale)
设置帧级默认语言区域。
Sourcepub fn override_locale(&self, locale: Locale)
pub fn override_locale(&self, locale: Locale)
在当前帧渲染期间覆盖活跃语言区域(与 Self::override_theme 对称,零可变别名风险)。
Sourcepub fn set_i18n_catalog(&mut self, catalog: &'static StaticCatalog)
pub fn set_i18n_catalog(&mut self, catalog: &'static StaticCatalog)
注册静态零堆多语言词典集合。
Sourcepub fn override_i18n_catalog(&self, catalog: &'static StaticCatalog)
pub fn override_i18n_catalog(&self, catalog: &'static StaticCatalog)
在当前帧渲染期间临时覆盖静态词典集合(例如根视图挂载应用级词典)。
Sourcepub fn set_dynamic_catalog(&mut self, catalog: Arc<DynamicCatalog>)
pub fn set_dynamic_catalog(&mut self, catalog: Arc<DynamicCatalog>)
注册 std 运行时动态翻译目录(支持运行时热加载 JSON / key=value 语言包,优先于静态词典)。
Sourcepub fn t_or<'a>(&'a self, key: &str, fallback: &'a str) -> StrRef<'a>
pub fn t_or<'a>(&'a self, key: &str, fallback: &'a str) -> StrRef<'a>
翻译无参数文本键,若未命中任何词典则返回显式默认值 fallback。
Sourcepub fn t_args<'a>(
&'a self,
key: &str,
args: &[(&str, I18nArg<'_>)],
) -> StrRef<'a>
pub fn t_args<'a>( &'a self, key: &str, args: &[(&str, I18nArg<'_>)], ) -> StrRef<'a>
翻译带命名/位置参数的文本键并在 ScratchArena 中零堆完成插值(如 cx.t_args("greeting", &[("name", "Velox".into())]))。
Sourcepub fn t_plural<'a>(&'a self, key: &str, count: i64) -> StrRef<'a>
pub fn t_plural<'a>(&'a self, key: &str, count: i64) -> StrRef<'a>
按 CLDR 复数规则翻译文本键并自动注入 {count} 参数(如 cx.t_plural("files", 3))。
Sourcepub fn push_id(&self, seed: u32)
pub fn push_id(&self, seed: u32)
压入一层作用域 ID 种子(ImGui / egui 风格 Scoped ID Stack,最多支持 8 层嵌套)。
同一页面中多次复用相同子组件或列表项模板时,通过 push_id / with_id 自动隔离所有内部交互与动画 ID。
Sourcepub fn pop_id(&self)
pub fn pop_id(&self)
弹出当前最顶层的作用域 ID 种子(与 Self::push_id 配对使用)。
Sourcepub fn with_id<'a, R>(&'a self, seed: u32, f: impl FnOnce(&'a Self) -> R) -> R
pub fn with_id<'a, R>(&'a self, seed: u32, f: impl FnOnce(&'a Self) -> R) -> R
在指定作用域 ID 种子内执行渲染闭包,退出时自动弹栈恢复外层作用域。
Sourcepub fn scoped_id(&self, local_id: u32) -> u32
pub fn scoped_id(&self, local_id: u32) -> u32
基于当前作用域 ID 栈与局部 ID 派生全局唯一、不与用户显式 ID 撞车的稳定 u32 元素 ID。
Sourcepub fn override_theme(&self, theme: CoreTheme)
pub fn override_theme(&self, theme: CoreTheme)
在当前帧渲染期间覆盖活跃主题配色(分配在 ScratchArena 中,零可变别名风险)。
Sourcepub fn current_pod(&self) -> PodId
pub fn current_pod(&self) -> PodId
获取当前正在渲染的 PodId。
Sourcepub fn set_now_ms(&mut self, now_ms: u32)
pub fn set_now_ms(&mut self, now_ms: u32)
设置动画时钟(由引擎在每帧渲染前自动调用;自定义宿主或测试可手动设置)。
Sourcepub fn request_frame(&self)
pub fn request_frame(&self)
请求引擎在下一帧继续重新渲染(用于由 now_ms() 驱动的连续动画,如旋转加载指示器)。
Sourcepub fn keep_animating(&self, running: bool) -> bool
pub fn keep_animating(&self, running: bool) -> bool
若 running 为真则请求下一帧,并原样返回 running(便于 cx.keep_animating(tween.is_running(now)))。
Sourcepub fn is_frame_requested(&self) -> bool
pub fn is_frame_requested(&self) -> bool
本帧渲染期间是否有视图请求了下一帧(request_frame() / keep_animating(true))。
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FrameScope
impl !RefUnwindSafe for FrameScope
impl !Send for FrameScope
impl !Sync for FrameScope
impl !UnwindSafe for FrameScope
impl Forget for FrameScope
impl Move for FrameScope
impl Unpin for FrameScope
impl UnsafeUnpin for FrameScope
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) 时执行闭包修饰自身,否则原样返回。