pub struct StateLayer { /* private fields */ }Expand description
Tracks a widget’s hover/focus/pressed/dragged interaction state and paints the M3 state-layer overlay for it. See the module docs.
Implementations§
Source§impl StateLayer
impl StateLayer
Sourcepub fn set_hovered(&mut self, hovered: bool) -> bool
pub fn set_hovered(&mut self, hovered: bool) -> bool
Record the widget’s hover state. Returns whether the flag changed.
Sourcepub fn set_focused(&mut self, focused: bool) -> bool
pub fn set_focused(&mut self, focused: bool) -> bool
Record the widget’s focus state. Returns whether the flag changed.
Sourcepub fn set_pressed(&mut self, pressed: bool) -> bool
pub fn set_pressed(&mut self, pressed: bool) -> bool
Record the widget’s pressed state. Returns whether the flag changed.
Sourcepub fn set_dragged(&mut self, dragged: bool) -> bool
pub fn set_dragged(&mut self, dragged: bool) -> bool
Record the widget’s dragged state. Returns whether the flag changed.
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Whether any interaction state is currently active (i.e. whether
StateLayer::paint will paint anything).
Sourcepub fn opacity(&self) -> f32
pub fn opacity(&self) -> f32
The overlay opacity for the current state: the maximum of every active
state’s opacity (see the module docs), or 0.0 if none are
active.
Sourcepub fn paint(
&self,
_ctx: &mut PaintCtx<'_>,
scene: &mut dyn PaintScene,
shape_rect: Rect,
radius: f64,
content_color: Color,
)
pub fn paint( &self, _ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene, shape_rect: Rect, radius: f64, content_color: Color, )
Paint the overlay: a filled rounded rect covering shape_rect with
radius, filled with content_color at the current interaction
opacity (replacing, not multiplying, content_color’s own alpha — the
M3 spec expresses state layers as “content color at N% opacity”). A
no-op when no interaction state is active.
Trait Implementations§
Source§impl Clone for StateLayer
impl Clone for StateLayer
impl Copy for StateLayer
Source§impl Debug for StateLayer
impl Debug for StateLayer
Source§impl Default for StateLayer
impl Default for StateLayer
Source§impl PartialEq for StateLayer
impl PartialEq for StateLayer
impl StructuralPartialEq for StateLayer
Auto Trait Implementations§
impl Freeze for StateLayer
impl RefUnwindSafe for StateLayer
impl Send for StateLayer
impl Sync for StateLayer
impl Unpin for StateLayer
impl UnsafeUnpin for StateLayer
impl UnwindSafe for StateLayer
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<T> Brush for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.