resize implemented

This commit is contained in:
daa84 2016-03-29 12:43:01 +03:00
parent ffed15e697
commit 183f600e1b
2 changed files with 12 additions and 0 deletions

View File

@ -17,6 +17,8 @@ pub trait RedrawEvents {
fn on_put(&mut self, text: &str); fn on_put(&mut self, text: &str);
fn on_clear(&mut self); fn on_clear(&mut self);
fn on_resize(&mut self, columns: u64, rows: u64);
} }
macro_rules! try_str { macro_rules! try_str {
@ -103,6 +105,12 @@ fn call(ui: &SharedUi, method: &str, args: Vec<Value>) {
Ok(()) Ok(())
}) })
} }
"resize" => {
safe_call(ui, move |ui| {
ui.borrow_mut().on_resize(try_int!(args[0]), try_int!(args[1]));
Ok(())
});
}
_ => println!("Event {}", method), _ => println!("Event {}", method),
}; };
} }

View File

@ -90,5 +90,9 @@ impl RedrawEvents for Ui {
fn on_clear(&mut self) { fn on_clear(&mut self) {
self.model.clear(); self.model.clear();
} }
fn on_resize(&mut self, columns: u64, rows: u64) {
self.model = UiModel::new(rows, columns);
}
} }