mirror of
https://github.com/penpot/penpot.git
synced 2025-07-17 09:27:12 +02:00
✨ Reparent modifiers
This commit is contained in:
parent
f3d13005b2
commit
daf048e258
10 changed files with 283 additions and 52 deletions
|
@ -1,8 +1,8 @@
|
|||
#![allow(dead_code)]
|
||||
use crate::math::{self as math, Bounds, Matrix, Point, Vector, VectorExt};
|
||||
use crate::shapes::{
|
||||
AlignContent, AlignItems, AlignSelf, FlexData, JustifyContent, LayoutData, LayoutItem,
|
||||
Modifier, Shape,
|
||||
modified_children_ids, AlignContent, AlignItems, AlignSelf, FlexData, JustifyContent,
|
||||
LayoutData, LayoutItem, Modifier, Shape, StructureEntry,
|
||||
};
|
||||
use crate::uuid::Uuid;
|
||||
|
||||
|
@ -180,10 +180,11 @@ fn initialize_tracks(
|
|||
flex_data: &FlexData,
|
||||
shapes: &HashMap<Uuid, Shape>,
|
||||
bounds: &HashMap<Uuid, Bounds>,
|
||||
structure: &HashMap<Uuid, Vec<StructureEntry>>,
|
||||
) -> Vec<TrackData> {
|
||||
let mut tracks = Vec::<TrackData>::new();
|
||||
let mut current_track = TrackData::default();
|
||||
let mut children = shape.children.clone();
|
||||
let mut children = modified_children_ids(shape, structure.get(&shape.id));
|
||||
let mut first = true;
|
||||
|
||||
if !flex_data.is_reverse() {
|
||||
|
@ -421,6 +422,7 @@ fn calculate_track_data(
|
|||
layout_bounds: &Bounds,
|
||||
shapes: &HashMap<Uuid, Shape>,
|
||||
bounds: &HashMap<Uuid, Bounds>,
|
||||
structure: &HashMap<Uuid, Vec<StructureEntry>>,
|
||||
) -> Vec<TrackData> {
|
||||
let layout_axis = LayoutAxis::new(shape, layout_bounds, layout_data, flex_data);
|
||||
let mut tracks = initialize_tracks(
|
||||
|
@ -430,6 +432,7 @@ fn calculate_track_data(
|
|||
flex_data,
|
||||
shapes,
|
||||
bounds,
|
||||
structure,
|
||||
);
|
||||
|
||||
if !layout_axis.is_auto_main {
|
||||
|
@ -550,11 +553,20 @@ pub fn reflow_flex_layout(
|
|||
flex_data: &FlexData,
|
||||
shapes: &HashMap<Uuid, Shape>,
|
||||
bounds: &mut HashMap<Uuid, Bounds>,
|
||||
structure: &HashMap<Uuid, Vec<StructureEntry>>,
|
||||
) -> VecDeque<Modifier> {
|
||||
let mut result = VecDeque::new();
|
||||
let layout_bounds = &bounds.find(&shape);
|
||||
let layout_axis = LayoutAxis::new(shape, layout_bounds, layout_data, flex_data);
|
||||
let tracks = calculate_track_data(shape, layout_data, flex_data, layout_bounds, shapes, bounds);
|
||||
let tracks = calculate_track_data(
|
||||
shape,
|
||||
layout_data,
|
||||
flex_data,
|
||||
layout_bounds,
|
||||
shapes,
|
||||
bounds,
|
||||
structure,
|
||||
);
|
||||
|
||||
for track in tracks.iter() {
|
||||
let total_shapes_size = track.shapes.iter().map(|s| s.main_size).sum::<f32>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue