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.

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§