diff options
author | 2024-09-04 21:42:11 +0200 | |
---|---|---|
committer | 2024-09-04 21:42:11 +0200 | |
commit | 6009420b57933ccf799f1b7eac8debab950cdd5e (patch) | |
tree | e6218826131a702e51adf3041a45871140bae0be /widget/src/text | |
parent | 8d826cc662554b337282e7c982383f5db428d7aa (diff) | |
parent | 3a70462a7232cc2b3a7cc3fe8d07f0c29cc578cc (diff) | |
download | iced-6009420b57933ccf799f1b7eac8debab950cdd5e.tar.gz iced-6009420b57933ccf799f1b7eac8debab950cdd5e.tar.bz2 iced-6009420b57933ccf799f1b7eac8debab950cdd5e.zip |
Merge pull request #2279 from nrjais/wrapping
Add `text::Wrapping` support
Diffstat (limited to 'widget/src/text')
-rw-r--r-- | widget/src/text/rich.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/widget/src/text/rich.rs b/widget/src/text/rich.rs index 1eb0d296..921c55a5 100644 --- a/widget/src/text/rich.rs +++ b/widget/src/text/rich.rs @@ -5,7 +5,7 @@ use crate::core::mouse; use crate::core::renderer; use crate::core::text::{Paragraph, Span}; use crate::core::widget::text::{ - self, Catalog, LineHeight, Shaping, Style, StyleFn, + self, Catalog, LineHeight, Shaping, Style, StyleFn, Wrapping, }; use crate::core::widget::tree::{self, Tree}; use crate::core::{ @@ -29,6 +29,7 @@ where font: Option<Renderer::Font>, align_x: alignment::Horizontal, align_y: alignment::Vertical, + wrapping: Wrapping, class: Theme::Class<'a>, } @@ -50,6 +51,7 @@ where font: None, align_x: alignment::Horizontal::Left, align_y: alignment::Vertical::Top, + wrapping: Wrapping::default(), class: Theme::default(), } } @@ -118,6 +120,12 @@ where self } + /// Sets the [`Wrapping`] strategy of the [`Rich`] text. + pub fn wrapping(mut self, wrapping: Wrapping) -> Self { + self.wrapping = wrapping; + self + } + /// Sets the default style of the [`Rich`] text. #[must_use] pub fn style(mut self, style: impl Fn(&Theme) -> Style + 'a) -> Self @@ -218,6 +226,7 @@ where self.font, self.align_x, self.align_y, + self.wrapping, ) } @@ -444,6 +453,7 @@ fn layout<Link, Renderer>( font: Option<Renderer::Font>, horizontal_alignment: alignment::Horizontal, vertical_alignment: alignment::Vertical, + wrapping: Wrapping, ) -> layout::Node where Link: Clone, @@ -464,6 +474,7 @@ where horizontal_alignment, vertical_alignment, shaping: Shaping::Advanced, + wrapping, }; if state.spans != spans { @@ -480,6 +491,7 @@ where horizontal_alignment, vertical_alignment, shaping: Shaping::Advanced, + wrapping, }) { core::text::Difference::None => {} core::text::Difference::Bounds => { |