pub struct RichText {
pub spans: Vec<TextSpan>,
pub wrap: WrapMode,
pub max_width: Option<f32>,
}Expand description
Ordered spans plus wrap and optional logical-pixel width constraints.
None means unbounded width. An empty span list draws nothing.
§Examples
use ailloli_ui_core::{Color, FontId, TextStyle};
use ailloli_ui_widgets::text::{RichText, WrapMode};
let rich = RichText::plain("hello", TextStyle::new(FontId::Ui, 14, Color::WHITE));
assert_eq!(rich.spans.len(), 1);
assert_eq!(rich.wrap, WrapMode::NoWrap);
assert_eq!(rich.max_width, None);Fields§
§spans: Vec<TextSpan>Ordered owned fragments; the first also supplies the rendered style.
wrap: WrapModeLine-breaking policy applied to the concatenated text.
max_width: Option<f32>Optional maximum line width in logical pixels, passed through unchanged.
Implementations§
Source§impl RichText
impl RichText
Sourcepub fn plain(text: impl Into<String>, style: TextStyle) -> Self
pub fn plain(text: impl Into<String>, style: TextStyle) -> Self
Creates one unwrapped span with no maximum width.
§Examples
use ailloli_ui_core::{Color, FontId, TextStyle};
use ailloli_ui_widgets::text::RichText;
let rich = RichText::plain("hello", TextStyle::new(FontId::Ui, 14, Color::WHITE));
assert_eq!(rich.spans[0].text, "hello");Trait Implementations§
Auto Trait Implementations§
impl Freeze for RichText
impl RefUnwindSafe for RichText
impl Send for RichText
impl Sync for RichText
impl Unpin for RichText
impl UnwindSafe for RichText
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.