Add alignment to resize.

This commit is contained in:
Andrey Antukh 2016-04-22 18:20:38 +03:00
parent 7d17926060
commit 9e25f7ab9d
No known key found for this signature in database
GPG Key ID: 4DFEBCB8316A8B95

View File

@ -10,7 +10,8 @@
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.data.shapes :as uds] [uxbox.data.shapes :as uds]
[uxbox.ui.core :as uuc] [uxbox.ui.core :as uuc]
[uxbox.ui.workspace.base :as uuwb] [uxbox.ui.workspace.base :as wb]
[uxbox.ui.workspace.align :as align]
[uxbox.util.geom.point :as gpt])) [uxbox.util.geom.point :as gpt]))
(declare initialize) (declare initialize)
@ -33,11 +34,21 @@
stoper (->> uuc/actions-s stoper (->> uuc/actions-s
(rx/map :type) (rx/map :type)
(rx/filter #(empty? %)) (rx/filter #(empty? %))
(rx/take 1))] (rx/take 1))
(as-> uuwb/mouse-delta-s $
(rx/take-until stoper $) align? @wb/alignment-l
(rx/with-latest-from vector uuwb/mouse-ctrl-s $) stream (->> wb/mouse-viewport-s
(rx/subscribe $ #(handle-resize payload %))))) (rx/sample 10)
(rx/mapcat (fn [point]
(if align?
(align/translate point)
(rx/of point))))
(rx/buffer 2 1)
(rx/map wb/coords-delta)
(rx/take-until stoper)
(rx/map #(gpt/divide % @wb/zoom-l))
(rx/with-latest-from vector wb/mouse-ctrl-s))]
(rx/subscribe stream #(handle-resize payload %))))
(defn- handle-resize (defn- handle-resize
[{:keys [vid shape]} [delta ctrl?]] [{:keys [vid shape]} [delta ctrl?]]