mirror of
https://github.com/penpot/penpot.git
synced 2026-02-12 14:42:56 +00:00
🐛 Fix resize board to fit (wasm)
This commit is contained in:
@@ -631,7 +631,7 @@
|
||||
(let [structure-entries (parse-structure-modifiers modif-tree)]
|
||||
(wasm.api/set-structure-modifiers structure-entries)
|
||||
(let [geometry-entries (parse-geometry-modifiers modif-tree)
|
||||
modifiers (wasm.api/propagate-modifiers geometry-entries pixel-precision)]
|
||||
modifiers (wasm.api/propagate-modifiers geometry-entries pixel-precision true)]
|
||||
(wasm.api/set-modifiers modifiers)
|
||||
(let [ids (into [] xf:map-key geometry-entries)
|
||||
selrect (wasm.api/get-selection-rect ids)]
|
||||
@@ -663,8 +663,8 @@
|
||||
|
||||
#_:clj-kondo/ignore
|
||||
(defn apply-wasm-modifiers
|
||||
[modif-tree & {:keys [ignore-constraints ignore-snap-pixel snap-ignore-axis undo-transation?]
|
||||
:or {ignore-constraints false ignore-snap-pixel false snap-ignore-axis nil undo-transation? true}
|
||||
[modif-tree & {:keys [ignore-constraints ignore-snap-pixel snap-ignore-axis undo-transation? propagate?]
|
||||
:or {ignore-constraints false ignore-snap-pixel false snap-ignore-axis nil undo-transation? true propagate? true}
|
||||
:as params}]
|
||||
(ptk/reify ::apply-wasm-modifiesr
|
||||
ptk/WatchEvent
|
||||
@@ -682,7 +682,7 @@
|
||||
(and (not ignore-snap-pixel) (contains? (:workspace-layout state) :snap-pixel-grid))
|
||||
|
||||
transforms
|
||||
(into {} (wasm.api/propagate-modifiers geometry-entries snap-pixel?))
|
||||
(into {} (wasm.api/propagate-modifiers geometry-entries snap-pixel? propagate?))
|
||||
|
||||
ignore-tree
|
||||
(calculate-ignore-tree-wasm transforms objects)
|
||||
|
||||
@@ -1247,9 +1247,8 @@
|
||||
(some? new-modif)
|
||||
(assoc (:id frame) {:modifiers new-modif})))))
|
||||
{}))]
|
||||
|
||||
(if (features/active-feature? state "render-wasm/v1")
|
||||
(rx/of (dwm/apply-wasm-modifiers modifiers {:undo-group undo-group}))
|
||||
(rx/of (dwm/apply-wasm-modifiers modifiers {:undo-group undo-group :propagate? false}))
|
||||
(rx/of (dwm/apply-modifiers {:modifiers modifiers :undo-group undo-group})))))))
|
||||
|
||||
(defn resize-text-editor
|
||||
|
||||
@@ -1072,7 +1072,7 @@
|
||||
(defn- set-objects-async
|
||||
"Asynchronously process shapes in chunks, yielding to the browser between chunks.
|
||||
Returns a promise that resolves when all shapes are processed.
|
||||
|
||||
|
||||
Renders a preview only periodically during loading to show progress,
|
||||
then does a full tile-based render at the end."
|
||||
[shapes render-callback]
|
||||
@@ -1230,7 +1230,7 @@
|
||||
(h/call wasm/internal-module "_set_structure_modifiers"))))
|
||||
|
||||
(defn propagate-modifiers
|
||||
[entries pixel-precision]
|
||||
[entries pixel-precision propagate?]
|
||||
(when-not ^boolean (empty? entries)
|
||||
(let [heapf32 (mem/get-heap-f32)
|
||||
heapu32 (mem/get-heap-u32)
|
||||
@@ -1244,7 +1244,7 @@
|
||||
offset
|
||||
entries)
|
||||
|
||||
(let [offset (-> (h/call wasm/internal-module "_propagate_modifiers" pixel-precision)
|
||||
(let [offset (-> (h/call wasm/internal-module "_propagate_modifiers" pixel-precision propagate?)
|
||||
(mem/->offset-32))
|
||||
length (aget heapu32 offset)
|
||||
max-offset (+ offset 1 (* length MODIFIER-U32-SIZE))
|
||||
|
||||
@@ -702,14 +702,18 @@ pub extern "C" fn clean_modifiers() {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn propagate_modifiers(pixel_precision: bool) -> *mut u8 {
|
||||
pub extern "C" fn propagate_modifiers(pixel_precision: bool, propagate: bool) -> *mut u8 {
|
||||
let bytes = mem::bytes();
|
||||
|
||||
let entries: Vec<_> = bytes
|
||||
let mut entries: Vec<_> = bytes
|
||||
.chunks(size_of::<<TransformEntry as SerializableResult>::BytesType>())
|
||||
.map(|data| TransformEntry::try_from(data).unwrap())
|
||||
.collect();
|
||||
|
||||
for entry in entries.iter_mut() {
|
||||
entry.propagate = propagate;
|
||||
}
|
||||
|
||||
with_state!(state, {
|
||||
let result = shapes::propagate_modifiers(state, &entries, pixel_precision);
|
||||
mem::write_vec(result)
|
||||
|
||||
Reference in New Issue
Block a user