mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 16:30:37 -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
|
(defn move-selected
|
||||||
"Move a minimal position unit the selected shapes."
|
"Move a minimal position unit the selected shapes."
|
||||||
[dir]
|
([dir] (move-selected dir 1))
|
||||||
{:pre [(contains? #{:up :down :right :left} dir)]}
|
([dir n]
|
||||||
(reify
|
{:pre [(contains? #{:up :down :right :left} dir)]}
|
||||||
rs/WatchEvent
|
(reify
|
||||||
(-apply-watch [_ state]
|
rs/WatchEvent
|
||||||
(let [selected (get-in state [:workspace :selected])
|
(-apply-watch [_ state]
|
||||||
delta (case dir
|
(let [selected (get-in state [:workspace :selected])
|
||||||
:up [0 -1]
|
delta (case dir
|
||||||
:down [0 +1]
|
:up (gpt/point 0 (- n))
|
||||||
:right [+1 0]
|
:down (gpt/point 0 n)
|
||||||
:left [-1 0])]
|
:right (gpt/point n 0)
|
||||||
(rx/from-coll
|
:left (gpt/point (- n) 0))]
|
||||||
(map #(move-shape % delta) selected))))))
|
(rx/from-coll
|
||||||
|
(map #(move-shape % delta) selected)))))))
|
||||||
|
|
||||||
(defn update-selected-shapes-fill
|
(defn update-selected-shapes-fill
|
||||||
"Update the fill related attributed on
|
"Update the fill related attributed on
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
;; Keyboard Shortcuts Handlers
|
;; 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+
|
(defonce ^:const +shortcuts+
|
||||||
{:ctrl+g #(rs/emit! (dw/toggle-flag :grid))
|
{:ctrl+g #(rs/emit! (dw/toggle-flag :grid))
|
||||||
:ctrl+shift+f #(rs/emit! (dw/toggle-flag :drawtools))
|
:ctrl+shift+f #(rs/emit! (dw/toggle-flag :drawtools))
|
||||||
|
@ -23,10 +29,14 @@
|
||||||
:esc #(rs/emit! (dw/deselect-all))
|
:esc #(rs/emit! (dw/deselect-all))
|
||||||
:backspace #(rs/emit! (dw/delete-selected))
|
:backspace #(rs/emit! (dw/delete-selected))
|
||||||
:delete #(rs/emit! (dw/delete-selected))
|
:delete #(rs/emit! (dw/delete-selected))
|
||||||
:up #(rs/emit! (dw/move-selected :up))
|
:shift+up #(move-selected :up :fast)
|
||||||
:down #(rs/emit! (dw/move-selected :down))
|
:shift+down #(move-selected :down :fast)
|
||||||
:right #(rs/emit! (dw/move-selected :right))
|
:shift+right #(move-selected :right :fast)
|
||||||
:left #(rs/emit! (dw/move-selected :left))})
|
: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
|
;; Keyboard Shortcuts Watcher
|
||||||
|
|
Loading…
Reference in a new issue