diff options
author | 2025-01-30 03:45:14 +0100 | |
---|---|---|
committer | 2025-01-30 03:45:14 +0100 | |
commit | 6aab76e3a0ce219a950f7214cd2ab68171c5df00 (patch) | |
tree | 98cbd3c74bf4a00b236adef9056ec99937424aeb /widget | |
parent | fb87c971591042228c6ba5286e9d2efaf9852517 (diff) | |
download | iced-6aab76e3a0ce219a950f7214cd2ab68171c5df00.tar.gz iced-6aab76e3a0ce219a950f7214cd2ab68171c5df00.tar.bz2 iced-6aab76e3a0ce219a950f7214cd2ab68171c5df00.zip |
Add `min_height` and `max_height` to `text_editor`
Diffstat (limited to 'widget')
-rw-r--r-- | widget/src/text_editor.rs | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index 502b5de9..f1ec589b 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -110,6 +110,8 @@ pub struct TextEditor< line_height: LineHeight, width: Length, height: Length, + min_height: f32, + max_height: f32, padding: Padding, wrapping: Wrapping, class: Theme::Class<'a>, @@ -139,6 +141,8 @@ where line_height: LineHeight::default(), width: Length::Fill, height: Length::Shrink, + min_height: 0.0, + max_height: f32::INFINITY, padding: Padding::new(5.0), wrapping: Wrapping::default(), class: Theme::default(), @@ -169,15 +173,27 @@ where self } + /// Sets the width of the [`TextEditor`]. + pub fn width(mut self, width: impl Into<Pixels>) -> Self { + self.width = Length::from(width.into()); + self + } + /// Sets the height of the [`TextEditor`]. pub fn height(mut self, height: impl Into<Length>) -> Self { self.height = height.into(); self } - /// Sets the width of the [`TextEditor`]. - pub fn width(mut self, width: impl Into<Pixels>) -> Self { - self.width = Length::from(width.into()); + /// Sets the minimum height of the [`TextEditor`]. + pub fn min_height(mut self, min_height: impl Into<Pixels>) -> Self { + self.min_height = min_height.into().0; + self + } + + /// Sets the maximum height of the [`TextEditor`]. + pub fn max_height(mut self, max_height: impl Into<Pixels>) -> Self { + self.max_height = max_height.into().0; self } @@ -265,6 +281,8 @@ where line_height: self.line_height, width: self.width, height: self.height, + min_height: self.min_height, + max_height: self.max_height, padding: self.padding, wrapping: self.wrapping, class: self.class, @@ -549,7 +567,11 @@ where state.highlighter_settings = self.highlighter_settings.clone(); } - let limits = limits.width(self.width).height(self.height); + let limits = limits + .width(self.width) + .height(self.height) + .min_height(self.min_height) + .max_height(self.max_height); internal.editor.update( limits.shrink(self.padding).max(), |