LayerShellSandbox

Trait LayerShellSandbox 

Source
pub trait LayerShellSandbox {
    type Message: Debug + Send;

    // Required methods
    fn new() -> Self;
    fn namespace(&self) -> String;
    fn update(&mut self, message: Self::Message);
    fn view(&self) -> Element<'_, Self::Message>;

    // Provided methods
    fn theme(&self) -> Theme { ... }
    fn style(&self, theme: &Theme) -> Appearance { ... }
    fn scale_factor(&self) -> f64 { ... }
    fn run(settings: Settings<()>) -> Result<(), Error>
       where Self: 'static + Sized,
             Self::Message: 'static + TryInto<LayershellCustomActions, Error = Self::Message> { ... }
}

Required Associated Types§

Source

type Message: Debug + Send

The type of messages your LayerShellSandbox will produce.

Required Methods§

Source

fn new() -> Self

Initializes the LayerShellSandbox.

Here is where you should return the initial state of your app.

Source

fn namespace(&self) -> String

Returns the current namespace of the LayerShellSandbox.

This title can be dynamic! The runtime will automatically update the title of your application when necessary.

Source

fn update(&mut self, message: Self::Message)

Handles a message and updates the state of the LayerShellSandbox.

This is where you define your update logic. All the messages, produced by user interactions, will be handled by this method.

Source

fn view(&self) -> Element<'_, Self::Message>

Returns the widgets to display in the LayerShellSandbox.

These widgets can produce messages based on user interaction.

Provided Methods§

Source

fn theme(&self) -> Theme

Returns the current Theme of the LayerShellSandbox.

If you want to use your own custom theme type, you will have to use an Application.

By default, it returns Theme::default.

Source

fn style(&self, theme: &Theme) -> Appearance

Returns the current style variant of Appearance.

By default, it returns Theme::default_style().

Source

fn scale_factor(&self) -> f64

Returns the scale factor of the LayerShellSandbox.

It can be used to dynamically control the size of the UI at runtime (i.e. zooming).

For instance, a scale factor of 2.0 will make widgets twice as big, while a scale factor of 0.5 will shrink them to half their size.

By default, it returns 1.0.

Source

fn run(settings: Settings<()>) -> Result<(), Error>
where Self: 'static + Sized, Self::Message: 'static + TryInto<LayershellCustomActions, Error = Self::Message>,

Runs the LayerShellSandbox.

On native platforms, this method will take control of the current thread and will NOT return.

It should probably be that last thing you call in your main function.

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§