GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
feat: per-widget TextBox line-wrap override (with_line_wrap)
Flowed-text consumers (an email compose body) can keep wrapping even when
the user's config turns multiline wrap off DE-wide; None still defers to
the global textbox_line_wrap() style.
Co-Authored-By: Claude Fable 5 <[email protected]>
src/widget/input/text_box.rs | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/widget/input/text_box.rs b/src/widget/input/text_box.rs
index d61fc9d..ca8930f 100644
--- a/src/widget/input/text_box.rs
+++ b/src/widget/input/text_box.rs
@@ -62,6 +62,10 @@ pub struct TextBox {
pub width: Option<f32>,
pub is_password: bool,
pub multiline: bool,
+ /// Per-widget wrap override; `None` defers to the global `textbox_line_wrap()`
+ /// style. Flowed-text consumers (an email body) set this to keep wrapping even
+ /// when the user's config turns multiline wrap off DE-wide.
+ pub line_wrap_override: Option<bool>,
pub draw_bg_border: bool,
pub text_color: Option<[u8; 3]>,
pub font_size: f32,
@@ -108,6 +112,7 @@ impl TextBox {
width: None,
is_password: false,
multiline: false,
+ line_wrap_override: None,
draw_bg_border: true,
text_color: None,
font_size: style_size,
@@ -302,7 +307,7 @@ impl TextBox {
}
pub fn line_wrap_enabled(&self) -> bool {
- self.multiline && crate::layout::textbox_line_wrap()
+ self.multiline && self.line_wrap_override.unwrap_or_else(crate::layout::textbox_line_wrap)
}
pub fn set_max_width(&mut self, max_w: Option<f32>) {
@@ -1015,6 +1020,11 @@ impl Adapted<TextBox> {
self
}
+ pub fn with_line_wrap(mut self, wrap: bool) -> Self {
+ self.line_wrap_override = Some(wrap);
+ self
+ }
+
pub fn with_draw_bg_border(mut self, draw: bool) -> Self {
self.draw_bg_border = draw;
self