Merge pull request #4390 from penpot/alotor-bugfix-39

🐛 Remove transforming flag and use a global flag
This commit is contained in:
Alejandro 2024-04-10 07:01:58 +02:00 committed by GitHub
commit bbe0baac5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 6 additions and 11 deletions

View file

@ -387,7 +387,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn update-shape-flags (defn update-shape-flags
[ids {:keys [blocked hidden transforming undo-group] :as flags}] [ids {:keys [blocked hidden undo-group] :as flags}]
(dm/assert! (dm/assert!
"expected valid coll of uuids" "expected valid coll of uuids"
(every? uuid? ids)) (every? uuid? ids))
@ -403,15 +403,14 @@
(fn [obj] (fn [obj]
(cond-> obj (cond-> obj
(boolean? blocked) (assoc :blocked blocked) (boolean? blocked) (assoc :blocked blocked)
(boolean? hidden) (assoc :hidden hidden) (boolean? hidden) (assoc :hidden hidden)))
(boolean? transforming) (assoc :transforming transforming)))
objects (wsh/lookup-page-objects state) objects (wsh/lookup-page-objects state)
;; We have change only the hidden behaviour, to hide only the ;; We have change only the hidden behaviour, to hide only the
;; selected shape, block behaviour remains the same. ;; selected shape, block behaviour remains the same.
ids (if (boolean? blocked) ids (if (boolean? blocked)
(into ids (->> ids (mapcat #(cfh/get-children-ids objects %)))) (into ids (->> ids (mapcat #(cfh/get-children-ids objects %))))
ids)] ids)]
(rx/of (dch/update-shapes ids update-fn {:attrs #{:blocked :hidden :transforming} :undo-group undo-group})))))) (rx/of (dch/update-shapes ids update-fn {:attrs #{:blocked :hidden} :undo-group undo-group}))))))
(defn toggle-visibility-selected (defn toggle-visibility-selected
[] []

View file

@ -28,7 +28,6 @@
[app.main.data.workspace.collapse :as dwc] [app.main.data.workspace.collapse :as dwc]
[app.main.data.workspace.modifiers :as dwm] [app.main.data.workspace.modifiers :as dwm]
[app.main.data.workspace.selection :as dws] [app.main.data.workspace.selection :as dws]
[app.main.data.workspace.shapes :as dwsh]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
[app.main.data.workspace.undo :as dwu] [app.main.data.workspace.undo :as dwu]
[app.main.snap :as snap] [app.main.snap :as snap]
@ -291,10 +290,10 @@
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ stream] (watch [_ _ stream]
(rx/concat (rx/concat
(rx/of (dwsh/update-shape-flags ids {:transforming true})) (rx/of #(assoc-in % [:workspace-local :transform] :move))
(->> (rx/timer 1000) (->> (rx/timer 1000)
(rx/map (fn [] (rx/map (fn []
(dwsh/update-shape-flags ids {:transforming false}))) #(assoc-in % [:workspace-local :transform] nil)))
(rx/take-until (rx/take-until
(rx/filter (ptk/type? ::trigger-bounding-box-cloaking) stream))))))) (rx/filter (ptk/type? ::trigger-bounding-box-cloaking) stream)))))))

View file

@ -113,8 +113,7 @@
(defn- show-outline? (defn- show-outline?
[shape] [shape]
(and (not (:hidden shape)) (and (not (:hidden shape))
(not (:blocked shape)) (not (:blocked shape))))
(not (:transforming shape))))
(mf/defc shape-outlines (mf/defc shape-outlines
{::mf/wrap-props false} {::mf/wrap-props false}

View file

@ -321,7 +321,6 @@
transform (gsh/transform-str shape)] transform (gsh/transform-str shape)]
(when (and (some? selrect) (when (and (some? selrect)
(not (:transforming shape))
(not (or (= transform-type :move) (not (or (= transform-type :move)
(= transform-type :rotate)))) (= transform-type :rotate))))
[:g.controls {:pointer-events (if ^boolean disable-handlers "none" "visible")} [:g.controls {:pointer-events (if ^boolean disable-handlers "none" "visible")}
@ -356,7 +355,6 @@
(and flip-y (not flip-x)))] (and flip-y (not flip-x)))]
(when (and (not ^boolean read-only?) (when (and (not ^boolean read-only?)
(not (:transforming shape))
(not (or (= transform-type :move) (not (or (= transform-type :move)
(= transform-type :rotate)))) (= transform-type :rotate))))