pub struct StyledContainer { /* private fields */ }Implementations§
Source§impl StyledContainer
impl StyledContainer
pub fn new( layout_style: LayoutStyle, style: impl Fn(Rect) -> RectStyle + 'static, children: Vec<Box<dyn LayoutItem>>, ) -> Result<StyledContainer, LayoutError>
Sourcepub fn from_slots(
layout_style: LayoutStyle,
style: impl Fn(Rect) -> RectStyle + 'static,
slots: Vec<ChildSlot>,
) -> Result<StyledContainer, LayoutError>
pub fn from_slots( layout_style: LayoutStyle, style: impl Fn(Rect) -> RectStyle + 'static, slots: Vec<ChildSlot>, ) -> Result<StyledContainer, LayoutError>
A styled box whose children are a mix of static widgets and reactive fragments (ChildSlots),
reconciled into this box’s own node so they inherit its flex direction/gap — the transparent
box-with-a-for path (see Container::from_slots).
pub fn with_opacity( self, opacity: impl Fn() -> f32 + 'static, ) -> StyledContainer
Sourcepub fn with_transform(
self,
transform: impl Fn(Rect) -> Option<[f32; 6]> + 'static,
) -> StyledContainer
pub fn with_transform( self, transform: impl Fn(Rect) -> Option<[f32; 6]> + 'static, ) -> StyledContainer
Apply an affine transform (rotate/scale/translate) to the whole box each view(). The closure
takes the laid-out rect and returns the 2×3 matrix, or None for identity.
Sourcepub fn on_hover_style(
self,
f: impl Fn(Rect) -> RectStyle + 'static,
) -> StyledContainer
pub fn on_hover_style( self, f: impl Fn(Rect) -> RectStyle + 'static, ) -> StyledContainer
Paint the box with f while the mouse hovers it (a declarative style swap, like Button).
Hover is mouse-only; touch never sets it, so a tap leaves no stuck hover state.
Sourcepub fn on_active_style(
self,
f: impl Fn(Rect) -> RectStyle + 'static,
) -> StyledContainer
pub fn on_active_style( self, f: impl Fn(Rect) -> RectStyle + 'static, ) -> StyledContainer
Paint the box with f while a primary pointer is held down inside it — the pressed / CSS :active
state, which takes precedence over on_hover_style. Unlike hover it tracks touch as well as mouse,
and it clears on release, on leaving the box, or once the press drags off, so it never sticks.
Sourcepub fn on_press(self, f: impl Fn() + 'static) -> StyledContainer
pub fn on_press(self, f: impl Fn() + 'static) -> StyledContainer
Make the box itself pressable. The callback fires on a tap (release, not press) inside the box; a child widget that handles the press wins, and a scroll gesture started on the box does not fire it.
Sourcepub fn on_alt_press(
self,
f: impl Fn(PointerButton) + 'static,
) -> StyledContainer
pub fn on_alt_press( self, f: impl Fn(PointerButton) + 'static, ) -> StyledContainer
Fire f(button) on a tap with a non-primary button — Secondary (right) or Auxiliary (middle).
Same tap-on-release semantics as Self::on_press: a child that handles the press wins, and travel
past the tap slop cancels it.
Opt-in per box rather than folded into on_press, because a non-primary press otherwise falls through
to whatever is behind it — silently swallowing right-clicks on every pressable box would break that.
Sourcepub fn on_long_press(self, f: impl Fn() + 'static) -> StyledContainer
pub fn on_long_press(self, f: impl Fn() + 'static) -> StyledContainer
Fires once a press inside the box is held past ~500ms without moving past the tap slop, instead of
on_press’s tap-on-release. There is no dedicated timer in the gesture pipeline, so the threshold is
only checked on the next pointer event after the press (a move or the release) — it fires slightly
late, never at exactly 500ms, and a release before that next check-in is a normal tap.
Sourcepub fn on_drag_end(self, f: impl Fn(f32, f32) + 'static) -> StyledContainer
pub fn on_drag_end(self, f: impl Fn(f32, f32) + 'static) -> StyledContainer
Make the box draggable. The callback fires with the pointer position (layout space) on a press
inside the box and on every move until release — even after the pointer leaves the box. Map the
coordinate to a value (slider) or an offset (reorder/resize).
Fires once when a drag started on this box ends, with the position it finished at (layout space, local
to the box, same as on_drag).
This is what makes a threshold gesture expressible: on_drag alone reports where the pointer is but
never that it let go, so a swipe-to-dismiss or a drag-to-open can be tracked and never decided. A drag
also ends when the pointer leaves the window or a child consumes the release; those carry no position,
so the last one the drag reached is reported instead — the gesture always ends exactly once.
pub fn on_drag(self, f: impl Fn(f32, f32) + 'static) -> StyledContainer
Sourcepub fn on_hover(self, f: impl Fn(bool) + 'static) -> StyledContainer
pub fn on_hover(self, f: impl Fn(bool) + 'static) -> StyledContainer
Fire f(true) when the mouse enters the box and f(false) when it leaves (mouse only). Independent
of on_hover_style: a box can observe hover without swapping its paint.
Registers the box as a pointer target, like on_scroll does for the same reason: a
surface that carves its input region from its content (a click-through overlay) never receives a move
event over a box it left out of that region, so a hover it did not register is a hover it can’t observe.
Sourcepub fn on_scroll(self, f: impl Fn(f32, f32) + 'static) -> StyledContainer
pub fn on_scroll(self, f: impl Fn(f32, f32) + 'static) -> StyledContainer
Fire f(dx, dy) with the wheel delta while the mouse is over the box — scroll-to-adjust on a control
(a volume or brightness chip, a stepper). Deltas are normalised to pixels, matching
ScrollArea: a line delta counts as 20px, so one wheel notch is roughly ±60.
Scroll events carry no pointer position, so the box’s hover state is what targets them; this enables
hover tracking on its own, without needing an on_hover_style. A scrollable child (a scroll area
inside the box) hit-tests first and keeps the event.
Sourcepub fn on_key(self, f: impl Fn(&Key) + 'static) -> StyledContainer
pub fn on_key(self, f: impl Fn(&Key) + 'static) -> StyledContainer
Fire f(&key) on every key press. This is a GLOBAL handler (key events reach every widget; there is
no per-widget focus), so it suits app-level shortcuts, not focused text entry.
Sourcepub fn on_focus(self, f: impl Fn(bool) + 'static) -> StyledContainer
pub fn on_focus(self, f: impl Fn(bool) + 'static) -> StyledContainer
Make the box focusable and fire f(true)/f(false) when it gains/loses keyboard focus. It joins
the tab order (Tab/Shift-Tab reach it) and takes focus on tap. Use it to drive a focus ring or to
build a custom focusable widget on top of a box.
Trait Implementations§
Source§impl Component for StyledContainer
impl Component for StyledContainer
fn view(&self) -> RenderNode
fn on_event(&mut self, event: &Event) -> EventResult
Source§fn debug_name(&self) -> &'static str
fn debug_name(&self) -> &'static str
Source§impl Drop for StyledContainer
impl Drop for StyledContainer
Source§impl LayoutItem for StyledContainer
impl LayoutItem for StyledContainer
fn layout_node(&self) -> NodeId
Auto Trait Implementations§
impl !RefUnwindSafe for StyledContainer
impl !Send for StyledContainer
impl !Sync for StyledContainer
impl !UnwindSafe for StyledContainer
impl Freeze for StyledContainer
impl Unpin for StyledContainer
impl UnsafeUnpin for StyledContainer
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more