2017-01-24 02:54:33 +00:00
|
|
|
use Printer;
|
|
|
|
use view::{View, ViewWrapper};
|
|
|
|
|
|
|
|
/// Wrapper view that fills the background.
|
|
|
|
///
|
|
|
|
/// Used as layer in the [`StackView`].
|
|
|
|
///
|
|
|
|
/// [`StackView`]: struct.StackView.html
|
2017-12-12 01:31:55 +00:00
|
|
|
#[derive(Debug)]
|
2017-01-24 02:54:33 +00:00
|
|
|
pub struct Layer<T: View> {
|
|
|
|
view: T,
|
|
|
|
}
|
|
|
|
|
2017-02-07 02:18:17 +00:00
|
|
|
impl<T: View> Layer<T> {
|
2017-01-24 02:54:33 +00:00
|
|
|
/// Wraps the given view.
|
|
|
|
pub fn new(view: T) -> Self {
|
2018-05-18 00:35:57 +00:00
|
|
|
Layer { view }
|
2017-01-24 02:54:33 +00:00
|
|
|
}
|
2018-01-26 11:06:14 +00:00
|
|
|
|
2018-01-27 09:37:08 +00:00
|
|
|
inner_getters!(self.view: T);
|
2017-01-24 02:54:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|