pub struct Label { /* private fields */ }Expand description
State for a static text label widget.
This is a pure data structure. Rendering and actual pixel-accurate
truncation are handled by the caller (adapter layer) using the functions in
crate::truncation.
Implementations§
Source§impl Label
impl Label
Sourcepub fn new(text: impl Into<String>) -> Self
pub fn new(text: impl Into<String>) -> Self
Create a new Label with the given text and no line limit.
Sourcepub fn with_max_lines(self, n: usize) -> Self
pub fn with_max_lines(self, n: usize) -> Self
Limit the label to n visible lines.
When n is 1, adapters should apply single-line ellipsis truncation
via crate::truncation::truncate.
Sourcepub fn is_truncated(&self) -> bool
pub fn is_truncated(&self) -> bool
Returns true when an adapter reported that truncation occurred during
the last layout pass.
Sourcepub fn set_truncated(&mut self, truncated: bool)
pub fn set_truncated(&mut self, truncated: bool)
Called by adapters after each layout pass to record whether truncation occurred.
Sourcepub fn display_text(&self) -> &str
pub fn display_text(&self) -> &str
Returns the text that should be displayed.
For single-line labels (max_lines == Some(1)), pixel-accurate
truncation requires a TextPipeline; call crate::truncation::truncate
from the adapter and pass set_truncated(true) when the result
differs from the raw text. This method returns the full raw text so the
adapter can measure and decide.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Label
impl RefUnwindSafe for Label
impl Send for Label
impl Sync for Label
impl Unpin for Label
impl UnsafeUnpin for Label
impl UnwindSafe for Label
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,
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