summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-03-12 14:12:30 +0100
committerLaurenz <laurmaedje@gmail.com>2021-03-12 14:12:30 +0100
commit584a43277dbfbdba834a2681afe63d10598db3f9 (patch)
tree2a7b8d1f6b41fa39996c907d8d582b4c52448fcd /src/library
parentffcb8cd97a7107bfd66805b1073c5ef3e0dd59a7 (diff)
Rename ChildAlign to LayoutAligns ✏
Diffstat (limited to 'src/library')
-rw-r--r--src/library/align.rs14
-rw-r--r--src/library/image.rs8
2 files changed, 11 insertions, 11 deletions
diff --git a/src/library/align.rs b/src/library/align.rs
index d16e697d..07566f2d 100644
--- a/src/library/align.rs
+++ b/src/library/align.rs
@@ -54,7 +54,7 @@ pub fn align(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
} else if had.get(gen_axis) {
ctx.diag(error!(span, "duplicate alignment for {} axis", axis));
} else {
- *ctx.state.align.get_mut(gen_axis) = gen_align;
+ *ctx.state.aligns.get_mut(gen_axis) = gen_align;
*had.get_mut(gen_axis) = true;
}
} else {
@@ -67,8 +67,8 @@ pub fn align(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
} else if had_center {
// Both this and the previous one are unspecified `center`
// alignments. Both axes should be centered.
- ctx.state.align.main = Align::Center;
- ctx.state.align.cross = Align::Center;
+ ctx.state.aligns.main = Align::Center;
+ ctx.state.aligns.cross = Align::Center;
had = Gen::uniform(true);
} else {
had_center = true;
@@ -79,10 +79,10 @@ pub fn align(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
// `center` alignment.
if had_center && (had.main || had.cross) {
if had.main {
- ctx.state.align.cross = Align::Center;
+ ctx.state.aligns.cross = Align::Center;
had.cross = true;
} else {
- ctx.state.align.main = Align::Center;
+ ctx.state.aligns.main = Align::Center;
had.main = true;
}
had_center = false;
@@ -92,10 +92,10 @@ pub fn align(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
// If `had_center` wasn't flushed by now, it's the only argument and then we
// default to applying it to the cross axis.
if had_center {
- ctx.state.align.cross = Align::Center;
+ ctx.state.aligns.cross = Align::Center;
}
- if ctx.state.align.main != snapshot.align.main {
+ if ctx.state.aligns.main != snapshot.aligns.main {
ctx.end_par_group();
ctx.start_par_group();
}
diff --git a/src/library/image.rs b/src/library/image.rs
index 06908ce8..d9c0a0a7 100644
--- a/src/library/image.rs
+++ b/src/library/image.rs
@@ -25,7 +25,7 @@ pub fn image(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
dimensions,
width,
height,
- align: ctx.state.align,
+ aligns: ctx.state.aligns,
});
} else {
ctx.diag(error!(path.span, "failed to load image"));
@@ -37,6 +37,8 @@ pub fn image(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
/// An image node.
#[derive(Debug, Clone, PartialEq)]
struct NodeImage {
+ /// How to align this image node in its parent.
+ aligns: LayoutAligns,
/// The resource id of the image file.
res: ResourceId,
/// The pixel dimensions of the image.
@@ -45,8 +47,6 @@ struct NodeImage {
width: Option<Linear>,
/// The fixed height, if any.
height: Option<Linear>,
- /// How to align this image node in its parent.
- align: ChildAlign,
}
impl Layout for NodeImage {
@@ -81,7 +81,7 @@ impl Layout for NodeImage {
let mut frame = Frame::new(size);
frame.push(Point::ZERO, Element::Image(Image { res: self.res, size }));
- Layouted::Frame(frame, self.align)
+ Layouted::Frame(frame, self.aligns)
}
}