From a189dc8243fb0b25849b142d4720b148c787b395 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 28 Sep 2021 13:09:19 +0200 Subject: [PATCH] :bug: Fixed some problems with booleans and paths --- common/src/app/common/math.cljc | 2 +- frontend/src/app/main/refs.cljs | 15 ++++++++++++--- frontend/src/app/main/ui/shapes/bool.cljs | 2 +- .../app/main/ui/workspace/shapes/path/editor.cljs | 4 ++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/math.cljc b/common/src/app/common/math.cljc index f413283178..67a327da8c 100644 --- a/common/src/app/common/math.cljc +++ b/common/src/app/common/math.cljc @@ -150,7 +150,7 @@ (if (> num to) to num))) (defn almost-zero? [num] - (< (abs num) 1e-5)) + (< (abs (double num)) 1e-5)) (defonce float-equal-precision 0.001) diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index cc0197bfaa..7f880572a8 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -11,6 +11,7 @@ [app.common.data :as d] [app.common.geom.shapes :as gsh] [app.common.pages :as cp] + [app.common.path.commands :as upc] [app.main.data.workspace.state-helpers :as wsh] [app.main.store :as st] [okulary.core :as l])) @@ -255,13 +256,19 @@ (into [] xform ids)))] (l/derived selector st/state =)))) +(defn- set-content-modifiers [state] + (fn [id shape] + (let [content-modifiers (get-in state [:workspace-local :edit-path id :content-modifiers])] + (if (some? content-modifiers) + (update shape :content upc/apply-content-modifiers content-modifiers) + shape)))) + (defn select-children [id] (let [selector (fn [state] (let [objects (wsh/lookup-page-objects state) - children (cp/select-children id objects) - modifiers (-> (:workspace-modifiers state)) + modifiers (-> (:workspace-modifiers state)) {selected :selected disp-modifiers :modifiers} (-> (:workspace-local state) (select-keys [:modifiers :selected])) @@ -271,7 +278,9 @@ modifiers (into {} (map #(vector % {:modifiers disp-modifiers})) selected))] - (gsh/merge-modifiers children modifiers)))] + (as-> (cp/select-children id objects) $ + (gsh/merge-modifiers $ modifiers) + (d/mapm (set-content-modifiers state) $))))] (l/derived selector st/state =))) (def selected-data diff --git a/frontend/src/app/main/ui/shapes/bool.cljs b/frontend/src/app/main/ui/shapes/bool.cljs index ebbe4753f3..faa3b3f997 100644 --- a/frontend/src/app/main/ui/shapes/bool.cljs +++ b/frontend/src/app/main/ui/shapes/bool.cljs @@ -90,7 +90,7 @@ (mf/use-memo (mf/deps shape childs) (fn [] - (let [childs (d/mapm #(-> %2 (gsh/translate-to-frame frame) gsh/transform-shape) childs)] + (let [childs (d/mapm #(-> %2 gsh/transform-shape (gsh/translate-to-frame frame)) childs)] (->> (:shapes shape) (map #(get childs %)) (filter #(not (:hidden %))) diff --git a/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs b/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs index ed653f5880..0330f101fc 100644 --- a/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs @@ -272,6 +272,10 @@ (reset! hover-point (when (< (gpt/distance position point) (/ 10 zoom)) point))))) [:g.path-editor {:ref editor-ref} + [:path {:d (upf/format-path content) + :style {:fill "none" + :stroke pc/primary-color + :strokeWidth (/ 1 zoom)}}] (when (and preview (not drag-handler)) [:& path-preview {:command preview :from last-p