mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Implement Panel::wrap_important_area
This commit is contained in:
parent
d140e154aa
commit
c9a4fbf181
@ -1,5 +1,6 @@
|
|||||||
use Printer;
|
use Printer;
|
||||||
use event::{Event, EventResult};
|
use event::{Event, EventResult};
|
||||||
|
use rect::Rect;
|
||||||
use vec::Vec2;
|
use vec::Vec2;
|
||||||
use view::{View, ViewWrapper};
|
use view::{View, ViewWrapper};
|
||||||
|
|
||||||
@ -34,14 +35,17 @@ impl<V: View> ViewWrapper for Panel<V> {
|
|||||||
|
|
||||||
fn wrap_draw(&self, printer: &Printer) {
|
fn wrap_draw(&self, printer: &Printer) {
|
||||||
printer.print_box((0, 0), printer.size, true);
|
printer.print_box((0, 0), printer.size, true);
|
||||||
self.view.draw(&printer.sub_printer(
|
let size = printer.size.saturating_sub((2, 2));
|
||||||
(1, 1),
|
let printer = printer.sub_printer((1, 1), size, true);
|
||||||
printer.size.saturating_sub((2, 2)),
|
self.view.draw(&printer);
|
||||||
true,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_layout(&mut self, size: Vec2) {
|
fn wrap_layout(&mut self, size: Vec2) {
|
||||||
self.view.layout(size.saturating_sub((2, 2)));
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user