From 8b5a36a49f0257bbd3f91780083203e617e744d7 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 28 Feb 2023 13:15:48 +0100 Subject: [PATCH 1/3] :bug: Fix problem with auto layout an absolute positioning --- .../geom/shapes/flex_layout/bounds.cljc | 4 +- .../src/app/common/geom/shapes/modifiers.cljc | 5 +-- common/src/app/common/types/shape/layout.cljc | 40 ++++++++++--------- .../app/main/data/workspace/shape_layout.cljs | 5 ++- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/common/src/app/common/geom/shapes/flex_layout/bounds.cljc b/common/src/app/common/geom/shapes/flex_layout/bounds.cljc index d37dc32f3..358dbe34e 100644 --- a/common/src/app/common/geom/shapes/flex_layout/bounds.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/bounds.cljc @@ -117,7 +117,9 @@ child-bounds))] - (->> children (map get-child-bounds)))) + (->> children + (remove ctl/layout-absolute?) + (map get-child-bounds)))) (defn layout-content-bounds [bounds {:keys [layout-padding] :as parent} children] diff --git a/common/src/app/common/geom/shapes/modifiers.cljc b/common/src/app/common/geom/shapes/modifiers.cljc index 8e7d40704..df17fefd9 100644 --- a/common/src/app/common/geom/shapes/modifiers.cljc +++ b/common/src/app/common/geom/shapes/modifiers.cljc @@ -96,7 +96,6 @@ "Propagates the modifiers from a parent too its children applying constraints if necesary" [modif-tree children objects bounds parent transformed-parent-bounds ignore-constraints] (let [modifiers (dm/get-in modif-tree [(:id parent) :modifiers])] - ;; Move modifiers don't need to calculate constraints (if (ctm/only-move? modifiers) (loop [modif-tree modif-tree @@ -205,14 +204,14 @@ (let [origin (gpo/origin @parent-bounds) scale-width (/ auto-width (gpo/width-points @parent-bounds))] (-> modifiers - (ctm/resize-parent (gpt/point scale-width 1) origin (:transform parent) (:transform-inverse parent))))) + (ctm/resize (gpt/point scale-width 1) origin (:transform parent) (:transform-inverse parent))))) set-parent-auto-height (fn [modifiers auto-height] (let [origin (gpo/origin @parent-bounds) scale-height (/ auto-height (gpo/height-points @parent-bounds))] (-> modifiers - (ctm/resize-parent (gpt/point 1 scale-height) origin (:transform parent) (:transform-inverse parent))))) + (ctm/resize (gpt/point 1 scale-height) origin (:transform parent) (:transform-inverse parent))))) children (->> (cph/get-immediate-children objects parent-id) (remove :hidden)) diff --git a/common/src/app/common/types/shape/layout.cljc b/common/src/app/common/types/shape/layout.cljc index 3d9872d18..1f7b6950a 100644 --- a/common/src/app/common/types/shape/layout.cljc +++ b/common/src/app/common/types/shape/layout.cljc @@ -346,24 +346,6 @@ (defn align-self-stretch? [{:keys [layout-item-align-self]}] (= :stretch layout-item-align-self)) -(defn change-h-sizing? - [frame-id objects children-ids] - (and (layout? objects frame-id) - (auto-width? objects frame-id) - (or (and (col? objects frame-id) - (every? (partial fill-width? objects) children-ids)) - (and (row? objects frame-id) - (some (partial fill-width? objects) children-ids))))) - -(defn change-v-sizing? - [frame-id objects children-ids] - (and (layout? objects frame-id) - (auto-height? objects frame-id) - (or (and (col? objects frame-id) - (some (partial fill-height? objects) children-ids)) - (and (row? objects frame-id) - (every? (partial fill-height? objects) children-ids))))) - (defn layout-absolute? ([objects id] (layout-absolute? (get objects id))) @@ -376,6 +358,28 @@ ([shape] (or (:layout-item-z-index shape) 0))) +(defn change-h-sizing? + [frame-id objects children-ids] + (and (layout? objects frame-id) + (auto-width? objects frame-id) + (or (and (col? objects frame-id) + (->> children-ids + (remove (partial layout-absolute? objects)) + (every? (partial fill-width? objects)))) + (and (row? objects frame-id) + (->> children-ids + (remove (partial layout-absolute? objects)) + (some (partial fill-width? objects))))))) + +(defn change-v-sizing? + [frame-id objects children-ids] + (and (layout? objects frame-id) + (auto-height? objects frame-id) + (or (and (col? objects frame-id) + (some (partial fill-height? objects) children-ids)) + (and (row? objects frame-id) + (every? (partial fill-height? objects) children-ids))))) + (defn remove-layout-container-data [shape] (dissoc shape diff --git a/frontend/src/app/main/data/workspace/shape_layout.cljs b/frontend/src/app/main/data/workspace/shape_layout.cljs index 60e74eaa0..2a61391b9 100644 --- a/frontend/src/app/main/data/workspace/shape_layout.cljs +++ b/frontend/src/app/main/data/workspace/shape_layout.cljs @@ -349,7 +349,10 @@ col? (ctl/col? parent) row? (ctl/row? parent) - all-children (->> parent :shapes (map (d/getf objects)))] + all-children (->> parent + :shapes + (map (d/getf objects)) + (remove ctl/layout-absolute?))] (cond-> shape ;; If the parent is hug width and the direction column From 0ef5a37e33b2c651ea60a21748b1c260ccb9d8f5 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 28 Feb 2023 13:22:12 +0100 Subject: [PATCH 2/3] :bug: Allow set position when position absolute --- .../sidebar/options/menus/measures.cljs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs index 5a5c584f9..f79bfedba 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs @@ -84,13 +84,22 @@ selection-parents (mf/deref selection-parents-ref) flex-child? (->> selection-parents (some ctl/layout?)) - + absolute? (ctl/layout-absolute? shape) flex-container? (ctl/layout? shape) flex-auto-width? (ctl/auto-width? shape) flex-fill-width? (ctl/fill-width? shape) flex-auto-height? (ctl/auto-height? shape) flex-fill-height? (ctl/fill-height? shape) + disabled-position-x? (and flex-child? (not absolute?)) + disabled-position-y? (and flex-child? (not absolute?)) + disabled-width-sizing? (and (or flex-child? flex-container?) + (or flex-auto-width? flex-fill-width?) + (not absolute?)) + disabled-height-sizing? (and (or flex-child? flex-container?) + (or flex-auto-height? flex-fill-height?) + (not absolute?)) + ;; To show interactively the measures while the user is manipulating ;; the shape with the mouse, generate a copy of the shapes applying ;; the transient transformations. @@ -309,7 +318,7 @@ :placeholder "--" :on-click select-all :on-change on-width-change - :disabled (and (or flex-child? flex-container?) (or flex-auto-width? flex-fill-width?)) + :disabled disabled-width-sizing? :value (:width values)}]] [:div.input-element.height {:title (tr "workspace.options.height")} @@ -318,7 +327,7 @@ :placeholder "--" :on-click select-all :on-change on-height-change - :disabled (and (or flex-child? flex-container?) (or flex-auto-height? flex-fill-height?)) + :disabled disabled-height-sizing? :value (:height values)}]] [:div.lock-size {:class (dom/classnames @@ -338,13 +347,13 @@ :placeholder "--" :on-click select-all :on-change on-pos-x-change - :disabled flex-child? + :disabled disabled-position-x? :value (:x values)}]] [:div.input-element.Yaxis {:title (tr "workspace.options.y")} [:> numeric-input {:no-validate true :placeholder "--" :on-click select-all - :disabled flex-child? + :disabled disabled-position-y? :on-change on-pos-y-change :value (:y values)}]]]) From 4111cee3d6324f02ee0020c11434421bb12469ae Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 28 Feb 2023 15:21:53 +0100 Subject: [PATCH 3/3] :bug: Fix clipping overlay --- common/src/app/common/geom/shapes/bounds.cljc | 4 +- .../app/common/types/shape/interactions.cljc | 4 +- .../types_shape_interactions_test.cljc | 103 ++++++++++-------- frontend/src/app/main/ui/viewer/shapes.cljs | 3 + 4 files changed, 67 insertions(+), 47 deletions(-) diff --git a/common/src/app/common/geom/shapes/bounds.cljc b/common/src/app/common/geom/shapes/bounds.cljc index 065ff5e5d..3a2bb88c9 100644 --- a/common/src/app/common/geom/shapes/bounds.cljc +++ b/common/src/app/common/geom/shapes/bounds.cljc @@ -133,7 +133,9 @@ (-> (get-shape-filter-bounds shape) (add-padding (calculate-padding shape true)))) - bounds (if (or (:masked-group? shape) (cph/frame-shape? shape)) + bounds (if (or (:masked-group? shape) + (and (cph/frame-shape? shape) + (not (:show-content shape)))) [(calculate-base-bounds shape)] (cph/reduce-objects objects diff --git a/common/src/app/common/types/shape/interactions.cljc b/common/src/app/common/types/shape/interactions.cljc index 048e963d9..8b4975bdc 100644 --- a/common/src/app/common/types/shape/interactions.cljc +++ b/common/src/app/common/types/shape/interactions.cljc @@ -8,6 +8,7 @@ (:require [app.common.data :as d] [app.common.geom.point :as gpt] + [app.common.geom.shapes.bounds :as gsb] [app.common.spec :as us] [clojure.spec.alpha :as s])) @@ -362,6 +363,7 @@ (defn calc-overlay-position [interaction ;; interaction data + objects ;; the objects tree relative-to-shape ;; the interaction position is realtive to this sape base-frame ;; the base frame of the current interaction dest-frame ;; the frame to display with this interaction @@ -371,7 +373,7 @@ (assert (has-overlay-opts interaction)) (if (nil? dest-frame) (gpt/point 0 0) - (let [overlay-size (:selrect dest-frame) + (let [overlay-size (gsb/get-object-bounds objects dest-frame) base-frame-size (:selrect base-frame) relative-to-shape-size (:selrect relative-to-shape) relative-to-adjusted-to-base-frame {:x (- (:x relative-to-shape-size) (:x base-frame-size)) diff --git a/common/test/common_tests/types_shape_interactions_test.cljc b/common/test/common_tests/types_shape_interactions_test.cljc index c3202394b..b1bf12698 100644 --- a/common/test/common_tests/types_shape_interactions_test.cljc +++ b/common/test/common_tests/types_shape_interactions_test.cljc @@ -6,6 +6,7 @@ (ns common-tests.types-shape-interactions-test (:require + [app.common.geom.shapes :as gsh] [app.common.exceptions :as ex] [app.common.geom.point :as gpt] [app.common.types.shape :as cts] @@ -275,26 +276,38 @@ new-interaction (ctsi/set-position-relative-to i3 relative-to-id)] (t/is (= relative-to-id (:position-relative-to new-interaction))))))) +(defn setup-selrect [{:keys [x y width height] :as obj}] + (let [rect (gsh/make-rect x y width height) + center (gsh/center-rect rect) + selrect (gsh/rect->selrect rect) + points (gsh/rect->points rect)] + (-> obj + (assoc :selrect selrect) + (assoc :points points)))) (t/deftest calc-overlay-position (let [base-frame (-> (cts/make-minimal-shape :frame) - (assoc-in [:selrect :width] 100) - (assoc-in [:selrect :height] 100)) + (assoc :width 100) + (assoc :height 100) + (setup-selrect)) popup (-> (cts/make-minimal-shape :frame) - (assoc-in [:selrect :width] 50) - (assoc-in [:selrect :height] 50) - (assoc-in [:selrect :x] 10) - (assoc-in [:selrect :y] 10)) + (assoc :width 50) + (assoc :height 50) + (assoc :x 10) + (assoc :y 10) + (setup-selrect)) rect (-> (cts/make-minimal-shape :rect) - (assoc-in [:selrect :width] 50) - (assoc-in [:selrect :height] 50) - (assoc-in [:selrect :x] 10) - (assoc-in [:selrect :y] 10)) + (assoc :width 50) + (assoc :height 50) + (assoc :x 10) + (assoc :y 10) + (setup-selrect)) overlay-frame (-> (cts/make-minimal-shape :frame) - (assoc-in [:selrect :width] 30) - (assoc-in [:selrect :height] 20)) + (assoc :width 30) + (assoc :height 20) + (setup-selrect)) objects {(:id base-frame) base-frame (:id popup) popup @@ -311,49 +324,49 @@ interaction-rect (ctsi/set-position-relative-to interaction (:id rect))] (t/testing "Overlay top-left relative to auto" (let [i2 (ctsi/set-overlay-pos-type interaction-auto :top-left base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 0)) (t/is (= (:y overlay-pos) 0)))) (t/testing "Overlay top-center relative to auto" (let [i2 (ctsi/set-overlay-pos-type interaction-auto :top-center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 35)) (t/is (= (:y overlay-pos) 0)))) (t/testing "Overlay top-right relative to auto" (let [i2 (ctsi/set-overlay-pos-type interaction-auto :top-right base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 70)) (t/is (= (:y overlay-pos) 0)))) (t/testing "Overlay bottom-left relative to auto" (let [i2 (ctsi/set-overlay-pos-type interaction-auto :bottom-left base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 0)) (t/is (= (:y overlay-pos) 80)))) (t/testing "Overlay bottom-center relative to auto" (let [i2 (ctsi/set-overlay-pos-type interaction-auto :bottom-center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 35)) (t/is (= (:y overlay-pos) 80)))) (t/testing "Overlay bottom-right relative to auto" (let [i2 (ctsi/set-overlay-pos-type interaction-auto :bottom-right base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 70)) (t/is (= (:y overlay-pos) 80)))) (t/testing "Overlay center relative to auto" (let [i2 (ctsi/set-overlay-pos-type interaction-auto :center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 35)) (t/is (= (:y overlay-pos) 40)))) (t/testing "Overlay manual relative to auto" (let [i2 (ctsi/set-overlay-pos-type interaction-auto :center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 35)) (t/is (= (:y overlay-pos) 40)))) @@ -361,49 +374,49 @@ (let [i2 (-> interaction-auto (ctsi/set-overlay-pos-type :manual base-frame objects) (ctsi/set-overlay-position (gpt/point 12 62))) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 17)) (t/is (= (:y overlay-pos) 67)))) (t/testing "Overlay top-left relative to base-frame" (let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :top-left base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 5)) (t/is (= (:y overlay-pos) 5)))) (t/testing "Overlay top-center relative to base-frame" (let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :top-center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 40)) (t/is (= (:y overlay-pos) 5)))) (t/testing "Overlay top-right relative to base-frame" (let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :top-right base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 75)) (t/is (= (:y overlay-pos) 5)))) (t/testing "Overlay bottom-left relative to base-frame" (let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :bottom-left base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 5)) (t/is (= (:y overlay-pos) 85)))) (t/testing "Overlay bottom-center relative to base-frame" (let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :bottom-center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 40)) (t/is (= (:y overlay-pos) 85)))) (t/testing "Overlay bottom-right relative to base-frame" (let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :bottom-right base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 75)) (t/is (= (:y overlay-pos) 85)))) (t/testing "Overlay center relative to base-frame" (let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 40)) (t/is (= (:y overlay-pos) 45)))) @@ -411,49 +424,49 @@ (let [i2 (-> interaction-base-frame (ctsi/set-overlay-pos-type :manual base-frame objects) (ctsi/set-overlay-position (gpt/point 12 62))) - overlay-pos (ctsi/calc-overlay-position i2 base-frame base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects base-frame base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 17)) (t/is (= (:y overlay-pos) 67)))) (t/testing "Overlay top-left relative to popup" (let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-left base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 popup base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects popup base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 15)) (t/is (= (:y overlay-pos) 15)))) (t/testing "Overlay top-center relative to popup" (let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 popup base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects popup base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 25)) (t/is (= (:y overlay-pos) 15)))) (t/testing "Overlay top-right relative to popup" (let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-right base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 popup base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects popup base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 35)) (t/is (= (:y overlay-pos) 15)))) (t/testing "Overlay bottom-left relative to popup" (let [i2 (ctsi/set-overlay-pos-type interaction-popup :bottom-left base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 popup base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects popup base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 15)) (t/is (= (:y overlay-pos) 45)))) (t/testing "Overlay bottom-center relative to popup" (let [i2 (ctsi/set-overlay-pos-type interaction-popup :bottom-center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 popup base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects popup base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 25)) (t/is (= (:y overlay-pos) 45)))) (t/testing "Overlay bottom-right relative to popup" (let [i2 (ctsi/set-overlay-pos-type interaction-popup :bottom-right base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 popup base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects popup base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 35)) (t/is (= (:y overlay-pos) 45)))) (t/testing "Overlay center relative to popup" (let [i2 (ctsi/set-overlay-pos-type interaction-popup :center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 popup base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects popup base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 25)) (t/is (= (:y overlay-pos) 30)))) @@ -461,49 +474,49 @@ (let [i2 (-> interaction-popup (ctsi/set-overlay-pos-type :manual base-frame objects) (ctsi/set-overlay-position (gpt/point 12 62))) - overlay-pos (ctsi/calc-overlay-position i2 popup base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects popup base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 27)) (t/is (= (:y overlay-pos) 77)))) (t/testing "Overlay top-left relative to popup" (let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-left base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 popup base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects popup base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 15)) (t/is (= (:y overlay-pos) 15)))) (t/testing "Overlay top-center relative to rect" (let [i2 (ctsi/set-overlay-pos-type interaction-rect :top-center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 rect base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects rect base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 25)) (t/is (= (:y overlay-pos) 15)))) (t/testing "Overlay top-right relative to rect" (let [i2 (ctsi/set-overlay-pos-type interaction-rect :top-right base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 rect base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects rect base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 35)) (t/is (= (:y overlay-pos) 15)))) (t/testing "Overlay bottom-left relative to rect" (let [i2 (ctsi/set-overlay-pos-type interaction-rect :bottom-left base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 rect base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects rect base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 15)) (t/is (= (:y overlay-pos) 45)))) (t/testing "Overlay bottom-center relative to rect" (let [i2 (ctsi/set-overlay-pos-type interaction-rect :bottom-center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 rect base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects rect base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 25)) (t/is (= (:y overlay-pos) 45)))) (t/testing "Overlay bottom-right relative to rect" (let [i2 (ctsi/set-overlay-pos-type interaction-rect :bottom-right base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 rect base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects rect base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 35)) (t/is (= (:y overlay-pos) 45)))) (t/testing "Overlay center relative to rect" (let [i2 (ctsi/set-overlay-pos-type interaction-rect :center base-frame objects) - overlay-pos (ctsi/calc-overlay-position i2 rect base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects rect base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 25)) (t/is (= (:y overlay-pos) 30)))) @@ -511,7 +524,7 @@ (let [i2 (-> interaction-rect (ctsi/set-overlay-pos-type :manual base-frame objects) (ctsi/set-overlay-position (gpt/point 12 62))) - overlay-pos (ctsi/calc-overlay-position i2 rect base-frame overlay-frame frame-offset)] + overlay-pos (ctsi/calc-overlay-position i2 objects rect base-frame overlay-frame frame-offset)] (t/is (= (:x overlay-pos) 17)) (t/is (= (:y overlay-pos) 67)))))) diff --git a/frontend/src/app/main/ui/viewer/shapes.cljs b/frontend/src/app/main/ui/viewer/shapes.cljs index c364d38c1..ccd997a54 100644 --- a/frontend/src/app/main/ui/viewer/shapes.cljs +++ b/frontend/src/app/main/ui/viewer/shapes.cljs @@ -69,6 +69,7 @@ overlays-ids (set (map :id overlays)) relative-to-base-frame (find-relative-to-base-frame relative-to-shape objects overlays-ids base-frame) position (ctsi/calc-overlay-position interaction + viewer-objects relative-to-shape relative-to-base-frame dest-frame @@ -90,6 +91,7 @@ overlays-ids (set (map :id overlays)) relative-to-base-frame (find-relative-to-base-frame relative-to-shape objects overlays-ids base-frame) position (ctsi/calc-overlay-position interaction + objects relative-to-shape relative-to-base-frame dest-frame @@ -154,6 +156,7 @@ overlays-ids (set (map :id overlays)) relative-to-base-frame (find-relative-to-base-frame relative-to-shape objects overlays-ids base-frame) position (ctsi/calc-overlay-position interaction + objects relative-to-shape relative-to-base-frame dest-frame