summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Haug <mhaug@live.de>2021-02-06 12:54:44 +0100
committerMartin Haug <mhaug@live.de>2021-02-06 12:54:44 +0100
commita6cae89b47246a235ed7b1093747c6f3bcb64da4 (patch)
tree67c23ec9df3b9f535faf5fbd443e85d9a7813d37
parent80e076814dde330fb2136172580f11e939bc6601 (diff)
Generalize child of NodeBackground 🍼
-rw-r--r--src/layout/background.rs4
-rw-r--r--src/layout/mod.rs4
-rw-r--r--src/library/layout.rs4
-rw-r--r--tests/typeset.rs4
4 files changed, 7 insertions, 9 deletions
diff --git a/src/layout/background.rs b/src/layout/background.rs
index 94d5bf45..07248e02 100644
--- a/src/layout/background.rs
+++ b/src/layout/background.rs
@@ -5,8 +5,8 @@ use super::*;
pub struct NodeBackground {
/// The background fill.
pub fill: Fill,
- /// The child node whose sides to pad.
- pub child: NodeFixed,
+ /// The child node to be filled in.
+ pub child: Node,
}
impl Layout for NodeBackground {
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 0c7a6a68..30295841 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -1,10 +1,10 @@
//! Layouting.
+mod background;
mod fixed;
mod node;
mod pad;
mod par;
-mod background;
mod spacing;
mod stack;
mod text;
@@ -14,11 +14,11 @@ use crate::env::{Env, ResourceId};
use crate::geom::*;
use crate::shaping::Shaped;
+pub use background::*;
pub use fixed::*;
pub use node::*;
pub use pad::*;
pub use par::*;
-pub use background::*;
pub use spacing::*;
pub use stack::*;
pub use text::*;
diff --git a/src/library/layout.rs b/src/library/layout.rs
index bbcd7898..2812a48f 100644
--- a/src/library/layout.rs
+++ b/src/library/layout.rs
@@ -1,9 +1,9 @@
use std::fmt::{self, Display, Formatter};
-use crate::{eval::Softness, layout::NodeBackground};
use crate::layout::{Expansion, Fill, NodeFixed, NodeSpacing, NodeStack};
use crate::paper::{Paper, PaperClass};
use crate::prelude::*;
+use crate::{eval::Softness, layout::NodeBackground};
/// `align`: Align content along the layouting axes.
///
@@ -210,7 +210,7 @@ pub fn box_(ctx: &mut EvalContext, args: &mut Args) -> Value {
if let Some(color) = color {
ctx.push(NodeBackground {
fill: Fill::Color(color),
- child: fixed_node,
+ child: Node::Any(fixed_node.into()),
})
} else {
ctx.push(fixed_node);
diff --git a/tests/typeset.rs b/tests/typeset.rs
index b1f4ede2..d431abfe 100644
--- a/tests/typeset.rs
+++ b/tests/typeset.rs
@@ -464,10 +464,8 @@ fn draw_geometry(canvas: &mut Canvas, pos: Point, _: &Env, element: &Geometry) {
Shape::Rect(s) => {
let (w, h) = (s.width.to_pt() as f32, s.height.to_pt() as f32);
canvas.fill_rect(Rect::from_xywh(x, y, w, h).unwrap(), &paint);
- },
+ }
};
-
-
}
fn draw_image(canvas: &mut Canvas, pos: Point, env: &Env, element: &Image) {