From 26ab7f83fe66542d1f109ba9b7456858eb373411 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 29 Feb 2024 09:52:39 +0100 Subject: [PATCH] :lipstick: Add mainly cosmetic changes to `path-editing?` function --- .../app/main/data/workspace/path/state.cljs | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/frontend/src/app/main/data/workspace/path/state.cljs b/frontend/src/app/main/data/workspace/path/state.cljs index 00d626435e..923c340296 100644 --- a/frontend/src/app/main/data/workspace/path/state.cljs +++ b/frontend/src/app/main/data/workspace/path/state.cljs @@ -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"