mirror of
https://github.com/typst/typst
synced 2025-05-16 18:15:29 +08:00
initial attempt on repeating header height
- Faulty, as we have to update it when pushing new pending headers too - Need to have a vector associating a height to each row...
This commit is contained in:
parent
f21dc8b7e2
commit
ecc93297f8
@ -80,6 +80,14 @@ pub struct GridLayouter<'a> {
|
||||
/// header rows themselves are unbreakable, and unbreakable rows do not
|
||||
/// need to read this field at all.
|
||||
pub(super) header_height: Abs,
|
||||
/// The height of effectively repeating headers, that is, ignoring
|
||||
/// non-repeating pending headers.
|
||||
///
|
||||
/// This is used by multi-page auto rows so they can inform cell layout on
|
||||
/// how much space should be taken by headers if they break across regions.
|
||||
/// In particular, non-repeating headers only occupy the initial region,
|
||||
/// but disappear on new regions, so they can be ignored.
|
||||
pub(super) repeating_header_height: Abs,
|
||||
/// The simulated footer height for this region.
|
||||
/// The simulation occurs before any rows are laid out for a region.
|
||||
pub(super) footer_height: Abs,
|
||||
@ -152,6 +160,7 @@ impl<'a> GridLayouter<'a> {
|
||||
upcoming_headers: &grid.headers,
|
||||
pending_headers: Default::default(),
|
||||
header_height: Abs::zero(),
|
||||
repeating_header_height: Abs::zero(),
|
||||
footer_height: Abs::zero(),
|
||||
span,
|
||||
}
|
||||
@ -1587,6 +1596,9 @@ impl<'a> GridLayouter<'a> {
|
||||
|
||||
if !last {
|
||||
self.current_header_rows = 0;
|
||||
self.header_height = Abs::zero();
|
||||
self.repeating_header_height = Abs::zero();
|
||||
|
||||
let disambiguator = self.finished.len();
|
||||
if let Some(Repeatable::Repeated(footer)) = &self.grid.footer {
|
||||
self.prepare_footer(footer, engine, disambiguator)?;
|
||||
|
@ -224,6 +224,7 @@ impl<'a> GridLayouter<'a> {
|
||||
// Reset the header height for this region.
|
||||
// It will be re-calculated when laying out each header row.
|
||||
self.header_height = Abs::zero();
|
||||
self.repeating_header_height = Abs::zero();
|
||||
|
||||
if let Some(Repeatable::Repeated(footer)) = &self.grid.footer {
|
||||
if skipped_region {
|
||||
@ -276,10 +277,16 @@ impl<'a> GridLayouter<'a> {
|
||||
i += 1;
|
||||
}
|
||||
|
||||
// All rows so far were repeating headers at the top of the region.
|
||||
self.repeating_header_height = self.header_height;
|
||||
for header in self.pending_headers {
|
||||
let header_height = self.header_height;
|
||||
for y in header.unwrap().range() {
|
||||
self.layout_row(y, engine, disambiguator)?;
|
||||
}
|
||||
if matches!(header, Repeatable::Repeated(_)) {
|
||||
self.repeating_header_height += self.header_height - header_height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user