🐛 Fix problem with grid layout wasm

This commit is contained in:
alonso.torres 2025-06-19 11:20:43 +02:00
parent 5b4cd9f4f1
commit b997d5a320
3 changed files with 17 additions and 3 deletions

View file

@ -1,6 +1,8 @@
use skia_safe::{self as skia}; use skia_safe::{self as skia};
use std::collections::HashMap; use std::collections::HashMap;
use crate::shapes::modifiers::common::GetBounds;
use crate::math::{Bounds, Matrix, Rect}; use crate::math::{Bounds, Matrix, Rect};
use crate::shapes::modifiers::grid_layout::{calculate_tracks, create_cell_data}; use crate::shapes::modifiers::grid_layout::{calculate_tracks, create_cell_data};
use crate::shapes::{modified_children_ids, Frame, Layout, Shape, StructureEntry, Type}; use crate::shapes::{modified_children_ids, Frame, Layout, Shape, StructureEntry, Type};
@ -22,7 +24,7 @@ pub fn render_overlay(
return; return;
}; };
let bounds = &HashMap::<Uuid, Bounds>::new(); let bounds = &mut HashMap::<Uuid, Bounds>::new();
let shape = &mut shape.clone(); let shape = &mut shape.clone();
if let Some(modifiers) = modifiers.get(&shape.id) { if let Some(modifiers) = modifiers.get(&shape.id) {
@ -32,6 +34,18 @@ pub fn render_overlay(
let layout_bounds = shape.bounds(); let layout_bounds = shape.bounds();
let children = modified_children_ids(shape, structure.get(&shape.id), false); let children = modified_children_ids(shape, structure.get(&shape.id), false);
for child_id in children.iter() {
let Some(child) = shapes.get(child_id) else {
continue;
};
if let Some(modifier) = modifiers.get(child_id) {
let mut b = bounds.find(child);
b.transform_mut(modifier);
bounds.insert(*child_id, b);
}
}
let column_tracks = calculate_tracks( let column_tracks = calculate_tracks(
true, true,
shape, shape,

View file

@ -1,5 +1,5 @@
use std::collections::{HashMap, HashSet, VecDeque}; use std::collections::{HashMap, HashSet, VecDeque};
mod common; pub mod common;
mod constraints; mod constraints;
mod flex_layout; mod flex_layout;
pub mod grid_layout; pub mod grid_layout;

View file

@ -117,7 +117,7 @@ fn set_auto_base_size(
(cell.row, cell.row_span) (cell.row, cell.row_span)
}; };
if prop_span != 1 || (prop as usize) >= tracks.len() { if prop_span != 1 || (prop as usize) > tracks.len() {
continue; continue;
} }