pub struct Label { /* private fields */ }Expand description
A run of text drawn in a content colour, aligned inside its bounds.
Not interactive and not focusable, so a label inside a button never intercepts the click.
Implementations§
Source§impl Label
impl Label
Sourcepub fn new(text: impl Into<String>) -> Self
pub fn new(text: impl Into<String>) -> Self
A label in Role::BaseContent, left-aligned and vertically centred, in
the built-in font at 16 px.
Sourcepub fn with_role(self, role: Role) -> Self
pub fn with_role(self, role: Role) -> Self
Sets the colour role. Pass a *Content role, or a surface role to draw the
label in that colour rather than on it.
Sourcepub fn with_align(self, horizontal: Align, vertical: Align) -> Self
pub fn with_align(self, horizontal: Align, vertical: Align) -> Self
Sets horizontal and vertical alignment.
Sourcepub fn with_style(self, style: TextStyle) -> Self
pub fn with_style(self, style: TextStyle) -> Self
Sets the font and size.
Sourcepub fn set_text(&mut self, text: impl Into<String>)
pub fn set_text(&mut self, text: impl Into<String>)
Replaces the text.
Reach this through Ui::widget_mut, which marks
the node dirty on the way in.
Trait Implementations§
Source§impl Describe for Label
impl Describe for Label
Source§const DOC: &'static str = "Text that is read and not touched."
const DOC: &'static str = "Text that is read and not touched."
One line saying what this widget is, for somebody choosing one. Read more
Source§const ICON: &'static Icon
const ICON: &'static Icon
The widget’s glyph: a small portrait of the thing, for a palette to
draw beside — or instead of — its name. Read more
Source§const PROPERTIES: &'static [Property]
const PROPERTIES: &'static [Property]
Every property, in the order an inspector should show them.
Source§impl<M: 'static> Widget<M> for Label
impl<M: 'static> Widget<M> for Label
Source§fn describe(&self) -> Option<&dyn DynDescribe>
fn describe(&self) -> Option<&dyn DynDescribe>
This widget’s property description, if it has one. Read more
Source§fn describe_mut(&mut self) -> Option<&mut dyn DynDescribe>
fn describe_mut(&mut self) -> Option<&mut dyn DynDescribe>
The mutable half of
describe.Source§fn measure(&self, ctx: &mut MeasureCtx<'_>, _offered: Offer) -> Measured
fn measure(&self, ctx: &mut MeasureCtx<'_>, _offered: Offer) -> Measured
How big this widget would like to be, given what the caller can promise. Read more
Source§fn paint(&self, ctx: &mut PaintCtx<'_>, canvas: &mut Pen<'_>)
fn paint(&self, ctx: &mut PaintCtx<'_>, canvas: &mut Pen<'_>)
Draws into
canvas, which is already clipped to this widget’s bounds
intersected with the damage region being repainted. Read moreSource§fn on_event(&mut self, event: &Event<'_>, ctx: &mut EventCtx<'_, M>) -> Handled
fn on_event(&mut self, event: &Event<'_>, ctx: &mut EventCtx<'_, M>) -> Handled
Reacts to an event routed to this widget.
Source§fn accepts_pointer(&self) -> bool
fn accepts_pointer(&self) -> bool
Returns
true if the pointer can hit this widget. Read moreSource§fn preserves_focus(&self) -> bool
fn preserves_focus(&self) -> bool
Returns
true if a press on this widget should leave focus exactly where
it is. Read moreSource§fn animate(&mut self, now_ms: u64) -> Animation
fn animate(&mut self, now_ms: u64) -> Animation
Advances time-based state. Called only while this widget has asked to
animate — see
EventCtx::request_animation — and stops being called
the moment it answers Wake::Never. Read moreAuto 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DynDescribe for Twhere
T: Describe,
impl<T> DynDescribe for Twhere
T: Describe,
Source§fn kind(&self) -> &'static str
fn kind(&self) -> &'static str
See
Describe::KIND.Source§fn properties(&self) -> &'static [Property]
fn properties(&self) -> &'static [Property]
See
Describe::PROPERTIES.Source§fn get_property(&self, name: &str) -> Option<Value>
fn get_property(&self, name: &str) -> Option<Value>
See
Describe::get.Source§fn set_property(
&mut self,
name: &str,
value: Value,
) -> Result<(), PropertyError>
fn set_property( &mut self, name: &str, value: Value, ) -> Result<(), PropertyError>
See
Describe::set.