use papergrid::{height::HeightEstimator, records::Records, Estimate, GridConfig};
use crate::measurment::Measurment;
mod cell_height_increase;
mod cell_height_limit;
mod table_height_increase;
mod table_height_limit;
pub use cell_height_increase::CellHeightIncrease;
pub use cell_height_limit::CellHeightLimit;
pub use table_height_increase::TableHeightIncrease;
pub use table_height_limit::TableHeightLimit;
#[derive(Debug)]
pub struct Height;
impl Height {
pub fn increase<W>(width: W) -> CellHeightIncrease<W>
where
W: Measurment<Height>,
{
CellHeightIncrease::new(width)
}
pub fn limit<W>(width: W) -> CellHeightLimit<W>
where
W: Measurment<Height>,
{
CellHeightLimit::new(width)
}
}
pub(crate) fn get_table_total_height<R, E>(records: &R, cfg: &GridConfig, ctrl: &E) -> usize
where
R: Records,
E: Estimate<R>,
{
ctrl.total()
+ cfg.count_horizontal(records.count_rows())
+ cfg.get_margin().top.size
+ cfg.get_margin().bottom.size
}
pub(crate) fn get_table_total_height2<R>(records: &R, cfg: &GridConfig) -> (usize, Vec<usize>)
where
R: Records,
{
let mut ctrl = HeightEstimator::default();
ctrl.estimate(records, cfg);
let total = <HeightEstimator as Estimate<R>>::total(&ctrl)
+ cfg.count_horizontal(records.count_rows())
+ cfg.get_margin().top.size
+ cfg.get_margin().bottom.size;
(total, ctrl.into())
}