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.
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§
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_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§
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§fn default() -> WidgetText
fn default() -> WidgetText
Source§impl From<&String> for WidgetText
impl From<&String> for WidgetText
Source§fn from(text: &String) -> WidgetText
fn from(text: &String) -> WidgetText
Source§impl From<&str> for WidgetText
impl From<&str> for WidgetText
Source§fn from(text: &str) -> WidgetText
fn from(text: &str) -> WidgetText
Source§impl From<LayoutJob> for WidgetText
impl From<LayoutJob> for WidgetText
Source§fn from(layout_job: LayoutJob) -> WidgetText
fn from(layout_job: LayoutJob) -> WidgetText
Source§impl From<RichText> for WidgetText
impl From<RichText> for WidgetText
Source§fn from(rich_text: RichText) -> WidgetText
fn from(rich_text: RichText) -> WidgetText
Source§impl From<String> for WidgetText
impl From<String> for WidgetText
Source§fn from(text: String) -> WidgetText
fn from(text: String) -> 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§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.