🎉 Add resize scale for texts

This commit is contained in:
Andrés Moya 2021-05-04 09:59:21 +02:00
parent ebb6df4696
commit 4c48f34d61
9 changed files with 67 additions and 5 deletions

View file

@ -73,6 +73,7 @@
:rules
:display-grid
:snap-grid
:scale-text
:dynamic-alignment})
(s/def ::layout-flags (s/coll-of ::layout-flag))

View file

@ -30,7 +30,12 @@
(ptk/reify ::select-for-drawing
ptk/UpdateEvent
(update [_ state]
(update state :workspace-drawing assoc :tool tool :object data))
(-> state
(update :workspace-drawing assoc :tool tool :object data)
;; When changing drawing tool disable "scale text" mode
;; automatically, to help users that ignore how this
;; mode works.
(update :workspace-layout disj :scale-text)))
ptk/WatchEvent
(watch [_ state stream]

View file

@ -61,7 +61,11 @@
:toggle-alignment {:tooltip (ds/meta "\\")
:command (ds/c-mod "\\")
:fn #(st/emit! (dw/toggle-layout-flags :dynamic-alignment))}
:toggle-scale-text {:tooltip "K"
:command "k"
:fn #(st/emit! (dw/toggle-layout-flags :scale-text))}
:increase-zoom {:tooltip "+"
:command "+"
:fn #(st/emit! (dw/increase-zoom nil))}

View file

@ -81,11 +81,16 @@
;; -- RESIZE
(defn start-resize
[handler initial ids shape]
(letfn [(resize [shape initial resizing-shapes [point lock? point-snap]]
(letfn [(resize [shape initial resizing-shapes layout [point lock? point-snap]]
(let [{:keys [width height]} (:selrect shape)
{:keys [rotation]} shape
shapev (-> (gpt/point width height))
scale-text (:scale-text layout)
;; Force lock if the scale text mode is active
lock? (or lock? scale-text)
;; Vector modifiers depending on the handler
handler-modif (let [[x y] (handler-modifiers handler)] (gpt/point x y))
@ -119,6 +124,7 @@
{:resize-vector scalev
:resize-origin origin
:resize-transform shape-transform
:resize-scale-text scale-text
:resize-transform-inverse shape-transform-inverse}
false))))
@ -154,7 +160,7 @@
(rx/switch-map (fn [[point :as current]]
(->> (snap/closest-snap-point page-id resizing-shapes layout zoom point)
(rx/map #(conj current %)))))
(rx/mapcat (partial resize shape initial-position resizing-shapes))
(rx/mapcat (partial resize shape initial-position resizing-shapes layout))
(rx/take-until stoper))
(rx/of (apply-modifiers ids)
(finish-transform))))))))

View file

@ -218,6 +218,13 @@
(tr "workspace.header.menu.enable-dynamic-alignment"))]
[:span.shortcut (sc/get-tooltip :toggle-alignment)]]
[:li {:on-click #(st/emit! (dw/toggle-layout-flags :scale-text))}
[:span
(if (contains? layout :scale-text)
(tr "workspace.header.menu.disable-scale-text")
(tr "workspace.header.menu.enable-scale-text"))]
[:span.shortcut (sc/get-tooltip :toggle-scale-text)]]
(if (:is-shared file)
[:li {:on-click on-remove-shared}
[:span (tr "dashboard.remove-shared")]]