From 1052c0b74c82e11a2a58b1d2a97b6883a6c5d276 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Wed, 3 Aug 2016 21:58:00 -0700 Subject: [PATCH] Remove `EditView::min_length` Uses `.fixed_width()` from `Boxable` or something like that. --- examples/edit.rs | 4 ++-- examples/list_view.rs | 10 +++++----- src/views/edit_view.rs | 19 ++----------------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/examples/edit.rs b/examples/edit.rs index 36dddf0..db9a7f3 100644 --- a/examples/edit.rs +++ b/examples/edit.rs @@ -12,9 +12,9 @@ fn main() { .title("Enter your name") .padding((1, 1, 1, 0)) .content(EditView::new() - .min_length(20) .on_submit(show_popup) - .with_id("name")) + .with_id("name") + .fixed_width(20)) .button("Ok", |s| { let name = s.find_id::("name") .unwrap() diff --git a/examples/list_view.rs b/examples/list_view.rs index c712030..8dd96f2 100644 --- a/examples/list_view.rs +++ b/examples/list_view.rs @@ -9,18 +9,18 @@ fn main() { .title("Please fill out this form") .button("Ok", |s| s.quit()) .content(ListView::new() - .child("Name", EditView::new().min_length(10)) + .child("Name", EditView::new().fixed_width(10)) .child("Email", LinearLayout::horizontal() .child(EditView::new() - .min_length(15) .disabled() - .with_id("email1")) + .with_id("email1") + .fixed_width(15)) .child(TextView::new("@")) .child(EditView::new() - .min_length(10) .disabled() - .with_id("email2"))) + .with_id("email2") + .fixed_width(10))) .child("Receive spam?", Checkbox::new().on_change(|s, checked| { for name in &["email1", "email2"] { diff --git a/src/views/edit_view.rs b/src/views/edit_view.rs index 0b7c027..56db248 100644 --- a/src/views/edit_view.rs +++ b/src/views/edit_view.rs @@ -33,9 +33,9 @@ use utils::simple_suffix_length; /// .title("Enter your name") /// .padding((1, 1, 1, 0)) /// .content(EditView::new() -/// .min_length(20) /// .on_submit(show_popup) -/// .with_id("name")) +/// .with_id("name") +/// .fixed_width(20)) /// .button("Ok", |s| { /// let name = s.find_id::("name") /// .unwrap() @@ -61,8 +61,6 @@ pub struct EditView { content: Rc, /// Cursor position in the content, in bytes. cursor: usize, - /// Minimum layout length asked to the parent. - min_length: usize, /// Number of bytes to skip at the beginning of the content. /// @@ -94,7 +92,6 @@ impl EditView { content: Rc::new(String::new()), cursor: 0, offset: 0, - min_length: 1, last_length: 0, // scrollable: false, on_edit: None, on_submit: None, @@ -186,14 +183,6 @@ impl EditView { self } - /// Sets the minimum length for this view. - /// (This applies to the layout, not the content.) - pub fn min_length(mut self, min_length: usize) -> Self { - self.min_length = min_length; - - self - } - /// Insert `ch` at the current cursor position. pub fn insert(&mut self, ch: char) { // `make_mut` applies copy-on-write @@ -303,10 +292,6 @@ impl View for EditView { self.last_length = size.x; } - fn get_min_size(&mut self, _: Vec2) -> Vec2 { - Vec2::new(self.min_length, 1) - } - fn take_focus(&mut self, _: Direction) -> bool { self.enabled }