From 23370296024fc30b8721902955867c2fdab88832 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 13 Nov 2019 07:34:07 +0100 Subject: Remove default styling of `Button` - A background will only show if explicitly set. - `iced_wgpu` won't apply a `min_width` of 100 units anymore. --- core/src/widget/button.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core') diff --git a/core/src/widget/button.rs b/core/src/widget/button.rs index 9cf20071..e7961284 100644 --- a/core/src/widget/button.rs +++ b/core/src/widget/button.rs @@ -19,6 +19,8 @@ pub struct Button<'a, Message, Element> { pub width: Length, + pub min_width: u32, + pub padding: u16, pub background: Option, @@ -52,6 +54,7 @@ impl<'a, Message, Element> Button<'a, Message, Element> { content: content.into(), on_press: None, width: Length::Shrink, + min_width: 0, padding: 0, background: None, border_radius: 0, @@ -66,6 +69,11 @@ impl<'a, Message, Element> Button<'a, Message, Element> { self } + pub fn min_width(mut self, min_width: u32) -> Self { + self.min_width = min_width; + self + } + pub fn padding(mut self, padding: u16) -> Self { self.padding = padding; self -- cgit From 657e513651b4153268e06074ccc8ac91078ffe69 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 13 Nov 2019 07:38:06 +0100 Subject: Implement `text_input::State::focused` --- core/src/widget/text_input.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'core') diff --git a/core/src/widget/text_input.rs b/core/src/widget/text_input.rs index 9c7f4bc8..c4ca0abc 100644 --- a/core/src/widget/text_input.rs +++ b/core/src/widget/text_input.rs @@ -91,6 +91,13 @@ impl State { Self::default() } + pub fn focused(value: &str) -> Self { + Self { + is_focused: true, + cursor_position: Value::new(value).len(), + } + } + pub fn move_cursor_right(&mut self, value: &Value) { let current = self.cursor_position(value); @@ -107,6 +114,10 @@ impl State { } } + pub fn move_cursor_to_end(&mut self, value: &Value) { + self.cursor_position = value.len(); + } + pub fn cursor_position(&self, value: &Value) -> usize { self.cursor_position.min(value.len()) } -- cgit From be5466a0a7ee6a16b5c07e61c9a22068ad8e127f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 13 Nov 2019 07:57:22 +0100 Subject: Remove argument from `text_input::State::focused` --- core/src/widget/text_input.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/src/widget/text_input.rs b/core/src/widget/text_input.rs index c4ca0abc..450a7cae 100644 --- a/core/src/widget/text_input.rs +++ b/core/src/widget/text_input.rs @@ -91,10 +91,12 @@ impl State { Self::default() } - pub fn focused(value: &str) -> Self { + pub fn focused() -> Self { + use std::usize; + Self { is_focused: true, - cursor_position: Value::new(value).len(), + cursor_position: usize::MAX, } } -- cgit