mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 08:09:14 -05:00
📎 Minor changes on :reg-objects impl.
This commit is contained in:
parent
773e902a50
commit
a72da38f6d
1 changed files with 24 additions and 17 deletions
|
@ -156,28 +156,35 @@
|
|||
[data {:keys [page-id component-id shapes]}]
|
||||
;; FIXME: Improve performance
|
||||
(letfn [(reg-objects [objects]
|
||||
(reduce #(d/update-when %1 %2 update-group %1) objects
|
||||
(sequence (comp
|
||||
(mapcat #(cons % (cph/get-parents % objects)))
|
||||
(map #(get objects %))
|
||||
(filter #(contains? #{:group :bool} (:type %)))
|
||||
(map :id)
|
||||
(distinct))
|
||||
shapes)))
|
||||
(let [lookup (d/getf objects)
|
||||
update-fn #(d/update-when %1 %2 update-group %1)
|
||||
xform (comp
|
||||
(mapcat #(cons % (cph/get-parents % objects)))
|
||||
(map lookup)
|
||||
(filter #(contains? #{:group :bool} (:type %)))
|
||||
(map :id)
|
||||
(distinct))]
|
||||
|
||||
(->> (sequence xform shapes)
|
||||
(reduce update-fn objects))))
|
||||
|
||||
(set-mask-selrect [group children]
|
||||
(let [mask (first children)]
|
||||
(-> group
|
||||
(merge (select-keys mask [:selrect :points]))
|
||||
(assoc :x (-> mask :selrect :x)
|
||||
:y (-> mask :selrect :y)
|
||||
:width (-> mask :selrect :width)
|
||||
:height (-> mask :selrect :height)
|
||||
:flip-x (-> mask :flip-x)
|
||||
:flip-y (-> mask :flip-y)))))
|
||||
(assoc :selrect (-> mask :selrect))
|
||||
(assoc :points (-> mask :points))
|
||||
(assoc :x (-> mask :selrect :x))
|
||||
(assoc :y (-> mask :selrect :y))
|
||||
(assoc :width (-> mask :selrect :width))
|
||||
(assoc :height (-> mask :selrect :height))
|
||||
(assoc :flip-x (-> mask :flip-x))
|
||||
(assoc :flip-y (-> mask :flip-y)))))
|
||||
|
||||
(update-group [group objects]
|
||||
(let [children (->> group :shapes (map #(get objects %)))]
|
||||
(let [lookup (d/getf objects)
|
||||
children (->> group :shapes (map lookup))]
|
||||
(cond
|
||||
;; If the group is empty we don't make any changes. Should be removed by a later process
|
||||
;; If the group is empty we don't make any changes. Will be removed by a later process
|
||||
(empty? children)
|
||||
group
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue