summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/layout/background.rs1
-rw-r--r--src/layout/fixed.rs1
-rw-r--r--src/layout/grid.rs1
-rw-r--r--src/layout/image.rs1
-rw-r--r--src/layout/mod.rs3
-rw-r--r--src/layout/pad.rs1
-rw-r--r--src/layout/par.rs2
-rw-r--r--src/layout/stack.rs2
-rw-r--r--src/layout/tree.rs10
9 files changed, 21 insertions, 1 deletions
diff --git a/src/layout/background.rs b/src/layout/background.rs
index 306afd67..09282260 100644
--- a/src/layout/background.rs
+++ b/src/layout/background.rs
@@ -1,6 +1,7 @@
use super::*;
/// A node that places a rectangular filled background behind its child.
+#[derive(Debug)]
#[cfg_attr(feature = "layout-cache", derive(Hash))]
pub struct BackgroundNode {
/// The kind of shape to use as a background.
diff --git a/src/layout/fixed.rs b/src/layout/fixed.rs
index 5b103f9a..b7c58523 100644
--- a/src/layout/fixed.rs
+++ b/src/layout/fixed.rs
@@ -3,6 +3,7 @@ use decorum::N64;
use super::*;
/// A node that can fix its child's width and height.
+#[derive(Debug)]
#[cfg_attr(feature = "layout-cache", derive(Hash))]
pub struct FixedNode {
/// The fixed width, if any.
diff --git a/src/layout/grid.rs b/src/layout/grid.rs
index 606821e2..35706498 100644
--- a/src/layout/grid.rs
+++ b/src/layout/grid.rs
@@ -1,6 +1,7 @@
use super::*;
/// A node that arranges its children in a grid.
+#[derive(Debug)]
#[cfg_attr(feature = "layout-cache", derive(Hash))]
pub struct GridNode {
/// The inline (columns) and block (rows) directions of this grid.
diff --git a/src/layout/image.rs b/src/layout/image.rs
index 0220da3e..94f57167 100644
--- a/src/layout/image.rs
+++ b/src/layout/image.rs
@@ -4,6 +4,7 @@ use crate::image::ImageId;
use ::image::GenericImageView;
/// An image node.
+#[derive(Debug)]
#[cfg_attr(feature = "layout-cache", derive(Hash))]
pub struct ImageNode {
/// The id of the image file.
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 96bd7e7e..1ca9001d 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -30,6 +30,7 @@ pub use shaping::*;
pub use stack::*;
pub use tree::*;
+use std::fmt::Debug;
use std::rc::Rc;
use crate::font::FontStore;
@@ -73,7 +74,7 @@ impl<'a> LayoutContext<'a> {
}
/// Layout a node.
-pub trait Layout {
+pub trait Layout: Debug {
/// Layout the node into the given regions.
fn layout(
&self,
diff --git a/src/layout/pad.rs b/src/layout/pad.rs
index 506cb110..d1b575a9 100644
--- a/src/layout/pad.rs
+++ b/src/layout/pad.rs
@@ -1,6 +1,7 @@
use super::*;
/// A node that adds padding to its child.
+#[derive(Debug)]
#[cfg_attr(feature = "layout-cache", derive(Hash))]
pub struct PadNode {
/// The amount of padding.
diff --git a/src/layout/par.rs b/src/layout/par.rs
index d7fbde16..dc2ce0ef 100644
--- a/src/layout/par.rs
+++ b/src/layout/par.rs
@@ -10,6 +10,7 @@ use crate::util::{EcoString, RangeExt, SliceExt};
type Range = std::ops::Range<usize>;
/// A node that arranges its children into a paragraph.
+#[derive(Debug)]
#[cfg_attr(feature = "layout-cache", derive(Hash))]
pub struct ParNode {
/// The inline direction of this paragraph.
@@ -21,6 +22,7 @@ pub struct ParNode {
}
/// A child of a paragraph node.
+#[derive(Debug)]
#[cfg_attr(feature = "layout-cache", derive(Hash))]
pub enum ParChild {
/// Spacing between other nodes.
diff --git a/src/layout/stack.rs b/src/layout/stack.rs
index 211c8a7e..4afe9c64 100644
--- a/src/layout/stack.rs
+++ b/src/layout/stack.rs
@@ -1,6 +1,7 @@
use super::*;
/// A node that stacks its children.
+#[derive(Debug)]
#[cfg_attr(feature = "layout-cache", derive(Hash))]
pub struct StackNode {
/// The inline and block directions of this stack.
@@ -13,6 +14,7 @@ pub struct StackNode {
}
/// A child of a stack node.
+#[derive(Debug)]
#[cfg_attr(feature = "layout-cache", derive(Hash))]
pub enum StackChild {
/// Spacing between other nodes.
diff --git a/src/layout/tree.rs b/src/layout/tree.rs
index 224313f6..28cbbb51 100644
--- a/src/layout/tree.rs
+++ b/src/layout/tree.rs
@@ -1,3 +1,5 @@
+use std::fmt::{self, Debug, Formatter};
+
use super::*;
use std::any::Any;
@@ -9,6 +11,7 @@ use std::hash::{Hash, Hasher};
use fxhash::FxHasher64;
/// A tree of layout nodes.
+#[derive(Debug)]
pub struct LayoutTree {
/// Runs of pages with the same properties.
pub runs: Vec<PageRun>,
@@ -22,6 +25,7 @@ impl LayoutTree {
}
/// A run of pages that all have the same properties.
+#[derive(Debug)]
pub struct PageRun {
/// The size of each page.
pub size: Size,
@@ -95,6 +99,12 @@ impl Layout for LayoutNode {
}
}
+impl Debug for LayoutNode {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ self.node.fmt(f)
+ }
+}
+
#[cfg(feature = "layout-cache")]
impl Hash for LayoutNode {
fn hash<H: Hasher>(&self, state: &mut H) {