cushy::window

Trait WindowBehavior

source
pub trait WindowBehavior: Sized + 'static {
    type Context: Send + 'static;

    // Required methods
    fn initialize(
        window: &mut RunningWindow<Window<'_, WindowCommand>>,
        context: Self::Context,
    ) -> Self;
    fn make_root(&mut self) -> WidgetInstance;

    // Provided methods
    fn initialized<W>(&mut self, window: &mut W)
       where W: PlatformWindow { ... }
    fn close_requested<W>(&self, window: &mut W) -> bool
       where W: PlatformWindow { ... }
    fn run() -> Result
       where Self::Context: Default { ... }
    fn run_with(context: Self::Context) -> Result { ... }
}
Expand description

The behavior of a Cushy window.

Required Associated Types§

source

type Context: Send + 'static

The type that is provided when initializing this window.

Required Methods§

source

fn initialize( window: &mut RunningWindow<Window<'_, WindowCommand>>, context: Self::Context, ) -> Self

Return a new instance of this behavior using context.

source

fn make_root(&mut self) -> WidgetInstance

Create the window’s root widget. This function is only invoked once.

Provided Methods§

source

fn initialized<W>(&mut self, window: &mut W)
where W: PlatformWindow,

Invoked once the window has been fully initialized.

source

fn close_requested<W>(&self, window: &mut W) -> bool
where W: PlatformWindow,

The window has been requested to close. If this function returns true, the window will be closed. Returning false prevents the window from closing.

source

fn run() -> Result
where Self::Context: Default,

Runs this behavior as an application.

source

fn run_with(context: Self::Context) -> Result

Runs this behavior as an application, initialized with context.

Object Safety§

This trait is not object safe.

Implementors§