pub struct Label { /* private fields */ }
Expand description
Static text.
Usually it is more convenient to use Ui::label
.
ui.label("Equivalent");
ui.add(egui::Label::new("Equivalent"));
ui.add(egui::Label::new("With Options").wrap(false));
ui.label(egui::RichText::new("With formatting").underline());
For full control of the text you can use crate::text::LayoutJob
as argument to Self::new
.
Implementations§
Source§impl Label
impl Label
pub fn new(text: impl Into<WidgetText>) -> Label
pub fn text(&self) -> &str
Sourcepub fn wrap(self, wrap: bool) -> Label
pub fn wrap(self, wrap: bool) -> Label
If true
, the text will wrap to stay within the max width of the Ui
.
Calling wrap
will override Self::truncate
.
By default Self::wrap
will be true
in vertical layouts
and horizontal layouts with wrapping,
and false
on non-wrapping horizontal layouts.
Note that any \n
in the text will always produce a new line.
You can also use crate::Style::wrap
.
Sourcepub fn truncate(self, truncate: bool) -> Label
pub fn truncate(self, truncate: bool) -> Label
If true
, the text will stop at the max width of the Ui
,
and what doesn’t fit will be elided, replaced with …
.
If the text is truncated, the full text will be shown on hover as a tool-tip.
Default is false
, which means the text will expand the parent Ui
,
or wrap if Self::wrap
is set.
Calling truncate
will override Self::wrap
.
Sourcepub fn sense(self, sense: Sense) -> Label
pub fn sense(self, sense: Sense) -> Label
Make the label respond to clicks and/or drags.
By default, a label is inert and does not respond to click or drags. By calling this you can turn the label into a button of sorts. This will also give the label the hover-effect of a button, but without the frame.
if ui.add(Label::new("click me").sense(Sense::click())).clicked() {
/* … */
}
Source§impl Label
impl Label
Sourcepub fn layout_in_ui(self, ui: &mut Ui) -> (Pos2, WidgetTextGalley, Response)
pub fn layout_in_ui(self, ui: &mut Ui) -> (Pos2, WidgetTextGalley, Response)
Do layout and position the galley in the ui, without painting it or adding widget info.
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 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<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.