Only apply group offset when bbox is disjoint from content

The app only moves group children when the group bbox is disjoint from
its content (group moved away, e.g. groups 169/181). When the bbox
contains the content (e.g. group_64 with a taller frame), children stay
at their ppl coordinates. Fixes group_64 being shifted up 1225px.
This commit is contained in:
AskaEth committed 2026-08-27 15:51:15 +08:00
1 parent 3568472eeb
commit 4fcc5acc85
1 file changed
+14 -4
+14 -4
View File
@@ -741,15 +741,25 @@ def convert(ppl_path: str, out_path: str, preview_path: Optional[str] = None,
g = group_map.get(gid) g = group_map.get(gid)
if not g or "boundingRect" not in g: if not g or "boundingRect" not in g:
continue continue
gl, gt, _, _ = bounding_rect(g) gl, gt, gr, gb = bounding_rect(g)
# only this group's OWN layers (nested groups' layers excluded) # only this group's OWN layers (nested groups' layers excluded)
own = [i for i in range(first, last + 1) own = [i for i in range(first, last + 1)
if layers[i].get("groupId") == gid] if layers[i].get("groupId") == gid]
if not own: if not own:
continue continue
inner_l = min(bounding_rect(layers[i])[0] for i in own) rects = [bounding_rect(layers[i]) for i in own]
inner_t = min(bounding_rect(layers[i])[1] for i in own) inner_l = min(r[0] for r in rects)
group_offset[gid] = (gl - inner_l, gt - inner_t) inner_t = min(r[1] for r in rects)
inner_r = max(r[2] for r in rects)
inner_b = max(r[3] for r in rects)
# If the group bbox fully contains its content, the children sit
# at their ppl coordinates (the bbox is just a bigger frame, e.g.
# group_64). Only offset when the group was moved away from its
# content (bbox disjoint, e.g. groups 169/181).
if gl <= inner_l and gt <= inner_t and gr >= inner_r and gb >= inner_b:
group_offset[gid] = (0, 0)
else:
group_offset[gid] = (gl - inner_l, gt - inner_t)
rendered = [] rendered = []
skipped = 0 skipped = 0