summaryrefslogtreecommitdiff
path: root/src/eval/layout.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-07 18:04:29 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-07 18:04:29 +0200
commit4bb6240b401605ef6d905273db07545e14f9a21f (patch)
treeb01163a5fce3fe62d16abcbdabf37bc373617ff1 /src/eval/layout.rs
parent1192132dc0a9e991953fd29e93f87c8437a53ea0 (diff)
Make `Relative` generic
Diffstat (limited to 'src/eval/layout.rs')
-rw-r--r--src/eval/layout.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/eval/layout.rs b/src/eval/layout.rs
index f541694c..9bf44194 100644
--- a/src/eval/layout.rs
+++ b/src/eval/layout.rs
@@ -8,7 +8,9 @@ use std::sync::Arc;
use super::{Barrier, StyleChain};
use crate::diag::TypResult;
use crate::frame::{Element, Frame, Geometry, Shape, Stroke};
-use crate::geom::{Align, Length, Paint, Point, Relative, Sides, Size, Spec, Transform};
+use crate::geom::{
+ Align, Length, Numeric, Paint, Point, Relative, Sides, Size, Spec, Transform,
+};
use crate::library::graphics::MoveNode;
use crate::library::layout::{AlignNode, PadNode};
use crate::util::Prehashed;
@@ -161,7 +163,7 @@ impl LayoutNode {
}
/// Force a size for this node.
- pub fn sized(self, sizing: Spec<Option<Relative>>) -> Self {
+ pub fn sized(self, sizing: Spec<Option<Relative<Length>>>) -> Self {
if sizing.any(Option::is_some) {
SizedNode { sizing, child: self }.pack()
} else {
@@ -189,7 +191,7 @@ impl LayoutNode {
}
/// Pad this node at the sides.
- pub fn padded(self, padding: Sides<Relative>) -> Self {
+ pub fn padded(self, padding: Sides<Relative<Length>>) -> Self {
if !padding.left.is_zero()
|| !padding.top.is_zero()
|| !padding.right.is_zero()
@@ -205,7 +207,7 @@ impl LayoutNode {
pub fn moved(self, offset: Point) -> Self {
if !offset.is_zero() {
MoveNode {
- transform: Transform::translation(offset.x, offset.y),
+ transform: Transform::translate(offset.x, offset.y),
child: self,
}
.pack()
@@ -292,7 +294,7 @@ impl Layout for EmptyNode {
#[derive(Debug, Hash)]
struct SizedNode {
/// How to size the node horizontally and vertically.
- sizing: Spec<Option<Relative>>,
+ sizing: Spec<Option<Relative<Length>>>,
/// The node to be sized.
child: LayoutNode,
}