Enum egui::WidgetText
source · [−]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
sourceimpl 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_text_job(
self,
style: &Style,
fallback_font: FontSelection,
default_valign: Align
) -> WidgetTextJob
sourcepub fn into_galley(
self,
ui: &Ui,
wrap: Option<bool>,
available_width: f32,
fallback_font: impl Into<FontSelection>
) -> WidgetTextGalley
pub fn into_galley(
self,
ui: &Ui,
wrap: Option<bool>,
available_width: f32,
fallback_font: impl Into<FontSelection>
) -> WidgetTextGalley
Layout with wrap mode based on the containing Ui
.
wrap: override for Ui::wrap_text
.
Trait Implementations
sourceimpl Clone for WidgetText
impl Clone for WidgetText
sourcefn clone(&self) -> WidgetText
fn clone(&self) -> WidgetText
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Default for WidgetText
impl Default for WidgetText
sourceimpl From<&'_ String> for WidgetText
impl From<&'_ String> for WidgetText
sourceimpl From<&'_ str> for WidgetText
impl From<&'_ str> for WidgetText
sourceimpl From<Arc<Galley>> for WidgetText
impl From<Arc<Galley>> for WidgetText
sourceimpl From<LayoutJob> for WidgetText
impl From<LayoutJob> for WidgetText
sourceimpl From<RichText> for WidgetText
impl From<RichText> for WidgetText
Auto Trait Implementations
impl RefUnwindSafe for WidgetText
impl Send for WidgetText
impl Sync for WidgetText
impl Unpin for WidgetText
impl UnwindSafe for WidgetText
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more