mirror of
https://github.com/typst/typst
synced 2025-05-19 11:35:27 +08:00
parent
022b945fb3
commit
74fce3fc78
@ -483,7 +483,7 @@ fn layout(
|
|||||||
|
|
||||||
let mut frame;
|
let mut frame;
|
||||||
if let Some(child) = body {
|
if let Some(child) = body {
|
||||||
let mut region = resolved.unwrap_or(regions.base());
|
let region = resolved.unwrap_or(regions.base());
|
||||||
if kind.is_round() {
|
if kind.is_round() {
|
||||||
inset = inset.map(|side| side + Ratio::new(0.5 - SQRT_2 / 4.0));
|
inset = inset.map(|side| side + Ratio::new(0.5 - SQRT_2 / 4.0));
|
||||||
}
|
}
|
||||||
@ -494,17 +494,23 @@ fn layout(
|
|||||||
let pod = Regions::one(region, expand);
|
let pod = Regions::one(region, expand);
|
||||||
frame = child.layout(vt, styles, pod)?.into_frame();
|
frame = child.layout(vt, styles, pod)?.into_frame();
|
||||||
|
|
||||||
|
// Enforce correct size.
|
||||||
|
*frame.size_mut() = expand.select(region, frame.size());
|
||||||
|
|
||||||
// Relayout with full expansion into square region to make sure
|
// Relayout with full expansion into square region to make sure
|
||||||
// the result is really a square or circle.
|
// the result is really a square or circle.
|
||||||
if kind.is_quadratic() {
|
if kind.is_quadratic() {
|
||||||
|
frame.set_size(Size::splat(frame.size().max_by_side()));
|
||||||
let length = frame.size().max_by_side().min(region.min_by_side());
|
let length = frame.size().max_by_side().min(region.min_by_side());
|
||||||
region = Size::splat(length);
|
let pod = Regions::one(Size::splat(length), Axes::splat(true));
|
||||||
let pod = Regions::one(region, Axes::splat(true));
|
|
||||||
frame = child.layout(vt, styles, pod)?.into_frame();
|
frame = child.layout(vt, styles, pod)?.into_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enforce correct size.
|
// Enforce correct size again.
|
||||||
*frame.size_mut() = expand.select(region, frame.size());
|
*frame.size_mut() = expand.select(region, frame.size());
|
||||||
|
if kind.is_quadratic() {
|
||||||
|
frame.set_size(Size::splat(frame.size().max_by_side()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// The default size that a shape takes on if it has no child and
|
// The default size that a shape takes on if it has no child and
|
||||||
// enough space.
|
// enough space.
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Loading…
x
Reference in New Issue
Block a user