Skip to main content

ContainerView

Struct ContainerView 

Source
pub struct ContainerView<State>
where State: 'static,
{ /* private fields */ }
Expand description

A declarative decorated box. See the module docs.

Implementations§

Source§

impl<State> ContainerView<State>
where State: 'static,

Source

pub fn child<V>(self, child: V) -> ContainerView<State>
where V: View<State>,

Attach (or replace) the single child, switching this container into the wrapper family — the .child(...) counterpart to container’s direct-argument form. See the module docs.

Source

pub fn fill(self, color: AlphaColor<Srgb>) -> ContainerView<State>

Paint a solid fill behind the child (or, childless, behind whatever extent .expand()/.size(...) gives it). No fill by default.

Source

pub fn radius(self, radius: impl Into<CornerRadii>) -> ContainerView<State>

Corner radius for the fill and border, in logical px. Accepts impl Into<CornerRadii> rather than a second .radius_corners(...) method: CornerRadii already implements From<f64> for the uniform case, so the existing .radius(8.0) call keeps working exactly as before while .radius(CornerRadii::new(tl, tr, br, bl)) picks up the per-corner case (a bottom-anchored sheet with only its top corners rounded, a segmented control’s end caps) for free — one method, no ergonomics lost either way. Square corners (CornerRadii::default()) by default.

Source

pub fn border(self, color: AlphaColor<Srgb>, width: f64) -> ContainerView<State>

Paint a width-px border in color, stroked fully inside the container’s own bounds — see the module docs’ “Paint discipline” section. No border by default. Solid unless overridden with ContainerView::border_style.

Source

pub fn border_style(self, style: BorderStyle) -> ContainerView<State>

Set the border’s stroke style — BorderStyle::Solid (the default, so this call is only needed for BorderStyle::Dashed) or BorderStyle::Dashed with an explicit DashPattern. Has no effect without a .border(...) call — there is no stroke to style.

Source

pub fn glow( self, color: AlphaColor<Srgb>, std_dev: f64, spread: f64, ) -> ContainerView<State>

Paint a gaussian-blurred ambient glow/shadow beneath the fill and border, via frust_core::PaintScene::draw_shadow — an elevation-style knob, not a directional drop shadow (see below). No glow by default.

§Mapping to CSS box-shadow terms

.glow(color, std_dev, spread) maps loosely onto box-shadow: 0 0 <blur> <spread> <color> (an un-offset, centered shadow — see the note on offset below):

  • color — the shadow’s color, alpha included (CSS <color>).
  • std_dev — the Gaussian’s standard deviation. CSS’s blur-radius is twice the standard deviation (CSS Backgrounds and Borders 3 § 7.2.1), so a blur token translates in as std_dev = blur / 2.0 — the same halving frust_material::card/frust_shadcn::style::draw_shadow already apply at their own call sites.
  • spread — grows (positive) or shrinks (negative) the shadow’s rect symmetrically on every side before blurring. draw_shadow itself has no spread parameter (frust_shadcn::style::draw_shadow’s own doc drops it for the same reason), so this module computes the inflated rect directly — origin shifts by -spread on each axis, size grows by 2.0 * spread, clamped to non-negative before reaching draw_shadow.
  • border-radius — a per-corner ContainerView::radius lowers through CornerRadii::largest for this call (draw_shadow takes a single f64 radius, the same fallback Command::BlurredRoundedRect’s own doc names for a per-corner shadow caster) — but never unclamped: kurbo silently caps a RoundedRect’s own corner radius at half its shorter side, so the fill’s true rendered corner is radius.largest().min(size.min_side() / 2.0), not the raw builder value. Feeding an unclamped radius (e.g. a .radius(f64::MAX)-style pill/circle idiom) straight into the blurred-rect primitive on a small box is exactly the CSS box-shadow spread + border-radius interaction: per CSS Backgrounds and Borders 3 § 7.2.1, spreading a shadow grows its corner radii by the spread distance too (clamped at 0), so this module adds spread on top of the clamped fill radius — shadow_radius = clamped_fill_radius + spread.max(0.0) — rather than to the raw builder value or to a radius re-clamped against the already-inflated shadow rect. This is what keeps a circular fill’s halo circular instead of degenerating into the oversized dark ring a naive radius.largest() passthrough painted around a small pulsing-dot circle.
  • offset-x/offset-y are not modeled: .glow is a centered ambient glow, not a directional drop shadow like material::card’s Elevated variant (which offsets origin.y by the shadow rung’s y_offset). A caller wanting a directional shadow composes an explicit PaintScene::draw_shadow call instead, following that precedent.
Source

pub fn expand(self) -> ContainerView<State>

Fill the available space on both axes (the incoming constraint’s max) — the AppBackground full-bleed-background case. Childless only; see the module docs’ “Sizing + a child” section.

Source

pub fn size(self, width: f64, height: f64) -> ContainerView<State>

Force a fixed (width, height), clamped into the incoming constraints — the FillBox/swatch case. Childless only (a child stays hugged tight); use ContainerView::size_centered for a fixed size with a centered child. See the module docs’ “Sizing + a child” section.

Source

pub fn size_centered(self, width: f64, height: f64) -> ContainerView<State>

Force a fixed (width, height), clamped into the incoming constraints, with an attached child centered inside the free space — the Panel::fixed case (a settings panel/dialog/card that wants a fixed footprint but lets its content size itself rather than being stretched to fill it). Unlike ContainerView::size, this loosens the child’s own constraint to (width, height) (mirroring crate::Align’s child pass) instead of hugging it tight, then centers the child in whatever free space remains — see the module docs’ “Sizing + a child” section. Childless, this behaves exactly like ContainerView::size.

Trait Implementations§

Source§

impl<State> View<State> for ContainerView<State>
where State: 'static,

Source§

type Element = ContainerWidget

The retained widget this view produces.
Source§

fn build(&self, ctx: &mut BuildCtx<'_>) -> ContainerWidget

Materialise a fresh widget for this view.
Source§

fn rebuild( &self, prev: &ContainerView<State>, element: &mut ContainerWidget, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags

Reconcile prev (the previous view of the same type) against the live element, mutating it in place and reporting what changed.
Source§

fn teardown(&self, element: &mut ContainerWidget, ctx: &mut BuildCtx<'_>)

Tear down element when this view is being removed. Read more
Source§

fn message(&self, _element: &mut Self::Element, _state: &mut State)

Deliver an event message to this view, mutating application state. Read more

Auto Trait Implementations§

§

impl<State> !RefUnwindSafe for ContainerView<State>

§

impl<State> !Send for ContainerView<State>

§

impl<State> !Sync for ContainerView<State>

§

impl<State> !UnwindSafe for ContainerView<State>

§

impl<State> Freeze for ContainerView<State>
where Option<AnyView<State>>: Freeze,

§

impl<State> Unpin for ContainerView<State>
where Option<AnyView<State>>: Unpin,

§

impl<State> UnsafeUnpin for ContainerView<State>
where Option<AnyView<State>>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
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, !>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more