use super::{hwpunit_to_px, layout::border_width_to_px};
pub(crate) fn has_ink(color: crate::model::ColorRef) -> bool {
color != crate::model::color::NONE
}
pub(crate) fn completed_body_tail_spacing_hu(
items: &[super::pagination::PageItem],
paragraphs: &[crate::model::paragraph::Paragraph],
) -> i32 {
use super::pagination::PageItem;
let (index, end_line) = match items.last() {
Some(PageItem::FullParagraph { para_index }) => (*para_index, None),
Some(PageItem::PartialParagraph {
para_index,
end_line,
..
}) => (*para_index, Some(*end_line)),
_ => return 0,
};
let Some(paragraph) = paragraphs.get(index) else {
return 0;
};
if end_line.is_some_and(|end| end != paragraph.line_segs.len()) {
return 0;
}
paragraph
.line_segs
.last()
.map_or(0, |line| line.line_spacing.max(0))
}
pub(crate) struct NoteSeparatorGeometry {
pub(crate) center_offset: f64,
pub(crate) width: f64,
pub(crate) advance: f64,
}
impl NoteSeparatorGeometry {
pub(crate) fn new(above_hu: i32, below_hu: i32, visible: bool, width: u8, dpi: f64) -> Self {
let width = if visible {
border_width_to_px(width).max(0.5)
} else {
0.0
};
let center_offset = hwpunit_to_px(above_hu, dpi);
let advance = center_offset + hwpunit_to_px(below_hu, dpi);
Self {
center_offset,
width,
advance,
}
}
}