Write auto-keys during transform drags

This commit is contained in:
Your Name 2026-10-01 12:25:41 -04:00
parent 34f62ab007
commit 6e9409b0de

View file

@ -21,6 +21,7 @@
(:require [arthur.domain.clip :as clip]
[arthur.domain.correction :as correction]
[arthur.domain.gesture :as gesture]
[arthur.domain.history :as history]
[arthur.domain.nest :as nest]
[arthur.domain.node :as node]
[arthur.domain.lane :as lane]
@ -758,20 +759,30 @@
::gesture
;; 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.
;; 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]]
(let [active (get-in db [:ui :gesture])
auto? (if active (:auto-key? active) (boolean (get-in db [:ui :auto-key?])))]
(if g
(assoc-in db [:ui :gesture]
(assoc g :auto-key? (boolean (get-in db [:ui :auto-key?]))))
(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
::transform
;; The drag let go: one edit, so one undo step and one write to collaborators.
(fn [db [_ {:keys [sid id frame values]}]]
(let [auto? (boolean (get-in db [:ui :gesture :auto-key?]))]
(cond-> (update db :ui dissoc :gesture)
(seq values) (edit/edit #(gesture/apply-values
% sid id frame values
(boolean (get-in db [:ui :auto-key?])))))))
(seq values) (edit/edit #(gesture/apply-values % sid id frame values auto?))
auto? (edit/history history/settle)))))
(rf/reg-event-db
::delete-selected