mirror of
https://github.com/penpot/penpot.git
synced 2025-08-01 07:39:07 +02:00
✨ Add grid helpers to wasm
This commit is contained in:
parent
3624a14141
commit
0be8a6e0e6
11 changed files with 259 additions and 68 deletions
|
@ -13,7 +13,6 @@
|
|||
[app.common.files.helpers :as cfh]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.types.shape :as cts]
|
||||
[app.common.types.shape-tree :as ctt]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.main.data.workspace.transforms :as dwt]
|
||||
[app.main.features :as features]
|
||||
|
@ -329,6 +328,12 @@
|
|||
(when (and @canvas-init? initialized?)
|
||||
(wasm.api/set-canvas-background background)))
|
||||
|
||||
(mf/with-effect [@canvas-init? hover-grid? @hover-top-frame-id]
|
||||
(when @canvas-init?
|
||||
(if hover-grid?
|
||||
(wasm.api/show-grid @hover-top-frame-id)
|
||||
(wasm.api/clear-grid))))
|
||||
|
||||
(hooks/setup-dom-events zoom disable-paste in-viewport? read-only? drawing-tool drawing-path?)
|
||||
(hooks/setup-viewport-size vport viewport-ref)
|
||||
(hooks/setup-cursor cursor alt? mod? space? panning drawing-tool drawing-path? node-editing? z? read-only?)
|
||||
|
@ -639,25 +644,14 @@
|
|||
:zoom zoom}])
|
||||
|
||||
[:g.grid-layout-editor {:clipPath "url(#clip-handlers)"}
|
||||
(when (or show-grid-editor? hover-grid?)
|
||||
(when show-grid-editor?
|
||||
[:& grid-layout/editor
|
||||
{:zoom zoom
|
||||
:objects objects-modified
|
||||
:shape (or (get base-objects edition)
|
||||
(get base-objects @hover-top-frame-id))
|
||||
:view-only (not show-grid-editor?)}])
|
||||
:view-only (not show-grid-editor?)}])]
|
||||
|
||||
(for [frame (ctt/get-frames objects)]
|
||||
(when (and (ctl/grid-layout? frame)
|
||||
(empty? (:shapes frame))
|
||||
(not= edition (:id frame))
|
||||
(not= @hover-top-frame-id (:id frame)))
|
||||
[:& grid-layout/editor
|
||||
{:zoom zoom
|
||||
:key (dm/str (:id frame))
|
||||
:objects objects-modified
|
||||
:shape frame
|
||||
:view-only true}]))]
|
||||
[:g.scrollbar-wrapper {:clipPath "url(#clip-handlers)"}
|
||||
[:& scroll-bars/viewport-scrollbars
|
||||
{:objects base-objects
|
||||
|
|
|
@ -995,6 +995,21 @@
|
|||
;; TODO: perform corresponding cleaning
|
||||
(h/call wasm/internal-module "_clean_up"))
|
||||
|
||||
(defn show-grid
|
||||
[id]
|
||||
(let [buffer (uuid/get-u32 id)]
|
||||
(h/call wasm/internal-module "_show_grid"
|
||||
(aget buffer 0)
|
||||
(aget buffer 1)
|
||||
(aget buffer 2)
|
||||
(aget buffer 3)))
|
||||
(request-render "show-grid"))
|
||||
|
||||
(defn clear-grid
|
||||
[]
|
||||
(h/call wasm/internal-module "_hide_grid")
|
||||
(request-render "clear-grid"))
|
||||
|
||||
(defonce module
|
||||
(delay
|
||||
(if (exists? js/dynamicImport)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue