Skip to main content

VisualContext

Trait VisualContext 

Source
pub trait VisualContext: AppContext {
    type Result<T>;

    // 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 Associated Types§

Source

type Result<T>

The result type for window operations.

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".

Implementors§