1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
use Printer; use view::{View, ViewWrapper}; /// Wrapper view that fills the background. /// /// Used as layer in the [`StackView`]. /// /// [`StackView`]: struct.StackView.html pub struct Layer<T: View> { view: T, } impl<T: View> Layer<T> { /// Wraps the given view. pub fn new(view: T) -> Self { Layer { view: view } } } impl<T: View> ViewWrapper for Layer<T> { wrap_impl!(self.view: T); fn wrap_draw(&self, printer: &Printer) { for y in 0..printer.size.y { printer.print_hline((0, y), printer.size.x, " "); } self.view.draw(printer); } }