Paint route-D float placeholders at page edges
This commit is contained in:
1 parent
6e1ee13d68
commit
af50f1afa1
3 files changed
+86
-1
No files matched your search
@@ -7,7 +7,7 @@
|
||||
|
||||
use crate::cmr10::Cmr10Metrics;
|
||||
use crate::math::{self, MathAtom};
|
||||
use crate::{Halign, HorizontalItem, Page, VerticalItem};
|
||||
use crate::{FloatPlacement, Halign, HorizontalItem, Page, VerticalItem};
|
||||
|
||||
/// One absolute drawing primitive in scaled points.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
@@ -238,6 +238,27 @@ impl Page {
|
||||
pub fn display_list_with_goal(&self, page_goal: i64) -> DisplayList {
|
||||
let mut list = DisplayList::default();
|
||||
let mut y = 0_i64;
|
||||
let top_height: i64 = self
|
||||
.floats
|
||||
.iter()
|
||||
.filter(|float| float.placement == FloatPlacement::Top)
|
||||
.map(|float| float.height)
|
||||
.sum();
|
||||
let mut float_y = 0_i64;
|
||||
for float in self
|
||||
.floats
|
||||
.iter()
|
||||
.filter(|float| float.placement == FloatPlacement::Top)
|
||||
{
|
||||
list.push(DisplayItem::Rule {
|
||||
x: 0,
|
||||
y: float_y,
|
||||
width: float.width,
|
||||
height: float.height,
|
||||
});
|
||||
float_y += float.height;
|
||||
}
|
||||
y = top_height;
|
||||
let body_width = self
|
||||
.items
|
||||
.iter()
|
||||
@@ -361,6 +382,32 @@ impl Page {
|
||||
list.images.extend(insertion_list.images);
|
||||
list.width = list.width.max(width);
|
||||
}
|
||||
if page_goal > 0 {
|
||||
let bottom_height: i64 = self
|
||||
.floats
|
||||
.iter()
|
||||
.filter(|float| float.placement == FloatPlacement::Bottom)
|
||||
.map(|float| float.height)
|
||||
.sum();
|
||||
if bottom_height > 0 {
|
||||
let mut float_y = (page_goal - bottom_height).max(y);
|
||||
for float in self
|
||||
.floats
|
||||
.iter()
|
||||
.filter(|float| float.placement == FloatPlacement::Bottom)
|
||||
{
|
||||
list.push(DisplayItem::Rule {
|
||||
x: 0,
|
||||
y: float_y,
|
||||
width: float.width,
|
||||
height: float.height,
|
||||
});
|
||||
float_y += float.height;
|
||||
list.width = list.width.max(float.width);
|
||||
}
|
||||
y = y.max(float_y);
|
||||
}
|
||||
}
|
||||
list.width = list.width.max(
|
||||
self.items
|
||||
.iter()
|
||||
|
||||
Reference in new issue
Block a user