Enum egui::widget_text::WidgetText
source · 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) -> Self
pub fn text_style(self, text_style: TextStyle) -> Self
sourcepub fn fallback_text_style(self, text_style: TextStyle) -> Self
pub fn fallback_text_style(self, text_style: TextStyle) -> Self
sourcepub fn strikethrough(self) -> Self
pub fn strikethrough(self) -> Self
Prefer using RichText
directly!
sourcepub fn small_raised(self) -> Self
pub fn small_raised(self) -> Self
Prefer using RichText
directly!
sourcepub fn background_color(self, background_color: impl Into<Color32>) -> Self
pub fn background_color(self, background_color: impl Into<Color32>) -> Self
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: Option<bool>,
available_width: f32,
fallback_font: impl Into<FontSelection>
) -> Arc<Galley>
pub fn into_galley( self, ui: &Ui, wrap: Option<bool>, available_width: f32, fallback_font: impl Into<FontSelection> ) -> Arc<Galley>
Layout with wrap mode based on the containing Ui
.
wrap: override for Ui::wrap_text
.
pub fn into_galley_impl( self, ctx: &Context, style: &Style, wrap: bool, available_width: f32, 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 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more