mirror of
https://github.com/penpot/penpot.git
synced 2025-03-15 17:21:17 -05:00
🐛 Fix problem with hug layout and groups
This commit is contained in:
parent
2c558a6a02
commit
29b1b4dbc9
5 changed files with 41 additions and 32 deletions
|
@ -13,9 +13,9 @@
|
|||
[app.common.geom.shapes.flex-layout.modifiers :as fmo]))
|
||||
|
||||
(dm/export fbo/layout-content-bounds)
|
||||
(dm/export fbo/child-layout-bound-points)
|
||||
(dm/export fdr/get-drop-index)
|
||||
(dm/export fdr/layout-drop-areas)
|
||||
(dm/export fli/calc-layout-data)
|
||||
(dm/export fmo/layout-child-modifiers)
|
||||
(dm/export fmo/normalize-child-modifiers)
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
child-bounds @(get bounds child-id)
|
||||
child-bounds
|
||||
(if (or (ctl/fill-height? child) (ctl/fill-height? child))
|
||||
(child-layout-bound-points parent child parent-bounds parent-bounds)
|
||||
(child-layout-bound-points parent child parent-bounds child-bounds)
|
||||
child-bounds)]
|
||||
(gpo/parent-coords-bounds child-bounds parent-bounds)))]
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
[app.common.geom.shapes.constraints :as gct]
|
||||
[app.common.geom.shapes.flex-layout :as gcl]
|
||||
[app.common.geom.shapes.pixel-precision :as gpp]
|
||||
[app.common.geom.shapes.points :as cpo]
|
||||
[app.common.geom.shapes.points :as gpo]
|
||||
[app.common.geom.shapes.transforms :as gtr]
|
||||
[app.common.pages.helpers :as cph]
|
||||
|
@ -138,29 +139,34 @@
|
|||
(let [children (map (d/getf objects) (:shapes parent))]
|
||||
(reduce process-child modif-tree children))))
|
||||
|
||||
|
||||
(defn get-group-bounds
|
||||
[objects bounds modif-tree shape]
|
||||
(let [shape-id (:id shape)
|
||||
modifiers (-> (dm/get-in modif-tree [shape-id :modifiers])
|
||||
(ctm/select-geometry))
|
||||
|
||||
children (cph/get-immediate-children objects shape-id)
|
||||
group-bounds
|
||||
(cond
|
||||
(cph/group-shape? shape)
|
||||
(let [children-bounds (->> children (mapv #(get-group-bounds objects bounds modif-tree %)))]
|
||||
(gtr/group-bounds shape children-bounds))
|
||||
children (cph/get-immediate-children objects shape-id)]
|
||||
|
||||
(cph/mask-shape? shape)
|
||||
(get-group-bounds objects bounds modif-tree (-> children first))
|
||||
(cond
|
||||
(cph/group-shape? shape)
|
||||
(let [;; Transform here to then calculate the bounds relative to the transform
|
||||
current-bounds
|
||||
(cond-> @(get bounds shape-id)
|
||||
(not (ctm/empty? modifiers))
|
||||
(gtr/transform-bounds modifiers))
|
||||
|
||||
:else
|
||||
@(get bounds shape-id))]
|
||||
children-bounds
|
||||
(->> children
|
||||
(mapv #(get-group-bounds objects bounds modif-tree %)))]
|
||||
(cpo/merge-parent-coords-bounds children-bounds current-bounds))
|
||||
|
||||
(cond-> group-bounds
|
||||
(not (ctm/empty? modifiers))
|
||||
(gtr/transform-bounds modifiers))))
|
||||
(cph/mask-shape? shape)
|
||||
(get-group-bounds objects bounds modif-tree (-> children first))
|
||||
|
||||
:else
|
||||
(cond-> @(get bounds shape-id)
|
||||
(not (ctm/empty? modifiers))
|
||||
(gtr/transform-bounds modifiers)))))
|
||||
|
||||
(defn- set-layout-modifiers
|
||||
[modif-tree objects bounds parent transformed-parent-bounds]
|
||||
|
|
|
@ -369,16 +369,6 @@
|
|||
(update :width + (:width deltas))
|
||||
(update :height + (:height deltas)))))))
|
||||
|
||||
(defn group-bounds
|
||||
[group children-bounds]
|
||||
(let [shape-center (gco/center-shape group)
|
||||
points (flatten children-bounds)
|
||||
points (if (empty? points) (:points group) points)]
|
||||
(-> points
|
||||
(gco/transform-points shape-center (:transform-inverse group (gmt/matrix)))
|
||||
(gpr/squared-points)
|
||||
(gco/transform-points shape-center (:transform group (gmt/matrix))))))
|
||||
|
||||
(defn update-group-selrect
|
||||
[group children]
|
||||
(let [shape-center (gco/center-shape group)
|
||||
|
|
|
@ -152,7 +152,7 @@
|
|||
[props]
|
||||
|
||||
(let [objects (unchecked-get props "objects")
|
||||
zoom (unchecked-get props "objects")
|
||||
zoom (unchecked-get props "zoom")
|
||||
selected-shapes (unchecked-get props "selected-shapes")
|
||||
hover-top-frame-id (unchecked-get props "hover-top-frame-id")
|
||||
|
||||
|
@ -160,13 +160,26 @@
|
|||
(when (and (= (count selected-shapes) 1) (= :frame (-> selected-shapes first :type)))
|
||||
(first selected-shapes))
|
||||
|
||||
parent (or selected-frame (get objects hover-top-frame-id))]
|
||||
parent (or selected-frame (get objects hover-top-frame-id))
|
||||
parent-bounds (:points parent)]
|
||||
|
||||
(when (and (some? parent) (not= uuid/zero (:id parent)))
|
||||
(let [children (cph/get-immediate-children objects (:id parent))]
|
||||
[:g.debug-parent-bounds {:pointer-events "none"}
|
||||
(for [[idx child] (d/enumerate children)]
|
||||
[:> shape-parent-bound {:key (dm/str "bound-" idx)
|
||||
:zoom zoom
|
||||
:shape child
|
||||
:parent parent}])]))))
|
||||
[:*
|
||||
[:> shape-parent-bound {:key (dm/str "bound-" idx)
|
||||
:zoom zoom
|
||||
:shape child
|
||||
:parent parent}]
|
||||
|
||||
(let [child-bounds (:points child)
|
||||
points
|
||||
(if (or (ctl/fill-height? child) (ctl/fill-height? child))
|
||||
(gsl/child-layout-bound-points parent child parent-bounds child-bounds)
|
||||
child-bounds)]
|
||||
(for [point points]
|
||||
[:circle {:cx (:x point)
|
||||
:cy (:y point)
|
||||
:r (/ 2 zoom)
|
||||
:style {:fill "red"}}]))])]))))
|
||||
|
|
Loading…
Add table
Reference in a new issue