gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1115HTML 1041Markdown 12TOML 94777 Definiciones

Apply aspect ratio to leaf nodes whose size is determined by padding/border sum

c3720058e676d5e7d0ff11d2cbf757fffebc545e · por Nico Burns · (hace 3 años) · padre b44b3452b · ver el árbol en este commit

Delta semántico · 1

src/compute/leaf.rs

1 archivos · +6 −0

diff --git a/src/compute/leaf.rs b/src/compute/leaf.rs
index 5d0a59e8f..2b567ccc4 100644
--- a/src/compute/leaf.rs
+++ b/src/compute/leaf.rs
@@ -141,5 +141,11 @@ pub(crate) fn compute(
             .maybe_clamp(node_min_size.height, node_max_size.height)
             .maybe_max(padding_border.vertical_axis_sum().into()),
     };
+
+    let size = Size {
+        width: f32_max(size.width, aspect_ratio.map(|ratio| size.height * ratio).unwrap_or(0.0)),
+        height: f32_max(size.height, aspect_ratio.map(|ratio| size.width / ratio).unwrap_or(0.0)),
+    };
+
     SizeAndBaselines { size, first_baselines: Point::NONE }
 }