0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-15 17:21:17 -05:00

Draw tools shortcuts (#21)

* Add shortcuts for shapes

* Fix problem with draw or select shapes when a shape is selected
This commit is contained in:
Jesús Espino 2016-04-24 22:04:34 +02:00 committed by Andrey Antukh
parent 9e96bbce99
commit c7801a793c
5 changed files with 39 additions and 25 deletions

View file

@ -113,9 +113,9 @@
(reify
rs/UpdateEvent
(-apply-update [_ state]
(if shape
(assoc-in state [:workspace :drawing] shape)
(update-in state [:workspace] dissoc :drawing)))))
(if (or (nil? shape) (= (get-in state [:workspace :drawing]) shape))
(update-in state [:workspace] dissoc :drawing)
(assoc-in state [:workspace :drawing] shape)))))
;; --- Activate Workspace Flag

View file

@ -91,11 +91,12 @@
zoom (or (:zoom workspace) 1)]
(letfn [(on-mouse-down [event]
(dom/stop-propagation event)
(when-not (empty? (:selected workspace))
(rs/emit! (uds/deselect-all)))
(if-let [shape (:drawing workspace)]
(uuc/acquire-action! "ui.shape.draw")
(uuc/acquire-action! "ui.selrect")))
(do
(when-not (empty? (:selected workspace))
(rs/emit! (uds/deselect-all)))
(uuc/acquire-action! "ui.selrect"))))
(on-mouse-up [event]
(dom/stop-propagation event)
(uuc/release-action! "ui.shape"

View file

@ -12,6 +12,7 @@
[uxbox.data.lightbox :as udl]
[uxbox.data.workspace :as dw]
[uxbox.data.shapes :as uds]
[uxbox.ui.workspace.sidebar.drawtools :as wsd]
[uxbox.data.history :as udh])
(:import goog.events.EventType
goog.events.KeyCodes
@ -33,6 +34,10 @@
:ctrl+c #(rs/emit! (dw/copy-to-clipboard))
:ctrl+v #(rs/emit! (dw/paste-from-clipboard))
:ctrl+z #(rs/emit! (udh/backwards-to-previous-version))
:ctrl+b #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-rect+))
:ctrl+e #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-circle+))
:ctrl+l #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-line+))
:ctrl+t #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-text+))
:ctrl+shift+z #(rs/emit! (udh/forward-to-next-version))
:ctrl+shift+v #(udl/open! :clipboard)
:esc #(rs/emit! (uds/deselect-all))

View file

@ -37,34 +37,46 @@
;; Draw Tools
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:const +draw-tool-rect+
{:type :rect
:name "Rect"
:stroke "#000000"})
(def ^:const +draw-tool-circle+
{:type :circle
:name "Circle"})
(def ^:const +draw-tool-line+
{:type :line
:name "Line"
:stroke-type :solid
:stroke "#000000"})
(def ^:const +draw-tool-text+
{:type :text
:name "Text"
:content "Hello world"})
(def ^:const +draw-tools+
{:rect
{:icon i/box
:help (tr "ds.help.rect")
:shape {:type :rect
:name "Rect"
:stroke "#000000"}
:shape +draw-tool-rect+
:priority 1}
:circle
{:icon i/circle
:help (tr "ds.help.circle")
:shape {:type :circle
:name "Circle"}
:shape +draw-tool-circle+
:priority 2}
:line
{:icon i/line
:help (tr "ds.help.line")
:shape {:type :line
:name "Line"
:stroke-type :solid
:stroke "#000000"}
:shape +draw-tool-line+
:priority 3}
:text
{:icon i/text
:help (tr "ds.help.text")
:shape {:type :text
:name "Text"
:content "Hello world"}
:shape +draw-tool-text+
:priority 4}})
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -72,10 +84,8 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn- select-for-draw
[icon]
(if (= (:drawing @wb/workspace-l) icon)
(rs/emit! (dw/select-for-drawing nil))
(rs/emit! (dw/select-for-drawing icon))))
[shape]
(rs/emit! (dw/select-for-drawing shape)))
(defn draw-tools-render
[open-toolboxes]

View file

@ -39,9 +39,7 @@
(defn- select-icon
[icon]
(if (= (:drawing @wb/workspace-l) icon)
(rs/emit! (dw/select-for-drawing nil))
(rs/emit! (dw/select-for-drawing icon))))
(rs/emit! (dw/select-for-drawing icon)))
(defn- change-icon-coll
[local event]