summaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs34
1 files changed, 32 insertions, 2 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 {