mirror of
https://github.com/penpot/penpot.git
synced 2025-06-21 18:57:00 +02:00
Merge pull request #6585 from penpot/alotor-scale-content
✨ Add scale content to render wasm
This commit is contained in:
commit
04a1f8475d
18 changed files with 282 additions and 33 deletions
|
@ -456,9 +456,9 @@
|
|||
(mapcat
|
||||
(fn [[parent-id data]]
|
||||
(when (ctm/has-structure? (:modifiers data))
|
||||
(->> data
|
||||
:modifiers
|
||||
:structure-parent
|
||||
(->> (concat
|
||||
(get-in data [:modifiers :structure-parent])
|
||||
(get-in data [:modifiers :structure-child]))
|
||||
(mapcat
|
||||
(fn [modifier]
|
||||
(case (:type modifier)
|
||||
|
@ -468,7 +468,8 @@
|
|||
{:type :remove-children
|
||||
:parent parent-id
|
||||
:id child-id
|
||||
:index 0})))
|
||||
:index 0
|
||||
:value 0})))
|
||||
|
||||
:add-children
|
||||
(->> (:value modifier)
|
||||
|
@ -476,7 +477,15 @@
|
|||
{:type :add-children
|
||||
:parent parent-id
|
||||
:id child-id
|
||||
:index (:index modifier)})))
|
||||
:index (:index modifier)
|
||||
:value 0})))
|
||||
|
||||
:scale-content
|
||||
[{:type :scale-content
|
||||
:parent parent-id
|
||||
:id parent-id
|
||||
:index 0
|
||||
:value (:value modifier)}]
|
||||
nil)))))))
|
||||
modif-tree))
|
||||
|
||||
|
@ -554,6 +563,29 @@
|
|||
(rx/of (set-temporary-selrect selrect)
|
||||
(set-temporary-modifiers modifiers)))))))))
|
||||
|
||||
(defn propagate-structure-modifiers
|
||||
[modif-tree objects]
|
||||
(letfn [(propagate-children
|
||||
[modif-tree parent-id modifiers]
|
||||
(let [new-modifiers (ctm/select-child-structre-modifiers modifiers)]
|
||||
(->> (get-in objects [parent-id :shapes])
|
||||
(reduce
|
||||
#(update-in %1 [%2 :modifiers] ctm/add-modifiers new-modifiers)
|
||||
modif-tree))))]
|
||||
(loop [pending (into [] (keys modif-tree))
|
||||
modif-tree modif-tree]
|
||||
(if-let [next (first pending)]
|
||||
(let [pending (rest pending)
|
||||
modifiers (get-in modif-tree [next :modifiers])
|
||||
|
||||
[pending modif-tree]
|
||||
(if (ctm/has-structure-child? modifiers)
|
||||
[(into pending (get-in objects [next :shapes]))
|
||||
(propagate-children modif-tree next modifiers)]
|
||||
[pending modif-tree])]
|
||||
(recur pending modif-tree))
|
||||
modif-tree))))
|
||||
|
||||
#_:clj-kondo/ignore
|
||||
(defn apply-wasm-modifiers
|
||||
[modif-tree & {:keys [ignore-constraints ignore-snap-pixel snap-ignore-axis undo-group]
|
||||
|
@ -574,6 +606,9 @@
|
|||
(map (fn [{:keys [id transform]}] [id transform]))
|
||||
(wasm.api/propagate-modifiers geometry-entries snap-pixel?))
|
||||
|
||||
modif-tree
|
||||
(propagate-structure-modifiers modif-tree (dsh/lookup-page-objects state))
|
||||
|
||||
ids
|
||||
(into (set (keys modif-tree)) (keys transforms))
|
||||
|
||||
|
@ -585,7 +620,6 @@
|
|||
(-> shape
|
||||
(gsh/apply-transform transform)
|
||||
(ctm/apply-structure-modifiers modifiers))))]
|
||||
|
||||
(rx/of
|
||||
(clear-local-transform)
|
||||
(dwsh/update-shapes ids update-shape))))))
|
||||
|
|
|
@ -793,17 +793,19 @@
|
|||
(defn set-structure-modifiers
|
||||
[entries]
|
||||
(when-not (empty? entries)
|
||||
(let [offset (mem/alloc-bytes-32 (mem/get-list-size entries 40))
|
||||
heapu32 (mem/get-heap-u32)]
|
||||
(let [offset (mem/alloc-bytes-32 (mem/get-list-size entries 44))
|
||||
heapu32 (mem/get-heap-u32)
|
||||
heapf32 (mem/get-heap-f32)]
|
||||
(loop [entries (seq entries)
|
||||
current-offset offset]
|
||||
(when-not (empty? entries)
|
||||
(let [{:keys [type parent id index] :as entry} (first entries)]
|
||||
(let [{:keys [type parent id index value] :as entry} (first entries)]
|
||||
(sr/heapu32-set-u32 (sr/translate-structure-modifier-type type) heapu32 (+ current-offset 0))
|
||||
(sr/heapu32-set-u32 (or index 0) heapu32 (+ current-offset 1))
|
||||
(sr/heapu32-set-uuid parent heapu32 (+ current-offset 2))
|
||||
(sr/heapu32-set-uuid id heapu32 (+ current-offset 6))
|
||||
(recur (rest entries) (+ current-offset 10)))))
|
||||
(aset heapf32 (+ current-offset 10) value)
|
||||
(recur (rest entries) (+ current-offset 11)))))
|
||||
(h/call wasm/internal-module "_set_structure_modifiers"))))
|
||||
|
||||
(defn propagate-modifiers
|
||||
|
|
|
@ -281,7 +281,8 @@
|
|||
[type]
|
||||
(case type
|
||||
:remove-children 1
|
||||
:add-children 2))
|
||||
:add-children 2
|
||||
:scale-content 3))
|
||||
|
||||
(defn translate-grow-type
|
||||
[grow-type]
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns app.render-wasm.shape
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.transit :as t]
|
||||
[app.common.types.shape :as shape]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
|
@ -132,6 +133,12 @@
|
|||
:constraints-h (api/set-constraints-h v)
|
||||
:constraints-v (api/set-constraints-v v)
|
||||
|
||||
(:r1 :r2 :r3 :r4)
|
||||
(api/set-shape-corners [(dm/get-prop shape :r1)
|
||||
(dm/get-prop shape :r2)
|
||||
(dm/get-prop shape :r3)
|
||||
(dm/get-prop shape :r4)])
|
||||
|
||||
:svg-attrs
|
||||
(when (= (:type shape) :path)
|
||||
(api/set-shape-path-attrs v))
|
||||
|
|
|
@ -5115,9 +5115,14 @@ msgstr "File"
|
|||
msgid "workspace.header.menu.option.help-info"
|
||||
msgstr "Help & info"
|
||||
|
||||
#: src/app/main/ui/workspace/main_menu.cljs:881
|
||||
msgid "workspace.header.menu.option.preferences"
|
||||
msgstr "Preferences"
|
||||
|
||||
#: src/app/main/ui/workspace/main_menu.cljs:916
|
||||
msgid "workspace.header.menu.option.power-up"
|
||||
msgstr "Power up your plan"
|
||||
|
||||
msgid "workspace.header.menu.option.view"
|
||||
msgstr "View"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue