Improved flex tracks behavior and auto sizing

This commit is contained in:
alonso.torres 2023-06-05 15:33:00 +02:00
parent 06ab577e41
commit e86939b8ee
7 changed files with 197 additions and 41 deletions

View file

@ -597,6 +597,6 @@
{:zoom zoom
:objects base-objects
:modifiers modifiers
:shape (or (get objects-modified edition)
:shape (or (get base-objects edition)
(get base-objects @hover-top-frame-id))
:view-only (not show-grid-editor?)}]])]]]))

View file

@ -40,8 +40,19 @@
(let [children (->> (cph/get-immediate-children objects (:id shape))
(remove :hidden))
bounds (d/lazy-map (keys objects) #(dm/get-in objects [% :points]))
layout-bounds (gsl/layout-content-bounds bounds shape children)
layout-points (flatten (gsl/layout-content-points bounds shape children))]
layout-bounds
(cond (ctl/flex-layout? shape)
(gsl/layout-content-bounds bounds shape children)
(ctl/grid-layout? shape)
(gsg/layout-content-bounds bounds shape children))
layout-points
(cond (ctl/flex-layout? shape)
(flatten (gsl/layout-content-points bounds shape children))
(ctl/grid-layout? shape)
(flatten (gsg/layout-content-points bounds shape children)))]
[:g.debug-layout {:pointer-events "none"}
[:polygon {:points (->> layout-bounds (map #(dm/fmt "%, %" (:x %) (:y %))) (str/join " "))
:style {:stroke "red" :fill "none"}}]

View file

@ -665,11 +665,12 @@
zoom (unchecked-get props "zoom")
view-only (unchecked-get props "view-only")
shape (mf/use-memo
(mf/deps modifiers base-shape)
#(gsh/transform-shape
base-shape
(dm/get-in modifiers [(:id base-shape) :modifiers])))
shape
(mf/use-memo
(mf/deps modifiers base-shape)
#(gsh/transform-shape
base-shape
(dm/get-in modifiers [(:id base-shape) :modifiers])))
snap-pixel? (mf/deref refs/snap-pixel?)