From 02044a81533d80f39e704b75fb00c2d522ef4968 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 19 Jan 2024 14:28:06 +0100 Subject: [PATCH] :bug: Fix problem in viewer with hidden elements --- common/src/app/common/geom/shapes/bounds.cljc | 35 ++++++++++--------- .../app/main/ui/workspace/shapes/debug.cljs | 2 +- .../app/main/ui/workspace/shapes/frame.cljs | 4 ++- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/common/src/app/common/geom/shapes/bounds.cljc b/common/src/app/common/geom/shapes/bounds.cljc index b6769d763..bb14ea345 100644 --- a/common/src/app/common/geom/shapes/bounds.cljc +++ b/common/src/app/common/geom/shapes/bounds.cljc @@ -140,40 +140,41 @@ (update :width + (* 2 h-padding)) (update :height + (* 2 v-padding))))) +(defn calculate-base-bounds + [shape] + (-> (get-shape-filter-bounds shape) + (add-padding (calculate-padding shape true)))) + (defn get-object-bounds [objects shape] - (let [calculate-base-bounds - (fn [shape] - (-> (get-shape-filter-bounds shape) - (add-padding (calculate-padding shape true)))) - + (let [base-bounds (calculate-base-bounds shape) bounds (cond - (empty? (:shapes shape)) - [(calculate-base-bounds shape)] - - (or (:masked-group shape) (= :bool (:type shape))) - [(calculate-base-bounds shape)] - - (and (cfh/frame-shape? shape) (not (:show-content shape))) - [(calculate-base-bounds shape)] + (or (empty? (:shapes shape)) + (or (:masked-group shape) (= :bool (:type shape))) + (and (cfh/frame-shape? shape) (not (:show-content shape)))) + [base-bounds] :else (cfh/reduce-objects objects (fn [shape] - (and (d/not-empty? (:shapes shape)) + (and (not (:hidden shape)) + (d/not-empty? (:shapes shape)) (or (not (cfh/frame-shape? shape)) (:show-content shape)) (or (not (cfh/group-shape? shape)) (not (:masked-group shape))))) (:id shape) - (fn [result child] - (conj result (calculate-base-bounds child))) - [(calculate-base-bounds shape)])) + (fn [result child] + (cond-> result + (not (:hidden child)) + (conj (calculate-base-bounds child)))) + + [base-bounds])) children-bounds (cond->> (grc/join-rects bounds) diff --git a/frontend/src/app/main/ui/workspace/shapes/debug.cljs b/frontend/src/app/main/ui/workspace/shapes/debug.cljs index 71cec7d26..e1353644b 100644 --- a/frontend/src/app/main/ui/workspace/shapes/debug.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/debug.cljs @@ -91,7 +91,7 @@ [{:keys [shape]}] [:* (when ^boolean (dbg/enabled? :bounding-boxes) - [:& debug-bounding-boxes]) + [:& debug-bounding-boxes {:shape shape}]) (when (and ^boolean (cfh/text-shape? shape) ^boolean (dbg/enabled? :text-outline) diff --git a/frontend/src/app/main/ui/workspace/shapes/frame.cljs b/frontend/src/app/main/ui/workspace/shapes/frame.cljs index 9ecddd1e2..f36519996 100644 --- a/frontend/src/app/main/ui/workspace/shapes/frame.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/frame.cljs @@ -44,7 +44,9 @@ childs (mf/deref childs-ref)] [:& shape-container {:shape shape :ref ref :disable-shadows? (cfh/is-direct-child-of-root? shape)} - [:& frame-shape {:shape shape :childs childs}]])))) + [:& frame-shape {:shape shape :childs childs}] + (when *assert* + [:& wsd/shape-debug {:shape shape}])])))) (defn check-props [new-props old-props]