summaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/mod.rs34
-rw-r--r--src/layout/model.rs6
2 files changed, 35 insertions, 5 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 1cc16a26..209874a1 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -1,10 +1,11 @@
//! The core layouting engine.
use std::io::{self, Write};
+use std::fmt::{self, Display, Formatter};
use smallvec::SmallVec;
use toddle::query::{SharedFontLoader, FontIndex};
-use crate::error::Error;
+use crate::error::Errors;
use crate::syntax::{SyntaxModel, SpanVec};
use crate::size::{Size, Size2D, SizeBox};
use crate::style::LayoutStyle;
@@ -93,7 +94,7 @@ pub struct LayoutContext<'a, 'p> {
pub struct Layouted<T> {
pub output: T,
- pub errors: SpanVec<Error>,
+ pub errors: Errors,
}
impl<T> Layouted<T> {
@@ -231,6 +232,15 @@ impl GenericAxis {
}
}
+impl Display for GenericAxis {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ match self {
+ Primary => write!(f, "primary"),
+ Secondary => write!(f, "secondary"),
+ }
+ }
+}
+
/// The two specific layouting axes.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum SpecificAxis {
@@ -253,6 +263,15 @@ impl SpecificAxis {
}
}
+impl Display for SpecificAxis {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ match self {
+ Horizontal => write!(f, "horizontal"),
+ Vertical => write!(f, "vertical"),
+ }
+ }
+}
+
/// Directions along which content is laid out.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Direction {
@@ -298,6 +317,17 @@ impl Direction {
}
}
+impl Display for Direction {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ match self {
+ LeftToRight => write!(f, "left-to-right"),
+ RightToLeft => write!(f, "right-to-left"),
+ TopToBottom => write!(f, "top-to-bottom"),
+ BottomToTop => write!(f, "bottom-to-top"),
+ }
+ }
+}
+
/// Where to align a layout in a container.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub struct LayoutAlignment {
diff --git a/src/layout/model.rs b/src/layout/model.rs
index 73492dd9..13d38083 100644
--- a/src/layout/model.rs
+++ b/src/layout/model.rs
@@ -1,6 +1,6 @@
use smallvec::smallvec;
-use crate::error::Error;
+use crate::error::Errors;
use crate::func::Command;
use crate::syntax::{Model, DynFuture, SyntaxModel, Node};
use crate::syntax::{SpanVec, Spanned, Span, offset_spans};
@@ -12,7 +12,7 @@ pub struct ModelLayouter<'a, 'p> {
ctx: LayoutContext<'a, 'p>,
layouter: LineLayouter,
style: LayoutStyle,
- errors: SpanVec<Error>,
+ errors: Errors,
}
impl<'a, 'p> ModelLayouter<'a, 'p> {
@@ -105,7 +105,7 @@ impl<'a, 'p> ModelLayouter<'a, 'p> {
Add(layout) => self.layouter.add(layout),
AddMultiple(layouts) => self.layouter.add_multiple(layouts),
- SpacingFunc(space, kind, axis) => match axis {
+ AddSpacing(space, kind, axis) => match axis {
Primary => self.layouter.add_primary_spacing(space, kind),
Secondary => self.layouter.add_secondary_spacing(space, kind),
}