mirror of
https://github.com/penpot/penpot.git
synced 2025-01-26 08:29:42 -05:00
✨ Improve path editor
This commit is contained in:
parent
1c0822ffb3
commit
2582e87ffa
4 changed files with 46 additions and 8 deletions
|
@ -18,6 +18,7 @@
|
||||||
(d/export drawing/start-path-from-point)
|
(d/export drawing/start-path-from-point)
|
||||||
(d/export drawing/close-path-drag-start)
|
(d/export drawing/close-path-drag-start)
|
||||||
(d/export drawing/change-edit-mode)
|
(d/export drawing/change-edit-mode)
|
||||||
|
(d/export drawing/reset-last-handler)
|
||||||
|
|
||||||
;; Edition
|
;; Edition
|
||||||
(d/export edition/start-move-handler)
|
(d/export edition/start-move-handler)
|
||||||
|
|
|
@ -359,3 +359,13 @@
|
||||||
(and id (= :move mode)) (rx/of (common/finish-path "change-edit-mode"))
|
(and id (= :move mode)) (rx/of (common/finish-path "change-edit-mode"))
|
||||||
(and id (= :draw mode)) (rx/of (start-draw-mode))
|
(and id (= :draw mode)) (rx/of (start-draw-mode))
|
||||||
:else (rx/empty))))))
|
:else (rx/empty))))))
|
||||||
|
|
||||||
|
(defn reset-last-handler
|
||||||
|
[]
|
||||||
|
(ptk/reify ::reset-last-handler
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(let [id (st/get-path-id state)]
|
||||||
|
(-> state
|
||||||
|
(assoc-in [:workspace-local :edit-path id :prev-handler] nil))))))
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@
|
||||||
:command "p"
|
:command "p"
|
||||||
:fn #(st/emit! (drp/change-edit-mode :draw))}
|
:fn #(st/emit! (drp/change-edit-mode :draw))}
|
||||||
|
|
||||||
:add-node {:tooltip "+"
|
:add-node {:tooltip (ds/shift "+")
|
||||||
:command "+"
|
:command "shift++"
|
||||||
:fn #(st/emit! (drp/add-node))}
|
:fn #(st/emit! (drp/add-node))}
|
||||||
|
|
||||||
:delete-node {:tooltip (ds/supr)
|
:delete-node {:tooltip (ds/supr)
|
||||||
|
@ -88,7 +88,30 @@
|
||||||
:command [(ds/c-mod "shift+z") (ds/c-mod "y")]
|
:command [(ds/c-mod "shift+z") (ds/c-mod "y")]
|
||||||
:fn #(st/emit! (drp/redo-path))}
|
:fn #(st/emit! (drp/redo-path))}
|
||||||
|
|
||||||
|
;; ZOOM
|
||||||
|
|
||||||
|
:increase-zoom {:tooltip "+"
|
||||||
|
:command "+"
|
||||||
|
:fn #(st/emit! (dw/increase-zoom nil))}
|
||||||
|
|
||||||
|
:decrease-zoom {:tooltip "-"
|
||||||
|
:command "-"
|
||||||
|
:fn #(st/emit! (dw/decrease-zoom nil))}
|
||||||
|
|
||||||
|
:reset-zoom {:tooltip (ds/shift "0")
|
||||||
|
:command "shift+0"
|
||||||
|
:fn #(st/emit! dw/reset-zoom)}
|
||||||
|
|
||||||
|
:fit-all {:tooltip (ds/shift "1")
|
||||||
|
:command "shift+1"
|
||||||
|
:fn #(st/emit! dw/zoom-to-fit-all)}
|
||||||
|
|
||||||
|
:zoom-selected {:tooltip (ds/shift "2")
|
||||||
|
:command "shift+2"
|
||||||
|
:fn #(st/emit! dw/zoom-to-selected-shape)}
|
||||||
|
|
||||||
;; Arrow movement
|
;; Arrow movement
|
||||||
|
|
||||||
:move-fast-up {:tooltip (ds/shift ds/up-arrow)
|
:move-fast-up {:tooltip (ds/shift ds/up-arrow)
|
||||||
:command "shift+up"
|
:command "shift+up"
|
||||||
:fn #(st/emit! (drp/move-selected :up true))}
|
:fn #(st/emit! (drp/move-selected :up true))}
|
||||||
|
|
|
@ -30,12 +30,14 @@
|
||||||
(let [{:keys [x y]} position
|
(let [{:keys [x y]} position
|
||||||
|
|
||||||
on-enter
|
on-enter
|
||||||
(fn [event]
|
(mf/use-callback
|
||||||
(st/emit! (drp/path-pointer-enter position)))
|
(fn [event]
|
||||||
|
(st/emit! (drp/path-pointer-enter position))))
|
||||||
|
|
||||||
on-leave
|
on-leave
|
||||||
(fn [event]
|
(mf/use-callback
|
||||||
(st/emit! (drp/path-pointer-leave position)))
|
(fn [event]
|
||||||
|
(st/emit! (drp/path-pointer-leave position))))
|
||||||
|
|
||||||
on-mouse-down
|
on-mouse-down
|
||||||
(fn [event]
|
(fn [event]
|
||||||
|
@ -48,6 +50,9 @@
|
||||||
(let [shift? (kbd/shift? event)
|
(let [shift? (kbd/shift? event)
|
||||||
ctrl? (kbd/ctrl? event)]
|
ctrl? (kbd/ctrl? event)]
|
||||||
(cond
|
(cond
|
||||||
|
last-p?
|
||||||
|
(st/emit! (drp/reset-last-handler))
|
||||||
|
|
||||||
(and (= edit-mode :move) ctrl? (not curve?))
|
(and (= edit-mode :move) ctrl? (not curve?))
|
||||||
(st/emit! (drp/make-curve position))
|
(st/emit! (drp/make-curve position))
|
||||||
|
|
||||||
|
@ -81,8 +86,7 @@
|
||||||
:on-mouse-down on-mouse-down
|
:on-mouse-down on-mouse-down
|
||||||
:on-mouse-enter on-enter
|
:on-mouse-enter on-enter
|
||||||
:on-mouse-leave on-leave
|
:on-mouse-leave on-leave
|
||||||
:style {:pointer-events (when last-p? "none")
|
:style {:cursor (cond
|
||||||
:cursor (cond
|
|
||||||
(= edit-mode :draw) cur/pen-node
|
(= edit-mode :draw) cur/pen-node
|
||||||
(= edit-mode :move) cur/pointer-node)
|
(= edit-mode :move) cur/pointer-node)
|
||||||
:fill "transparent"}}]]))
|
:fill "transparent"}}]]))
|
||||||
|
|
Loading…
Add table
Reference in a new issue