Skip to main content

AppLayout

Struct AppLayout 

Source
#[non_exhaustive]
pub struct AppLayout<Node, Message>
where Message: Clone,
{
Show 13 fields pub body: Node, pub header: Option<Node>, pub side_bar: Option<Node>, pub footer: Option<Node>, pub header_menu: Option<Node>, pub context_menu: Option<Node>, pub dialog: Option<Dialog<Node, Message>>, pub sheet: Option<Sheet<Node, Message>>, pub toasts: Vec<Toast<Message>>, pub toast_position: ToastPosition, pub direction: LayoutDirection, pub on_close_menus: Option<Message>, pub on_close_modals: Option<Message>,
}
Expand description

The complete declarative description of what should be on screen.

Type parameters:

  • Node — the element type your engine consumes. With the snora engine, this is iced::Element<'a, Message>.
  • Message — your application’s top-level message type.

§Canonical construction

Use AppLayout::new plus chainable builder methods. This is the stable, long-term construction path:

use snora_core::AppLayout;

#[derive(Clone)]
enum Message { CloseMenus, CloseModals }

let body: () = ();
let header: () = ();
let sidebar: () = ();

let layout = AppLayout::new(body)
    .header(header)
    .side_bar(sidebar)
    .on_close_menus(Message::CloseMenus)
    .on_close_modals(Message::CloseModals);

Fields are pub for readability and in-crate access. Direct struct literal construction from outside snora-core is not supported (the struct is #[non_exhaustive]) so that future top-level surfaces can be added as additive changes. Any new field ships with a corresponding #[must_use] builder method.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§body: Node

The main content area. Required.

§header: Option<Node>

Top header bar (typically built with crate::menu::Menu entries).

§side_bar: Option<Node>

Vertical navigation rail. Renders on the start edge by default and flips with Self::direction.

§footer: Option<Node>

Status bar at the bottom of the window.

§header_menu: Option<Node>

Optional header-attached dropdown (e.g. File menu’s item list). When Some, the engine installs a transparent backdrop that dispatches Self::on_close_menus on any outside click.

§context_menu: Option<Node>

Optional floating context menu (right-click menu). Same backdrop behavior as header_menu.

§dialog: Option<Dialog<Node, Message>>

Centered modal content. The engine centers Dialog’s content and paints the dim backdrop around it; by default no card chrome is drawn — the application supplies its own, or opts into a token-styled card via snora::design::render (see the snora crate’s overlays guide).

§sheet: Option<Sheet<Node, Message>>

A modal panel anchored to one of the four window edges. The specific edge is configured on the Sheet itself.

§toasts: Vec<Toast<Message>>

The toast queue, owned by the application. snora does not mutate this slice — see snora::toast::sweep_expired for in-place expiration handling.

§toast_position: ToastPosition

Anchor corner of the toast stack. Defaults to ToastPosition::TopEnd (top-right under LTR, top-left under RTL).

§direction: LayoutDirection

Reading direction. Drives sidebar side, header start/end ordering, and toast anchor mirroring (when the position is *Start or *End).

§on_close_menus: Option<Message>

Dispatched when the user clicks outside an open menu (header or context). If None, menus still render but the click-outside-to- close backdrop is not installed — the application must then provide explicit close buttons inside its menu content.

§on_close_modals: Option<Message>

Dispatched when the user clicks the dim backdrop of a dialog or bottom sheet. Semantics mirror Self::on_close_menus.

Implementations§

Source§

impl<Node, Message> AppLayout<Node, Message>
where Message: Clone,

Source

pub fn new(body: Node) -> Self

Start a layout with only a body. All other slots default to their empty / None states.

Source

pub fn header(self, header: Node) -> Self

Set the header element.

Source

pub fn side_bar(self, side_bar: Node) -> Self

Set the sidebar element. Renders on the start edge by default.

Source

pub fn footer(self, footer: Node) -> Self

Set the footer element.

Source

pub fn header_menu(self, menu: Node) -> Self

Set the header dropdown menu. Setting any value (typically an empty Space) opts the application into the click-outside backdrop; the actual dropdown items are drawn inline by the header widget.

Source

pub fn context_menu(self, menu: Node) -> Self

Set the floating context menu. Pass a positioned element.

Source

pub fn dialog(self, dialog: Dialog<Node, Message>) -> Self

Show a modal dialog.

Source

pub fn sheet(self, sheet: Sheet<Node, Message>) -> Self

Show a modal sheet anchored to one of the window edges. Configure the anchor with Sheet::at(...) on the value passed in.

Source

pub fn toasts(self, toasts: Vec<Toast<Message>>) -> Self

Replace the toast queue. Each frame the application typically passes state.toasts.clone() here; snora does not mutate the slice. See snora::toast::subscription and snora::toast::sweep_expired for framework-managed lifetime handling.

Source

pub fn toast_position(self, position: ToastPosition) -> Self

Override the toast anchor corner. Defaults to ToastPosition::TopEnd.

Source

pub fn direction(self, direction: LayoutDirection) -> Self

Override the reading direction.

Source

pub fn on_close_menus(self, msg: Message) -> Self

Wire the click-outside-to-close handler for header / context menus.

Source

pub fn on_close_modals(self, msg: Message) -> Self

Wire the click-outside-to-close handler for dialog / bottom sheet.

Auto Trait Implementations§

§

impl<Node, Message> Freeze for AppLayout<Node, Message>
where Node: Freeze, Option<Node>: Freeze, Option<Dialog<Node, Message>>: Freeze, Option<Sheet<Node, Message>>: Freeze, Vec<Toast<Message>>: Freeze, Option<Message>: Freeze,

§

impl<Node, Message> RefUnwindSafe for AppLayout<Node, Message>
where Node: RefUnwindSafe, Option<Node>: RefUnwindSafe, Option<Dialog<Node, Message>>: RefUnwindSafe, Option<Sheet<Node, Message>>: RefUnwindSafe, Vec<Toast<Message>>: RefUnwindSafe, Option<Message>: RefUnwindSafe,

§

impl<Node, Message> Send for AppLayout<Node, Message>
where Node: Send, Option<Node>: Send, Option<Dialog<Node, Message>>: Send, Option<Sheet<Node, Message>>: Send, Vec<Toast<Message>>: Send, Option<Message>: Send,

§

impl<Node, Message> Sync for AppLayout<Node, Message>
where Node: Sync, Option<Node>: Sync, Option<Dialog<Node, Message>>: Sync, Option<Sheet<Node, Message>>: Sync, Vec<Toast<Message>>: Sync, Option<Message>: Sync,

§

impl<Node, Message> Unpin for AppLayout<Node, Message>
where Node: Unpin, Option<Node>: Unpin, Option<Dialog<Node, Message>>: Unpin, Option<Sheet<Node, Message>>: Unpin, Vec<Toast<Message>>: Unpin, Option<Message>: Unpin,

§

impl<Node, Message> UnsafeUnpin for AppLayout<Node, Message>
where Node: UnsafeUnpin, Option<Node>: UnsafeUnpin, Option<Dialog<Node, Message>>: UnsafeUnpin, Option<Sheet<Node, Message>>: UnsafeUnpin, Vec<Toast<Message>>: UnsafeUnpin, Option<Message>: UnsafeUnpin,

§

impl<Node, Message> UnwindSafe for AppLayout<Node, Message>
where Node: UnwindSafe, Option<Node>: UnwindSafe, Option<Dialog<Node, Message>>: UnwindSafe, Option<Sheet<Node, Message>>: UnwindSafe, Vec<Toast<Message>>: UnwindSafe, Option<Message>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.