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] (: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]]
(let [active (get-in db [:ui :gesture])
auto? (if active (:auto-key? active) (boolean (get-in db [:ui :auto-key?])))]
(if g (if g
(assoc-in db [:ui :gesture] (let [{:keys [sid id frame values] :as g} (assoc g :auto-key? auto?)]
(assoc g :auto-key? (boolean (get-in db [:ui :auto-key?])))) (cond-> db
(update db :ui dissoc :gesture)))) (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]}]]
(let [auto? (boolean (get-in db [:ui :gesture :auto-key?]))]
(cond-> (update db :ui dissoc :gesture) (cond-> (update db :ui dissoc :gesture)
(seq values) (edit/edit #(gesture/apply-values (seq values) (edit/edit #(gesture/apply-values % sid id frame values auto?))
% sid id frame values auto? (edit/history history/settle)))))
(boolean (get-in db [:ui :auto-key?])))))))
(rf/reg-event-db (rf/reg-event-db
::delete-selected ::delete-selected