mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 10:58:32 +02:00
Add basic icons rendering on canvas.
This commit is contained in:
parent
fc03388d70
commit
f28d54936f
4 changed files with 92 additions and 13 deletions
|
@ -6,11 +6,22 @@
|
|||
[uxbox.time :as time]
|
||||
[bouncer.validators :as v]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Schemas
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def ^:static +shape-props-schema+
|
||||
{:x [v/required v/integer]
|
||||
:y [v/required v/integer]
|
||||
:width [v/required v/integer]
|
||||
:height [v/required v/integer]})
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Events
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn toggle-tool
|
||||
"Toggle the enabled flag of the specified tool."
|
||||
[toolname]
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
|
@ -20,9 +31,10 @@
|
|||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.s.p/toggle-tool>"))))
|
||||
(-write writer "#<event:u.d.w/toggle-tool>"))))
|
||||
|
||||
(defn toggle-toolbox
|
||||
"Toggle the visibility flag of the specified toolbox."
|
||||
[toolname]
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
|
@ -36,9 +48,44 @@
|
|||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.s.p/toggle-toolbox>"))))
|
||||
(-write writer "#<event:u.d.w/toggle-toolbox>"))))
|
||||
|
||||
(defn select-for-drawing
|
||||
"Mark a shape selected for drawing in the canvas."
|
||||
[shape]
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(println "select-for-drawing" shape)
|
||||
(if shape
|
||||
(assoc-in state [:workspace :drawing] shape)
|
||||
(update-in state [:workspace] dissoc :drawing)))
|
||||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.d.w/select-for-drawing>"))))
|
||||
|
||||
;; TODO: validate shape
|
||||
|
||||
(defn add-shape
|
||||
"Mark a shape selected for drawing in the canvas."
|
||||
[shape props]
|
||||
(sc/validate! +shape-props-schema+ props)
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(println "add-shape")
|
||||
(if-let [pageid (get-in state [:workspace :page])]
|
||||
(update-in state [:pages-by-id pageid :shapes] conj
|
||||
(merge shape props))
|
||||
state))
|
||||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.d.w/add-shape>"))))
|
||||
|
||||
(defn initialize
|
||||
"Initialize the workspace state."
|
||||
[projectid pageid]
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
|
@ -52,4 +99,5 @@
|
|||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.s.p/initialize>"))))
|
||||
(-write writer "#<event:u.d.w/initialize>"))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue