pub enum WidgetText {
    RichText(RichText),
    LayoutJob(LayoutJob),
    Galley(Arc<Galley>),
}
Expand description

This is how you specify text for a widget.

A lot of widgets use impl Into<WidgetText> as an argument, allowing you to pass in String, RichText, LayoutJob, and more.

Often a WidgetText is just a simple String, but it can be a RichText (text with color, style, etc), a LayoutJob (for when you want full control of how the text looks) or text that has already been layed out in a Galley.

Variants

RichText(RichText)

LayoutJob(LayoutJob)

Use this LayoutJob when laying out the text.

Only LayoutJob::text and LayoutJob::sections are guaranteed to be respected.

TextWrapping::max_width, LayoutJob::halign, LayoutJob::justify and LayoutJob::first_row_min_height will likely be determined by the crate::Layout of the Ui the widget is placed in. If you want all parts of the LayoutJob respected, then convert it to a Galley and use Self::Galley instead.

Galley(Arc<Galley>)

Use exactly this galley when painting the text.

Implementations

Override the TextStyle if, and only if, this is a RichText.

Prefer using RichText directly!

Set the TextStyle unless it has already been set

Prefer using RichText directly!

Override text color if, and only if, this is a RichText.

Prefer using RichText directly!

Prefer using RichText directly!

Prefer using RichText directly!

Prefer using RichText directly!

Prefer using RichText directly!

Prefer using RichText directly!

Prefer using RichText directly!

Prefer using RichText directly!

Prefer using RichText directly!

Prefer using RichText directly!

Prefer using RichText directly!

Prefer using RichText directly!

Prefer using RichText directly!

Layout with wrap mode based on the containing Ui.

wrap: override for Ui::wrap_text.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.