mirror of
https://github.com/penpot/penpot.git
synced 2026-09-08 11:54:36 -04:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
815969f4d0 | ||
|
|
6022f070eb | ||
|
|
acce410f78 | ||
|
|
cf934fcc4b |
No files matched your search
@@ -482,11 +482,8 @@ pub fn propagate_modifiers(
|
||||
// are already reflowed before their parents.
|
||||
let mut layout_reflows_vec: Vec<Uuid> =
|
||||
std::mem::take(&mut layout_reflows).into_iter().collect();
|
||||
layout_reflows_vec.sort_unstable_by(|id_a, id_b| {
|
||||
let da = shapes.get_depth(id_a);
|
||||
let db = shapes.get_depth(id_b);
|
||||
db.cmp(&da)
|
||||
});
|
||||
// Deepest-first; cache get_depth (O(depth) parent walk) per id.
|
||||
layout_reflows_vec.sort_by_cached_key(|id| std::cmp::Reverse(shapes.get_depth(id)));
|
||||
|
||||
// This temporary bounds is necesary so the layouts can be calculated
|
||||
// correctly but will be discarded before the next iteration for the
|
||||
@@ -501,8 +498,11 @@ pub fn propagate_modifiers(
|
||||
}
|
||||
}
|
||||
|
||||
// Drop identity matrices: the reflow-mark inserts a no-op entry for every
|
||||
// descendant of a reflowed subtree; emitting them floods the FFI output.
|
||||
Ok(modifiers
|
||||
.iter()
|
||||
.filter(|(_, val)| !identitish(val))
|
||||
.map(|(key, val)| TransformEntry::from_input(*key, *val))
|
||||
.collect())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::error::{Error, Result};
|
||||
use crate::math::{is_move_only_matrix, Bounds, Matrix};
|
||||
use crate::math::{is_close_to, is_move_only_matrix, Bounds, Matrix};
|
||||
use crate::shapes::{ConstraintH, ConstraintV};
|
||||
|
||||
pub fn calculate_resize(
|
||||
@@ -36,7 +36,9 @@ pub fn calculate_resize(
|
||||
_ => 1.0,
|
||||
};
|
||||
|
||||
if (scale_width - 1.0).abs() < f32::EPSILON && (scale_height - 1.0).abs() < f32::EPSILON {
|
||||
// 0.001 threshold (not f32::EPSILON) so near-identity resizes short-circuit
|
||||
// before building the per-child parent matrix.
|
||||
if is_close_to(scale_width, 1.0) && is_close_to(scale_height, 1.0) {
|
||||
None
|
||||
} else {
|
||||
Some((scale_width, scale_height))
|
||||
@@ -91,7 +93,7 @@ pub fn calculate_displacement(
|
||||
_ => 0.0,
|
||||
};
|
||||
|
||||
if delta_x.abs() < f32::EPSILON && delta_y.abs() < f32::EPSILON {
|
||||
if is_close_to(delta_x, 0.0) && is_close_to(delta_y, 0.0) {
|
||||
None
|
||||
} else {
|
||||
Some((delta_x, delta_y))
|
||||
|
||||
@@ -684,15 +684,13 @@ fn child_frame_aabb(child_bounds: &Bounds, hv: Vector, vv: Vector) -> (f32, f32,
|
||||
|
||||
fn child_position(
|
||||
child: &Shape,
|
||||
layout_bounds: &Bounds,
|
||||
hv: Vector,
|
||||
vv: Vector,
|
||||
layout_data: &LayoutData,
|
||||
child_bounds: &Bounds,
|
||||
layout_item: Option<LayoutItem>,
|
||||
cell: &CellData,
|
||||
) -> Point {
|
||||
let hv = layout_bounds.hv(1.0);
|
||||
let vv = layout_bounds.vv(1.0);
|
||||
|
||||
let margin_left = layout_item.map(|i| i.margin_left).unwrap_or(0.0);
|
||||
let margin_top = layout_item.map(|i| i.margin_top).unwrap_or(0.0);
|
||||
let margin_right = layout_item.map(|i| i.margin_right).unwrap_or(0.0);
|
||||
@@ -779,13 +777,14 @@ pub fn reflow_grid_layout(
|
||||
false,
|
||||
);
|
||||
|
||||
// hv/vv are loop-invariant; compute once instead of per cell and per child.
|
||||
let hv = layout_bounds.hv(1.0);
|
||||
let vv = layout_bounds.vv(1.0);
|
||||
|
||||
for cell in cells.iter() {
|
||||
let Some(child) = cell.shape else { continue };
|
||||
let child_bounds = bounds.find(child);
|
||||
|
||||
// Compute frame-axis projections once; used for both sizing and positioning.
|
||||
let hv = layout_bounds.hv(1.0);
|
||||
let vv = layout_bounds.vv(1.0);
|
||||
let (h_min, v_min, child_frame_w, child_frame_h) = child_frame_aabb(&child_bounds, hv, vv);
|
||||
|
||||
// resize_matrix scales the child in the parent's local frame coordinate system
|
||||
@@ -842,7 +841,8 @@ pub fn reflow_grid_layout(
|
||||
|
||||
let position = child_position(
|
||||
child,
|
||||
&layout_bounds,
|
||||
hv,
|
||||
vv,
|
||||
layout_data,
|
||||
&child_bounds,
|
||||
child.layout_item,
|
||||
|
||||
Reference in new issue
Block a user