mirror of
https://github.com/penpot/penpot.git
synced 2025-07-07 11:17:16 +02:00
✨ Allow for rotated auto-layout
This commit is contained in:
parent
5e5355230c
commit
28abe785e8
6 changed files with 72 additions and 44 deletions
|
@ -32,8 +32,8 @@
|
|||
:layout-wrap-type :wrap
|
||||
:layout-padding-type :simple
|
||||
:layout-padding {:p1 0 :p2 0 :p3 0 :p4 0}
|
||||
:layout-h-orientation :top
|
||||
:layout-v-orientation :left})
|
||||
:layout-h-orientation :left
|
||||
:layout-v-orientation :top})
|
||||
|
||||
(defn update-layout-positions
|
||||
[ids]
|
||||
|
|
|
@ -128,7 +128,6 @@
|
|||
(ptk/reify ::set-modifiers
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
||||
(let [objects (wsh/lookup-page-objects state)
|
||||
ids (into #{} (remove #(get-in objects [% :blocked] false)) ids)
|
||||
|
||||
|
@ -138,7 +137,7 @@
|
|||
modif-tree
|
||||
(gsh/set-objects-modifiers ids objects (constantly modifiers) ignore-constraints snap-pixel?)]
|
||||
|
||||
(assoc state :workspace-modifiers modif-tree))))))
|
||||
(update state :workspace-modifiers merge modif-tree))))))
|
||||
|
||||
;; Rotation use different algorithm to calculate children modifiers (and do not use child constraints).
|
||||
(defn- set-rotation-modifiers
|
||||
|
@ -147,19 +146,25 @@
|
|||
|
||||
([angle shapes center]
|
||||
(ptk/reify ::set-rotation-modifiers
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [objects (wsh/lookup-page-objects state)
|
||||
shapes
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [objects (wsh/lookup-page-objects state)
|
||||
ids
|
||||
(->> shapes
|
||||
(remove #(get % :blocked false))
|
||||
(mapcat #(cph/get-children objects (:id %)))
|
||||
(concat shapes)
|
||||
(filter #((cpc/editable-attrs (:type %)) :rotation)))]
|
||||
(->> (rx/from shapes)
|
||||
(rx/map (fn [shape]
|
||||
(let [rotate-modifiers (gsh/rotation-modifiers shape center angle)]
|
||||
(set-modifiers [(:id shape)] rotate-modifiers))))))))))
|
||||
(filter #((cpc/editable-attrs (:type %)) :rotation))
|
||||
(map :id))
|
||||
|
||||
get-modifier
|
||||
(fn [shape]
|
||||
(gsh/rotation-modifiers shape center angle))
|
||||
|
||||
modif-tree
|
||||
(gsh/set-objects-modifiers ids objects get-modifier false false)]
|
||||
|
||||
(update state :workspace-modifiers merge modif-tree))))))
|
||||
|
||||
(defn- update-grow-type
|
||||
[shape old-shape]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue