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,
impl<State> ContainerView<State>where
State: 'static,
Sourcepub fn child<V>(self, child: V) -> ContainerView<State>where
V: View<State>,
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.
Sourcepub fn fill(self, color: AlphaColor<Srgb>) -> ContainerView<State>
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.
Sourcepub fn radius(self, radius: impl Into<CornerRadii>) -> ContainerView<State>
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.
Sourcepub fn border(self, color: AlphaColor<Srgb>, width: f64) -> ContainerView<State>
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.
Sourcepub fn border_style(self, style: BorderStyle) -> ContainerView<State>
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.
Sourcepub fn glow(
self,
color: AlphaColor<Srgb>,
std_dev: f64,
spread: f64,
) -> ContainerView<State>
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’sblur-radiusis twice the standard deviation (CSS Backgrounds and Borders 3 § 7.2.1), so a blur token translates in asstd_dev = blur / 2.0— the same halvingfrust_material::card/frust_shadcn::style::draw_shadowalready apply at their own call sites.spread— grows (positive) or shrinks (negative) the shadow’s rect symmetrically on every side before blurring.draw_shadowitself 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 —originshifts by-spreadon each axis,sizegrows by2.0 * spread, clamped to non-negative before reachingdraw_shadow.border-radius— a per-cornerContainerView::radiuslowers throughCornerRadii::largestfor this call (draw_shadowtakes a singlef64radius, the same fallbackCommand::BlurredRoundedRect’s own doc names for a per-corner shadow caster) — but never unclamped: kurbo silently caps aRoundedRect’s own corner radius at half its shorter side, so the fill’s true rendered corner isradius.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 CSSbox-shadowspread+border-radiusinteraction: 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 addsspreadon 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 naiveradius.largest()passthrough painted around a small pulsing-dot circle.- offset-x/offset-y are not modeled:
.glowis a centered ambient glow, not a directional drop shadow likematerial::card’sElevatedvariant (which offsetsorigin.yby the shadow rung’sy_offset). A caller wanting a directional shadow composes an explicitPaintScene::draw_shadowcall instead, following that precedent.
Sourcepub fn expand(self) -> ContainerView<State>
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.
Sourcepub fn size(self, width: f64, height: f64) -> ContainerView<State>
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.
Sourcepub fn size_centered(self, width: f64, height: f64) -> ContainerView<State>
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,
impl<State> View<State> for ContainerView<State>where
State: 'static,
Source§type Element = ContainerWidget
type Element = ContainerWidget
Source§fn build(&self, ctx: &mut BuildCtx<'_>) -> ContainerWidget
fn build(&self, ctx: &mut BuildCtx<'_>) -> ContainerWidget
Source§fn rebuild(
&self,
prev: &ContainerView<State>,
element: &mut ContainerWidget,
ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &ContainerView<State>, element: &mut ContainerWidget, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags
prev (the previous view of the same type) against the live
element, mutating it in place and reporting what changed.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>
impl<State> Unpin for ContainerView<State>
impl<State> UnsafeUnpin for ContainerView<State>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.