mirror of
https://github.com/penpot/penpot.git
synced 2026-08-05 12:29:00 +00:00
🐛 Fix problem with layout sizing
This commit is contained in:
parent
bec683d1ef
commit
6d5af8d6ef
@ -70,11 +70,8 @@
|
|||||||
child-max-width (ctl/child-max-width child)
|
child-max-width (ctl/child-max-width child)
|
||||||
child-max-height (ctl/child-max-height child)
|
child-max-height (ctl/child-max-height child)
|
||||||
|
|
||||||
[child-margin-top child-margin-right child-margin-bottom child-margin-left]
|
child-margin-width (ctl/child-width-margin child)
|
||||||
(ctl/child-margins child)
|
child-margin-height (ctl/child-height-margin child)
|
||||||
|
|
||||||
child-margin-width (+ child-margin-left child-margin-right)
|
|
||||||
child-margin-height (+ child-margin-top child-margin-bottom)
|
|
||||||
|
|
||||||
fill-width? (ctl/fill-width? child)
|
fill-width? (ctl/fill-width? child)
|
||||||
fill-height? (ctl/fill-height? child)
|
fill-height? (ctl/fill-height? child)
|
||||||
|
|||||||
@ -61,13 +61,15 @@
|
|||||||
|
|
||||||
(defn child-min-width
|
(defn child-min-width
|
||||||
[child child-bounds bounds objects]
|
[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)
|
(def -child-min-height nil)
|
||||||
|
|
||||||
(defn child-min-height
|
(defn child-min-height
|
||||||
[child child-bounds bounds objects]
|
[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
|
(defn layout-bounds
|
||||||
[parent shape-bounds]
|
[parent shape-bounds]
|
||||||
|
|||||||
@ -17,53 +17,53 @@
|
|||||||
|
|
||||||
(defn child-min-width
|
(defn child-min-width
|
||||||
[child child-bounds bounds objects]
|
[child child-bounds bounds objects]
|
||||||
(let [min-width
|
(cond
|
||||||
(cond
|
(and (ctl/fill-width? child) (ctl/flex-layout? child))
|
||||||
(and (ctl/fill-width? child) (ctl/flex-layout? child))
|
(ctl/child-min-width child)
|
||||||
(let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})]
|
;; Uncomment this to activate "auto" as min size
|
||||||
(max (ctl/child-min-width child)
|
#_(let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})]
|
||||||
(gpo/width-points (fb/layout-content-bounds bounds child children objects))))
|
(max (ctl/child-min-width child)
|
||||||
|
(gpo/width-points (fb/layout-content-bounds bounds child children objects))))
|
||||||
|
|
||||||
(and (ctl/fill-width? child)
|
(and (ctl/fill-width? child)
|
||||||
(ctl/grid-layout? child))
|
(ctl/grid-layout? child))
|
||||||
(let [children
|
(let [children
|
||||||
(->> (cph/get-immediate-children objects (:id child) {:remove-hidden true})
|
(->> (cph/get-immediate-children objects (:id child) {:remove-hidden true})
|
||||||
(map #(vector @(get bounds (:id %)) %)))
|
(map #(vector @(get bounds (:id %)) %)))
|
||||||
layout-data (gd/calc-layout-data child @(get bounds (:id child)) children bounds objects true)]
|
layout-data (gd/calc-layout-data child @(get bounds (:id child)) children bounds objects true)]
|
||||||
(max (ctl/child-min-width child)
|
(max (ctl/child-min-width child)
|
||||||
(gpo/width-points (gb/layout-content-bounds bounds child layout-data))))
|
(gpo/width-points (gb/layout-content-bounds bounds child layout-data))))
|
||||||
|
|
||||||
(ctl/fill-width? child)
|
(ctl/fill-width? child)
|
||||||
(ctl/child-min-width child)
|
(ctl/child-min-width child)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(gpo/width-points child-bounds))]
|
(gpo/width-points child-bounds)))
|
||||||
(+ min-width (ctl/child-width-margin child))))
|
|
||||||
|
|
||||||
(defn child-min-height
|
(defn child-min-height
|
||||||
[child child-bounds bounds objects]
|
[child child-bounds bounds objects]
|
||||||
(let [min-height
|
(cond
|
||||||
(cond
|
(and (ctl/fill-height? child) (ctl/flex-layout? child))
|
||||||
(and (ctl/fill-height? child) (ctl/flex-layout? child))
|
;; Uncomment this to activate "auto" as min size
|
||||||
(let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})]
|
(ctl/child-min-height child)
|
||||||
(max (ctl/child-min-height child)
|
#_(let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})]
|
||||||
(gpo/height-points (fb/layout-content-bounds bounds child children objects))))
|
(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 (ctl/fill-height? child) (ctl/grid-layout? child))
|
||||||
(let [children
|
(let [children
|
||||||
(->> (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})
|
(->> (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})
|
||||||
(map (fn [child] [@(get bounds (:id child)) child])))
|
(map (fn [child] [@(get bounds (:id child)) child])))
|
||||||
layout-data (gd/calc-layout-data child (:points child) children bounds objects true)
|
layout-data (gd/calc-layout-data child (:points child) children bounds objects true)
|
||||||
auto-bounds (gb/layout-content-bounds bounds child layout-data)]
|
auto-bounds (gb/layout-content-bounds bounds child layout-data)]
|
||||||
(max (ctl/child-min-height child)
|
(max (ctl/child-min-height child)
|
||||||
(gpo/height-points auto-bounds)))
|
(gpo/height-points auto-bounds)))
|
||||||
|
|
||||||
(ctl/fill-height? child)
|
(ctl/fill-height? child)
|
||||||
(ctl/child-min-height child)
|
(ctl/child-min-height child)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(gpo/height-points child-bounds))]
|
(gpo/height-points child-bounds)))
|
||||||
(+ min-height (ctl/child-height-margin child))))
|
|
||||||
|
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
(do (set! fd/-child-min-width child-min-width)
|
(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 #'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-width (constantly child-min-width))
|
||||||
(alter-var-root #'gd/-child-min-height (constantly child-min-height))))
|
(alter-var-root #'gd/-child-min-height (constantly child-min-height))))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user