pub struct Label {
pub style: Style,
pub text_color: Color,
/* private fields */
}Expand description
Simple text element.
Fields§
§style: StyleVisual style of the label background.
text_color: Coloruse the resolved TextStyle text_color cascade when drawing labels
Color used to render the text.
Implementations§
Source§impl Label
impl Label
Sourcepub fn new(text: impl Into<String>, bounds: Rect) -> Self
pub fn new(text: impl Into<String>, bounds: Rect) -> Self
Create a new label with the provided text and bounds.
Sourcepub fn set_font(&mut self, font: &'static dyn FontMetrics)
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.
Sourcepub fn resolved_font(&self) -> &'static dyn FontMetrics
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.
Sourcepub fn set_text_color(&mut self, color: Color)
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.
Sourcepub fn text_color_with_alpha(&self, alpha: u8) -> Color
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.
Sourcepub fn draw_with_font(
&self,
renderer: &mut dyn Renderer,
font: &dyn FontMetrics,
)
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
impl Widget for Label
Source§fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>
fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>
Source§fn handle_event(&mut self, _event: &Event) -> bool
fn handle_event(&mut self, _event: &Event) -> bool
true if it was consumed. Read moreSource§fn clear_region(&mut self) -> Option<Rect>
fn clear_region(&mut self) -> Option<Rect>
None. Read more