From 7b369842959511f17d5c27941fd0308484bff8ea Mon Sep 17 00:00:00 2001 From: Casper Storm Date: Mon, 13 Feb 2023 11:38:05 +0100 Subject: feat: added handle to text_input --- native/src/widget/text_input.rs | 119 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) (limited to 'native') diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index ee0473ea..7696da99 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -31,6 +31,47 @@ use crate::{ pub use iced_style::text_input::{Appearance, StyleSheet}; +/// The position of the [`Handle`]. +#[derive(Clone, Default, Debug)] +pub enum HandlePosition { + /// Position the handle to the left. + Left, + /// Position the handle to the left. + /// + /// This is the default. + #[default] + Right, +} + +/// The content of the [`Handle`]. +#[derive(Clone)] +pub struct Handle +where + Renderer: text::Renderer, +{ + /// Font that will be used to display the `text`. + pub font: Renderer::Font, + /// Text that will be shown. + pub text: String, + /// Font size of the content. + pub size: Option, + /// Position of the handle. + pub position: HandlePosition, +} + +impl std::fmt::Debug for Handle +where + Renderer: text::Renderer, +{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Handle") + .field("text", &self.text) + .field("size", &self.size) + .field("position", &self.position) + .finish() + } +} + /// A field that can be filled with text. /// /// # Example @@ -68,6 +109,7 @@ where on_change: Box Message + 'a>, on_paste: Option Message + 'a>>, on_submit: Option, + handle: Option>, style: ::Style, } @@ -99,6 +141,7 @@ where on_change: Box::new(on_change), on_paste: None, on_submit: None, + handle: None, style: Default::default(), } } @@ -132,6 +175,13 @@ where self.font = font; self } + + /// Sets the [`Handle`] of the [`TextInput`]. + pub fn handle(mut self, handle: Handle) -> Self { + self.handle = Some(handle); + self + } + /// Sets the width of the [`TextInput`]. pub fn width(mut self, width: impl Into) -> Self { self.width = width.into(); @@ -188,8 +238,10 @@ where value.unwrap_or(&self.value), &self.placeholder, self.size, + self.padding, &self.font, self.is_secure, + self.handle.as_ref(), &self.style, ) } @@ -286,8 +338,10 @@ where &self.value, &self.placeholder, self.size, + self.padding, &self.font, self.is_secure, + self.handle.as_ref(), &self.style, ) } @@ -812,8 +866,10 @@ pub fn draw( value: &Value, placeholder: &str, size: Option, + padding: Padding, font: &Renderer::Font, is_secure: bool, + handle: Option<&Handle>, style: &::Style, ) where Renderer: text::Renderer, @@ -823,7 +879,37 @@ pub fn draw( let value = secure_value.as_ref().unwrap_or(value); let bounds = layout.bounds(); - let text_bounds = layout.children().next().unwrap().bounds(); + let text_bounds = { + let bounds = layout.children().next().unwrap().bounds(); + if let Some(handle) = handle { + let Handle { + font, + size, + text, + position, + } = handle; + + let padding = f32::from(padding.horizontal()); + let size = size.unwrap_or_else(|| renderer.default_size()); + let width = + renderer.measure_width(text.as_str(), size, font.clone()); + + match position { + HandlePosition::Left => Rectangle { + x: bounds.x + (width + padding), + width: bounds.width - (width + padding), + ..bounds + }, + HandlePosition::Right => Rectangle { + x: bounds.x, + width: bounds.width - (width + padding), + ..bounds + }, + } + } else { + bounds + } + }; let is_mouse_over = bounds.contains(cursor_position); @@ -845,6 +931,37 @@ pub fn draw( appearance.background, ); + if let Some(handle) = handle { + let Handle { + size, + font, + text, + position, + } = handle; + + let padding = f32::from(padding.horizontal()); + let size = size.unwrap_or_else(|| renderer.default_size()); + let width = renderer.measure_width(text.as_str(), size, font.clone()); + + renderer.fill_text(Text { + content: text, + size: f32::from(size), + font: font.clone(), + color: appearance.handle_color, + bounds: Rectangle { + x: match position { + HandlePosition::Left => bounds.x + width + padding, + HandlePosition::Right => bounds.x + bounds.width - padding, + }, + y: bounds.center_y() - f32::from(size) / 2.0, + height: f32::from(size), + ..bounds + }, + horizontal_alignment: alignment::Horizontal::Right, + vertical_alignment: alignment::Vertical::Top, + }); + } + let text = value.to_string(); let size = size.unwrap_or_else(|| renderer.default_size()); -- cgit From d24a4a46895ed711ddfc3199a0445f0b69a812e4 Mon Sep 17 00:00:00 2001 From: Casper Storm Date: Thu, 16 Feb 2023 14:32:59 +0100 Subject: Changed `Handle` to `Icon` to be consistent --- native/src/widget/text_input.rs | 87 +++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 43 deletions(-) (limited to 'native') diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index 7696da99..575f4436 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -31,41 +31,38 @@ use crate::{ pub use iced_style::text_input::{Appearance, StyleSheet}; -/// The position of the [`Handle`]. +/// The position of the [`Icon`]. #[derive(Clone, Default, Debug)] -pub enum HandlePosition { - /// Position the handle to the left. +pub enum IconPosition { + /// Position the [`Icon`] to the left. Left, - /// Position the handle to the left. + /// Position the [`Icon`] to the left. /// /// This is the default. #[default] Right, } -/// The content of the [`Handle`]. +/// The content of the [`Icon`]. #[derive(Clone)] -pub struct Handle -where - Renderer: text::Renderer, -{ - /// Font that will be used to display the `text`. - pub font: Renderer::Font, - /// Text that will be shown. - pub text: String, +pub struct Icon { + /// Font that will be used to display the `code_point`. + pub font: Font, + /// The unicode code point that will be used as the icon. + pub code_point: char, /// Font size of the content. pub size: Option, - /// Position of the handle. - pub position: HandlePosition, + /// Position of the icon. + pub position: IconPosition, } -impl std::fmt::Debug for Handle +impl std::fmt::Debug for Icon where Renderer: text::Renderer, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("Handle") - .field("text", &self.text) + f.debug_struct("Icon") + .field("code_point", &self.code_point) .field("size", &self.size) .field("position", &self.position) .finish() @@ -109,7 +106,7 @@ where on_change: Box Message + 'a>, on_paste: Option Message + 'a>>, on_submit: Option, - handle: Option>, + icon: Option>, style: ::Style, } @@ -141,7 +138,7 @@ where on_change: Box::new(on_change), on_paste: None, on_submit: None, - handle: None, + icon: None, style: Default::default(), } } @@ -176,9 +173,9 @@ where self } - /// Sets the [`Handle`] of the [`TextInput`]. - pub fn handle(mut self, handle: Handle) -> Self { - self.handle = Some(handle); + /// Sets the [`Icon`] of the [`TextInput`]. + pub fn icon(mut self, icon: Icon) -> Self { + self.icon = Some(icon); self } @@ -241,7 +238,7 @@ where self.padding, &self.font, self.is_secure, - self.handle.as_ref(), + self.icon.as_ref(), &self.style, ) } @@ -341,7 +338,7 @@ where self.padding, &self.font, self.is_secure, - self.handle.as_ref(), + self.icon.as_ref(), &self.style, ) } @@ -869,7 +866,7 @@ pub fn draw( padding: Padding, font: &Renderer::Font, is_secure: bool, - handle: Option<&Handle>, + icon: Option<&Icon>, style: &::Style, ) where Renderer: text::Renderer, @@ -881,26 +878,29 @@ pub fn draw( let bounds = layout.bounds(); let text_bounds = { let bounds = layout.children().next().unwrap().bounds(); - if let Some(handle) = handle { - let Handle { + if let Some(icon) = icon { + let Icon { font, size, - text, + code_point, position, - } = handle; + } = icon; let padding = f32::from(padding.horizontal()); let size = size.unwrap_or_else(|| renderer.default_size()); - let width = - renderer.measure_width(text.as_str(), size, font.clone()); + let width = renderer.measure_width( + &code_point.to_string(), + size, + font.clone(), + ); match position { - HandlePosition::Left => Rectangle { + IconPosition::Left => Rectangle { x: bounds.x + (width + padding), width: bounds.width - (width + padding), ..bounds }, - HandlePosition::Right => Rectangle { + IconPosition::Right => Rectangle { x: bounds.x, width: bounds.width - (width + padding), ..bounds @@ -931,27 +931,28 @@ pub fn draw( appearance.background, ); - if let Some(handle) = handle { - let Handle { + if let Some(icon) = icon { + let Icon { size, font, - text, + code_point, position, - } = handle; + } = icon; let padding = f32::from(padding.horizontal()); let size = size.unwrap_or_else(|| renderer.default_size()); - let width = renderer.measure_width(text.as_str(), size, font.clone()); + let width = + renderer.measure_width(&code_point.to_string(), size, font.clone()); renderer.fill_text(Text { - content: text, + content: &code_point.to_string(), size: f32::from(size), font: font.clone(), - color: appearance.handle_color, + color: appearance.icon_color, bounds: Rectangle { x: match position { - HandlePosition::Left => bounds.x + width + padding, - HandlePosition::Right => bounds.x + bounds.width - padding, + IconPosition::Left => bounds.x + width + padding, + IconPosition::Right => bounds.x + bounds.width - padding, }, y: bounds.center_y() - f32::from(size) / 2.0, height: f32::from(size), -- cgit From 0e2fc99eb864800d2d1522c015054d84cad078f4 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 11 Apr 2023 05:13:56 +0200 Subject: Use `f32` for `Icon::size` and remove unnecessary conversions --- native/src/widget/text_input.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'native') diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index 575f4436..95e3b720 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -51,7 +51,7 @@ pub struct Icon { /// The unicode code point that will be used as the icon. pub code_point: char, /// Font size of the content. - pub size: Option, + pub size: Option, /// Position of the icon. pub position: IconPosition, } @@ -886,7 +886,7 @@ pub fn draw( position, } = icon; - let padding = f32::from(padding.horizontal()); + let padding = padding.horizontal(); let size = size.unwrap_or_else(|| renderer.default_size()); let width = renderer.measure_width( &code_point.to_string(), @@ -939,14 +939,14 @@ pub fn draw( position, } = icon; - let padding = f32::from(padding.horizontal()); + let padding = padding.horizontal(); let size = size.unwrap_or_else(|| renderer.default_size()); let width = renderer.measure_width(&code_point.to_string(), size, font.clone()); renderer.fill_text(Text { content: &code_point.to_string(), - size: f32::from(size), + size, font: font.clone(), color: appearance.icon_color, bounds: Rectangle { @@ -954,8 +954,8 @@ pub fn draw( IconPosition::Left => bounds.x + width + padding, IconPosition::Right => bounds.x + bounds.width - padding, }, - y: bounds.center_y() - f32::from(size) / 2.0, - height: f32::from(size), + y: bounds.center_y() - size / 2.0, + height: size, ..bounds }, horizontal_alignment: alignment::Horizontal::Right, -- cgit From 9852b4b36442ef036f0b308f798e892ddaa06c2d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 11 Apr 2023 05:45:55 +0200 Subject: Move `Icon` layout logic to `layout` in `text_input` Also add `Icon::spacing` field. --- native/src/widget/text_input.rs | 129 ++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 65 deletions(-) (limited to 'native') diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index 95e3b720..f331f05a 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -52,6 +52,8 @@ pub struct Icon { pub code_point: char, /// Font size of the content. pub size: Option, + /// The spacing between the [`Icon`] and the text in a [`TextInput`]. + pub spacing: f32, /// Position of the icon. pub position: IconPosition, } @@ -235,7 +237,6 @@ where value.unwrap_or(&self.value), &self.placeholder, self.size, - self.padding, &self.font, self.is_secure, self.icon.as_ref(), @@ -272,7 +273,14 @@ where renderer: &Renderer, limits: &layout::Limits, ) -> layout::Node { - layout(renderer, limits, self.width, self.padding, self.size) + layout( + renderer, + limits, + self.width, + self.padding, + self.size, + self.icon.as_ref(), + ) } fn operate( @@ -335,7 +343,6 @@ where &self.value, &self.placeholder, self.size, - self.padding, &self.font, self.is_secure, self.icon.as_ref(), @@ -431,6 +438,7 @@ pub fn layout( width: Length, padding: Padding, size: Option, + icon: Option<&Icon>, ) -> layout::Node where Renderer: text::Renderer, @@ -440,10 +448,51 @@ where let padding = padding.fit(Size::ZERO, limits.max()); let limits = limits.width(width).pad(padding).height(text_size); - let mut text = layout::Node::new(limits.resolve(Size::ZERO)); - text.move_to(Point::new(padding.left, padding.top)); + let text_bounds = limits.resolve(Size::ZERO); + + if let Some(icon) = icon { + let icon_width = renderer.measure_width( + &icon.code_point.to_string(), + icon.size.unwrap_or_else(|| renderer.default_size()), + icon.font.clone(), + ); + + let mut text_node = layout::Node::new( + text_bounds - Size::new(icon_width + icon.spacing, 0.0), + ); + + let mut icon_node = + layout::Node::new(Size::new(icon_width, text_bounds.height)); + + match icon.position { + IconPosition::Left => { + text_node.move_to(Point::new( + padding.left + icon_width + icon.spacing, + padding.top, + )); + + icon_node.move_to(Point::new(padding.left, padding.top)); + } + IconPosition::Right => { + text_node.move_to(Point::new(padding.left, padding.top)); + + icon_node.move_to(Point::new( + padding.left + text_bounds.width - icon_width, + padding.top, + )); + } + }; + + layout::Node::with_children( + text_bounds.pad(padding), + vec![text_node, icon_node], + ) + } else { + let mut text = layout::Node::new(text_bounds); + text.move_to(Point::new(padding.left, padding.top)); - layout::Node::with_children(text.size().pad(padding), vec![text]) + layout::Node::with_children(text.size().pad(padding), vec![text]) + } } /// Processes an [`Event`] and updates the [`State`] of a [`TextInput`] @@ -863,7 +912,6 @@ pub fn draw( value: &Value, placeholder: &str, size: Option, - padding: Padding, font: &Renderer::Font, is_secure: bool, icon: Option<&Icon>, @@ -876,40 +924,9 @@ pub fn draw( let value = secure_value.as_ref().unwrap_or(value); let bounds = layout.bounds(); - let text_bounds = { - let bounds = layout.children().next().unwrap().bounds(); - if let Some(icon) = icon { - let Icon { - font, - size, - code_point, - position, - } = icon; - - let padding = padding.horizontal(); - let size = size.unwrap_or_else(|| renderer.default_size()); - let width = renderer.measure_width( - &code_point.to_string(), - size, - font.clone(), - ); - - match position { - IconPosition::Left => Rectangle { - x: bounds.x + (width + padding), - width: bounds.width - (width + padding), - ..bounds - }, - IconPosition::Right => Rectangle { - x: bounds.x, - width: bounds.width - (width + padding), - ..bounds - }, - } - } else { - bounds - } - }; + + let mut children_layout = layout.children(); + let text_bounds = children_layout.next().unwrap().bounds(); let is_mouse_over = bounds.contains(cursor_position); @@ -932,33 +949,15 @@ pub fn draw( ); if let Some(icon) = icon { - let Icon { - size, - font, - code_point, - position, - } = icon; - - let padding = padding.horizontal(); - let size = size.unwrap_or_else(|| renderer.default_size()); - let width = - renderer.measure_width(&code_point.to_string(), size, font.clone()); + let icon_layout = children_layout.next().unwrap(); renderer.fill_text(Text { - content: &code_point.to_string(), - size, - font: font.clone(), + content: &icon.code_point.to_string(), + size: icon.size.unwrap_or_else(|| renderer.default_size()), + font: icon.font.clone(), color: appearance.icon_color, - bounds: Rectangle { - x: match position { - IconPosition::Left => bounds.x + width + padding, - IconPosition::Right => bounds.x + bounds.width - padding, - }, - y: bounds.center_y() - size / 2.0, - height: size, - ..bounds - }, - horizontal_alignment: alignment::Horizontal::Right, + bounds: icon_layout.bounds(), + horizontal_alignment: alignment::Horizontal::Left, vertical_alignment: alignment::Vertical::Top, }); } -- cgit From 870b2fe513bd5b3fbcf3ba369afb14d68324aaa2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 11 Apr 2023 05:48:12 +0200 Subject: Derive `Debug` for `text_input::Icon` --- native/src/widget/text_input.rs | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'native') diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index f331f05a..a7fdcb1c 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -32,19 +32,16 @@ use crate::{ pub use iced_style::text_input::{Appearance, StyleSheet}; /// The position of the [`Icon`]. -#[derive(Clone, Default, Debug)] +#[derive(Debug, Clone)] pub enum IconPosition { /// Position the [`Icon`] to the left. Left, - /// Position the [`Icon`] to the left. - /// - /// This is the default. - #[default] + /// Position the [`Icon`] to the right. Right, } /// The content of the [`Icon`]. -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct Icon { /// Font that will be used to display the `code_point`. pub font: Font, @@ -58,19 +55,6 @@ pub struct Icon { pub position: IconPosition, } -impl std::fmt::Debug for Icon -where - Renderer: text::Renderer, -{ - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("Icon") - .field("code_point", &self.code_point) - .field("size", &self.size) - .field("position", &self.position) - .finish() - } -} - /// A field that can be filled with text. /// /// # Example -- cgit From 57265ff211e8d040dce2a13e71409bdd6482204c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 11 Apr 2023 05:53:22 +0200 Subject: Move `Icon` definitions after `Widget` implementation --- native/src/widget/checkbox.rs | 22 +++++++++---------- native/src/widget/text_input.rs | 48 ++++++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 35 deletions(-) (limited to 'native') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 9b69e574..ad05a8e7 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -14,17 +14,6 @@ use crate::{ pub use iced_style::checkbox::{Appearance, StyleSheet}; -/// The icon in a [`Checkbox`]. -#[derive(Debug, Clone, PartialEq)] -pub struct Icon { - /// Font that will be used to display the `code_point`, - pub font: Font, - /// The unicode code point that will be used as the icon. - pub code_point: char, - /// Font size of the content. - pub size: Option, -} - /// A box that can be checked. /// /// # Example @@ -319,3 +308,14 @@ where Element::new(checkbox) } } + +/// The icon in a [`Checkbox`]. +#[derive(Debug, Clone, PartialEq)] +pub struct Icon { + /// Font that will be used to display the `code_point`, + pub font: Font, + /// The unicode code point that will be used as the icon. + pub code_point: char, + /// Font size of the content. + pub size: Option, +} diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index a7fdcb1c..c43b735c 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -31,30 +31,6 @@ use crate::{ pub use iced_style::text_input::{Appearance, StyleSheet}; -/// The position of the [`Icon`]. -#[derive(Debug, Clone)] -pub enum IconPosition { - /// Position the [`Icon`] to the left. - Left, - /// Position the [`Icon`] to the right. - Right, -} - -/// The content of the [`Icon`]. -#[derive(Debug, Clone)] -pub struct Icon { - /// Font that will be used to display the `code_point`. - pub font: Font, - /// The unicode code point that will be used as the icon. - pub code_point: char, - /// Font size of the content. - pub size: Option, - /// The spacing between the [`Icon`] and the text in a [`TextInput`]. - pub spacing: f32, - /// Position of the icon. - pub position: IconPosition, -} - /// A field that can be filled with text. /// /// # Example @@ -360,6 +336,30 @@ where } } +/// The content of the [`Icon`]. +#[derive(Debug, Clone)] +pub struct Icon { + /// The font that will be used to display the `code_point`. + pub font: Font, + /// The unicode code point that will be used as the icon. + pub code_point: char, + /// The font size of the content. + pub size: Option, + /// The spacing between the [`Icon`] and the text in a [`TextInput`]. + pub spacing: f32, + /// The position of the icon. + pub position: IconPosition, +} + +/// The position of an [`Icon`]. +#[derive(Debug, Clone)] +pub enum IconPosition { + /// Position the [`Icon`] on the left side of a [`TextInput`]. + Left, + /// Position the [`Icon`] on the right side of a [`TextInput`]. + Right, +} + /// The identifier of a [`TextInput`]. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Id(widget::Id); -- cgit From cf9d8e01048845ee503a62eb55e634a76a0e9163 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 11 Apr 2023 05:54:51 +0200 Subject: Rename `IconPosition` to `Side` in `text_input` --- native/src/widget/text_input.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'native') diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index c43b735c..bb397645 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -347,16 +347,16 @@ pub struct Icon { pub size: Option, /// The spacing between the [`Icon`] and the text in a [`TextInput`]. pub spacing: f32, - /// The position of the icon. - pub position: IconPosition, + /// The side of a [`TextInput`] where to display the [`Icon`]. + pub side: Side, } -/// The position of an [`Icon`]. +/// The side of a [`TextInput`]. #[derive(Debug, Clone)] -pub enum IconPosition { - /// Position the [`Icon`] on the left side of a [`TextInput`]. +pub enum Side { + /// The left side of a [`TextInput`]. Left, - /// Position the [`Icon`] on the right side of a [`TextInput`]. + /// The right side of a [`TextInput`]. Right, } @@ -448,8 +448,8 @@ where let mut icon_node = layout::Node::new(Size::new(icon_width, text_bounds.height)); - match icon.position { - IconPosition::Left => { + match icon.side { + Side::Left => { text_node.move_to(Point::new( padding.left + icon_width + icon.spacing, padding.top, @@ -457,7 +457,7 @@ where icon_node.move_to(Point::new(padding.left, padding.top)); } - IconPosition::Right => { + Side::Right => { text_node.move_to(Point::new(padding.left, padding.top)); icon_node.move_to(Point::new( -- cgit From 927c3a8caaefc241c48d6200266d286e20dc2076 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 11 Apr 2023 05:59:08 +0200 Subject: Reuse `text_bounds` in `text_input::layout` --- native/src/widget/text_input.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'native') diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index bb397645..fd61a849 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -475,7 +475,7 @@ where let mut text = layout::Node::new(text_bounds); text.move_to(Point::new(padding.left, padding.top)); - layout::Node::with_children(text.size().pad(padding), vec![text]) + layout::Node::with_children(text_bounds.pad(padding), vec![text]) } } -- cgit