Add min_height and max_height to text_editor
This commit is contained in:
parent
fb87c97159
commit
6aab76e3a0
1 changed files with 26 additions and 4 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue