From e30cfc3b76f2fc3bfc45e584815afd029fe30e69 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sat, 27 Feb 2016 14:51:16 +0200 Subject: [PATCH] Add faster movement shortcuts. --- src/uxbox/data/workspace.cljs | 27 ++++++++++++++------------- src/uxbox/ui/workspace/shortcuts.cljs | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/uxbox/data/workspace.cljs b/src/uxbox/data/workspace.cljs index 11391183d..982f695f5 100644 --- a/src/uxbox/data/workspace.cljs +++ b/src/uxbox/data/workspace.cljs @@ -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 diff --git a/src/uxbox/ui/workspace/shortcuts.cljs b/src/uxbox/ui/workspace/shortcuts.cljs index 23a5c9476..5898bd2ce 100644 --- a/src/uxbox/ui/workspace/shortcuts.cljs +++ b/src/uxbox/ui/workspace/shortcuts.cljs @@ -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