mirror of
https://github.com/penpot/penpot.git
synced 2025-12-24 06:58:34 -05:00
Compare commits
4 Commits
tokens-api
...
azazeln28-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79b06aa092 | ||
|
|
7d8e985877 | ||
|
|
6f8e8da466 | ||
|
|
eb1bc480ca |
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"stdint.h": "c"
|
||||
}
|
||||
}
|
||||
@@ -389,6 +389,7 @@
|
||||
([vector]
|
||||
(move (empty) vector)))
|
||||
|
||||
;; This function is never used
|
||||
(defn move-parent-modifiers
|
||||
([x y]
|
||||
(move-parent (empty) (gpt/point x y)))
|
||||
@@ -403,6 +404,7 @@
|
||||
([vector origin transform transform-inverse]
|
||||
(resize (empty) vector origin transform transform-inverse)))
|
||||
|
||||
;; This function is never used
|
||||
(defn resize-parent-modifiers
|
||||
([vector origin]
|
||||
(resize-parent (empty) vector origin))
|
||||
|
||||
10
frontend/resources/public/wasm/Makefile
Normal file
10
frontend/resources/public/wasm/Makefile
Normal file
@@ -0,0 +1,10 @@
|
||||
all:
|
||||
mkdir -p build
|
||||
clang \
|
||||
-target wasm32 \
|
||||
-nostdlib \
|
||||
-Wl,--no-entry \
|
||||
-Wl,--export-all \
|
||||
-o build/resize.wasm \
|
||||
src/resize.c
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n]
|
||||
[app.util.theme :as theme]
|
||||
[app.wasm :as wasm]
|
||||
[beicon.core :as rx]
|
||||
[debug]
|
||||
[features]
|
||||
@@ -73,6 +74,7 @@
|
||||
|
||||
(defn ^:export init
|
||||
[]
|
||||
(wasm/init!)
|
||||
(worker/init!)
|
||||
(i18n/init! cf/translations)
|
||||
(theme/init! cf/themes)
|
||||
|
||||
@@ -392,6 +392,7 @@
|
||||
(reduce merge {}))
|
||||
undo-id (js/Symbol)]
|
||||
|
||||
(js/console.log (clj->js object-modifiers) (clj->js text-modifiers) (clj->js objects))
|
||||
(rx/concat
|
||||
(if undo-transation?
|
||||
(rx/of (dwu/start-undo-transaction undo-id))
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
[app.main.snap :as snap]
|
||||
[app.main.streams :as ms]
|
||||
[app.util.dom :as dom]
|
||||
[app.wasm :as wasm]
|
||||
[beicon.core :as rx]
|
||||
[cljs.spec.alpha :as s]
|
||||
[potok.core :as ptk]))
|
||||
@@ -175,6 +176,9 @@
|
||||
set-fix-height?
|
||||
(not (mth/close? (:y scalev) 1))
|
||||
|
||||
;; Creates the initial structure of modifiers
|
||||
;; that will be later filled in the create-modif-tree
|
||||
;; call
|
||||
modifiers
|
||||
(-> (ctm/empty)
|
||||
(cond-> displacement
|
||||
@@ -190,7 +194,10 @@
|
||||
(cond-> scale-text
|
||||
(ctm/scale-content (:x scalev))))
|
||||
|
||||
modif-tree (dwm/create-modif-tree ids modifiers)]
|
||||
;; Fills modifiers using identifiers
|
||||
modif-tree (dwm/create-modif-tree ids modifiers)]
|
||||
(js/console.log (clj->js modif-tree))
|
||||
(wasm/resize handler ids shape)
|
||||
(rx/of (dwm/set-modifiers modif-tree))))
|
||||
|
||||
;; Unifies the instantaneous proportion lock modifier
|
||||
@@ -199,6 +206,7 @@
|
||||
(normalize-proportion-lock [[point shift? alt?]]
|
||||
(let [proportion-lock? (:proportion-lock shape)]
|
||||
[point (or proportion-lock? shift?) alt?]))]
|
||||
|
||||
(reify
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
@@ -208,7 +216,7 @@
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [initial-position @ms/mouse-position
|
||||
stoper (rx/filter ms/mouse-up? stream)
|
||||
stopper (rx/filter ms/mouse-up? stream)
|
||||
layout (:workspace-layout state)
|
||||
page-id (:current-page-id state)
|
||||
focus (:workspace-focus-selected state)
|
||||
@@ -225,7 +233,7 @@
|
||||
(->> (snap/closest-snap-point page-id resizing-shapes objects layout zoom focus point)
|
||||
(rx/map #(conj current %)))))
|
||||
(rx/mapcat (partial resize shape initial-position layout))
|
||||
(rx/take-until stoper))
|
||||
(rx/take-until stopper))
|
||||
(rx/of (dwm/apply-modifiers)
|
||||
(finish-transform))))))))
|
||||
|
||||
|
||||
@@ -370,6 +370,7 @@
|
||||
(when (dom/left-mouse? event)
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (dw/start-resize current-position selected shape))))
|
||||
;;(js/console.log event (dw/start-resize current-position selected shape))))
|
||||
|
||||
on-rotate
|
||||
(fn [event]
|
||||
@@ -410,6 +411,7 @@
|
||||
(when (dom/left-mouse? event)
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (dw/start-resize current-position #{shape-id} shape))))
|
||||
;;(js/console.log event (clj->js (dw/start-resize current-position #{shape-id} shape)))))
|
||||
|
||||
on-rotate
|
||||
(fn [event]
|
||||
|
||||
47
frontend/src/app/wasm.cljs
Normal file
47
frontend/src/app/wasm.cljs
Normal file
@@ -0,0 +1,47 @@
|
||||
(ns app.wasm
|
||||
(:require
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defonce assembly (atom nil))
|
||||
|
||||
(defn load-wasm
|
||||
"Loads a WebAssembly module"
|
||||
[uri]
|
||||
(->
|
||||
(p/let [response (js/fetch uri)
|
||||
array-buffer (.arrayBuffer response)
|
||||
assembly (.instantiate js/WebAssembly array-buffer (js-obj "env" (js-obj)))]
|
||||
assembly)
|
||||
(p/catch (fn [error] (prn "error: " error)))))
|
||||
|
||||
(defn init!
|
||||
"Initializes WebAssembly module"
|
||||
[]
|
||||
(p/then
|
||||
(load-wasm "wasm/build/resize.wasm")
|
||||
(fn [asm]
|
||||
(reset! assembly
|
||||
(js-obj "instance" asm.instance
|
||||
"module" asm.module
|
||||
"exports" asm.instance.exports)))))
|
||||
|
||||
(defn get-handler-id
|
||||
[handler]
|
||||
(case handler
|
||||
:top 0
|
||||
:top-right 1
|
||||
:right 2
|
||||
:bottom-right 3
|
||||
:bottom 4
|
||||
:bottom-left 5
|
||||
:left 6
|
||||
:top-left 7))
|
||||
|
||||
(defn resize
|
||||
[handler ids shape]
|
||||
;; TODO: Tenemos que resolver los diferentes shapes
|
||||
;; para subirlos al módulo de WebAssembly.
|
||||
(when @assembly
|
||||
(let [asm @assembly]
|
||||
(js/console.log (clj->js ids) (clj->js shape))
|
||||
(asm.exports.resize (get-handler-id handler) ids shape))))
|
||||
Reference in New Issue
Block a user