Adapt zoom widget to new state layout.

This commit is contained in:
Andrey Antukh 2020-01-08 19:18:43 +01:00
parent 1e57de2d6e
commit 904664319a
2 changed files with 28 additions and 36 deletions

View file

@ -527,38 +527,29 @@
;; --- Zoom Management ;; --- Zoom Management
(defrecord IncreaseZoom [] (def increase-zoom
(ptk/reify ::increase-zoom
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(let [increase #(nth c/zoom-levels (let [increase #(nth c/zoom-levels
(+ (index-of c/zoom-levels %) 1) (+ (index-of c/zoom-levels %) 1)
(last c/zoom-levels))] (last c/zoom-levels))]
(update-in state [:workspace :zoom] (fnil increase 1))))) (update-in state [:workspace-local :zoom] (fnil increase 1))))))
(defn increase-zoom (def decrease-zoom
[] (ptk/reify ::decrease-zoom
(IncreaseZoom.))
(defrecord DecreaseZoom []
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(let [decrease #(nth c/zoom-levels (let [decrease #(nth c/zoom-levels
(- (index-of c/zoom-levels %) 1) (- (index-of c/zoom-levels %) 1)
(first c/zoom-levels))] (first c/zoom-levels))]
(update-in state [:workspace :zoom] (fnil decrease 1))))) (update-in state [:workspace-local :zoom] (fnil decrease 1))))))
(defn decrease-zoom (def reset-zoom
[] (ptk/reify ::reset-zoom
(DecreaseZoom.))
(defrecord ResetZoom []
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(assoc-in state [:workspace :zoom] 1))) (assoc-in state [:workspace-local :zoom] 1))))
(defn reset-zoom
[]
(ResetZoom.))
;; --- Grid Alignment ;; --- Grid Alignment

View file

@ -26,10 +26,11 @@
;; --- Zoom Widget ;; --- Zoom Widget
(mf/defc zoom-widget (mf/defc zoom-widget
{:wrap [mf/wrap-memo]}
[props] [props]
(let [zoom (mf/deref refs/selected-zoom) (let [zoom (mf/deref refs/selected-zoom)
increase #(st/emit! (dw/increase-zoom)) increase #(st/emit! dw/increase-zoom)
decrease #(st/emit! (dw/decrease-zoom))] decrease #(st/emit! dw/decrease-zoom)]
[:ul.options-view [:ul.options-view
[:li.zoom-input [:li.zoom-input
[:span.add-zoom {:on-click decrease} "-"] [:span.add-zoom {:on-click decrease} "-"]