#[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 thesnoraengine, this isiced::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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.body: NodeThe 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.
Status bar at the bottom of the window.
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.
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: ToastPositionAnchor corner of the toast stack. Defaults to
ToastPosition::TopEnd (top-right under LTR, top-left under RTL).
direction: LayoutDirectionReading direction. Drives sidebar side, header start/end ordering,
and toast anchor mirroring (when the position is *Start or *End).
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,
impl<Node, Message> AppLayout<Node, Message>where
Message: Clone,
Sourcepub fn new(body: Node) -> Self
pub fn new(body: Node) -> Self
Start a layout with only a body. All other slots default to their
empty / None states.
Sourcepub fn side_bar(self, side_bar: Node) -> Self
pub fn side_bar(self, side_bar: Node) -> Self
Set the sidebar element. Renders on the start edge by default.
Set the footer element.
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.
Set the floating context menu. Pass a positioned element.
Sourcepub fn sheet(self, sheet: Sheet<Node, Message>) -> Self
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.
Sourcepub fn toasts(self, toasts: Vec<Toast<Message>>) -> Self
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.
Sourcepub fn toast_position(self, position: ToastPosition) -> Self
pub fn toast_position(self, position: ToastPosition) -> Self
Override the toast anchor corner. Defaults to
ToastPosition::TopEnd.
Sourcepub fn direction(self, direction: LayoutDirection) -> Self
pub fn direction(self, direction: LayoutDirection) -> Self
Override the reading direction.
Wire the click-outside-to-close handler for header / context menus.
Sourcepub fn on_close_modals(self, msg: Message) -> Self
pub fn on_close_modals(self, msg: Message) -> Self
Wire the click-outside-to-close handler for dialog / bottom sheet.