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(crate) fn font_height(&self, fonts: &Fonts, style: &Style) -> f32
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 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Default for WidgetText
impl Default for WidgetText
source§impl From<&String> for WidgetText
impl From<&String> for WidgetText
source§impl From<&str> for WidgetText
impl From<&str> for WidgetText
source§impl From<LayoutJob> for WidgetText
impl From<LayoutJob> for WidgetText
source§impl From<RichText> for WidgetText
impl From<RichText> for WidgetText
Auto Trait Implementations§
impl Freeze for WidgetText
impl RefUnwindSafe for WidgetText
impl Send for WidgetText
impl Sync for WidgetText
impl Unpin for WidgetText
impl UnwindSafe for WidgetText
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)