Shift-T traces the selection only
Tracing on for the tracing layers in the selection — the selected node, what it places at any depth, its children, a face's own footage — and every other layer off. Again, and every layer shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ea2becf4c7
commit
4fe620f50a
4 changed files with 155 additions and 63 deletions
|
|
@ -477,6 +477,39 @@
|
||||||
#(cond-> (update % :hidden (fnil (if on? disj conj) #{}) layer)
|
#(cond-> (update % :hidden (fnil (if on? disj conj) #{}) layer)
|
||||||
on? (assoc :on? true)))))
|
on? (assoc :on? true)))))
|
||||||
|
|
||||||
|
(defn- trace-layers
|
||||||
|
"The tracing layers in symbol `sid` and everything it places, as
|
||||||
|
`arthur.db/tracing` names them: a placement of a tracing symbol is
|
||||||
|
`[sid id]`, a face's footage `[face :plate]`. Only nodes `keep?` says yes to
|
||||||
|
are looked in at the top; below that, everything is."
|
||||||
|
[clip sid keep?]
|
||||||
|
(let [nodes (:nodes (clip/symbol clip sid))]
|
||||||
|
(into (if (get nodes :plate) #{[sid :plate]} #{})
|
||||||
|
(mapcat (fn [[id n]]
|
||||||
|
(when (keep? id)
|
||||||
|
(let [src (node/source n)]
|
||||||
|
(cond (and src (clip/trace? (clip/symbol clip src))) [[sid id]]
|
||||||
|
src (trace-layers clip src (constantly true)))))))
|
||||||
|
nodes)))
|
||||||
|
|
||||||
|
(rf/reg-event-db
|
||||||
|
::trace-selection
|
||||||
|
;; ⇧T: tracing on for what is in the selection only — the selected node, what
|
||||||
|
;; it places, its children — and every other layer off. Again, all of them.
|
||||||
|
(fn [db _]
|
||||||
|
(let [clip (:clip (store/entry (:clip/current db)))
|
||||||
|
[kind sid id] (get-in db [:ui :selection])
|
||||||
|
nodes (:nodes (clip/symbol clip sid))
|
||||||
|
mine (if (and (= :node kind) id)
|
||||||
|
(trace-layers clip sid #(some #{id} (symbol/lineage nodes %)))
|
||||||
|
#{})
|
||||||
|
every (into #{} (mapcat #(trace-layers clip % (constantly true))) (keys (:symbols clip)))
|
||||||
|
solo (assoc (get-in db [:ui :tracing]) :on? true :hidden (reduce disj every mine))]
|
||||||
|
(cond
|
||||||
|
(empty? mine) (assoc-in db [:project :status] "no tracing in the selection")
|
||||||
|
(= solo (get-in db [:ui :tracing])) (assoc-in db [:ui :tracing :hidden] #{})
|
||||||
|
:else (assoc-in db [:ui :tracing] solo)))))
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::tracing-on
|
::tracing-on
|
||||||
;; Every tracing layer at once, from the bar above the stage.
|
;; Every tracing layer at once, from the bar above the stage.
|
||||||
|
|
|
||||||
|
|
@ -715,7 +715,7 @@
|
||||||
(when (and face-fps fps)
|
(when (and face-fps fps)
|
||||||
[:div.prop {:style {:margin-top "6px"}
|
[:div.prop {:style {:margin-top "6px"}
|
||||||
:title "roto drawn a frame or two ahead of the sound reads as in sync"}
|
:title "roto drawn a frame or two ahead of the sound reads as in sync"}
|
||||||
[:span.prop-name "lead"]
|
[:span.prop-name {:style {:flex "none"}} "mouth lead"]
|
||||||
[number-input {:step 0.5 :aria-label "lead in frames"
|
[number-input {:step 0.5 :aria-label "lead in frames"
|
||||||
:value (/ (js/Math.round (* 10 offset (/ fps face-fps))) 10)
|
:value (/ (js/Math.round (* 10 offset (/ fps face-fps))) 10)
|
||||||
:parse js/parseFloat
|
:parse js/parseFloat
|
||||||
|
|
@ -723,13 +723,33 @@
|
||||||
(js/Math.round (* % (/ face-fps fps)))])}]
|
(js/Math.round (* % (/ face-fps fps)))])}]
|
||||||
[:span.dim (str "f · " (js/Math.round (/ (* 1000 offset) face-fps)) "ms")]])))
|
[:span.dim (str "f · " (js/Math.round (/ (* 1000 offset) face-fps)) "ms")]])))
|
||||||
|
|
||||||
(defn- tracking-section [all]
|
(defn- tracking-section
|
||||||
|
"The generated settings of one of `all`, the tracked objects in view.
|
||||||
|
|
||||||
|
WHICH ONE IS SHOWN IS NOT THE SELECTION. The dropdown used to select the
|
||||||
|
object it picked, which deselected the placement every other section of the
|
||||||
|
inspector is about, so the inspector emptied under the person using it. The
|
||||||
|
pick is kept here instead, `[selection owner]`, and only for as long as the
|
||||||
|
selection it was made under: select something else and the section follows."
|
||||||
|
[_]
|
||||||
|
(let [shown (r/atom nil)]
|
||||||
|
(fn [all]
|
||||||
(let [clip @(rf/subscribe [::render/clip])
|
(let [clip @(rf/subscribe [::render/clip])
|
||||||
selection @(rf/subscribe [::sub/selection])
|
selection @(rf/subscribe [::sub/selection])
|
||||||
knobs @(rf/subscribe [::sub/knobs])
|
knobs @(rf/subscribe [::sub/knobs])
|
||||||
busy? (:busy? @(rf/subscribe [::playback/project]))
|
busy? (:busy? @(rf/subscribe [::playback/project]))
|
||||||
report @(rf/subscribe [::project/regeneration])
|
report @(rf/subscribe [::project/regeneration])
|
||||||
[scope id :as owner] (if (some #{selection} all) selection (first all))
|
[under picked] @shown
|
||||||
|
[scope id :as owner] (cond
|
||||||
|
(and (= under selection) (some #{picked} all)) picked
|
||||||
|
(some #{selection} all) selection
|
||||||
|
:else (first all))
|
||||||
|
;; The face's mouth, whose lead is shown with its face and with itself.
|
||||||
|
mouth (case scope
|
||||||
|
:subject (let [m (feature/owned id :mouth)]
|
||||||
|
(when (get-in clip [:features m]) m))
|
||||||
|
:feature (when (= :mouth (get-in clip [:features id :area])) id)
|
||||||
|
nil)
|
||||||
area (case scope
|
area (case scope
|
||||||
:subject :subject
|
:subject :subject
|
||||||
:feature (get-in clip [:features id :area])
|
:feature (get-in clip [:features id :area])
|
||||||
|
|
@ -749,13 +769,12 @@
|
||||||
;; — the same trap `events/export/target-value` exists to avoid. An index
|
;; — the same trap `events/export/target-value` exists to avoid. An index
|
||||||
;; into a vector both ends agree on cannot be misread.
|
;; into a vector both ends agree on cannot be misread.
|
||||||
[:select {:value (or (first (keep-indexed #(when (= %2 owner) %1) all)) 0)
|
[:select {:value (or (first (keep-indexed #(when (= %2 owner) %1) all)) 0)
|
||||||
:on-change #(rf/dispatch
|
:on-change #(reset! shown [selection (nth all (js/parseInt (.. % -target -value) 10))])}
|
||||||
[::ui/select (nth all (js/parseInt (.. % -target -value) 10))])}
|
|
||||||
(doall
|
(doall
|
||||||
(for [[i [kind object-id]] (map-indexed vector all)]
|
(for [[i [kind object-id]] (map-indexed vector all)]
|
||||||
^{:key i}
|
^{:key i}
|
||||||
[:option {:value i} (str (name kind) " · " (subs (str object-id) 1))]))]
|
[:option {:value i} (str (name kind) " · " (subs (str object-id) 1))]))]
|
||||||
(when (= :mouth area) [lead-row clip id])
|
(when mouth [lead-row clip mouth])
|
||||||
(when area
|
(when area
|
||||||
[:div {:style {:margin-top "6px"}}
|
[:div {:style {:margin-top "6px"}}
|
||||||
(doall
|
(doall
|
||||||
|
|
@ -784,7 +803,7 @@
|
||||||
[:div.dim.regeneration-debug {:style {:margin-top "6px"}}
|
[:div.dim.regeneration-debug {:style {:margin-top "6px"}}
|
||||||
(str "dirty: " (pr-str (:features report))
|
(str "dirty: " (pr-str (:features report))
|
||||||
" · blocks: " (if (seq (:roles report))
|
" · blocks: " (if (seq (:roles report))
|
||||||
(pr-str (sort (:roles report))) "tier 1 only"))])]))
|
(pr-str (sort (:roles report))) "tier 1 only"))])]))))
|
||||||
|
|
||||||
;; ---------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,8 @@
|
||||||
{:label "Clear out" :keys ["shift+o"] :run (constantly [::pb/clear-mark :out])}
|
{:label "Clear out" :keys ["shift+o"] :run (constantly [::pb/clear-mark :out])}
|
||||||
{:label "Tracing" :keys ["t"]
|
{:label "Tracing" :keys ["t"]
|
||||||
:run #(vector ::ui/tracing-on (not (get-in % [:ui :tracing :on?])))}
|
:run #(vector ::ui/tracing-on (not (get-in % [:ui :tracing :on?])))}
|
||||||
|
{:label "Tracing for the selection only" :keys ["shift+t"]
|
||||||
|
:run (constantly [::ui/trace-selection])}
|
||||||
{:label "Onion skin" :keys ["g"] :note "ghosts"
|
{:label "Onion skin" :keys ["g"] :note "ghosts"
|
||||||
:run #(let [on? (get-in % [:ui :onion (:clip/current %) (get-in % [:ui :open]) :on?])]
|
:run #(let [on? (get-in % [:ui :onion (:clip/current %) (get-in % [:ui :open]) :on?])]
|
||||||
[::layout/onion :on? (not on?)])}]]
|
[::layout/onion :on? (not on?)])}]]
|
||||||
|
|
|
||||||
38
frontend/test/arthur/events/tracing_test.cljs
Normal file
38
frontend/test/arthur/events/tracing_test.cljs
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
(ns arthur.events.tracing-test
|
||||||
|
(:require [cljs.test :refer [deftest is]]
|
||||||
|
[arthur.events.ui :as ui]
|
||||||
|
[arthur.footage.store :as store]
|
||||||
|
[re-frame.core :as rf]
|
||||||
|
[re-frame.db :as rf-db]))
|
||||||
|
|
||||||
|
(defn- placed [id src] {:id id :kind :instance :z (name id) :source {:symbol src}})
|
||||||
|
|
||||||
|
(def document
|
||||||
|
;; Two references side by side, and a face traced from footage of its own.
|
||||||
|
{:fps 12 :width 320 :height 200
|
||||||
|
:symbols {:main {:id :main :frames 12
|
||||||
|
:nodes {:a (placed :a :ref) :c (placed :c :ref) :b (placed :b :face)}}
|
||||||
|
:ref {:id :ref :frames 12 :type :trace :nodes {}}
|
||||||
|
:face {:id :face :frames 12
|
||||||
|
:nodes {:plate {:id :plate :kind :rect :z "a"}
|
||||||
|
:mouth {:id :mouth :kind :rect :z "b"}}}}})
|
||||||
|
|
||||||
|
(defn- shift-t [selection tracing]
|
||||||
|
(let [id (store/install! {:clip document :store {}} "trace-selection")]
|
||||||
|
(reset! rf-db/app-db {:clip/current id :ui {:open :main :selection selection :tracing tracing}})
|
||||||
|
(rf/dispatch-sync [::ui/trace-selection])
|
||||||
|
(get-in @rf-db/app-db [:ui :tracing])))
|
||||||
|
|
||||||
|
(deftest shift-t-traces-the-selection-only
|
||||||
|
(is (= {:on? true :opacity 0.5 :hidden #{[:main :c] [:face :plate]}}
|
||||||
|
(shift-t [:node :main :a [:a]] {:on? false :opacity 0.5 :hidden #{}}))
|
||||||
|
"one reference: the other and the face's footage go")
|
||||||
|
(is (= #{[:main :a] [:main :c]}
|
||||||
|
(:hidden (shift-t [:node :main :b [:b]] {:on? false :opacity 0.5 :hidden #{}})))
|
||||||
|
"the face: its own footage, wherever it is placed")
|
||||||
|
(is (= #{} (:hidden (shift-t [:node :main :a [:a]]
|
||||||
|
{:on? true :opacity 0.5 :hidden #{[:main :c] [:face :plate]}})))
|
||||||
|
"again, and every layer is back")
|
||||||
|
(is (= {:on? false :opacity 0.5 :hidden #{}}
|
||||||
|
(shift-t nil {:on? false :opacity 0.5 :hidden #{}}))
|
||||||
|
"nothing selected changes nothing"))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue