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