0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 16:21:57 -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?
"Returns true if we're editing a path or creating a new one."
[state]
(let [workspace-local (dm/get-in state [:workspace-local])
drawing (dm/get-in state [:workspace-drawing])
{:keys [selected edition]} workspace-local
edit-path? (dm/get-in workspace-local [:edit-path edition])
[{local :workspace-local
drawing :workspace-drawing}]
(let [selected (:selected local)
edition (:edition local)
drawing-obj (:object drawing)
drawing-obj (:object drawing)
drawing-tool (:tool drawing)
shape (or drawing-obj (-> selected first))
shape-id (:id shape)
edit-path? (dm/get-in local [:edit-path edition])
single? (= (count selected) 1)
editing? (and (some? shape-id) (some? edition) (= shape-id edition))
shape (or drawing-obj (first selected))
shape-id (:id shape)
;; we need to check if we're drawing a new object
;; but we're not using the pencil tool.
draw-path? (and (some? drawing-obj)
(cph/path-shape? drawing-obj)
(not= :curve (:tool drawing)))
single? (= (count selected) 1)
editing? (and (some? shape-id)
(some? edition)
(= shape-id edition))
path-edition? (or (and single? editing?
(and (not (cph/text-shape? shape))
(not (cph/frame-shape? shape))))
draw-path?
edit-path?)]
path-edition?))
;; we need to check if we're drawing a new object but we're
;; not using the pencil tool.
draw-path? (and (some? drawing-obj)
(cph/path-shape? drawing-obj)
(not= :curve drawing-tool))]
(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
"Retrieves the currently editing path id"