mirror of
https://github.com/penpot/penpot.git
synced 2025-05-14 14:26:37 +02:00
🐛 Improve html generation
This commit is contained in:
parent
1f04304210
commit
7fd02022ac
8 changed files with 210 additions and 174 deletions
|
@ -205,3 +205,6 @@
|
||||||
|
|
||||||
;; Modifiers
|
;; Modifiers
|
||||||
(dm/export gsm/set-objects-modifiers)
|
(dm/export gsm/set-objects-modifiers)
|
||||||
|
|
||||||
|
;; Rect
|
||||||
|
(dm/export grc/rect->points)
|
||||||
|
|
|
@ -107,9 +107,7 @@
|
||||||
margin
|
margin
|
||||||
(if ignore-margin?
|
(if ignore-margin?
|
||||||
0
|
0
|
||||||
(->> strokes
|
(shape-stroke-margin shape stroke-width))
|
||||||
(map #(shape-stroke-margin % stroke-width))
|
|
||||||
(reduce d/max 0)))
|
|
||||||
|
|
||||||
shadow-width
|
shadow-width
|
||||||
(->> (:shadow shape)
|
(->> (:shadow shape)
|
||||||
|
@ -125,8 +123,8 @@
|
||||||
0))
|
0))
|
||||||
(reduce d/max 0))]
|
(reduce d/max 0))]
|
||||||
|
|
||||||
{:horizontal (+ stroke-width margin shadow-width)
|
{:horizontal (mth/ceil (+ stroke-width margin shadow-width))
|
||||||
:vertical (+ stroke-width margin shadow-height)})))
|
:vertical (mth/ceil (+ stroke-width margin shadow-height))})))
|
||||||
|
|
||||||
(defn- add-padding
|
(defn- add-padding
|
||||||
[bounds padding]
|
[bounds padding]
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
(ns common-tests.types-shape-interactions-test
|
(ns common-tests.types-shape-interactions-test
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.math :as mth]
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.rect :as grc]
|
[app.common.geom.rect :as grc]
|
||||||
|
@ -332,56 +333,56 @@
|
||||||
(t/testing "Overlay top-center relative to auto"
|
(t/testing "Overlay top-center relative to auto"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :top-center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :top-center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 35))
|
(t/is (mth/close? (:x overlay-pos) 35))
|
||||||
(t/is (= (:y overlay-pos) 0))
|
(t/is (mth/close? (:y overlay-pos) 0))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
(t/testing "Overlay top-right relative to auto"
|
(t/testing "Overlay top-right relative to auto"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :top-right base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :top-right base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 70))
|
(t/is (mth/close? (:x overlay-pos) 70))
|
||||||
(t/is (= (:y overlay-pos) 0))
|
(t/is (mth/close? (:y overlay-pos) 0))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :right))))
|
(t/is (= snap-h :right))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-left relative to auto"
|
(t/testing "Overlay bottom-left relative to auto"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :bottom-left base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :bottom-left base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 0))
|
(t/is (mth/close? (:x overlay-pos) 0))
|
||||||
(t/is (= (:y overlay-pos) 80))
|
(t/is (mth/close? (:y overlay-pos) 80))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :left))))
|
(t/is (= snap-h :left))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-center relative to auto"
|
(t/testing "Overlay bottom-center relative to auto"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :bottom-center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :bottom-center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 35))
|
(t/is (mth/close? (:x overlay-pos) 35))
|
||||||
(t/is (= (:y overlay-pos) 80))
|
(t/is (mth/close? (:y overlay-pos) 80))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-right relative to auto"
|
(t/testing "Overlay bottom-right relative to auto"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :bottom-right base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :bottom-right base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 70))
|
(t/is (mth/close? (:x overlay-pos) 70))
|
||||||
(t/is (= (:y overlay-pos) 80))
|
(t/is (mth/close? (:y overlay-pos) 80))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :right))))
|
(t/is (= snap-h :right))))
|
||||||
|
|
||||||
(t/testing "Overlay center relative to auto"
|
(t/testing "Overlay center relative to auto"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 35))
|
(t/is (mth/close? (:x overlay-pos) 35))
|
||||||
(t/is (= (:y overlay-pos) 40))
|
(t/is (mth/close? (:y overlay-pos) 40))
|
||||||
(t/is (= snap-v :center))
|
(t/is (= snap-v :center))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
(t/testing "Overlay manual relative to auto"
|
(t/testing "Overlay manual relative to auto"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-auto :center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 35))
|
(t/is (mth/close? (:x overlay-pos) 35))
|
||||||
(t/is (= (:y overlay-pos) 40))
|
(t/is (mth/close? (:y overlay-pos) 40))
|
||||||
(t/is (= snap-v :center))
|
(t/is (= snap-v :center))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
|
@ -390,64 +391,64 @@
|
||||||
(ctsi/set-overlay-pos-type :manual base-frame objects)
|
(ctsi/set-overlay-pos-type :manual base-frame objects)
|
||||||
(ctsi/set-overlay-position (gpt/point 12 62)))
|
(ctsi/set-overlay-position (gpt/point 12 62)))
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 17))
|
(t/is (mth/close? (:x overlay-pos) 17))
|
||||||
(t/is (= (:y overlay-pos) 67))
|
(t/is (mth/close? (:y overlay-pos) 67))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :left))))
|
(t/is (= snap-h :left))))
|
||||||
|
|
||||||
(t/testing "Overlay top-left relative to base-frame"
|
(t/testing "Overlay top-left relative to base-frame"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :top-left base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :top-left base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 5))
|
(t/is (mth/close? (:x overlay-pos) 5))
|
||||||
(t/is (= (:y overlay-pos) 5))
|
(t/is (mth/close? (:y overlay-pos) 5))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :left))))
|
(t/is (= snap-h :left))))
|
||||||
|
|
||||||
(t/testing "Overlay top-center relative to base-frame"
|
(t/testing "Overlay top-center relative to base-frame"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :top-center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :top-center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 40))
|
(t/is (mth/close? (:x overlay-pos) 40))
|
||||||
(t/is (= (:y overlay-pos) 5))
|
(t/is (mth/close? (:y overlay-pos) 5))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
(t/testing "Overlay top-right relative to base-frame"
|
(t/testing "Overlay top-right relative to base-frame"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :top-right base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :top-right base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 75))
|
(t/is (mth/close? (:x overlay-pos) 75))
|
||||||
(t/is (= (:y overlay-pos) 5))
|
(t/is (mth/close? (:y overlay-pos) 5))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :right))))
|
(t/is (= snap-h :right))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-left relative to base-frame"
|
(t/testing "Overlay bottom-left relative to base-frame"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :bottom-left base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :bottom-left base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 5))
|
(t/is (mth/close? (:x overlay-pos) 5))
|
||||||
(t/is (= (:y overlay-pos) 85))
|
(t/is (mth/close? (:y overlay-pos) 85))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :left))))
|
(t/is (= snap-h :left))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-center relative to base-frame"
|
(t/testing "Overlay bottom-center relative to base-frame"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :bottom-center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :bottom-center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 40))
|
(t/is (mth/close? (:x overlay-pos) 40))
|
||||||
(t/is (= (:y overlay-pos) 85))
|
(t/is (mth/close? (:y overlay-pos) 85))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-right relative to base-frame"
|
(t/testing "Overlay bottom-right relative to base-frame"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :bottom-right base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :bottom-right base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 75))
|
(t/is (mth/close? (:x overlay-pos) 75))
|
||||||
(t/is (= (:y overlay-pos) 85))
|
(t/is (mth/close? (:y overlay-pos) 85))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :right))))
|
(t/is (= snap-h :right))))
|
||||||
|
|
||||||
(t/testing "Overlay center relative to base-frame"
|
(t/testing "Overlay center relative to base-frame"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-base-frame :center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 40))
|
(t/is (mth/close? (:x overlay-pos) 40))
|
||||||
(t/is (= (:y overlay-pos) 45))
|
(t/is (mth/close? (:y overlay-pos) 45))
|
||||||
(t/is (= snap-v :center))
|
(t/is (= snap-v :center))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
|
@ -456,64 +457,64 @@
|
||||||
(ctsi/set-overlay-pos-type :manual base-frame objects)
|
(ctsi/set-overlay-pos-type :manual base-frame objects)
|
||||||
(ctsi/set-overlay-position (gpt/point 12 62)))
|
(ctsi/set-overlay-position (gpt/point 12 62)))
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects base-frame base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 17))
|
(t/is (mth/close? (:x overlay-pos) 17))
|
||||||
(t/is (= (:y overlay-pos) 67))
|
(t/is (mth/close? (:y overlay-pos) 67))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :left))))
|
(t/is (= snap-h :left))))
|
||||||
|
|
||||||
(t/testing "Overlay top-left relative to popup"
|
(t/testing "Overlay top-left relative to popup"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-left base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-left base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 15))
|
(t/is (mth/close? (:x overlay-pos) 15))
|
||||||
(t/is (= (:y overlay-pos) 15))
|
(t/is (mth/close? (:y overlay-pos) 15))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :left))))
|
(t/is (= snap-h :left))))
|
||||||
|
|
||||||
(t/testing "Overlay top-center relative to popup"
|
(t/testing "Overlay top-center relative to popup"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 25))
|
(t/is (mth/close? (:x overlay-pos) 25))
|
||||||
(t/is (= (:y overlay-pos) 15))
|
(t/is (mth/close? (:y overlay-pos) 15))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
(t/testing "Overlay top-right relative to popup"
|
(t/testing "Overlay top-right relative to popup"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-right base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-right base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 35))
|
(t/is (mth/close? (:x overlay-pos) 35))
|
||||||
(t/is (= (:y overlay-pos) 15))
|
(t/is (mth/close? (:y overlay-pos) 15))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :right))))
|
(t/is (= snap-h :right))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-left relative to popup"
|
(t/testing "Overlay bottom-left relative to popup"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :bottom-left base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :bottom-left base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 15))
|
(t/is (mth/close? (:x overlay-pos) 15))
|
||||||
(t/is (= (:y overlay-pos) 45))
|
(t/is (mth/close? (:y overlay-pos) 45))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :left))))
|
(t/is (= snap-h :left))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-center relative to popup"
|
(t/testing "Overlay bottom-center relative to popup"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :bottom-center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :bottom-center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 25))
|
(t/is (mth/close? (:x overlay-pos) 25))
|
||||||
(t/is (= (:y overlay-pos) 45))
|
(t/is (mth/close? (:y overlay-pos) 45))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-right relative to popup"
|
(t/testing "Overlay bottom-right relative to popup"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :bottom-right base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :bottom-right base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 35))
|
(t/is (mth/close? (:x overlay-pos) 35))
|
||||||
(t/is (= (:y overlay-pos) 45))
|
(t/is (mth/close? (:y overlay-pos) 45))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :right))))
|
(t/is (= snap-h :right))))
|
||||||
|
|
||||||
(t/testing "Overlay center relative to popup"
|
(t/testing "Overlay center relative to popup"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 25))
|
(t/is (mth/close? (:x overlay-pos) 25))
|
||||||
(t/is (= (:y overlay-pos) 30))
|
(t/is (mth/close? (:y overlay-pos) 30))
|
||||||
(t/is (= snap-v :center))
|
(t/is (= snap-v :center))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
|
@ -522,64 +523,64 @@
|
||||||
(ctsi/set-overlay-pos-type :manual base-frame objects)
|
(ctsi/set-overlay-pos-type :manual base-frame objects)
|
||||||
(ctsi/set-overlay-position (gpt/point 12 62)))
|
(ctsi/set-overlay-position (gpt/point 12 62)))
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 27))
|
(t/is (mth/close? (:x overlay-pos) 27))
|
||||||
(t/is (= (:y overlay-pos) 77))
|
(t/is (mth/close? (:y overlay-pos) 77))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :left))))
|
(t/is (= snap-h :left))))
|
||||||
|
|
||||||
(t/testing "Overlay top-left relative to popup"
|
(t/testing "Overlay top-left relative to popup"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-left base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-popup :top-left base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects popup base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 15))
|
(t/is (mth/close? (:x overlay-pos) 15))
|
||||||
(t/is (= (:y overlay-pos) 15))
|
(t/is (mth/close? (:y overlay-pos) 15))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :left))))
|
(t/is (= snap-h :left))))
|
||||||
|
|
||||||
(t/testing "Overlay top-center relative to rect"
|
(t/testing "Overlay top-center relative to rect"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :top-center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :top-center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 25))
|
(t/is (mth/close? (:x overlay-pos) 25))
|
||||||
(t/is (= (:y overlay-pos) 15))
|
(t/is (mth/close? (:y overlay-pos) 15))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
(t/testing "Overlay top-right relative to rect"
|
(t/testing "Overlay top-right relative to rect"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :top-right base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :top-right base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 35))
|
(t/is (mth/close? (:x overlay-pos) 35))
|
||||||
(t/is (= (:y overlay-pos) 15))
|
(t/is (mth/close? (:y overlay-pos) 15))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :right))))
|
(t/is (= snap-h :right))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-left relative to rect"
|
(t/testing "Overlay bottom-left relative to rect"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :bottom-left base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :bottom-left base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 15))
|
(t/is (mth/close? (:x overlay-pos) 15))
|
||||||
(t/is (= (:y overlay-pos) 45))
|
(t/is (mth/close? (:y overlay-pos) 45))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :left))))
|
(t/is (= snap-h :left))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-center relative to rect"
|
(t/testing "Overlay bottom-center relative to rect"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :bottom-center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :bottom-center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 25))
|
(t/is (mth/close? (:x overlay-pos) 25))
|
||||||
(t/is (= (:y overlay-pos) 45))
|
(t/is (mth/close? (:y overlay-pos) 45))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
(t/testing "Overlay bottom-right relative to rect"
|
(t/testing "Overlay bottom-right relative to rect"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :bottom-right base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :bottom-right base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 35))
|
(t/is (mth/close? (:x overlay-pos) 35))
|
||||||
(t/is (= (:y overlay-pos) 45))
|
(t/is (mth/close? (:y overlay-pos) 45))
|
||||||
(t/is (= snap-v :bottom))
|
(t/is (= snap-v :bottom))
|
||||||
(t/is (= snap-h :right))))
|
(t/is (= snap-h :right))))
|
||||||
|
|
||||||
(t/testing "Overlay center relative to rect"
|
(t/testing "Overlay center relative to rect"
|
||||||
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :center base-frame objects)
|
(let [i2 (ctsi/set-overlay-pos-type interaction-rect :center base-frame objects)
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 25))
|
(t/is (mth/close? (:x overlay-pos) 25))
|
||||||
(t/is (= (:y overlay-pos) 30))
|
(t/is (mth/close? (:y overlay-pos) 30))
|
||||||
(t/is (= snap-v :center))
|
(t/is (= snap-v :center))
|
||||||
(t/is (= snap-h :center))))
|
(t/is (= snap-h :center))))
|
||||||
|
|
||||||
|
@ -588,8 +589,8 @@
|
||||||
(ctsi/set-overlay-pos-type :manual base-frame objects)
|
(ctsi/set-overlay-pos-type :manual base-frame objects)
|
||||||
(ctsi/set-overlay-position (gpt/point 12 62)))
|
(ctsi/set-overlay-position (gpt/point 12 62)))
|
||||||
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
[overlay-pos [snap-v snap-h]] (ctsi/calc-overlay-position i2 rect objects rect base-frame overlay-frame frame-offset)]
|
||||||
(t/is (= (:x overlay-pos) 17))
|
(t/is (mth/close? (:x overlay-pos) 17))
|
||||||
(t/is (= (:y overlay-pos) 67))
|
(t/is (mth/close? (:y overlay-pos) 67))
|
||||||
(t/is (= snap-v :top))
|
(t/is (= snap-v :top))
|
||||||
(t/is (= snap-h :left))))))
|
(t/is (= snap-h :left))))))
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,11 @@
|
||||||
handle-load
|
handle-load
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(fn [data width height]
|
(fn [data width height]
|
||||||
(prn "handle-load" data)
|
|
||||||
(reset! last-data* data)
|
(reset! last-data* data)
|
||||||
(let [iframe-dom (mf/ref-val iframe-ref)]
|
(let [iframe-dom (mf/ref-val iframe-ref)]
|
||||||
(when iframe-dom
|
(when iframe-dom
|
||||||
(-> iframe-dom (aset "width" width))
|
(-> iframe-dom (aset "width" (+ width 64)))
|
||||||
(-> iframe-dom (aset "height" height))
|
(-> iframe-dom (aset "height" (+ height 64)))
|
||||||
(-> iframe-dom .-contentWindow .-document .open)
|
(-> iframe-dom .-contentWindow .-document .open)
|
||||||
(-> iframe-dom .-contentWindow .-document (.write data))
|
(-> iframe-dom .-contentWindow .-document (.write data))
|
||||||
(-> iframe-dom .-contentWindow .-document .close)))))
|
(-> iframe-dom .-contentWindow .-document .close)))))
|
||||||
|
@ -59,13 +58,13 @@
|
||||||
[:div {:style {:display "flex" :width "100%" :height "100%" :flex-direction "column" :overflow "auto" :align-items "center"}}
|
[:div {:style {:display "flex" :width "100%" :height "100%" :flex-direction "column" :overflow "auto" :align-items "center"}}
|
||||||
[:input {:id "zoom-input"
|
[:input {:id "zoom-input"
|
||||||
:ref zoom-ref
|
:ref zoom-ref
|
||||||
:type "range" :min 1 :max 200 :default-value 100
|
:type "range" :min 1 :max 400 :default-value 100
|
||||||
:on-change change-zoom
|
:on-change change-zoom
|
||||||
:style {:max-width "500px"}}]
|
:style {:max-width "500px"}}]
|
||||||
|
|
||||||
[:div {:style {:width "100%" :height "100%" :overflow "auto"}}
|
[:div {:style {:width "100%" :height "100%" :overflow "auto"}}
|
||||||
[:iframe {:ref load-ref
|
[:iframe {:ref load-ref
|
||||||
:frameborder "0"
|
:frame-border "0"
|
||||||
:scrolling "no"
|
:scrolling "no"
|
||||||
:style {:transform-origin "top center"
|
:style {:transform-origin "top left"
|
||||||
:transform (str "scale(" zoom ")")}}]]]))
|
:transform (str "scale(" zoom ")")}}]]]))
|
||||||
|
|
|
@ -58,5 +58,6 @@
|
||||||
[objects shape]
|
[objects shape]
|
||||||
;; Layout children with a transform should be wrapped
|
;; Layout children with a transform should be wrapped
|
||||||
(and (ctl/any-layout-immediate-child? objects shape)
|
(and (ctl/any-layout-immediate-child? objects shape)
|
||||||
|
(not (ctl/layout-absolute? shape))
|
||||||
(not (gmt/unit? (:transform shape)))))
|
(not (gmt/unit? (:transform shape)))))
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
(generate-html objects shape 0))
|
(generate-html objects shape 0))
|
||||||
|
|
||||||
([objects shape level]
|
([objects shape level]
|
||||||
|
(when (and (some? shape) (some? (:selrect shape)))
|
||||||
(let [indent (str/repeat " " level)
|
(let [indent (str/repeat " " level)
|
||||||
maybe-reverse (if (ctl/any-layout? shape) reverse identity)
|
maybe-reverse (if (ctl/any-layout? shape) reverse identity)
|
||||||
|
|
||||||
|
@ -81,10 +82,10 @@
|
||||||
shape-html)
|
shape-html)
|
||||||
|
|
||||||
shape-html)]
|
shape-html)]
|
||||||
(dm/fmt "%<!-- % -->\n%" indent (dm/str (d/name (:type shape)) ": " (:name shape)) shape-html))))
|
(dm/fmt "%<!-- % -->\n%" indent (dm/str (d/name (:type shape)) ": " (:name shape)) shape-html)))))
|
||||||
|
|
||||||
(defn generate-markup
|
(defn generate-markup
|
||||||
[objects shapes]
|
[objects shapes]
|
||||||
(->> shapes
|
(->> shapes
|
||||||
(map #(generate-html objects %))
|
(keep #(generate-html objects %))
|
||||||
(str/join "\n")))
|
(str/join "\n")))
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes.bounds :as gsb]
|
||||||
|
[app.common.geom.shapes.points :as gpo]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
|
@ -38,13 +39,6 @@ body {
|
||||||
gap: 2rem;
|
gap: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
svg {
|
|
||||||
position: absolute;
|
|
||||||
left: 50%;
|
|
||||||
top: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +58,10 @@ svg {
|
||||||
:justify-self
|
:justify-self
|
||||||
:grid-column
|
:grid-column
|
||||||
:grid-row
|
:grid-row
|
||||||
:z-index})
|
:z-index
|
||||||
|
:top
|
||||||
|
:left
|
||||||
|
:position})
|
||||||
|
|
||||||
(def shape-css-properties
|
(def shape-css-properties
|
||||||
[:position
|
[:position
|
||||||
|
@ -139,12 +136,16 @@ svg {
|
||||||
[shape objects]
|
[shape objects]
|
||||||
(when (and (ctl/any-layout-immediate-child? objects shape)
|
(when (and (ctl/any-layout-immediate-child? objects shape)
|
||||||
(not (gmt/unit? (:transform shape))))
|
(not (gmt/unit? (:transform shape))))
|
||||||
(let [{:keys [width height]} (gsh/shapes->rect [shape])]
|
(let [parent (get objects (:parent-id shape))
|
||||||
(cond-> [[:position "relative"]
|
bounds (gpo/parent-coords-bounds (:points shape) (:points parent))
|
||||||
[:width width]
|
width (gpo/width-points bounds)
|
||||||
|
height (gpo/height-points bounds)]
|
||||||
|
(cond-> [[:width width]
|
||||||
[:height height]]
|
[:height height]]
|
||||||
(ctl/flex-layout-immediate-child? objects shape)
|
|
||||||
(conj [:flex-shrink 0])))))
|
(or (not (ctl/any-layout-immediate-child? objects shape))
|
||||||
|
(not (ctl/layout-absolute? shape)))
|
||||||
|
(conj [:position "relative"])))))
|
||||||
|
|
||||||
(defn shape->wrapper-child-css-properties
|
(defn shape->wrapper-child-css-properties
|
||||||
[shape objects]
|
[shape objects]
|
||||||
|
@ -153,6 +154,16 @@ svg {
|
||||||
[:left "50%"]
|
[:left "50%"]
|
||||||
[:top "50%"]]))
|
[:top "50%"]]))
|
||||||
|
|
||||||
|
(defn shape->svg-props
|
||||||
|
[shape objects]
|
||||||
|
(let [bounds (gsb/get-object-bounds objects shape)]
|
||||||
|
[[:position "absolute"]
|
||||||
|
[:top 0]
|
||||||
|
[:left 0]
|
||||||
|
[:transform (dm/fmt "translate(%,%)"
|
||||||
|
(dm/str (- (:x bounds) (-> shape :selrect :x)) "px")
|
||||||
|
(dm/str (- (:y bounds) (-> shape :selrect :y)) "px"))]]))
|
||||||
|
|
||||||
(defn shape->css-properties
|
(defn shape->css-properties
|
||||||
"Given a shape extract the CSS properties in the format of list [property value]"
|
"Given a shape extract the CSS properties in the format of list [property value]"
|
||||||
[shape objects properties]
|
[shape objects properties]
|
||||||
|
@ -235,9 +246,11 @@ svg {
|
||||||
(get-shape-css-selector shape objects nil))
|
(get-shape-css-selector shape objects nil))
|
||||||
|
|
||||||
([shape objects options]
|
([shape objects options]
|
||||||
|
(when (and (some? shape) (some? (:selrect shape)))
|
||||||
(let [selector (cgc/shape->selector shape)
|
(let [selector (cgc/shape->selector shape)
|
||||||
|
|
||||||
wrapper? (cgc/has-wrapper? objects shape)
|
wrapper? (cgc/has-wrapper? objects shape)
|
||||||
|
svg? (cgc/svg-markup? shape)
|
||||||
|
|
||||||
css-properties
|
css-properties
|
||||||
(if wrapper?
|
(if wrapper?
|
||||||
|
@ -260,6 +273,12 @@ svg {
|
||||||
(when wrapper?
|
(when wrapper?
|
||||||
(-> shape
|
(-> shape
|
||||||
(shape->wrapper-child-css-properties objects)
|
(shape->wrapper-child-css-properties objects)
|
||||||
|
(format-css-properties options)))
|
||||||
|
|
||||||
|
svg-child-props
|
||||||
|
(when svg?
|
||||||
|
(-> shape
|
||||||
|
(shape->svg-props objects)
|
||||||
(format-css-properties options)))]
|
(format-css-properties options)))]
|
||||||
|
|
||||||
(str/join
|
(str/join
|
||||||
|
@ -267,8 +286,9 @@ svg {
|
||||||
(filter some? [(str/fmt "/* %s */" (:name shape))
|
(filter some? [(str/fmt "/* %s */" (:name shape))
|
||||||
(when wrapper? (str/fmt ".%s-wrapper {\n%s\n}" selector wrapper-properties))
|
(when wrapper? (str/fmt ".%s-wrapper {\n%s\n}" selector wrapper-properties))
|
||||||
(when wrapper? (str/fmt ".%s-wrapper > * {\n%s\n}" selector wrapper-child-properties))
|
(when wrapper? (str/fmt ".%s-wrapper > * {\n%s\n}" selector wrapper-child-properties))
|
||||||
|
(when svg? (str/fmt ".%s > svg {\n%s\n}" selector svg-child-props))
|
||||||
(str/fmt ".%s {\n%s\n}" selector properties)
|
(str/fmt ".%s {\n%s\n}" selector properties)
|
||||||
(when (cph/text-shape? shape) (generate-text-css shape))])))))
|
(when (cph/text-shape? shape) (generate-text-css shape))]))))))
|
||||||
|
|
||||||
(defn get-css-property
|
(defn get-css-property
|
||||||
([objects shape property]
|
([objects shape property]
|
||||||
|
@ -294,5 +314,5 @@ svg {
|
||||||
(dm/str
|
(dm/str
|
||||||
prelude
|
prelude
|
||||||
(->> shapes
|
(->> shapes
|
||||||
(map #(get-shape-css-selector % objects options))
|
(keep #(get-shape-css-selector % objects options))
|
||||||
(str/join "\n\n")))))
|
(str/join "\n\n")))))
|
||||||
|
|
|
@ -49,12 +49,14 @@
|
||||||
(when (and (not (cph/root-frame? shape))
|
(when (and (not (cph/root-frame? shape))
|
||||||
(or (not (ctl/any-layout-immediate-child? objects shape))
|
(or (not (ctl/any-layout-immediate-child? objects shape))
|
||||||
(ctl/layout-absolute? shape)))
|
(ctl/layout-absolute? shape)))
|
||||||
|
|
||||||
(let [parent (get objects (:parent-id shape))
|
(let [parent (get objects (:parent-id shape))
|
||||||
|
|
||||||
parent-value (dm/get-in parent [:selrect coord])
|
parent-value (dm/get-in parent [:selrect coord])
|
||||||
|
|
||||||
[selrect _ _]
|
[selrect _ _]
|
||||||
(-> (:points shape)
|
(-> (:points shape)
|
||||||
(gsh/transform-points (gsh/shape->center parent) (:transform-inverse parent))
|
(gsh/transform-points (gsh/shape->center parent) (:transform-inverse parent (gmt/matrix)))
|
||||||
(gsh/calculate-geometry))
|
(gsh/calculate-geometry))
|
||||||
|
|
||||||
shape-value (get selrect coord)]
|
shape-value (get selrect coord)]
|
||||||
|
@ -117,7 +119,17 @@
|
||||||
|
|
||||||
(defmethod get-value :transform
|
(defmethod get-value :transform
|
||||||
[_ shape objects]
|
[_ shape objects]
|
||||||
(when-not (cgc/svg-markup? shape)
|
(if (cgc/svg-markup? shape)
|
||||||
|
(let [parent (get objects (:parent-id shape))
|
||||||
|
transform
|
||||||
|
(:transform-inverse parent (gmt/matrix))
|
||||||
|
|
||||||
|
transform-str (when-not (gmt/unit? transform) (fmt/format-matrix transform))]
|
||||||
|
|
||||||
|
(if (cgc/has-wrapper? objects shape)
|
||||||
|
(dm/str "translate(-50%, -50%) " (d/nilv transform-str ""))
|
||||||
|
transform-str))
|
||||||
|
|
||||||
(let [parent (get objects (:parent-id shape))
|
(let [parent (get objects (:parent-id shape))
|
||||||
|
|
||||||
transform
|
transform
|
||||||
|
@ -207,6 +219,7 @@
|
||||||
(defmethod get-value :overflow
|
(defmethod get-value :overflow
|
||||||
[_ shape _]
|
[_ shape _]
|
||||||
(when (and (cph/frame-shape? shape)
|
(when (and (cph/frame-shape? shape)
|
||||||
|
(not (cgc/svg-markup? shape))
|
||||||
(not (:show-content shape)))
|
(not (:show-content shape)))
|
||||||
"hidden"))
|
"hidden"))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue