diff --git a/common/src/app/common/geom/shapes/flex_layout/bounds.cljc b/common/src/app/common/geom/shapes/flex_layout/bounds.cljc index d52c6be9c..f0ce544ec 100644 --- a/common/src/app/common/geom/shapes/flex_layout/bounds.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/bounds.cljc @@ -87,16 +87,19 @@ (let [parent-id (:id parent) parent-bounds @(get bounds parent-id) - row? (ctl/row? parent) - col? (ctl/col? parent) - space-around? (ctl/space-around? parent) + row? (ctl/row? parent) + col? (ctl/col? parent) + space-around? (ctl/space-around? parent) + content-around? (ctl/content-around? parent) [layout-gap-row layout-gap-col] (ctl/gaps parent) - row-pad (if (and col? space-around?) + row-pad (if (or (and col? space-around?) + (and row? content-around?)) layout-gap-row 0) - col-pad (if (and row? space-around?) + col-pad (if (or(and row? space-around?) + (and col? content-around?)) layout-gap-col 0) diff --git a/common/src/app/common/geom/shapes/flex_layout/lines.cljc b/common/src/app/common/geom/shapes/flex_layout/lines.cljc index 3801097b1..669dec6fa 100644 --- a/common/src/app/common/geom/shapes/flex_layout/lines.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/lines.cljc @@ -152,6 +152,8 @@ (let [row? (ctl/row? parent) col? (ctl/col? parent) + auto-width? (ctl/auto-width? parent) + auto-height? (ctl/auto-height? parent) [layout-gap-row layout-gap-col] (ctl/gaps parent) @@ -186,12 +188,12 @@ ;; When align-items is stretch we need to adjust the main axis size to grow for the full content stretch-width-fix - (if (and col? (ctl/content-stretch? parent)) + (if (and col? (ctl/content-stretch? parent) (not auto-width?)) (/ (- layout-width (* layout-gap-col (dec num-lines)) total-max-width) num-lines) 0) stretch-height-fix - (if (and row? (ctl/content-stretch? parent)) + (if (and row? (ctl/content-stretch? parent) (not auto-height?)) (/ (- layout-height (* layout-gap-row (dec num-lines)) total-max-height) num-lines) 0) diff --git a/common/src/app/common/geom/shapes/flex_layout/positions.cljc b/common/src/app/common/geom/shapes/flex_layout/positions.cljc index 1ad30c891..2e2e44bfd 100644 --- a/common/src/app/common/geom/shapes/flex_layout/positions.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/positions.cljc @@ -43,7 +43,7 @@ (gpt/add (vv free-height-gap)) around? - (gpt/add (vv (/ free-height (inc num-lines))))) + (gpt/add (vv (max lines-gap-row (/ free-height (inc num-lines)))))) col? (cond-> center? @@ -53,7 +53,7 @@ (gpt/add (hv free-width-gap)) around? - (gpt/add (hv (/ free-width (inc num-lines)))))))) + (gpt/add (hv (max lines-gap-col (/ free-width (inc num-lines))))))))) (defn get-next-line [parent layout-bounds {:keys [line-width line-height]} base-p total-width total-height num-lines] @@ -63,6 +63,9 @@ row? (ctl/row? parent) col? (ctl/col? parent) + auto-width? (ctl/auto-width? parent) + auto-height? (ctl/auto-height? parent) + [layout-gap-row layout-gap-col] (ctl/gaps parent) hv #(gpo/start-hv layout-bounds %) @@ -75,8 +78,11 @@ free-width (- layout-width total-width) free-height (- layout-height total-height) - line-gap-row + line-gap-col (cond + auto-width? + layout-gap-col + stretch? (/ free-width num-lines) @@ -89,8 +95,11 @@ :else layout-gap-col) - line-gap-col + line-gap-row (cond + auto-height? + layout-gap-row + stretch? (/ free-height num-lines) @@ -105,10 +114,10 @@ (cond-> base-p row? - (gpt/add (vv (+ line-height (max layout-gap-row line-gap-col)))) + (gpt/add (vv (+ line-height (max layout-gap-row line-gap-row)))) col? - (gpt/add (hv (+ line-width (max layout-gap-col line-gap-row))))))) + (gpt/add (hv (+ line-width (max layout-gap-col line-gap-col))))))) (defn get-start-line "Cross axis line. It's position is fixed along the different lines" @@ -126,18 +135,20 @@ v-center? (ctl/v-center? parent) v-end? (ctl/v-end? parent) content-stretch? (ctl/content-stretch? parent) + auto-width? (ctl/auto-width? parent) + auto-height? (ctl/auto-height? parent) hv (partial gpo/start-hv layout-bounds) vv (partial gpo/start-vv layout-bounds) children-gap-width (* layout-gap-col (dec num-children)) children-gap-height (* layout-gap-row (dec num-children)) line-height - (if (and row? content-stretch?) + (if (and row? content-stretch? (not auto-height?)) (+ line-height (/ (- layout-height total-height) num-lines)) line-height) line-width - (if (and col? content-stretch?) + (if (and col? content-stretch? (not auto-width?)) (+ line-width (/ (- layout-width total-width) num-lines)) line-width) @@ -263,7 +274,7 @@ col? (-> (gpt/add (vv (+ margin-top margin-bottom))) (gpt/add (vv (+ child-height layout-gap-row)))) - + (some? margin-x) (gpt/add (hv margin-x))