🐛 Fix problems with grid layout and flex children absolute

This commit is contained in:
alonso.torres
2024-02-07 16:38:35 +01:00
committed by Andrés Moya
parent c8d19c846a
commit 4e1353caf1
7 changed files with 42 additions and 38 deletions

View File

@@ -224,8 +224,18 @@
(remove ctl/position-absolute?)
(remove gco/invalid-geometry?))
auto? (or (ctl/auto? parent)
(and (ctl/grid-layout? objects (:parent-id parent))
(ctl/fill? parent)))
auto-width? (or (ctl/auto-width? parent)
(and (ctl/grid-layout? objects (:parent-id parent))
(ctl/fill-width? parent)))
auto-height? (or (ctl/auto-height? parent)
(and (ctl/grid-layout? objects (:parent-id parent))
(ctl/fill-height? parent)))
content-bounds
(when (and (d/not-empty? children) (ctl/auto? parent))
(when (and (d/not-empty? children) auto?)
(cond
(ctl/flex-layout? parent)
(gcfl/layout-content-bounds bounds parent children objects)
@@ -238,12 +248,11 @@
auto-width (when content-bounds (gpo/width-points content-bounds))
auto-height (when content-bounds (gpo/height-points content-bounds))]
(cond-> (ctm/empty)
(and (some? auto-width) (ctl/auto-width? parent))
(and (some? auto-width) auto-width?)
(set-parent-auto-width auto-width)
(and (some? auto-height) (ctl/auto-height? parent))
(and (some? auto-height) auto-height?)
(set-parent-auto-height auto-height))))
(defn find-auto-layouts

View File

@@ -14,7 +14,7 @@
(def conjv (fnil conj []))
;; Setted in app.common.geom.shapes.common-layout
;; Setted in app.common.geom.shapes.min-size-layout
;; We do it this way because circular dependencies
(def -child-min-width nil)

View File

@@ -24,14 +24,16 @@
(ctl/child-min-width child)
(and strict? (ctl/fill-width? child) (ctl/flex-layout? child))
(let [children (cfh/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})]
(let [children (->> (cfh/get-immediate-children objects (dm/get-prop child :id))
(remove ctl/position-absolute?))]
(max (ctl/child-min-width child)
(gpo/width-points (fb/layout-content-bounds bounds child children objects))))
(and (ctl/fill-width? child)
(ctl/grid-layout? child))
(let [children
(->> (cfh/get-immediate-children objects (:id child) {:remove-hidden true})
(->> (cfh/get-immediate-children objects (:id child))
(remove ctl/position-absolute?)
(map #(vector @(get bounds (:id %)) %)))
layout-data (gd/calc-layout-data child @(get bounds (:id child)) children bounds objects true)]
(max (ctl/child-min-width child)
@@ -52,13 +54,15 @@
(ctl/child-min-height child)
(and strict? (ctl/fill-height? child) (ctl/flex-layout? child))
(let [children (cfh/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})]
(let [children (->> (cfh/get-immediate-children objects (dm/get-prop child :id))
(remove ctl/position-absolute?))]
(max (ctl/child-min-height child)
(gpo/height-points (fb/layout-content-bounds bounds child children objects))))
(and (ctl/fill-height? child) (ctl/grid-layout? child))
(let [children
(->> (cfh/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})
(->> (cfh/get-immediate-children objects (dm/get-prop child :id))
(remove ctl/position-absolute?)
(map (fn [child] [@(get bounds (:id child)) child])))
layout-data (gd/calc-layout-data child (:points child) children bounds objects true)
auto-bounds (gb/layout-content-bounds bounds child layout-data)]

View File

@@ -517,7 +517,6 @@
ids (seq ids)]
(if (empty? ids)
objects
(let [id (first ids)
modifier (dm/get-in modifiers [id :modifiers])]
(recur (d/update-when objects id transform-shape modifier)

View File

@@ -1599,13 +1599,13 @@
(into #{}
(filter #(and
(not (contains? deleted-cells %))
(not= (dissoc (get source-cells %) :shapes :row :column :row-span :column-span)
(dissoc (get target-cells %) :shapes :row :column :row-span :column-span))))
(not= (get-data source-cells %)
(get-data target-cells %))))
(keys target-cells))]
(->> touched-cells
(reduce
(fn [cells id]
(-> cells
(d/update-when id d/patch-object (dissoc (get target-cells id) :shapes :row :column :row-span :column-span))))
(d/update-when id d/patch-object (get-data target-cells id))))
source-cells))))))