0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-14 08:41:48 -05:00

💄 Add mainly cosmetic changes to path-editing? function

This commit is contained in:
Andrey Antukh 2024-02-29 09:52:39 +01:00
parent f0955c0e99
commit 26ab7f83fe

View file

@ -12,32 +12,36 @@
(defn path-editing? (defn path-editing?
"Returns true if we're editing a path or creating a new one." "Returns true if we're editing a path or creating a new one."
[state] [{local :workspace-local
(let [workspace-local (dm/get-in state [:workspace-local]) drawing :workspace-drawing}]
drawing (dm/get-in state [:workspace-drawing]) (let [selected (:selected local)
{:keys [selected edition]} workspace-local edition (:edition local)
edit-path? (dm/get-in workspace-local [:edit-path edition])
drawing-obj (:object drawing) drawing-obj (:object drawing)
drawing-tool (:tool drawing)
shape (or drawing-obj (-> selected first)) edit-path? (dm/get-in local [:edit-path edition])
shape-id (:id shape)
single? (= (count selected) 1) shape (or drawing-obj (first selected))
editing? (and (some? shape-id) (some? edition) (= shape-id edition)) shape-id (:id shape)
;; we need to check if we're drawing a new object single? (= (count selected) 1)
;; but we're not using the pencil tool. editing? (and (some? shape-id)
draw-path? (and (some? drawing-obj) (some? edition)
(cph/path-shape? drawing-obj) (= shape-id edition))
(not= :curve (:tool drawing)))
path-edition? (or (and single? editing? ;; we need to check if we're drawing a new object but we're
(and (not (cph/text-shape? shape)) ;; not using the pencil tool.
(not (cph/frame-shape? shape)))) draw-path? (and (some? drawing-obj)
draw-path? (cph/path-shape? drawing-obj)
edit-path?)] (not= :curve drawing-tool))]
path-edition?))
(or (and ^boolean single?
^boolean editing?
(and (not (cph/text-shape? shape))
(not (cph/frame-shape? shape))))
draw-path?
edit-path?)))
(defn get-path-id (defn get-path-id
"Retrieves the currently editing path id" "Retrieves the currently editing path id"