Remove EditView::min_length

Uses `.fixed_width()` from `Boxable` or something like that.
This commit is contained in:
Alexandre Bury 2016-08-03 21:58:00 -07:00
parent b38995b906
commit 1052c0b74c
3 changed files with 9 additions and 24 deletions

View File

@ -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::<EditView>("name")
.unwrap()

View File

@ -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"] {

View File

@ -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::<EditView>("name")
/// .unwrap()
@ -61,8 +61,6 @@ pub struct EditView {
content: Rc<String>,
/// 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
}