use crate::background::*;
use wrflib::*;
#[derive(Default)]
pub struct Popover {
component_base: ComponentBase,
background: Background,
turtle_outer: Option<Turtle>,
}
impl Popover {
pub fn handle(&mut self, cx: &mut Cx, event: &mut Event) {
event.hits(cx, &self.component_base, HitOpt::default());
}
pub fn begin_turtle(&mut self, cx: &mut Cx, color: Vec4, layout: Layout) -> Turtle {
let popover_y_bottom = cx.get_turtle_pos().y;
self.turtle_outer = Some(cx.begin_turtle(Layout {
direction: Direction::Down,
absolute: true,
walk: Walk { width: Width::Fill, height: Height::Fix(popover_y_bottom) },
..Layout::default()
}));
cx.begin_bottom_align();
self.background.begin_turtle(cx, layout, color)
}
pub fn end_turtle(&mut self, cx: &mut Cx, turtle: Turtle) {
self.background.end_turtle(cx, turtle);
cx.end_bottom_align();
cx.end_turtle(self.turtle_outer.take().unwrap());
self.component_base.register_component_area(cx, self.background.area());
}
}