From c9a4fbf181b3b20750fc36727b631ad680804a4b Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Thu, 22 Mar 2018 15:21:54 -0700 Subject: [PATCH] Implement Panel::wrap_important_area --- src/views/panel.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/views/panel.rs b/src/views/panel.rs index 07627fb..238823c 100644 --- a/src/views/panel.rs +++ b/src/views/panel.rs @@ -1,5 +1,6 @@ use Printer; use event::{Event, EventResult}; +use rect::Rect; use vec::Vec2; use view::{View, ViewWrapper}; @@ -34,14 +35,17 @@ impl ViewWrapper for Panel { fn wrap_draw(&self, printer: &Printer) { printer.print_box((0, 0), printer.size, true); - self.view.draw(&printer.sub_printer( - (1, 1), - printer.size.saturating_sub((2, 2)), - true, - )); + let size = printer.size.saturating_sub((2, 2)); + let printer = printer.sub_printer((1, 1), size, true); + self.view.draw(&printer); } fn wrap_layout(&mut self, size: Vec2) { self.view.layout(size.saturating_sub((2, 2))); } + + fn wrap_important_area(&self, size: Vec2) -> Rect { + let inner_size = size.saturating_sub((2, 2)); + self.view.important_area(inner_size) + (1, 1) + } }