Skip to main content

WindowContext

Struct WindowContext 

Source
pub struct WindowContext<'a> { /* private fields */ }
Expand description

窗口初始化闭包上下文(在 open_window 回调中提供 cx.new(|cx| ...) 与子视图挂载能力)。

Implementations§

Source§

impl<'a> WindowContext<'a>

Source

pub fn new<V: View>(&mut self, build: impl FnOnce(&mut Self) -> V) -> Handle<V>

构造并挂载窗口根视图(参照 gpui-kit |cx| cx.new(|_| Example) 写法)。

Source

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

注册一个独立的子视图(L2 局部重排边界),返回其 Handle<V>。

Source

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

直接挂载已构造好的根视图实例。

Source

pub fn engine(&self) -> &VeloxEngine

获取当前窗口绑定的 VeloxEngine 只读引用。

Source

pub fn engine_mut(&mut self) -> &mut VeloxEngine

获取当前窗口绑定的 VeloxEngine 可变引用(可用于挂载复合子视图、设置初始状态或派生启动任务)。

Source

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

返回当前引擎绑定的调度器名称。

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,

在窗口初始化阶段为指定视图派生启动期前景异步任务。

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for WindowContext<'a>

§

impl<'a> !Send for WindowContext<'a>

§

impl<'a> !Sync for WindowContext<'a>

§

impl<'a> !UnwindSafe for WindowContext<'a>

§

impl<'a> Forget for WindowContext<'a>

§

impl<'a> Freeze for WindowContext<'a>

§

impl<'a> Move for WindowContext<'a>

§

impl<'a> Unpin for WindowContext<'a>

§

impl<'a> UnsafeUnpin for WindowContext<'a>

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.