summaryrefslogtreecommitdiffstats
path: root/widget/src/text/rich.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-04 21:25:59 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-04 21:26:47 +0200
commitf98328f4f1ee58b6288e4f19d7475e7eeb9a7ba7 (patch)
tree8fb3e8b470bff711e0ca2f1bf120ab6c66ba9a9d /widget/src/text/rich.rs
parent8d826cc662554b337282e7c982383f5db428d7aa (diff)
downloadiced-f98328f4f1ee58b6288e4f19d7475e7eeb9a7ba7.tar.gz
iced-f98328f4f1ee58b6288e4f19d7475e7eeb9a7ba7.tar.bz2
iced-f98328f4f1ee58b6288e4f19d7475e7eeb9a7ba7.zip
Add `text::Wrapping` support
Co-authored-by: Neeraj Jaiswal <neerajj85@gmail.com>
Diffstat (limited to 'widget/src/text/rich.rs')
-rw-r--r--widget/src/text/rich.rs14
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 => {