mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 12:46:11 +02:00
Reimplemented the draw shapes/icons.
This commit is contained in:
parent
28047aa64d
commit
32b7bfe383
5 changed files with 139 additions and 66 deletions
|
@ -17,6 +17,7 @@
|
|||
[uxbox.ui.dom :as dom]
|
||||
[uxbox.ui.workspace.base :as wb]
|
||||
[uxbox.ui.workspace.canvas.movement]
|
||||
[uxbox.ui.workspace.canvas.draw :refer (draw-area)]
|
||||
[uxbox.ui.workspace.canvas.selection :refer (shapes-selection)]
|
||||
[uxbox.ui.workspace.canvas.selrect :refer (selrect)]
|
||||
[uxbox.ui.workspace.grid :refer (grid)]
|
||||
|
@ -67,7 +68,6 @@
|
|||
(do
|
||||
(dom/stop-propagation event)
|
||||
(swap! local assoc :init-coords [x y])
|
||||
#_(reset! wb/shapes-dragging? true)
|
||||
(if (.-ctrlKey event)
|
||||
(rs/emit! (dw/select-shape id))
|
||||
(rs/emit! (dw/deselect-all)
|
||||
|
@ -162,7 +162,8 @@
|
|||
(for [item (sequence xf (:shapes page))]
|
||||
(-> (shape item workspace-selected)
|
||||
(rum/with-key (str (:id item)))))
|
||||
(selrect)]]])))
|
||||
(selrect)
|
||||
(draw-area)]]])))
|
||||
|
||||
(def canvas
|
||||
(mx/component
|
||||
|
@ -187,27 +188,16 @@
|
|||
(dom/stop-propagation event)
|
||||
(when-not (empty? (:selected workspace))
|
||||
(rs/emit! (dw/deselect-all)))
|
||||
(wb/emit-interaction! :selrect/draw))
|
||||
(if-let [shape (:drawing workspace)]
|
||||
(wb/emit-interaction! :draw/shape)
|
||||
(wb/emit-interaction! :draw/selrect)))
|
||||
(on-mouse-up [event]
|
||||
(dom/stop-propagation event)
|
||||
(wb/emit-interaction! :nothing))
|
||||
(on-click [event wstate]
|
||||
(let [mousepos @wb/mouse-position
|
||||
scroll-top @wb/scroll-top
|
||||
shape (:drawing wstate)]
|
||||
(when shape
|
||||
(let [props {:x (first mousepos)
|
||||
:y (+ (second mousepos) scroll-top)
|
||||
:width 100
|
||||
:height 100}]
|
||||
(rs/emit!
|
||||
(dw/add-shape shape props)
|
||||
(dw/select-for-drawing nil))))))]
|
||||
(wb/emit-interaction! :nothing))]
|
||||
(html
|
||||
[:svg.viewport {:width wb/viewport-height
|
||||
:height wb/viewport-width
|
||||
:class (when drawing? "drawing")
|
||||
:on-click #(on-click % workspace)
|
||||
:on-mouse-down on-mouse-down
|
||||
:on-mouse-up on-mouse-up}
|
||||
[:g.zoom {:transform (str "scale(" zoom ", " zoom ")")}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue