pub struct SurfaceScaffold { /* private fields */ }Expand description
A full-viewport scaffold that positions a panel against a screen edge, optionally dims the area behind it, and dismisses on a press outside the panel. It is the reusable body of a drawer/modal: a shell mounts it as the root of a full-screen layer-shell surface, and a windowed app can mount it in-tree as an in-window portal — both get the same positioning and dismiss behaviour.
Like other full-surface roots it (re)computes its own layout on WindowResized; the runner synthesizes
an initial one on resume, so the scaffold is laid out before its first frame.
Implementations§
Source§impl SurfaceScaffold
impl SurfaceScaffold
Sourcepub fn new(
edge: Edge,
align: AlignItems,
margin: (i32, i32, i32, i32),
scrim: Option<Color>,
dismiss: Option<Rc<dyn Fn()>>,
content: Box<dyn LayoutItem>,
) -> Result<Self, LayoutError>
pub fn new( edge: Edge, align: AlignItems, margin: (i32, i32, i32, i32), scrim: Option<Color>, dismiss: Option<Rc<dyn Fn()>>, content: Box<dyn LayoutItem>, ) -> Result<Self, LayoutError>
margin is (top, right, bottom, left) and becomes padding on all four sides, so the panel floats off
every viewport edge rather than only the one it is pinned to. scrim paints behind the panel when set
(see DEFAULT_SCRIM); dismiss fires on a press outside it, and None means outside presses fall
through.
pub fn animate_in(self) -> Self
Sourcepub fn animate(self, transition: SurfaceTransition) -> Self
pub fn animate(self, transition: SurfaceTransition) -> Self
Drives the scaffold from a transition the caller owns, so it can also send the surface back out — see
SurfaceTransition::leave.