0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-22 22:49:01 -05:00

wip fixes

This commit is contained in:
Andrés Moya 2022-11-23 17:08:09 +01:00
parent 4eaa9394f6
commit a4e36390e2
6 changed files with 22 additions and 16 deletions

View file

@ -193,10 +193,6 @@
(dm/export gtr/transform-bounds) (dm/export gtr/transform-bounds)
(dm/export gtr/move-position-data) (dm/export gtr/move-position-data)
(dm/export gtr/apply-objects-modifiers) (dm/export gtr/apply-objects-modifiers)
(dm/export gtr/parent-coords-rect)
(dm/export gtr/parent-coords-points)
(dm/export gtr/apply-modifiers)
(dm/export gtr/apply-transform)
;; Constratins ;; Constratins
(dm/export gct/calc-child-modifiers) (dm/export gct/calc-child-modifiers)

View file

@ -14,6 +14,7 @@
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.pages.common :refer [file-version]] [app.common.pages.common :refer [file-version]]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us]
[app.common.types.color :as ctc] [app.common.types.color :as ctc]
[app.common.types.colors-list :as ctcl] [app.common.types.colors-list :as ctcl]
[app.common.types.component :as ctk] [app.common.types.component :as ctk]

View file

@ -15,6 +15,7 @@
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.types.modifiers :as ctm] [app.common.types.modifiers :as ctm]
[app.common.types.container :as ctn]
[app.common.types.shape :as cts] [app.common.types.shape :as cts]
[app.common.types.shape.layout :as ctl] [app.common.types.shape.layout :as ctl]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
@ -54,7 +55,7 @@
shape shape
(nil? root) (nil? root)
(cph/get-root-shape objects shape) (ctn/get-root-shape objects shape)
:else root) :else root)
@ -64,7 +65,7 @@
transformed-shape transformed-shape
(nil? transformed-root) (nil? transformed-root)
(as-> (cph/get-root-shape objects transformed-shape) $ (as-> (ctn/get-root-shape objects transformed-shape) $
(gsh/transform-shape (merge $ (get modif-tree (:id $))))) (gsh/transform-shape (merge $ (get modif-tree (:id $)))))
:else transformed-root) :else transformed-root)

View file

@ -14,6 +14,7 @@
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.types.component :as ctk] [app.common.types.component :as ctk]
[app.common.types.container :as ctn]
[app.common.types.page :as ctp] [app.common.types.page :as ctp]
[app.common.types.shape :as cts] [app.common.types.shape :as cts]
[app.common.types.shape-tree :as ctst] [app.common.types.shape-tree :as ctst]
@ -159,7 +160,7 @@
;; not the root. In this case, they must not be deleted, ;; not the root. In this case, they must not be deleted,
;; but hidden (to be able to recover them more easily). ;; but hidden (to be able to recover them more easily).
(let [shape (get objects shape-id) (let [shape (get objects shape-id)
component-shape (cph/get-component-shape objects shape)] component-shape (ctn/get-component-shape objects shape)]
(and (ctk/in-component-instance? shape) (and (ctk/in-component-instance? shape)
(not= shape component-shape) (not= shape component-shape)
(not (ctk/main-instance? component-shape))))) (not (ctk/main-instance? component-shape)))))

View file

@ -14,6 +14,7 @@
[app.common.geom.shapes.flex-layout :as gsl] [app.common.geom.shapes.flex-layout :as gsl]
[app.common.math :as mth] [app.common.math :as mth]
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.pages.common :as cpc]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.types.component :as ctk] [app.common.types.component :as ctk]
@ -51,7 +52,8 @@
(let [children (->> root-shape (let [children (->> root-shape
:shapes :shapes
(map #(get objects %)) (map #(get objects %))
(map #(gsh/apply-modifiers % (get-in modifiers [(:id %) :modifiers])))) ;; %% (map #(gsh/apply-modifiers % (get-in modifiers [(:id %) :modifiers])))
)
root-shape (gsh/update-group-selrect root-shape children)] root-shape (gsh/update-group-selrect root-shape children)]
[(:id root-shape) [root-shape (ctn/get-instances objects root-shape)]]))))] [(:id root-shape) [root-shape (ctn/get-instances objects root-shape)]]))))]
@ -130,7 +132,8 @@
] ]
(->> (get-in modifiers [(:id shape) :modifiers]) (->> (get-in modifiers [(:id shape) :modifiers])
(process-text-modifiers shape) (process-text-modifiers shape)
(gsh/apply-modifiers shape)))) ;; %% (gsh/apply-modifiers shape)
)))
main-shapes)] main-shapes)]
(reduce #(add-copy-modifiers %1 %2 main-root main-shapes main-shapes-modif) (reduce #(add-copy-modifiers %1 %2 main-root main-shapes main-shapes-modif)
modifiers modifiers
@ -249,7 +252,8 @@
(contains? (:workspace-layout state) :snap-pixel-grid)) (contains? (:workspace-layout state) :snap-pixel-grid))
modif-tree modif-tree
(gsh/set-objects-modifiers ids objects (constantly modifiers) ignore-constraints snap-pixel?) {}
;; %% (gsh/set-objects-modifiers ids objects (constantly modifiers) ignore-constraints snap-pixel?)
copies (get-copies (mapv (d/getf objects) ids) objects modif-tree) copies (get-copies (mapv (d/getf objects) ids) objects modif-tree)
@ -285,10 +289,11 @@
get-modifier get-modifier
(fn [shape] (fn [shape]
(gsh/rotation-modifiers shape center angle)) (ctm/rotation-modifiers shape center angle))
modif-tree modif-tree
(gsh/set-objects-modifiers ids objects get-modifier false false)] {}]
;;%% (gsh/set-objects-modifiers ids objects get-modifier false false)]
(update state :workspace-modifiers merge modif-tree)))))) (update state :workspace-modifiers merge modif-tree))))))
@ -672,7 +677,7 @@
(rx/map (rx/map
(fn [[[pos mod?] shift?]] (fn [[[pos mod?] shift?]]
(let [delta-angle (calculate-angle pos mod? shift?)] (let [delta-angle (calculate-angle pos mod? shift?)]
(dwm/set-rotation-modifiers delta-angle shapes group-center)))) (set-rotation-modifiers delta-angle shapes group-center))))
(rx/take-until stoper)) (rx/take-until stoper))
(rx/of (dwm/apply-modifiers) (rx/of (dwm/apply-modifiers)
(finish-transform))))))) (finish-transform)))))))
@ -688,7 +693,7 @@
objects (wsh/lookup-page-objects state page-id) objects (wsh/lookup-page-objects state page-id)
rotate-shape (fn [shape] rotate-shape (fn [shape]
(let [delta (- rotation (:rotation shape))] (let [delta (- rotation (:rotation shape))]
(dwm/set-rotation-modifiers delta [shape])))] (set-rotation-modifiers delta [shape])))]
(rx/concat (rx/concat
(rx/from (->> ids (map #(get objects %)) (map rotate-shape))) (rx/from (->> ids (map #(get objects %)) (map rotate-shape)))
(rx/of (dwm/apply-modifiers))))))) (rx/of (dwm/apply-modifiers)))))))

View file

@ -208,7 +208,8 @@
(let [children (->> root-shape (let [children (->> root-shape
:shapes :shapes
(map #(get objects %)) (map #(get objects %))
(map #(gsh/apply-modifiers % (get-in modifiers [(:id %) :modifiers])))) ;; %% (map #(gsh/apply-modifiers % (get-in modifiers [(:id %) :modifiers])))
)
root-shape (gsh/update-group-selrect root-shape children)] root-shape (gsh/update-group-selrect root-shape children)]
[(:id root-shape) [root-shape (ctn/get-instances objects root-shape)]]))))] [(:id root-shape) [root-shape (ctn/get-instances objects root-shape)]]))))]
@ -323,7 +324,8 @@
] ]
(->> (get-in modifiers [(:id shape) :modifiers]) (->> (get-in modifiers [(:id shape) :modifiers])
(process-text-modifiers shape) (process-text-modifiers shape)
(gsh/apply-modifiers shape)))) ;; %% (gsh/apply-modifiers shape)
)))
main-shapes)] main-shapes)]
(reduce #(add-copy-modifiers %1 %2 main-root main-shapes main-shapes-modif) (reduce #(add-copy-modifiers %1 %2 main-root main-shapes main-shapes-modif)
modifiers modifiers