summaryrefslogtreecommitdiff
path: root/library/src/layout
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/layout')
-rw-r--r--library/src/layout/flow.rs12
-rw-r--r--library/src/layout/grid.rs6
-rw-r--r--library/src/layout/mod.rs40
-rw-r--r--library/src/layout/page.rs1
-rw-r--r--library/src/layout/stack.rs22
5 files changed, 39 insertions, 42 deletions
diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs
index a5992796..347c1dd8 100644
--- a/library/src/layout/flow.rs
+++ b/library/src/layout/flow.rs
@@ -80,7 +80,7 @@ impl PartialOrd for FlowChild {
}
/// Performs flow layout.
-pub struct FlowLayouter {
+struct FlowLayouter {
/// The regions to layout children into.
regions: Regions,
/// Whether the flow should expand to fill the region.
@@ -112,7 +112,7 @@ enum FlowItem {
impl FlowLayouter {
/// Create a new flow layouter.
- pub fn new(regions: &Regions) -> Self {
+ fn new(regions: &Regions) -> Self {
let expand = regions.expand;
let full = regions.first;
@@ -132,7 +132,7 @@ impl FlowLayouter {
}
/// Layout spacing.
- pub fn layout_spacing(&mut self, spacing: Spacing, styles: StyleChain) {
+ fn layout_spacing(&mut self, spacing: Spacing, styles: StyleChain) {
match spacing {
Spacing::Relative(v) => {
// Resolve the spacing and limit it to the remaining space.
@@ -150,7 +150,7 @@ impl FlowLayouter {
}
/// Layout a block.
- pub fn layout_block(
+ fn layout_block(
&mut self,
world: Tracked<dyn World>,
block: &Content,
@@ -206,7 +206,7 @@ impl FlowLayouter {
}
/// Finish the frame for one region.
- pub fn finish_region(&mut self) {
+ fn finish_region(&mut self) {
// Determine the size of the flow in this region dependening on whether
// the region expands.
let mut size = self.expand.select(self.full, self.used);
@@ -254,7 +254,7 @@ impl FlowLayouter {
}
/// Finish layouting and return the resulting frames.
- pub fn finish(mut self) -> Vec<Frame> {
+ fn finish(mut self) -> Vec<Frame> {
if self.expand.y {
while !self.regions.backlog.is_empty() {
self.finish_region();
diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs
index f6610d78..a6f93ab6 100644
--- a/library/src/layout/grid.rs
+++ b/library/src/layout/grid.rs
@@ -99,7 +99,7 @@ castable! {
}
/// Performs grid layout.
-pub struct GridLayouter<'a> {
+struct GridLayouter<'a> {
/// The core context.
world: Tracked<'a, dyn World>,
/// The grid cells.
@@ -140,7 +140,7 @@ impl<'a> GridLayouter<'a> {
/// Create a new grid layouter.
///
/// This prepares grid layout by unifying content and gutter tracks.
- pub fn new(
+ fn new(
world: Tracked<'a, dyn World>,
tracks: Axes<&[TrackSizing]>,
gutter: Axes<&[TrackSizing]>,
@@ -211,7 +211,7 @@ impl<'a> GridLayouter<'a> {
}
/// Determines the columns sizes and then layouts the grid row-by-row.
- pub fn layout(mut self) -> SourceResult<Vec<Frame>> {
+ fn layout(mut self) -> SourceResult<Vec<Frame>> {
self.measure_columns()?;
for y in 0 .. self.rows.len() {
diff --git a/library/src/layout/mod.rs b/library/src/layout/mod.rs
index ddfaa351..5ab5f42e 100644
--- a/library/src/layout/mod.rs
+++ b/library/src/layout/mod.rs
@@ -44,16 +44,16 @@ use crate::text::{
LinebreakNode, ParChild, ParNode, ParbreakNode, SmartQuoteNode, SpaceNode, TextNode,
};
-/// The root-level layout.
+/// Root-level layout.
#[capability]
-pub trait Layout: 'static + Sync + Send {
+pub trait LayoutRoot: 'static + Sync + Send {
/// Layout into one frame per page.
- fn layout(&self, world: Tracked<dyn World>) -> SourceResult<Vec<Frame>>;
+ fn layout_root(&self, world: Tracked<dyn World>) -> SourceResult<Vec<Frame>>;
}
-impl Layout for Content {
+impl LayoutRoot for Content {
#[comemo::memoize]
- fn layout(&self, world: Tracked<dyn World>) -> SourceResult<Vec<Frame>> {
+ fn layout_root(&self, world: Tracked<dyn World>) -> SourceResult<Vec<Frame>> {
let styles = StyleChain::with_root(&world.config().styles);
let scratch = Scratch::default();
@@ -259,7 +259,7 @@ struct Scratch<'a> {
/// Determines whether a style could interrupt some composable structure.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
-pub enum Interruption {
+enum Interruption {
/// The style forces a list break.
List,
/// The style forces a paragraph break.
@@ -269,11 +269,7 @@ pub enum Interruption {
}
impl<'a> Builder<'a> {
- pub fn new(
- world: Tracked<'a, dyn World>,
- scratch: &'a Scratch<'a>,
- top: bool,
- ) -> Self {
+ fn new(world: Tracked<'a, dyn World>, scratch: &'a Scratch<'a>, top: bool) -> Self {
Self {
world,
scratch,
@@ -284,7 +280,7 @@ impl<'a> Builder<'a> {
}
}
- pub fn into_doc(
+ fn into_doc(
mut self,
styles: StyleChain<'a>,
) -> SourceResult<(DocNode, StyleChain<'a>)> {
@@ -293,7 +289,7 @@ impl<'a> Builder<'a> {
Ok((DocNode(pages), shared))
}
- pub fn into_flow(
+ fn into_flow(
mut self,
styles: StyleChain<'a>,
) -> SourceResult<(FlowNode, StyleChain<'a>)> {
@@ -302,7 +298,7 @@ impl<'a> Builder<'a> {
Ok((FlowNode(children), shared))
}
- pub fn accept(
+ fn accept(
&mut self,
content: &'a Content,
styles: StyleChain<'a>,
@@ -740,7 +736,7 @@ enum Last {
impl<'a, T> CollapsingBuilder<'a, T> {
/// Create a new style-vec builder.
- pub fn new() -> Self {
+ fn new() -> Self {
Self {
builder: StyleVecBuilder::new(),
staged: vec![],
@@ -749,7 +745,7 @@ impl<'a, T> CollapsingBuilder<'a, T> {
}
/// Whether the builder is empty.
- pub fn is_empty(&self) -> bool {
+ fn is_empty(&self) -> bool {
self.builder.is_empty() && self.staged.is_empty()
}
@@ -760,7 +756,7 @@ impl<'a, T> CollapsingBuilder<'a, T> {
/// Between weak items, there may be at least one per layer and among the
/// candidates the strongest one (smallest `weakness`) wins. When tied,
/// the one that compares larger through `PartialOrd` wins.
- pub fn weak(&mut self, item: T, styles: StyleChain<'a>, weakness: u8)
+ fn weak(&mut self, item: T, styles: StyleChain<'a>, weakness: u8)
where
T: PartialOrd,
{
@@ -788,31 +784,31 @@ impl<'a, T> CollapsingBuilder<'a, T> {
}
/// Forces nearby weak items to collapse.
- pub fn destructive(&mut self, item: T, styles: StyleChain<'a>) {
+ fn destructive(&mut self, item: T, styles: StyleChain<'a>) {
self.flush(false);
self.builder.push(item, styles);
self.last = Last::Destructive;
}
/// Allows nearby weak items to exist.
- pub fn supportive(&mut self, item: T, styles: StyleChain<'a>) {
+ fn supportive(&mut self, item: T, styles: StyleChain<'a>) {
self.flush(true);
self.builder.push(item, styles);
self.last = Last::Supportive;
}
/// Has no influence on other items.
- pub fn ignorant(&mut self, item: T, styles: StyleChain<'a>) {
+ fn ignorant(&mut self, item: T, styles: StyleChain<'a>) {
self.staged.push((item, styles, None));
}
/// Iterate over the contained items.
- pub fn items(&self) -> impl DoubleEndedIterator<Item = &T> {
+ fn items(&self) -> impl DoubleEndedIterator<Item = &T> {
self.builder.items().chain(self.staged.iter().map(|(item, ..)| item))
}
/// Return the finish style vec and the common prefix chain.
- pub fn finish(mut self) -> (StyleVec<T>, StyleChain<'a>) {
+ fn finish(mut self) -> (StyleVec<T>, StyleChain<'a>) {
self.flush(false);
self.builder.finish()
}
diff --git a/library/src/layout/page.rs b/library/src/layout/page.rs
index 53a8cbc7..7ce0d633 100644
--- a/library/src/layout/page.rs
+++ b/library/src/layout/page.rs
@@ -2,6 +2,7 @@ use std::str::FromStr;
use super::ColumnsNode;
use crate::prelude::*;
+use crate::text::TextNode;
/// Layouts its child onto one or multiple pages.
#[derive(PartialEq, Clone, Hash)]
diff --git a/library/src/layout/stack.rs b/library/src/layout/stack.rs
index 44bcbf67..ec1063fd 100644
--- a/library/src/layout/stack.rs
+++ b/library/src/layout/stack.rs
@@ -89,7 +89,7 @@ castable! {
}
/// Performs stack layout.
-pub struct StackLayouter<'a> {
+struct StackLayouter<'a> {
/// The stacking direction.
dir: Dir,
/// The axis of the stacking direction.
@@ -125,7 +125,7 @@ enum StackItem {
impl<'a> StackLayouter<'a> {
/// Create a new stack layouter.
- pub fn new(dir: Dir, regions: &Regions, styles: StyleChain<'a>) -> Self {
+ fn new(dir: Dir, regions: &Regions, styles: StyleChain<'a>) -> Self {
let axis = dir.axis();
let expand = regions.expand;
let full = regions.first;
@@ -149,7 +149,7 @@ impl<'a> StackLayouter<'a> {
}
/// Add spacing along the spacing direction.
- pub fn layout_spacing(&mut self, spacing: Spacing) {
+ fn layout_spacing(&mut self, spacing: Spacing) {
match spacing {
Spacing::Relative(v) => {
// Resolve the spacing and limit it to the remaining space.
@@ -169,7 +169,7 @@ impl<'a> StackLayouter<'a> {
}
/// Layout an arbitrary block.
- pub fn layout_block(
+ fn layout_block(
&mut self,
world: Tracked<dyn World>,
block: &Content,
@@ -223,7 +223,7 @@ impl<'a> StackLayouter<'a> {
}
/// Advance to the next region.
- pub fn finish_region(&mut self) {
+ fn finish_region(&mut self) {
// Determine the size of the stack in this region dependening on whether
// the region expands.
let used = self.used.to_axes(self.axis);
@@ -279,7 +279,7 @@ impl<'a> StackLayouter<'a> {
}
/// Finish layouting and return the resulting frames.
- pub fn finish(mut self) -> Vec<Frame> {
+ fn finish(mut self) -> Vec<Frame> {
self.finish_region();
self.finished
}
@@ -287,7 +287,7 @@ impl<'a> StackLayouter<'a> {
/// A container with a main and cross component.
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash)]
-pub struct Gen<T> {
+struct Gen<T> {
/// The main component.
pub cross: T,
/// The cross component.
@@ -296,12 +296,12 @@ pub struct Gen<T> {
impl<T> Gen<T> {
/// Create a new instance from the two components.
- pub const fn new(cross: T, main: T) -> Self {
+ const fn new(cross: T, main: T) -> Self {
Self { cross, main }
}
/// Convert to the specific representation, given the current main axis.
- pub fn to_axes(self, main: Axis) -> Axes<T> {
+ fn to_axes(self, main: Axis) -> Axes<T> {
match main {
Axis::X => Axes::new(self.main, self.cross),
Axis::Y => Axes::new(self.cross, self.main),
@@ -311,12 +311,12 @@ impl<T> Gen<T> {
impl Gen<Abs> {
/// The zero value.
- pub fn zero() -> Self {
+ fn zero() -> Self {
Self { cross: Abs::zero(), main: Abs::zero() }
}
/// Convert to a point.
- pub fn to_point(self, main: Axis) -> Point {
+ fn to_point(self, main: Axis) -> Point {
self.to_axes(main).to_point()
}
}