Struct StatusBubble
pub struct StatusBubble { /* private fields */ }Expand description
Every method takes an explicit now: Instant, so a test drives the
whole show → linger → fade → hide cycle without a wall clock.
Implementations§
§impl StatusBubble
impl StatusBubble
pub fn new() -> StatusBubble
pub fn with_linger(self, linger: Duration) -> StatusBubble
pub fn poke(&mut self, now: Instant) -> bool
pub fn poke(&mut self, now: Instant) -> bool
Returns whether visibility changed (so the caller can request a redraw).
pub fn set_hover(&mut self, over: bool, now: Instant) -> bool
pub fn set_hover(&mut self, over: bool, now: Instant) -> bool
While true the bubble is pinned fully open; on the transition to
false it starts a fresh linger countdown.
pub fn is_visible(&self, now: Instant) -> bool
pub fn alpha(&self, now: Instant) -> f32
pub fn alpha(&self, now: Instant) -> f32
Fully opaque while hovered or fresh, ramping to zero across the
final FADE of the linger.
pub fn show(&mut self, text: &str, now: Instant) -> bool
pub fn show(&mut self, text: &str, now: Instant) -> bool
Report the status. A change shows the bubble (and restarts its linger); the same text again does nothing, so calling this every frame is fine. Returns whether visibility changed.
pub fn set_text(&mut self, text: &str)
pub fn set_text(&mut self, text: &str)
Change what the bubble says without showing it: a count that follows the document reads current while the bubble shows, but does not reopen it.
pub fn rect_in(&self, area: Rect, tr: &mut TextRenderer, theme: &Theme) -> Rect
pub fn rect_in(&self, area: Rect, tr: &mut TextRenderer, theme: &Theme) -> Rect
The bubble’s rect when it floats in area: the bottom-trailing
corner, spacing.s4 in.
pub fn pointer_moved(
&mut self,
area: Rect,
p: Point,
tr: &mut TextRenderer,
theme: &Theme,
now: Instant,
) -> bool
pub fn pointer_moved( &mut self, area: Rect, p: Point, tr: &mut TextRenderer, theme: &Theme, now: Instant, ) -> bool
The pointer moved to p: resting on the bubble’s corner (the
bubble plus a gutter around it) pins it open, leaving starts its
linger. Returns whether visibility changed.
pub fn paint(
&self,
scene: &mut Scene,
transform: Affine,
tr: &mut TextRenderer,
theme: &Theme,
area: Rect,
now: Instant,
) -> Option<Rect>
pub fn paint( &self, scene: &mut Scene, transform: Affine, tr: &mut TextRenderer, theme: &Theme, area: Rect, now: Instant, ) -> Option<Rect>
Paint the bubble in area at its current opacity; nothing while it
is hidden. Returns the painted rect.
pub fn alpha_in(&self, theme: &Theme, now: Instant) -> f32
pub fn alpha_in(&self, theme: &Theme, now: Instant) -> f32
Self::alpha as theme shows it: under reduced motion the bubble
cuts in and out instead of fading.
pub fn needs_frame(&self, now: Instant) -> bool
pub fn needs_frame(&self, now: Instant) -> bool
Hovered/hidden states need no frames.
Trait Implementations§
§impl Clone for StatusBubble
impl Clone for StatusBubble
§fn clone(&self) -> StatusBubble
fn clone(&self) -> StatusBubble
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for StatusBubble
impl Debug for StatusBubble
§impl Default for StatusBubble
impl Default for StatusBubble
§fn default() -> StatusBubble
fn default() -> StatusBubble
Auto Trait Implementations§
impl Freeze for StatusBubble
impl RefUnwindSafe for StatusBubble
impl Send for StatusBubble
impl Sync for StatusBubble
impl Unpin for StatusBubble
impl UnsafeUnpin for StatusBubble
impl UnwindSafe for StatusBubble
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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