diff --git a/common/src/app/common/geom/shapes/flex_layout.cljc b/common/src/app/common/geom/shapes/flex_layout.cljc index 937975246..9119d8dab 100644 --- a/common/src/app/common/geom/shapes/flex_layout.cljc +++ b/common/src/app/common/geom/shapes/flex_layout.cljc @@ -18,4 +18,4 @@ (dm/export fdr/layout-drop-areas) (dm/export fli/calc-layout-data) (dm/export fmo/layout-child-modifiers) -(dm/export fmo/normalize-child-modifiers) + diff --git a/common/src/app/common/geom/shapes/flex_layout/modifiers.cljc b/common/src/app/common/geom/shapes/flex_layout/modifiers.cljc index 481d27390..29eea82f0 100644 --- a/common/src/app/common/geom/shapes/flex_layout/modifiers.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/modifiers.cljc @@ -6,41 +6,12 @@ (ns app.common.geom.shapes.flex-layout.modifiers (:require - [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes.flex-layout.positions :as fpo] [app.common.geom.shapes.points :as gpo] - [app.common.geom.shapes.transforms :as gtr] [app.common.types.modifiers :as ctm] [app.common.types.shape.layout :as ctl])) -(defn normalize-child-modifiers - "Apply the modifiers and then normalized them against the parent coordinates" - [modifiers {:keys [transform transform-inverse] :as parent} child-bounds parent-bounds transformed-parent-bounds] - - (let [transformed-child-bounds (gtr/transform-bounds child-bounds modifiers) - - child-bb-before (gpo/parent-coords-bounds child-bounds parent-bounds) - child-bb-after (gpo/parent-coords-bounds transformed-child-bounds transformed-parent-bounds) - - scale-x (/ (gpo/width-points child-bb-before) (gpo/width-points child-bb-after)) - scale-y (/ (gpo/height-points child-bb-before) (gpo/height-points child-bb-after)) - - resize-vector (gpt/point scale-x scale-y) - modif-transform (or (ctm/modifiers->transform modifiers) (gmt/matrix)) - modif-transform-inverse (gmt/inverse modif-transform) - resize-transform (gmt/multiply modif-transform transform) - resize-transform-inverse (gmt/multiply transform-inverse modif-transform-inverse) - resize-origin (gpo/origin transformed-child-bounds)] - - (-> modifiers - (ctm/select-child) - (ctm/resize - resize-vector - resize-origin - resize-transform - resize-transform-inverse)))) - (defn calc-fill-width-data "Calculates the size and modifiers for the width of an auto-fill child" [{:keys [transform transform-inverse] :as parent} diff --git a/common/src/app/common/geom/shapes/modifiers.cljc b/common/src/app/common/geom/shapes/modifiers.cljc index 5470730d7..887681e75 100644 --- a/common/src/app/common/geom/shapes/modifiers.cljc +++ b/common/src/app/common/geom/shapes/modifiers.cljc @@ -121,23 +121,6 @@ (update-in [child-id :modifiers] ctm/add-modifiers child-modifiers)) (rest children))))))))) -#_(defn- process-layout-children - [modif-tree objects bounds parent transformed-parent-bounds] - (letfn [(process-child [modif-tree child] - (let [child-id (:id child) - parent-id (:id parent) - modifiers (dm/get-in modif-tree [parent-id :modifiers]) - child-bounds @(get bounds child-id) - parent-bounds @(get bounds parent-id) - child-modifiers (-> modifiers - (ctm/select-child-geometry-modifiers) - (gcl/normalize-child-modifiers parent child-bounds parent-bounds @transformed-parent-bounds))] - (cond-> modif-tree - (not (ctm/empty? child-modifiers)) - (update-in [child-id :modifiers] ctm/add-modifiers child-modifiers))))] - (let [children (map (d/getf objects) (:shapes parent))] - (reduce process-child modif-tree children)))) - (defn get-group-bounds [objects bounds modif-tree shape] (let [shape-id (:id shape) @@ -275,8 +258,7 @@ (set-children-modifiers objects bounds parent transformed-parent-bounds ignore-constraints) layout? - (-> #_(process-layout-children objects bounds parent transformed-parent-bounds) - (set-layout-modifiers objects bounds parent transformed-parent-bounds))) + (set-layout-modifiers objects bounds parent transformed-parent-bounds)) ;; Auto-width/height can change the positions in the parent so we need to recalculate (cond-> autolayouts auto? (conj (:id parent)))]))