mirror of
https://github.com/penpot/penpot.git
synced 2025-07-18 18:27:13 +02:00
✨ Add drop grid cells in wasm
This commit is contained in:
parent
52a4fc6030
commit
8dcb376b18
12 changed files with 215 additions and 119 deletions
|
@ -967,42 +967,42 @@ impl Shape {
|
|||
pub fn has_inner_strokes(&self) -> bool {
|
||||
self.strokes.iter().any(|s| s.kind == StrokeKind::Inner)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the list of children taking into account the structure modifiers
|
||||
*/
|
||||
pub fn modified_children_ids(
|
||||
element: &Shape,
|
||||
structure: Option<&Vec<StructureEntry>>,
|
||||
include_hidden: bool,
|
||||
) -> IndexSet<Uuid> {
|
||||
if let Some(structure) = structure {
|
||||
let mut result: Vec<Uuid> =
|
||||
Vec::from_iter(element.children_ids(include_hidden).iter().copied());
|
||||
let mut to_remove = HashSet::<&Uuid>::new();
|
||||
/*
|
||||
Returns the list of children taking into account the structure modifiers
|
||||
*/
|
||||
pub fn modified_children_ids(
|
||||
&self,
|
||||
structure: Option<&Vec<StructureEntry>>,
|
||||
include_hidden: bool,
|
||||
) -> IndexSet<Uuid> {
|
||||
if let Some(structure) = structure {
|
||||
let mut result: Vec<Uuid> =
|
||||
Vec::from_iter(self.children_ids(include_hidden).iter().copied());
|
||||
let mut to_remove = HashSet::<&Uuid>::new();
|
||||
|
||||
for st in structure {
|
||||
match st.entry_type {
|
||||
StructureEntryType::AddChild => {
|
||||
result.insert(result.len() - st.index as usize, st.id);
|
||||
for st in structure {
|
||||
match st.entry_type {
|
||||
StructureEntryType::AddChild => {
|
||||
result.insert(result.len() - st.index as usize, st.id);
|
||||
}
|
||||
StructureEntryType::RemoveChild => {
|
||||
to_remove.insert(&st.id);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
StructureEntryType::RemoveChild => {
|
||||
to_remove.insert(&st.id);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let ret: IndexSet<Uuid> = result
|
||||
.iter()
|
||||
.filter(|id| !to_remove.contains(id))
|
||||
.copied()
|
||||
.collect();
|
||||
|
||||
ret
|
||||
} else {
|
||||
self.children_ids(include_hidden)
|
||||
}
|
||||
|
||||
let ret: IndexSet<Uuid> = result
|
||||
.iter()
|
||||
.filter(|id| !to_remove.contains(id))
|
||||
.copied()
|
||||
.collect();
|
||||
|
||||
ret
|
||||
} else {
|
||||
element.children_ids(include_hidden)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue