Skip to main content

Container

Struct Container 

Source
pub struct Container {
Show 18 fields pub background: Option<Color>, pub gradient: Option<(Color, Color, bool)>, pub border_color: Option<Color>, pub border_width: f32, pub border_radius: f32, pub shape: BoxShape, pub shadow_blur: f32, pub shadow_color: Color, pub padding: EdgeInsets, pub margin: EdgeInsets, pub width: Option<f32>, pub height: Option<f32>, pub min_width: f32, pub min_height: f32, pub clip: bool, pub align: Option<Alignment>, pub material: Option<ShaderMaterial>, pub child: Option<BoxedWidget>,
}
Expand description

The most fundamental building block — a maximally-configurable box: shape, background (solid or gradient), border, shadow, corner radius, padding, margin, fixed/min size, alignment, child clipping, and a child.

Everything box-shaped is a Container — there is no ColoredBox / CircleBox / GradientBox (D095). Analogous to a CSS div or Flutter’s Container.

Fields§

§background: Option<Color>§gradient: Option<(Color, Color, bool)>§border_color: Option<Color>§border_width: f32§border_radius: f32§shape: BoxShape§shadow_blur: f32§shadow_color: Color§padding: EdgeInsets§margin: EdgeInsets§width: Option<f32>§height: Option<f32>§min_width: f32§min_height: f32§clip: bool§align: Option<Alignment>§material: Option<ShaderMaterial>§child: Option<BoxedWidget>

Implementations§

Source§

impl Container

Source

pub fn new() -> Self

Source

pub fn align(self, a: Alignment) -> Self

Source

pub fn background(self, c: Color) -> Self

Source

pub fn gradient(self, from: Color, to: Color) -> Self

Two-stop linear gradient background (overrides solid background).

Source

pub fn gradient_h(self, from: Color, to: Color) -> Self

Source

pub fn border(self, c: Color, w: f32) -> Self

Source

pub fn radius(self, r: f32) -> Self

Source

pub fn shape(self, s: BoxShape) -> Self

Source

pub fn circle(self) -> Self

Source

pub fn stadium(self) -> Self

Source

pub fn shadow(self, color: Color, blur: f32) -> Self

Source

pub fn elevation(self, e: f32) -> Self

Material-style elevation shortcut (black shadow scaled by elevation).

Source

pub fn padding(self, p: EdgeInsets) -> Self

Source

pub fn margin(self, m: EdgeInsets) -> Self

Source

pub fn clip(self) -> Self

Clip the child to the box shape (rounded/circle content masking).

Source

pub fn width(self, w: f32) -> Self

Source

pub fn height(self, h: f32) -> Self

Source

pub fn size(self, w: f32, h: f32) -> Self

Source

pub fn min_size(self, w: f32, h: f32) -> Self

Source

pub fn child(self, w: impl Widget + 'static) -> Self

Source

pub fn material(self, m: ShaderMaterial) -> Self

Per-instance shader material — replaces the background fill (gradient/ solid) when resolved. Beats the theme’s ContainerMaterial default. Corners are drawn square under the shader (no rounded-clip primitive yet, D124 Step 4+); border/shadow/child/radius are unaffected.

Trait Implementations§

Source§

impl Default for Container

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Widget for Container

Source§

fn layout(&self, ctx: &LayoutCtx<'_>) -> Size

Measure under ctx.constraints and return a size within them. Read more
Source§

fn paint(&self, ctx: &mut PaintCtx<'_>)

Record draw commands for ctx.rect. Read more
Source§

fn children(&self) -> Children<'_>

Declare this widget’s children. Drives every default below.
Source§

fn flex_factor(&self) -> f32

Flex weight inside Row/Column. Wrappers are transparent by default.
Source§

fn into_element(self) -> Element
where Self: Sized + 'static,

Wrap this widget in an Element so it can be returned from Component::build().

Auto Trait Implementations§

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<W> FocusApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn focus_node(self, node: FocusNode) -> WithFocus<Self>

Attach a focus node. This enables focus-ring rendering and explicit neighbor wiring.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<W> HeroApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn hero_tag(self, tag: impl Into<String>) -> Hero<Self>

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<W> OverlayApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn dropdown( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn sheet( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn dialog( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn rich_tooltip( self, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn toast( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

impl<W> PressApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn on_press(self, f: impl Fn() + Send + Sync + 'static) -> Pressable<Self>

Source§

fn on_long_press( self, f: impl Fn() + Send + Sync + 'static, ) -> LongPressable<Self>

Source§

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

Source§

type Error = Infallible

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.
Source§

impl<W> WidgetExt for W
where W: Widget + 'static,

Source§

fn tooltip(self, label: impl Into<String>) -> Tooltip

Show label while the pointer hovers this widget.