diff --git a/common/src/app/common/types/modifiers.cljc b/common/src/app/common/types/modifiers.cljc index 22c5ff6368..fe308d402a 100644 --- a/common/src/app/common/types/modifiers.cljc +++ b/common/src/app/common/types/modifiers.cljc @@ -27,6 +27,7 @@ ;; * reflow ;; - structure-child: Structure recursive ;; * scale-content +;; * rotation ;; (def conjv (fnil conj [])) @@ -62,6 +63,8 @@ (defn set-rotation [modifiers center angle] (-> modifiers + (update :structure-child conjv {:type :rotation + :rotation angle}) (update :geometry conjv {:type :rotation :center center :rotation angle}))) @@ -327,11 +330,12 @@ (let [remove? (set children-to-remove)] (d/removev remove? shapes))) - - apply-modifier - (fn [shape {:keys [type value index]}] + (fn [shape {:keys [type value index rotation]}] (cond-> shape + (= type :rotation) + (update :rotation #(mod (+ % rotation) 360)) + (and (= type :add-children) (some? index)) (update :shapes (fn [shapes] @@ -348,7 +352,6 @@ (= type :scale-content) (apply-scale-content value)))] - (as-> shape $ (reduce apply-modifier $ (:structure-parent modifiers)) (reduce apply-modifier $ (:structure-child modifiers))))) diff --git a/frontend/src/app/main/ui/workspace/shapes/frame/dynamic_modifiers.cljs b/frontend/src/app/main/ui/workspace/shapes/frame/dynamic_modifiers.cljs index 288ebcbff5..b5a34ba654 100644 --- a/frontend/src/app/main/ui/workspace/shapes/frame/dynamic_modifiers.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/frame/dynamic_modifiers.cljs @@ -248,18 +248,22 @@ (mf/use-layout-effect (mf/deps transforms) (fn [] - (let [is-prev-val? (d/not-empty? @prev-modifiers) - is-cur-val? (d/not-empty? modifiers)] - (when (and (not is-prev-val?) is-cur-val?) - (start-transform! node shapes)) + (let [curr-shapes-set (into #{} (map :id) shapes) + prev-shapes-set (into #{} (map :id) @prev-shapes) - (when is-cur-val? + new-shapes (->> shapes (remove #(contains? prev-shapes-set (:id %)))) + removed-shapes (->> @prev-shapes (remove #(contains? curr-shapes-set (:id %))))] + + (when (d/not-empty? new-shapes) + (start-transform! node new-shapes)) + + (when (d/not-empty? shapes) (update-transform! node shapes transforms modifiers)) - (when (and is-prev-val? (not is-cur-val?)) - (remove-transform! node @prev-shapes)) + (when (d/not-empty? removed-shapes) + (remove-transform! node @prev-shapes))) - (reset! prev-modifiers modifiers) - (reset! prev-transforms transforms) - (reset! prev-shapes shapes)))))) + (reset! prev-modifiers modifiers) + (reset! prev-transforms transforms) + (reset! prev-shapes shapes))))) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options.cljs b/frontend/src/app/main/ui/workspace/sidebar/options.cljs index 99f65f0fe3..1a0faed463 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options.cljs @@ -60,12 +60,9 @@ {::mf/wrap [mf/memo]} [{:keys [selected section shapes shapes-with-children page-id file-id]}] (let [drawing (mf/deref refs/workspace-drawing) - base-objects (-> (mf/deref refs/workspace-page-objects)) + objects (mf/deref refs/workspace-page-objects) shared-libs (mf/deref refs/workspace-libraries) - modifiers (mf/deref refs/workspace-modifiers) - objects-modified (mf/with-memo [base-objects modifiers] - (ctm/merge-modifiers base-objects modifiers)) - selected-shapes (into [] (keep (d/getf objects-modified)) selected)] + selected-shapes (into [] (keep (d/getf objects)) selected)] [:div.tool-window [:div.tool-window-content [:& tab-container {:on-change-tab #(st/emit! (udw/set-options-mode %)) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs index 8a9e73f3c9..2fdea6e9f6 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs @@ -68,7 +68,9 @@ ;; -- User/drawing coords (mf/defc measures-menu [{:keys [ids ids-with-children values type all-types shape] :as props}] - (let [options (if (= type :multiple) + (let [workspace-modifiers (mf/deref refs/workspace-modifiers) + + options (if (= type :multiple) (reduce #(union %1 %2) (map #(get type->options %) all-types)) (get type->options type)) @@ -83,7 +85,9 @@ ;; the shape with the mouse, generate a copy of the shapes applying ;; the transient transformations. shapes (as-> old-shapes $ - #_(map gsh/transform-shape $) + (map (fn [shape] + (let [modifiers (get-in workspace-modifiers [(:id shape) :modifiers])] + (gsh/transform-shape shape modifiers))) $) (map gsh/translate-to-frame $ frames)) ;; For rotated or stretched shapes, the origin point we show in the menu @@ -441,5 +445,3 @@ (tr "workspace.options.show-in-viewer")]]) ]]])) - -