2015-05-22 23:28:05 +00:00
|
|
|
use view::{View,ViewWrapper,SizeRequest,DimensionRequest};
|
|
|
|
use vec::Vec2;
|
|
|
|
|
2015-05-22 23:57:29 +00:00
|
|
|
/// Simple wrapper view that asks for all the space it can get.
|
2015-05-22 23:28:05 +00:00
|
|
|
pub struct FullView<T: View> {
|
2015-05-26 23:48:27 +00:00
|
|
|
view: T,
|
2015-05-22 23:28:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl <T: View> FullView<T> {
|
2015-05-22 23:57:29 +00:00
|
|
|
/// Wraps the given view into a new FullView.
|
2015-05-22 23:28:05 +00:00
|
|
|
pub fn new(view: T) -> Self {
|
|
|
|
FullView {
|
|
|
|
view: view,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl <T: View> ViewWrapper for FullView<T> {
|
|
|
|
wrap_impl!(&self.view);
|
|
|
|
|
|
|
|
fn wrap_get_min_size(&self, req: SizeRequest) -> Vec2 {
|
|
|
|
let w = match req.w {
|
|
|
|
DimensionRequest::Fixed(w) => w,
|
|
|
|
DimensionRequest::AtMost(w) => w,
|
|
|
|
DimensionRequest::Unknown => self.view.get_min_size(req).x,
|
|
|
|
};
|
|
|
|
let h = match req.h {
|
|
|
|
DimensionRequest::Fixed(h) => h,
|
|
|
|
DimensionRequest::AtMost(h) => h,
|
|
|
|
DimensionRequest::Unknown => self.view.get_min_size(req).y,
|
|
|
|
};
|
|
|
|
|
|
|
|
Vec2::new(w,h)
|
|
|
|
}
|
|
|
|
}
|