VisualContext

Trait VisualContext 

Source
pub trait VisualContext: AppContext {
    // Required methods
    fn window_handle(&self) -> AnyWindowHandle;
    fn update_window_entity<T: 'static, R>(
        &mut self,
        entity: &Entity<T>,
        update: impl FnOnce(&mut T, &mut Window, &mut Context<'_, T>) -> R,
    ) -> Self::Result<R>;
    fn new_window_entity<T: 'static>(
        &mut self,
        build_entity: impl FnOnce(&mut Window, &mut Context<'_, T>) -> T,
    ) -> Self::Result<Entity<T>>;
    fn replace_root_view<V>(
        &mut self,
        build_view: impl FnOnce(&mut Window, &mut Context<'_, V>) -> V,
    ) -> Self::Result<Entity<V>>
       where V: 'static + Render;
    fn focus<V>(&mut self, entity: &Entity<V>) -> Self::Result<()>
       where V: Focusable;
}
Expand description

This trait is used for the different visual contexts in GPUI that require a window to be present.

Required Methods§

Source

fn window_handle(&self) -> AnyWindowHandle

Returns the handle of the window associated with this context.

Source

fn update_window_entity<T: 'static, R>( &mut self, entity: &Entity<T>, update: impl FnOnce(&mut T, &mut Window, &mut Context<'_, T>) -> R, ) -> Self::Result<R>

Update a view with the given callback

Source

fn new_window_entity<T: 'static>( &mut self, build_entity: impl FnOnce(&mut Window, &mut Context<'_, T>) -> T, ) -> Self::Result<Entity<T>>

Create a new entity, with access to Window.

Source

fn replace_root_view<V>( &mut self, build_view: impl FnOnce(&mut Window, &mut Context<'_, V>) -> V, ) -> Self::Result<Entity<V>>
where V: 'static + Render,

Replace the root view of a window with a new view.

Source

fn focus<V>(&mut self, entity: &Entity<V>) -> Self::Result<()>
where V: Focusable,

Focus a entity in the window, if it implements the Focusable trait.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§