mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 12:06:12 +02:00
🐛 Fix problem with auto in grid and min sizes
This commit is contained in:
parent
d0244e0bef
commit
cf3c3cf989
2 changed files with 48 additions and 42 deletions
|
@ -62,14 +62,14 @@
|
||||||
(defn child-min-width
|
(defn child-min-width
|
||||||
[child child-bounds bounds objects]
|
[child child-bounds bounds objects]
|
||||||
(+ (ctl/child-width-margin child)
|
(+ (ctl/child-width-margin child)
|
||||||
(-child-min-width child child-bounds bounds objects)))
|
(-child-min-width child child-bounds bounds objects true)))
|
||||||
|
|
||||||
(def -child-min-height nil)
|
(def -child-min-height nil)
|
||||||
|
|
||||||
(defn child-min-height
|
(defn child-min-height
|
||||||
[child child-bounds bounds objects]
|
[child child-bounds bounds objects]
|
||||||
(+ (ctl/child-height-margin child)
|
(+ (ctl/child-height-margin child)
|
||||||
(-child-min-height child child-bounds bounds objects)))
|
(-child-min-height child child-bounds bounds objects true)))
|
||||||
|
|
||||||
(defn layout-bounds
|
(defn layout-bounds
|
||||||
[parent shape-bounds]
|
[parent shape-bounds]
|
||||||
|
|
|
@ -16,54 +16,60 @@
|
||||||
[app.common.types.shape.layout :as ctl]))
|
[app.common.types.shape.layout :as ctl]))
|
||||||
|
|
||||||
(defn child-min-width
|
(defn child-min-width
|
||||||
[child child-bounds bounds objects]
|
([child child-bounds bounds objects]
|
||||||
(cond
|
(child-min-width child child-bounds bounds objects false))
|
||||||
(and (ctl/fill-width? child) (ctl/flex-layout? child))
|
([child child-bounds bounds objects strict?]
|
||||||
(ctl/child-min-width child)
|
(cond
|
||||||
;; Uncomment this to activate "auto" as min size
|
(and (not strict?) (ctl/fill-width? child) (ctl/flex-layout? child))
|
||||||
#_(let [children (cfh/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})]
|
(ctl/child-min-width child)
|
||||||
(max (ctl/child-min-width child)
|
|
||||||
(gpo/width-points (fb/layout-content-bounds bounds child children objects))))
|
|
||||||
|
|
||||||
(and (ctl/fill-width? child)
|
(and strict? (ctl/fill-width? child) (ctl/flex-layout? child))
|
||||||
(ctl/grid-layout? child))
|
(let [children (cfh/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})]
|
||||||
(let [children
|
(max (ctl/child-min-width child)
|
||||||
(->> (cfh/get-immediate-children objects (:id child) {:remove-hidden true})
|
(gpo/width-points (fb/layout-content-bounds bounds child children objects))))
|
||||||
(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)
|
(and (ctl/fill-width? child)
|
||||||
(ctl/child-min-width child)
|
(ctl/grid-layout? child))
|
||||||
|
(let [children
|
||||||
|
(->> (cfh/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))))
|
||||||
|
|
||||||
:else
|
(ctl/fill-width? child)
|
||||||
(gpo/width-points child-bounds)))
|
(ctl/child-min-width child)
|
||||||
|
|
||||||
|
:else
|
||||||
|
(gpo/width-points child-bounds))))
|
||||||
|
|
||||||
(defn child-min-height
|
(defn child-min-height
|
||||||
[child child-bounds bounds objects]
|
([child child-bounds bounds objects]
|
||||||
(cond
|
(child-min-height child child-bounds bounds objects false))
|
||||||
(and (ctl/fill-height? child) (ctl/flex-layout? child))
|
([child child-bounds bounds objects strict?]
|
||||||
;; Uncomment this to activate "auto" as min size
|
(cond
|
||||||
(ctl/child-min-height child)
|
(and (not strict?) (ctl/fill-height? child) (ctl/flex-layout? child))
|
||||||
#_(let [children (cfh/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})]
|
(ctl/child-min-height child)
|
||||||
(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))
|
(and strict? (ctl/fill-height? child) (ctl/flex-layout? child))
|
||||||
(let [children
|
(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-hidden true})
|
(max (ctl/child-min-height child)
|
||||||
(map (fn [child] [@(get bounds (:id child)) child])))
|
(gpo/height-points (fb/layout-content-bounds bounds child children objects))))
|
||||||
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)
|
(and (ctl/fill-height? child) (ctl/grid-layout? child))
|
||||||
(ctl/child-min-height child)
|
(let [children
|
||||||
|
(->> (cfh/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)))
|
||||||
|
|
||||||
:else
|
(ctl/fill-height? child)
|
||||||
(gpo/height-points child-bounds)))
|
(ctl/child-min-height child)
|
||||||
|
|
||||||
|
:else
|
||||||
|
(gpo/height-points child-bounds))))
|
||||||
|
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
(do (set! fd/-child-min-width child-min-width)
|
(do (set! fd/-child-min-width child-min-width)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue