Small style changes

This commit is contained in:
Laurenz 2021-11-24 17:00:10 +01:00
parent 8a88f71cb1
commit 304d9dd110
13 changed files with 27 additions and 27 deletions

View File

@ -583,10 +583,10 @@ impl<'a> PageExporter<'a> {
let Transform { sx, ky, kx, sy, tx, ty } = transform;
self.state.transform = self.state.transform.pre_concat(transform);
self.content.transform([
sx.get() as f32,
ky.get() as f32,
kx.get() as f32,
sy.get() as f32,
sx.get() as _,
ky.get() as _,
kx.get() as _,
sy.get() as _,
tx.to_f32(),
ty.to_f32(),
]);

View File

@ -106,7 +106,7 @@ impl PackedNode {
/// Force a size for this node.
pub fn sized(self, sizing: Spec<Option<Linear>>) -> Self {
if sizing.any(Option::is_some) {
SizedNode { child: self, sizing }.pack()
SizedNode { sizing, child: self }.pack()
} else {
self
}
@ -115,7 +115,7 @@ impl PackedNode {
/// Set alignments for this node.
pub fn aligned(self, aligns: Spec<Option<Align>>) -> Self {
if aligns.any(Option::is_some) {
AlignNode { child: self, aligns }.pack()
AlignNode { aligns, child: self }.pack()
} else {
self
}
@ -128,7 +128,7 @@ impl PackedNode {
|| !padding.right.is_zero()
|| !padding.bottom.is_zero()
{
PadNode { child: self, padding }.pack()
PadNode { padding, child: self }.pack()
} else {
self
}
@ -145,7 +145,7 @@ impl PackedNode {
/// Transform this node's contents without affecting layout.
pub fn transformed(self, transform: Transform, origin: Spec<Align>) -> Self {
if !transform.is_identity() {
TransformNode { child: self, transform, origin }.pack()
TransformNode { transform, origin, child: self }.pack()
} else {
self
}

View File

@ -17,10 +17,10 @@ pub fn align(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
/// A node that aligns its child.
#[derive(Debug, Hash)]
pub struct AlignNode {
/// The node to be aligned.
pub child: PackedNode,
/// How to align the node horizontally and vertically.
pub aligns: Spec<Option<Align>>,
/// The node to be aligned.
pub child: PackedNode,
}
impl Layout for AlignNode {

View File

@ -68,7 +68,7 @@ pub enum FlowChild {
impl Debug for FlowChild {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
Self::Spacing(v) => write!(f, "Spacing({:?})", v),
Self::Spacing(spacing) => spacing.fmt(f),
Self::Node(node) => node.fmt(f),
}
}

View File

@ -490,19 +490,19 @@ impl<'a> GridLayouter<'a> {
fn layout_multi_row(
&self,
ctx: &mut LayoutContext,
resolved: &[Length],
heights: &[Length],
y: usize,
) -> Vec<Frame> {
// Prepare frames.
let mut outputs: Vec<_> = resolved
let mut outputs: Vec<_> = heights
.iter()
.map(|&h| Frame::new(Size::new(self.used.w, h), h))
.collect();
// Prepare regions.
let size = Size::new(self.used.w, resolved[0]);
let size = Size::new(self.used.w, heights[0]);
let mut pod = Regions::one(size, self.regions.base, Spec::splat(true));
pod.backlog = resolved[1 ..]
pod.backlog = heights[1 ..]
.iter()
.map(|&h| Size::new(self.used.w, h))
.collect::<Vec<_>>()

View File

@ -73,7 +73,7 @@ impl Layout for ImageNode {
ImageFit::Stretch => canvas,
};
// The position of the image so that it is centered in the canvas.
// Position the image so that it is centered in the canvas.
let mut frame = Frame::new(canvas, canvas.h);
frame.push(
(canvas - size).to_point() / 2.0,

View File

@ -23,10 +23,10 @@ pub fn pad(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
/// A node that adds padding to its child.
#[derive(Debug, Hash)]
pub struct PadNode {
/// The child node whose sides to pad.
pub child: PackedNode,
/// The amount of padding.
pub padding: Sides<Linear>,
/// The child node whose sides to pad.
pub child: PackedNode,
}
impl Layout for PadNode {

View File

@ -82,12 +82,12 @@ pub fn pagebreak(_: &mut EvalContext, _: &mut Args) -> TypResult<Value> {
/// Layouts its children onto one or multiple pages.
#[derive(Debug, Hash)]
pub struct PageNode {
/// The node that produces the actual pages.
pub child: PackedNode,
/// The size of the page.
pub size: Size,
/// The background fill.
pub fill: Option<Paint>,
/// The node that produces the actual pages.
pub child: PackedNode,
}
impl PageNode {

View File

@ -23,10 +23,10 @@ pub fn block(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
/// A node that sizes its child.
#[derive(Debug, Hash)]
pub struct SizedNode {
/// The node to be sized.
pub child: PackedNode,
/// How to size the node horizontally and vertically.
pub sizing: Spec<Option<Linear>>,
/// The node to be sized.
pub child: PackedNode,
}
impl Layout for SizedNode {

View File

@ -82,7 +82,7 @@ pub enum StackChild {
impl Debug for StackChild {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
Self::Spacing(v) => write!(f, "Spacing({:?})", v),
Self::Spacing(spacing) => spacing.fmt(f),
Self::Node(node) => node.fmt(f),
}
}

View File

@ -165,7 +165,7 @@ pub fn font(ctx: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
let tracking = args.named("tracking")?.map(Em::new);
let top_edge = args.named("top-edge")?;
let bottom_edge = args.named("bottom-edge")?;
let fill = args.named("fill")?.or_else(|| args.find()).map(Paint::Solid);
let fill = args.named("fill")?.or_else(|| args.find());
let kerning = args.named("kerning")?;
let smallcaps = args.named("smallcaps")?;
let alternates = args.named("alternates")?;

View File

@ -40,12 +40,12 @@ fn transform_impl(args: &mut Args, transform: Transform) -> TypResult<Value> {
/// A node that transforms its child without affecting layout.
#[derive(Debug, Hash)]
pub struct TransformNode {
/// The node whose contents should be transformed.
pub child: PackedNode,
/// Transformation to apply to the contents.
pub transform: Transform,
/// The origin of the transformation.
pub origin: Spec<Align>,
/// The node whose contents should be transformed.
pub child: PackedNode,
}
impl Layout for TransformNode {

View File

@ -16,7 +16,7 @@ use crate::geom::{AngularUnit, LengthUnit};
use crate::source::SourceId;
use crate::util::EcoString;
/// An inner of leaf node in the untyped green tree.
/// An inner or leaf node in the untyped green tree.
#[derive(Clone, PartialEq)]
pub enum Green {
/// A reference-counted inner node.