fix: Check for insufficient space in Panel::required_size

This commit is contained in:
Alexandre Bury 2017-03-06 14:53:10 -08:00
parent 5f5fb4e502
commit 87676295a0

View File

@ -20,7 +20,13 @@ impl<V: View> ViewWrapper for Panel<V> {
fn wrap_required_size(&mut self, req: Vec2) -> Vec2 {
// TODO: make borders conditional?
self.view.required_size(req - (2, 2)) + (2, 2)
let req = if Vec2::new(2, 2).fits_in(req) {
req - (2, 2)
} else {
Vec2::zero()
};
self.view.required_size(req) + (2, 2)
}
fn wrap_draw(&self, printer: &Printer) {