Skip to main content

Label

Struct Label 

Source
pub struct Label {
    pub style: Style,
    pub text_color: Color,
    /* private fields */
}
Expand description

Simple text element.

Fields§

§style: Style

Visual style of the label background.

§text_color: Color
👎Deprecated:

use the resolved TextStyle text_color cascade when drawing labels

Color used to render the text.

Implementations§

Source§

impl Label

Source

pub fn new(text: impl Into<String>, bounds: Rect) -> Self

Create a new label with the provided text and bounds.

Source

pub fn set_font(&mut self, font: &'static dyn FontMetrics)

Assign the font used to render this label (FONT-00 §5).

Pass any process-lifetime FontMetrics — e.g. a PackedFont for anti-aliased text. With no assignment the label renders with the built-in FONT_6X10.

Source

pub fn resolved_font(&self) -> &'static dyn FontMetrics

Resolve this label’s font handle — the assigned font, or FONT_6X10.

Lets a containing widget (e.g. ui::Input/Textarea) draw extra text with the same font this label resolves, without duplicating the slot.

Source

pub fn set_text(&mut self, text: impl Into<String>)

Update the text displayed by the label.

Source

pub fn text(&self) -> &str

Retrieve the current label text.

Source

pub fn set_text_color(&mut self, color: Color)

Update text color for this label.

Prefer migrated TextStyle plumbing for future callers; this method is the compatibility path while upstream migration continues.

Source

pub fn text_color_with_alpha(&self, alpha: u8) -> Color

Return text color blended by widget alpha.

Prefer TextStyle plumbing for long-lived callers; this helper keeps existing widget implementations warning-free until migration completes.

Source

pub fn draw_with_font( &self, renderer: &mut dyn Renderer, font: &dyn FontMetrics, )

Draw this label using an explicit font metrics backend.

The shaped text path clips glyph coverage to the label bounds. The Widget::draw impl calls this with the set_font assignment resolved via WidgetFont (FONT-00 §5); callers may also invoke it directly with any &dyn FontMetrics.

Trait Implementations§

Source§

impl Widget for Label

Source§

fn bounds(&self) -> Rect

Return the area this widget occupies relative to its parent.
Source§

fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>

Expose this widget’s font slot for cascade-driven font resolution (FONT-05 §5.B). Read more
Source§

fn draw(&self, renderer: &mut dyn Renderer)

Render the widget using the provided Renderer.
Source§

fn handle_event(&mut self, _event: &Event) -> bool

Handle an event and return true if it was consumed. Read more
Source§

fn clear_region(&mut self) -> Option<Rect>

Return a region (in draw/landscape coordinates) that should be restored from the pristine background copy, or None. Read more
Source§

fn set_bounds(&mut self, _bounds: Rect)

Called by the LPAR-10 layout pass to notify this widget of its layout-computed bounds. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Label

§

impl !Send for Label

§

impl !Sync for Label

§

impl !UnwindSafe for Label

§

impl Freeze for Label

§

impl Unpin for Label

§

impl UnsafeUnpin for Label

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.