summaryrefslogtreecommitdiff
path: root/library/src/layout/place.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-09 14:17:24 +0100
committerLaurenz <laurmaedje@gmail.com>2023-03-09 14:42:14 +0100
commitc38d72383d2068361d635d6c1c78ba97aa917801 (patch)
treee758418a2d704d69dee88faf4a9a9c69b25b47ca /library/src/layout/place.rs
parentd7a65fa26d131179d9d82226e5ee1b562084e48a (diff)
Make all optional fields settable
Diffstat (limited to 'library/src/layout/place.rs')
-rw-r--r--library/src/layout/place.rs24
1 files changed, 10 insertions, 14 deletions
diff --git a/library/src/layout/place.rs b/library/src/layout/place.rs
index b4aaf73d..8d7aa229 100644
--- a/library/src/layout/place.rs
+++ b/library/src/layout/place.rs
@@ -34,11 +34,6 @@ pub struct PlaceNode {
#[default(Axes::with_x(Some(GenAlign::Start)))]
pub alignment: Axes<Option<GenAlign>>,
- /// The content to place.
- #[positional]
- #[required]
- pub body: Content,
-
/// The horizontal displacement of the placed content.
///
/// ```example
@@ -48,14 +43,15 @@ pub struct PlaceNode {
/// place(center, dx: amount - 32pt, dy: amount)[A]
/// }
/// ```
- #[named]
- #[default]
pub dx: Rel<Length>,
/// The vertical displacement of the placed content.
- #[named]
- #[default]
pub dy: Rel<Length>,
+
+ /// The content to place.
+ #[positional]
+ #[required]
+ pub body: Content,
}
impl Layout for PlaceNode {
@@ -65,7 +61,7 @@ impl Layout for PlaceNode {
styles: StyleChain,
regions: Regions,
) -> SourceResult<Fragment> {
- let out_of_flow = self.out_of_flow();
+ let out_of_flow = self.out_of_flow(styles);
// The pod is the base area of the region because for absolute
// placement we don't really care about the already used area.
@@ -77,8 +73,8 @@ impl Layout for PlaceNode {
let child = self
.body()
- .moved(Axes::new(self.dx(), self.dy()))
- .aligned(self.alignment());
+ .moved(Axes::new(self.dx(styles), self.dy(styles)))
+ .aligned(self.alignment(styles));
let mut frame = child.layout(vt, styles, pod)?.into_frame();
@@ -95,8 +91,8 @@ impl PlaceNode {
/// Whether this node wants to be placed relative to its its parent's base
/// origin. Instead of relative to the parent's current flow/cursor
/// position.
- pub fn out_of_flow(&self) -> bool {
- self.alignment().y.is_some()
+ pub fn out_of_flow(&self, styles: StyleChain) -> bool {
+ self.alignment(styles).y.is_some()
}
}