diff --git a/common/src/app/common/geom/shapes/flex_layout/layout_data.cljc b/common/src/app/common/geom/shapes/flex_layout/layout_data.cljc index ed818c66b..9a8dafd5c 100644 --- a/common/src/app/common/geom/shapes/flex_layout/layout_data.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/layout_data.cljc @@ -70,11 +70,8 @@ child-max-width (ctl/child-max-width child) child-max-height (ctl/child-max-height child) - [child-margin-top child-margin-right child-margin-bottom child-margin-left] - (ctl/child-margins child) - - child-margin-width (+ child-margin-left child-margin-right) - child-margin-height (+ child-margin-top child-margin-bottom) + child-margin-width (ctl/child-width-margin child) + child-margin-height (ctl/child-height-margin child) fill-width? (ctl/fill-width? child) fill-height? (ctl/fill-height? child) diff --git a/common/src/app/common/geom/shapes/grid_layout/layout_data.cljc b/common/src/app/common/geom/shapes/grid_layout/layout_data.cljc index 51ce068aa..fa07db760 100644 --- a/common/src/app/common/geom/shapes/grid_layout/layout_data.cljc +++ b/common/src/app/common/geom/shapes/grid_layout/layout_data.cljc @@ -61,13 +61,15 @@ (defn child-min-width [child child-bounds bounds objects] - (-child-min-width child child-bounds bounds objects)) + (+ (ctl/child-width-margin child) + (-child-min-width child child-bounds bounds objects))) (def -child-min-height nil) (defn child-min-height [child child-bounds bounds objects] - (-child-min-height child child-bounds bounds objects)) + (+ (ctl/child-height-margin child) + (-child-min-height child child-bounds bounds objects))) (defn layout-bounds [parent shape-bounds] diff --git a/common/src/app/common/geom/shapes/min_size_layout.cljc b/common/src/app/common/geom/shapes/min_size_layout.cljc index 8f1d6b6f7..ab9ca25ac 100644 --- a/common/src/app/common/geom/shapes/min_size_layout.cljc +++ b/common/src/app/common/geom/shapes/min_size_layout.cljc @@ -17,53 +17,53 @@ (defn child-min-width [child child-bounds bounds objects] - (let [min-width - (cond - (and (ctl/fill-width? child) (ctl/flex-layout? child)) - (let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})] - (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 - (->> (cph/get-immediate-children objects (:id child) {:remove-hidden true}) - (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) - (gpo/width-points (gb/layout-content-bounds bounds child layout-data)))) - - (ctl/fill-width? child) - (ctl/child-min-width child) + (cond + (and (ctl/fill-width? child) (ctl/flex-layout? child)) + (ctl/child-min-width child) + ;; Uncomment this to activate "auto" as min size + #_(let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})] + (max (ctl/child-min-width child) + (gpo/width-points (fb/layout-content-bounds bounds child children objects)))) - :else - (gpo/width-points child-bounds))] - (+ min-width (ctl/child-width-margin child)))) + (and (ctl/fill-width? child) + (ctl/grid-layout? child)) + (let [children + (->> (cph/get-immediate-children objects (:id child) {:remove-hidden true}) + (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) + (gpo/width-points (gb/layout-content-bounds bounds child layout-data)))) + + (ctl/fill-width? child) + (ctl/child-min-width child) + + :else + (gpo/width-points child-bounds))) (defn child-min-height [child child-bounds bounds objects] - (let [min-height - (cond - (and (ctl/fill-height? child) (ctl/flex-layout? child)) - (let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})] - (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 - (->> (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true}) - (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)] - (max (ctl/child-min-height child) - (gpo/height-points auto-bounds))) - - (ctl/fill-height? child) - (ctl/child-min-height child) + (cond + (and (ctl/fill-height? child) (ctl/flex-layout? child)) + ;; Uncomment this to activate "auto" as min size + (ctl/child-min-height child) + #_(let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})] + (max (ctl/child-min-height child) + (gpo/height-points (fb/layout-content-bounds bounds child children objects)))) - :else - (gpo/height-points child-bounds))] - (+ min-height (ctl/child-height-margin child)))) + (and (ctl/fill-height? child) (ctl/grid-layout? child)) + (let [children + (->> (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true}) + (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)] + (max (ctl/child-min-height child) + (gpo/height-points auto-bounds))) + + (ctl/fill-height? child) + (ctl/child-min-height child) + + :else + (gpo/height-points child-bounds))) #?(:cljs (do (set! fd/-child-min-width child-min-width) @@ -80,4 +80,3 @@ (alter-var-root #'fb/-child-min-height (constantly child-min-height)) (alter-var-root #'gd/-child-min-width (constantly child-min-width)) (alter-var-root #'gd/-child-min-height (constantly child-min-height)))) -