use std::cell::Cell;
use std::os::raw::c_void;
use newt_sys::*;
use crate::component::Component;
use crate::asm;
#[derive(Grid)]
pub struct VerticalGrid<'a> {
co: Cell<newtGrid>,
added_to_parent: Cell<bool>,
children: Vec<&'a dyn Component>
}
impl<'a> VerticalGrid<'a> {
pub fn new<'t>(components: &'t [&'a dyn Component])
-> VerticalGrid<'a> {
let func = newtGridVStacked as *const c_void;
let (grid, children) = unsafe {
asm::grid_new(components, func)
};
VerticalGrid {
co: Cell::new(grid),
added_to_parent: Cell::new(false),
children
}
}
pub fn new_close_stacked<'t>(components: &'t [&'a dyn Component])
-> VerticalGrid<'a> {
let func = newtGridVCloseStacked as *const c_void;
let (grid, children) = unsafe {
asm::grid_new(components, func)
};
VerticalGrid {
co: Cell::new(grid),
added_to_parent: Cell::new(false),
children
}
}
}