0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 00:40:30 -05:00

Improved blocking/unblocking shapes on layers toolbox.

This commit is contained in:
Andrey Antukh 2016-01-29 21:44:53 +02:00
parent 18b07d509c
commit 07359752ff
2 changed files with 31 additions and 8 deletions

View file

@ -254,16 +254,36 @@
(assoc-in state [:shapes-by-id sid] (assoc shape :hidden false))
(assoc-in state [:shapes-by-id sid] (assoc shape :hidden true)))))))
(defn toggle-shape-blocking
(defn block-shape
[sid]
(reify
rs/UpdateEvent
(-apply-update [_ state]
(let [shape (get-in state [:shapes-by-id sid])
blocked? (:blocked shape false)]
(if blocked?
(assoc-in state [:shapes-by-id sid] (assoc shape :blocked false))
(assoc-in state [:shapes-by-id sid] (assoc shape :blocked true)))))))
(assoc-in state [:shapes-by-id sid :blocked] true))
rs/WatchEvent
(-apply-watch [_ state]
(let [shape (get-in state [:shapes-by-id sid])]
(if-not (= (:type shape) :builtin/group)
(rx/empty)
(rx/from-coll
(map block-shape (:items shape))))))))
(defn unblock-shape
[sid]
(reify
rs/UpdateEvent
(-apply-update [_ state]
(assoc-in state [:shapes-by-id sid :blocked] false))
rs/WatchEvent
(-apply-watch [_ state]
(let [shape (get-in state [:shapes-by-id sid])]
(if-not (= (:type shape) :builtin/group)
(rx/empty)
(rx/from-coll
(map unblock-shape (:items shape))))))))
(defn toggle-shape-locking
[sid]

View file

@ -61,8 +61,11 @@
(defn- toggle-blocking
[item event]
(dom/stop-propagation event)
(let [id (:id item)]
(rs/emit! (dw/toggle-shape-blocking id))))
(let [id (:id item)
blocked? (:blocked item)]
(if blocked?
(rs/emit! (dw/unblock-shape id))
(rs/emit! (dw/block-shape id)))))
(defn- toggle-locking
[item event]