Write auto-keys during transform drags
This commit is contained in:
parent
34f62ab007
commit
6e9409b0de
1 changed files with 19 additions and 8 deletions
|
|
@ -21,6 +21,7 @@
|
||||||
(:require [arthur.domain.clip :as clip]
|
(:require [arthur.domain.clip :as clip]
|
||||||
[arthur.domain.correction :as correction]
|
[arthur.domain.correction :as correction]
|
||||||
[arthur.domain.gesture :as gesture]
|
[arthur.domain.gesture :as gesture]
|
||||||
|
[arthur.domain.history :as history]
|
||||||
[arthur.domain.nest :as nest]
|
[arthur.domain.nest :as nest]
|
||||||
[arthur.domain.node :as node]
|
[arthur.domain.node :as node]
|
||||||
[arthur.domain.lane :as lane]
|
[arthur.domain.lane :as lane]
|
||||||
|
|
@ -758,20 +759,30 @@
|
||||||
::gesture
|
::gesture
|
||||||
;; A transform in the middle of a drag on the stage, `{:sid :id :frame
|
;; A transform in the middle of a drag on the stage, `{:sid :id :frame
|
||||||
;; :values}`, drawn by `::render/clip` as `::sliding` is; nil when abandoned.
|
;; :values}`, drawn by `::render/clip` as `::sliding` is; nil when abandoned.
|
||||||
|
;; Auto-key is different: its first movement must materialize the key, or the
|
||||||
|
;; channel's existing interpolation remains the document truth throughout the
|
||||||
|
;; drag and fights the hand moving it. Each move therefore updates the real key
|
||||||
|
;; while history/hold makes the entire gesture one undo step.
|
||||||
(fn [db [_ g]]
|
(fn [db [_ g]]
|
||||||
(if g
|
(let [active (get-in db [:ui :gesture])
|
||||||
(assoc-in db [:ui :gesture]
|
auto? (if active (:auto-key? active) (boolean (get-in db [:ui :auto-key?])))]
|
||||||
(assoc g :auto-key? (boolean (get-in db [:ui :auto-key?]))))
|
(if g
|
||||||
(update db :ui dissoc :gesture))))
|
(let [{:keys [sid id frame values] :as g} (assoc g :auto-key? auto?)]
|
||||||
|
(cond-> db
|
||||||
|
(and auto? (nil? active)) (edit/history history/hold)
|
||||||
|
auto? (edit/edit #(gesture/apply-values % sid id frame values true))
|
||||||
|
true (assoc-in [:ui :gesture] g)))
|
||||||
|
(cond-> (update db :ui dissoc :gesture)
|
||||||
|
(:auto-key? active) (edit/history history/settle))))))
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::transform
|
::transform
|
||||||
;; The drag let go: one edit, so one undo step and one write to collaborators.
|
;; The drag let go: one edit, so one undo step and one write to collaborators.
|
||||||
(fn [db [_ {:keys [sid id frame values]}]]
|
(fn [db [_ {:keys [sid id frame values]}]]
|
||||||
(cond-> (update db :ui dissoc :gesture)
|
(let [auto? (boolean (get-in db [:ui :gesture :auto-key?]))]
|
||||||
(seq values) (edit/edit #(gesture/apply-values
|
(cond-> (update db :ui dissoc :gesture)
|
||||||
% sid id frame values
|
(seq values) (edit/edit #(gesture/apply-values % sid id frame values auto?))
|
||||||
(boolean (get-in db [:ui :auto-key?])))))))
|
auto? (edit/history history/settle)))))
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::delete-selected
|
::delete-selected
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue