diff options
Diffstat (limited to 'src/library/layout')
| -rw-r--r-- | src/library/layout/align.rs | 4 | ||||
| -rw-r--r-- | src/library/layout/columns.rs | 6 | ||||
| -rw-r--r-- | src/library/layout/container.rs | 4 | ||||
| -rw-r--r-- | src/library/layout/flow.rs | 4 | ||||
| -rw-r--r-- | src/library/layout/grid.rs | 27 | ||||
| -rw-r--r-- | src/library/layout/pad.rs | 4 | ||||
| -rw-r--r-- | src/library/layout/page.rs | 12 | ||||
| -rw-r--r-- | src/library/layout/place.rs | 4 | ||||
| -rw-r--r-- | src/library/layout/spacing.rs | 4 | ||||
| -rw-r--r-- | src/library/layout/stack.rs | 6 |
10 files changed, 43 insertions, 32 deletions
diff --git a/src/library/layout/align.rs b/src/library/layout/align.rs index 3b1a4aaf..0c758cf2 100644 --- a/src/library/layout/align.rs +++ b/src/library/layout/align.rs @@ -12,7 +12,7 @@ pub struct AlignNode { #[node] impl AlignNode { - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { let aligns: Spec<Option<RawAlign>> = args.find()?.unwrap_or_default(); let body: Content = args.expect("body")?; Ok(match (body, aligns) { @@ -31,7 +31,7 @@ impl Layout for AlignNode { world: &dyn World, regions: &Regions, styles: StyleChain, - ) -> TypResult<Vec<Frame>> { + ) -> SourceResult<Vec<Frame>> { // The child only needs to expand along an axis if there's no alignment. let mut pod = regions.clone(); pod.expand &= self.aligns.map_is_none(); diff --git a/src/library/layout/columns.rs b/src/library/layout/columns.rs index bfbbfd8d..e0163f63 100644 --- a/src/library/layout/columns.rs +++ b/src/library/layout/columns.rs @@ -17,7 +17,7 @@ impl ColumnsNode { #[property(resolve)] pub const GUTTER: Relative<RawLength> = Ratio::new(0.04).into(); - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { Ok(Content::block(Self { columns: args.expect("column count")?, child: args.expect("body")?, @@ -31,7 +31,7 @@ impl Layout for ColumnsNode { world: &dyn World, regions: &Regions, styles: StyleChain, - ) -> TypResult<Vec<Frame>> { + ) -> SourceResult<Vec<Frame>> { // Separating the infinite space into infinite columns does not make // much sense. if !regions.first.x.is_finite() { @@ -106,7 +106,7 @@ pub struct ColbreakNode; #[node] impl ColbreakNode { - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { let weak = args.named("weak")?.unwrap_or(false); Ok(Content::Colbreak { weak }) } diff --git a/src/library/layout/container.rs b/src/library/layout/container.rs index 66a43751..23556a2e 100644 --- a/src/library/layout/container.rs +++ b/src/library/layout/container.rs @@ -5,7 +5,7 @@ pub struct BoxNode; #[node] impl BoxNode { - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { let width = args.named("width")?; let height = args.named("height")?; let body: LayoutNode = args.eat()?.unwrap_or_default(); @@ -18,7 +18,7 @@ pub struct BlockNode; #[node] impl BlockNode { - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { Ok(Content::Block(args.eat()?.unwrap_or_default())) } } diff --git a/src/library/layout/flow.rs b/src/library/layout/flow.rs index 841b80aa..05c10789 100644 --- a/src/library/layout/flow.rs +++ b/src/library/layout/flow.rs @@ -28,7 +28,7 @@ impl Layout for FlowNode { world: &dyn World, regions: &Regions, styles: StyleChain, - ) -> TypResult<Vec<Frame>> { + ) -> SourceResult<Vec<Frame>> { let mut layouter = FlowLayouter::new(regions); for (child, map) in self.0.iter() { @@ -152,7 +152,7 @@ impl FlowLayouter { world: &dyn World, node: &LayoutNode, styles: StyleChain, - ) -> TypResult<()> { + ) -> SourceResult<()> { // Don't even try layouting into a full region. if self.regions.is_full() { self.finish_region(); diff --git a/src/library/layout/grid.rs b/src/library/layout/grid.rs index 3fde9c10..cd4fc6b4 100644 --- a/src/library/layout/grid.rs +++ b/src/library/layout/grid.rs @@ -13,7 +13,7 @@ pub struct GridNode { #[node] impl GridNode { - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { let columns = args.named("columns")?.unwrap_or_default(); let rows = args.named("rows")?.unwrap_or_default(); let base_gutter: Vec<TrackSizing> = args.named("gutter")?.unwrap_or_default(); @@ -36,7 +36,7 @@ impl Layout for GridNode { world: &dyn World, regions: &Regions, styles: StyleChain, - ) -> TypResult<Vec<Frame>> { + ) -> SourceResult<Vec<Frame>> { // Prepare grid layout by unifying content and gutter tracks. let layouter = GridLayouter::new( world, @@ -203,7 +203,7 @@ impl<'a> GridLayouter<'a> { } /// Determines the columns sizes and then layouts the grid row-by-row. - pub fn layout(mut self) -> TypResult<Vec<Frame>> { + pub fn layout(mut self) -> SourceResult<Vec<Frame>> { self.measure_columns()?; for y in 0 .. self.rows.len() { @@ -228,7 +228,7 @@ impl<'a> GridLayouter<'a> { } /// Determine all column sizes. - fn measure_columns(&mut self) -> TypResult<()> { + fn measure_columns(&mut self) -> SourceResult<()> { // Sum of sizes of resolved relative tracks. let mut rel = Length::zero(); @@ -275,7 +275,10 @@ impl<'a> GridLayouter<'a> { } /// Measure the size that is available to auto columns. - fn measure_auto_columns(&mut self, available: Length) -> TypResult<(Length, usize)> { + fn measure_auto_columns( + &mut self, + available: Length, + ) -> SourceResult<(Length, usize)> { let mut auto = Length::zero(); let mut count = 0; @@ -355,7 +358,7 @@ impl<'a> GridLayouter<'a> { /// Layout a row with automatic height. Such a row may break across multiple /// regions. - fn layout_auto_row(&mut self, y: usize) -> TypResult<()> { + fn layout_auto_row(&mut self, y: usize) -> SourceResult<()> { let mut resolved: Vec<Length> = vec![]; // Determine the size for each region of the row. @@ -423,7 +426,11 @@ impl<'a> GridLayouter<'a> { /// Layout a row with relative height. Such a row cannot break across /// multiple regions, but it may force a region break. - fn layout_relative_row(&mut self, v: Relative<RawLength>, y: usize) -> TypResult<()> { + fn layout_relative_row( + &mut self, + v: Relative<RawLength>, + y: usize, + ) -> SourceResult<()> { let resolved = v.resolve(self.styles).relative_to(self.regions.base.y); let frame = self.layout_single_row(resolved, y)?; @@ -444,7 +451,7 @@ impl<'a> GridLayouter<'a> { } /// Layout a row with fixed height and return its frame. - fn layout_single_row(&mut self, height: Length, y: usize) -> TypResult<Frame> { + fn layout_single_row(&mut self, height: Length, y: usize) -> SourceResult<Frame> { let mut output = Frame::new(Size::new(self.used.x, height)); let mut pos = Point::zero(); @@ -483,7 +490,7 @@ impl<'a> GridLayouter<'a> { &mut self, heights: &[Length], y: usize, - ) -> TypResult<Vec<Frame>> { + ) -> SourceResult<Vec<Frame>> { // Prepare frames. let mut outputs: Vec<_> = heights .iter() @@ -535,7 +542,7 @@ impl<'a> GridLayouter<'a> { } /// Finish rows for one region. - fn finish_region(&mut self) -> TypResult<()> { + fn finish_region(&mut self) -> SourceResult<()> { // Determine the size of the grid in this region, expanding fully if // there are fr rows. let mut size = self.used; diff --git a/src/library/layout/pad.rs b/src/library/layout/pad.rs index 72235ccd..983bfa11 100644 --- a/src/library/layout/pad.rs +++ b/src/library/layout/pad.rs @@ -11,7 +11,7 @@ pub struct PadNode { #[node] impl PadNode { - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { let all = args.named("rest")?.or(args.find()?); let x = args.named("x")?; let y = args.named("y")?; @@ -31,7 +31,7 @@ impl Layout for PadNode { world: &dyn World, regions: &Regions, styles: StyleChain, - ) -> TypResult<Vec<Frame>> { + ) -> SourceResult<Vec<Frame>> { // Layout child into padded regions. let padding = self.padding.resolve(styles); let pod = regions.map(|size| shrink(size, padding)); diff --git a/src/library/layout/page.rs b/src/library/layout/page.rs index 6e43c4ef..ba597263 100644 --- a/src/library/layout/page.rs +++ b/src/library/layout/page.rs @@ -41,7 +41,7 @@ impl PageNode { #[property(referenced)] pub const FOREGROUND: Marginal = Marginal::None; - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { Ok(Content::Page(Self(args.expect("body")?))) } @@ -60,7 +60,7 @@ impl PageNode { world: &dyn World, mut page: usize, styles: StyleChain, - ) -> TypResult<Vec<Frame>> { + ) -> SourceResult<Vec<Frame>> { // When one of the lengths is infinite the page fits its content along // that axis. let width = styles.get(Self::WIDTH).unwrap_or(Length::inf()); @@ -159,7 +159,7 @@ pub struct PagebreakNode; #[node] impl PagebreakNode { - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { let weak = args.named("weak")?.unwrap_or(false); Ok(Content::Pagebreak { weak }) } @@ -178,7 +178,11 @@ pub enum Marginal { impl Marginal { /// Resolve the marginal based on the page number. - pub fn resolve(&self, world: &dyn World, page: usize) -> TypResult<Option<Content>> { + pub fn resolve( + &self, + world: &dyn World, + page: usize, + ) -> SourceResult<Option<Content>> { Ok(match self { Self::None => None, Self::Content(content) => Some(content.clone()), diff --git a/src/library/layout/place.rs b/src/library/layout/place.rs index bb3aac2d..862c969e 100644 --- a/src/library/layout/place.rs +++ b/src/library/layout/place.rs @@ -7,7 +7,7 @@ pub struct PlaceNode(pub LayoutNode); #[node] impl PlaceNode { - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { let aligns = args.find()?.unwrap_or(Spec::with_x(Some(RawAlign::Start))); let dx = args.named("dx")?.unwrap_or_default(); let dy = args.named("dy")?.unwrap_or_default(); @@ -24,7 +24,7 @@ impl Layout for PlaceNode { world: &dyn World, regions: &Regions, styles: StyleChain, - ) -> TypResult<Vec<Frame>> { + ) -> SourceResult<Vec<Frame>> { let out_of_flow = self.out_of_flow(); // The pod is the base area of the region because for absolute diff --git a/src/library/layout/spacing.rs b/src/library/layout/spacing.rs index e435e60c..0c5cbb92 100644 --- a/src/library/layout/spacing.rs +++ b/src/library/layout/spacing.rs @@ -8,7 +8,7 @@ pub struct HNode; #[node] impl HNode { - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { let amount = args.expect("spacing")?; let weak = args.named("weak")?.unwrap_or(false); Ok(Content::Horizontal { amount, weak }) @@ -20,7 +20,7 @@ pub struct VNode; #[node] impl VNode { - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { let amount = args.expect("spacing")?; let weak = args.named("weak")?.unwrap_or(false); Ok(Content::Vertical { amount, weak, generated: false }) diff --git a/src/library/layout/stack.rs b/src/library/layout/stack.rs index d07dc35e..a9fc1621 100644 --- a/src/library/layout/stack.rs +++ b/src/library/layout/stack.rs @@ -15,7 +15,7 @@ pub struct StackNode { #[node] impl StackNode { - fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> { + fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> { Ok(Content::block(Self { dir: args.named("dir")?.unwrap_or(Dir::TTB), spacing: args.named("spacing")?, @@ -30,7 +30,7 @@ impl Layout for StackNode { world: &dyn World, regions: &Regions, styles: StyleChain, - ) -> TypResult<Vec<Frame>> { + ) -> SourceResult<Vec<Frame>> { let mut layouter = StackLayouter::new(self.dir, regions, styles); // Spacing to insert before the next node. @@ -171,7 +171,7 @@ impl<'a> StackLayouter<'a> { world: &dyn World, node: &LayoutNode, styles: StyleChain, - ) -> TypResult<()> { + ) -> SourceResult<()> { if self.regions.is_full() { self.finish_region(); } |
