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 laid out in a Galley.
You can color the text however you want, or use Color32::PLACEHOLDER
which will be replaced with a color chosen by the widget that paints the text.
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.
You can color the text however you want, or use Color32::PLACEHOLDER
which will be replaced with a color chosen by the widget that paints the text.
Galley(Arc<Galley>)
Use exactly this galley when painting the text.
You can color the text however you want, or use Color32::PLACEHOLDER
which will be replaced with a color chosen by the widget that paints the text.
Implementations§
Source§impl WidgetText
impl WidgetText
pub fn is_empty(&self) -> bool
pub fn text(&self) -> &str
Sourcepub fn text_style(self, text_style: TextStyle) -> WidgetText
pub fn text_style(self, text_style: TextStyle) -> WidgetText
Sourcepub fn fallback_text_style(self, text_style: TextStyle) -> WidgetText
pub fn fallback_text_style(self, text_style: TextStyle) -> WidgetText
Sourcepub fn color(self, color: impl Into<Color32>) -> WidgetText
pub fn color(self, color: impl Into<Color32>) -> WidgetText
Sourcepub fn heading(self) -> WidgetText
pub fn heading(self) -> WidgetText
Prefer using RichText directly!
Sourcepub fn monospace(self) -> WidgetText
pub fn monospace(self) -> WidgetText
Prefer using RichText directly!
Sourcepub fn code(self) -> WidgetText
pub fn code(self) -> WidgetText
Prefer using RichText directly!
Sourcepub fn strong(self) -> WidgetText
pub fn strong(self) -> WidgetText
Prefer using RichText directly!
Sourcepub fn weak(self) -> WidgetText
pub fn weak(self) -> WidgetText
Prefer using RichText directly!
Sourcepub fn underline(self) -> WidgetText
pub fn underline(self) -> WidgetText
Prefer using RichText directly!
Sourcepub fn strikethrough(self) -> WidgetText
pub fn strikethrough(self) -> WidgetText
Prefer using RichText directly!
Sourcepub fn italics(self) -> WidgetText
pub fn italics(self) -> WidgetText
Prefer using RichText directly!
Sourcepub fn small(self) -> WidgetText
pub fn small(self) -> WidgetText
Prefer using RichText directly!
Sourcepub fn small_raised(self) -> WidgetText
pub fn small_raised(self) -> WidgetText
Prefer using RichText directly!
Sourcepub fn raised(self) -> WidgetText
pub fn raised(self) -> WidgetText
Prefer using RichText directly!
Sourcepub fn background_color(
self,
background_color: impl Into<Color32>,
) -> WidgetText
pub fn background_color( self, background_color: impl Into<Color32>, ) -> WidgetText
Prefer using RichText directly!
pub fn into_layout_job( self, style: &Style, fallback_font: FontSelection, default_valign: Align, ) -> LayoutJob
Sourcepub fn into_galley(
self,
ui: &Ui,
wrap_mode: Option<TextWrapMode>,
available_width: f32,
fallback_font: impl Into<FontSelection>,
) -> Arc<Galley> ⓘ
pub fn into_galley( self, ui: &Ui, wrap_mode: Option<TextWrapMode>, available_width: f32, fallback_font: impl Into<FontSelection>, ) -> Arc<Galley> ⓘ
Layout with wrap mode based on the containing Ui.
wrap_mode: override for Ui::wrap_mode
pub fn into_galley_impl( self, ctx: &Context, style: &Style, text_wrapping: TextWrapping, fallback_font: FontSelection, default_valign: Align, ) -> Arc<Galley> ⓘ
Trait Implementations§
Source§impl Clone for WidgetText
impl Clone for WidgetText
Source§fn clone(&self) -> WidgetText
fn clone(&self) -> WidgetText
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more