pub struct Text { /* private fields */ }Expand description
A text label with newline handling, kerning, and optional character wrapping.
The family is independent of size and weight: Text::monospace sets the text in the
code font on a fixed cell grid, Text::tabular_numbers gives proportional text digits
of equal width. Both are separate from Text::wrap, which stays on by default; call
wrap(false) for code and columns so lines are never broken, only clipped by the parent.
Implementations§
Source§impl Text
impl Text
pub fn new(text: impl Into<String>) -> Self
pub fn style(self, style: TextStyle) -> Self
pub fn typography(self, role: TypographyRole) -> Self
pub fn size(self, size: f32) -> Self
Sourcepub fn weight(self, weight: FontWeight) -> Self
pub fn weight(self, weight: FontWeight) -> Self
The font file weight for this text; overrides the style and the role.
Sourcepub fn monospace(self) -> Self
pub fn monospace(self) -> Self
Set the text in the monospace family (bundled JetBrains Mono by default). Overrides
the style and the role; see Ui::monospace_metrics for the cell size.
Sourcepub fn family(self, family: TextFamily) -> Self
pub fn family(self, family: TextFamily) -> Self
The font family of this text; overrides the style and the role.
Sourcepub fn tabular_numbers(self, tabular: bool) -> Self
pub fn tabular_numbers(self, tabular: bool) -> Self
Tabular figures: every digit has the width of the widest one, so numbers in a column
line up. Uses the font’s OpenType tnum feature; a font without it (or the monospace
family, which is already tabular) renders unchanged. Never fakes alignment by padding.
Sourcepub fn tab_size(self, cells: u16) -> Self
pub fn tab_size(self, cells: u16) -> Self
Width of a tab character in cells (space advances), at least 1; default 8.
pub fn muted(self) -> Self
pub fn color(self, color: Color) -> Self
pub fn wrap(self, wrap: bool) -> Self
Trait Implementations§
Source§impl Widget for Text
impl Widget for Text
fn ui(self, ui: &mut Ui<'_>) -> Response
Source§fn tooltip(self, text: impl Into<String>) -> TooltipWidget<Self>where
Self: Sized,
fn tooltip(self, text: impl Into<String>) -> TooltipWidget<Self>where
Self: Sized,
ui.add(Button::new("Save").tooltip("Write the file")).Response::menu_selected on the pass it is picked.Source§fn accessible_label(self, label: impl Into<String>) -> Accessible<Self>where
Self: Sized,
fn accessible_label(self, label: impl Into<String>) -> Accessible<Self>where
Self: Sized,
Source§fn accessible_description(
self,
description: impl Into<String>,
) -> Accessible<Self>where
Self: Sized,
fn accessible_description(
self,
description: impl Into<String>,
) -> Accessible<Self>where
Self: Sized,
Source§fn accessible_role(self, role: AccessRole) -> Accessible<Self>where
Self: Sized,
fn accessible_role(self, role: AccessRole) -> Accessible<Self>where
Self: Sized,
role. A custom widget that does
not describe itself becomes a node of this role with the response’s bounds.Auto Trait Implementations§
impl Freeze for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnsafeUnpin for Text
impl UnwindSafe for Text
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.