mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 08:20:45 -05:00
Add faster movement shortcuts.
This commit is contained in:
parent
39850689fa
commit
e30cfc3b76
2 changed files with 28 additions and 17 deletions
|
@ -409,19 +409,20 @@
|
|||
|
||||
(defn move-selected
|
||||
"Move a minimal position unit the selected shapes."
|
||||
[dir]
|
||||
{:pre [(contains? #{:up :down :right :left} dir)]}
|
||||
(reify
|
||||
rs/WatchEvent
|
||||
(-apply-watch [_ state]
|
||||
(let [selected (get-in state [:workspace :selected])
|
||||
delta (case dir
|
||||
:up [0 -1]
|
||||
:down [0 +1]
|
||||
:right [+1 0]
|
||||
:left [-1 0])]
|
||||
(rx/from-coll
|
||||
(map #(move-shape % delta) selected))))))
|
||||
([dir] (move-selected dir 1))
|
||||
([dir n]
|
||||
{:pre [(contains? #{:up :down :right :left} dir)]}
|
||||
(reify
|
||||
rs/WatchEvent
|
||||
(-apply-watch [_ state]
|
||||
(let [selected (get-in state [:workspace :selected])
|
||||
delta (case dir
|
||||
:up (gpt/point 0 (- n))
|
||||
:down (gpt/point 0 n)
|
||||
:right (gpt/point n 0)
|
||||
:left (gpt/point (- n) 0))]
|
||||
(rx/from-coll
|
||||
(map #(move-shape % delta) selected)))))))
|
||||
|
||||
(defn update-selected-shapes-fill
|
||||
"Update the fill related attributed on
|
||||
|
|
|
@ -13,6 +13,12 @@
|
|||
;; Keyboard Shortcuts Handlers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn move-selected
|
||||
[dir speed]
|
||||
(case speed
|
||||
:std (rs/emit! (dw/move-selected dir 1))
|
||||
:fast (rs/emit! (dw/move-selected dir 20))))
|
||||
|
||||
(defonce ^:const +shortcuts+
|
||||
{:ctrl+g #(rs/emit! (dw/toggle-flag :grid))
|
||||
:ctrl+shift+f #(rs/emit! (dw/toggle-flag :drawtools))
|
||||
|
@ -23,10 +29,14 @@
|
|||
:esc #(rs/emit! (dw/deselect-all))
|
||||
:backspace #(rs/emit! (dw/delete-selected))
|
||||
:delete #(rs/emit! (dw/delete-selected))
|
||||
:up #(rs/emit! (dw/move-selected :up))
|
||||
:down #(rs/emit! (dw/move-selected :down))
|
||||
:right #(rs/emit! (dw/move-selected :right))
|
||||
:left #(rs/emit! (dw/move-selected :left))})
|
||||
:shift+up #(move-selected :up :fast)
|
||||
:shift+down #(move-selected :down :fast)
|
||||
:shift+right #(move-selected :right :fast)
|
||||
:shift+left #(move-selected :left :fast)
|
||||
:up #(move-selected :up :std)
|
||||
:down #(move-selected :down :std)
|
||||
:right #(move-selected :right :std)
|
||||
:left #(move-selected :left :std)})
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Keyboard Shortcuts Watcher
|
||||
|
|
Loading…
Reference in a new issue