I and O mark where playback loops, and the timeline dims the rest
Resolve's in and out marks, per tab. Play starts from the in mark when the playhead is outside them and goes round from the out mark back to the in, as Blender's preview range does; the loop is in the player's frame loop, so both clocks do it the same way. Alt-X clears them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
246b6d6468
commit
1c6c45e465
6 changed files with 72 additions and 8 deletions
|
|
@ -63,14 +63,24 @@
|
|||
(get-in db [:ui :gesture :auto-key?])
|
||||
(assoc :dispatch [:arthur.events.ui/record-gesture f])))))
|
||||
|
||||
(defn- start
|
||||
"Play from the playhead, or from the top when the playhead is on the last
|
||||
frame. Playing the last frame alone is a twenty-fourth of a second and then
|
||||
silence, so play there looked like a button that did nothing."
|
||||
(defn bounds
|
||||
"The frames playback runs between, both included: the open tab's in and out
|
||||
marks, or the whole symbol where one is not set."
|
||||
[db]
|
||||
(let [n (frames db)
|
||||
{:keys [in out]} (get-in db [:playback :range (get-in db [:ui :open])])]
|
||||
[(or in 0) (min (dec n) (or out (dec n)))]))
|
||||
|
||||
(defn- start
|
||||
"Play from the playhead, or from the in mark when the playhead is outside the
|
||||
marks or on the last frame they allow. Playing the last frame alone is a
|
||||
twenty-fourth of a second and then silence, so play there looked like a
|
||||
button that did nothing."
|
||||
[db]
|
||||
(let [n (frames db)
|
||||
[lo hi] (bounds db)
|
||||
f (get-in db [:playback :frame] 0)
|
||||
f (if (< f (dec n)) f 0)]
|
||||
f (if (and (<= lo f) (< f hi)) f lo)]
|
||||
{:db (update db :playback assoc :playing? true :frame f)
|
||||
::play-from! [(fps db) n f]}))
|
||||
|
||||
|
|
@ -101,6 +111,22 @@
|
|||
(fn [{:keys [db]} [_ delta]]
|
||||
{:fx [[:dispatch [::seek (+ (get-in db [:playback :frame]) delta)]]]}))
|
||||
|
||||
(rf/reg-event-db
|
||||
::mark
|
||||
;; Resolve's I and O, on the open tab. A mark the other one has passed goes,
|
||||
;; rather than leaving a range that ends before it starts.
|
||||
(fn [db [_ which]]
|
||||
(let [f (get-in db [:playback :frame] 0)]
|
||||
(update-in db [:playback :range (get-in db [:ui :open])]
|
||||
(fn [{:keys [in out] :as marks}]
|
||||
(case which
|
||||
:in (cond-> (assoc marks :in f) (and out (< out f)) (dissoc :out))
|
||||
:out (cond-> (assoc marks :out f) (and in (< f in)) (dissoc :in))))))))
|
||||
|
||||
(rf/reg-event-db
|
||||
::clear-marks
|
||||
(fn [db _] (update-in db [:playback :range] dissoc (get-in db [:ui :open]))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
::set-rate
|
||||
(fn [{:keys [db]} [_ r]]
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
(rf/reg-sub ::rate (fn [db _] (get-in db [:playback :rate])))
|
||||
(rf/reg-sub ::loop? (fn [db _] (get-in db [:playback :loop?])))
|
||||
(rf/reg-sub ::muted? (fn [db _] (get-in db [:playback :muted?])))
|
||||
(rf/reg-sub ::range (fn [db _] (get-in db [:playback :range (get-in db [:ui :open])])))
|
||||
(rf/reg-sub ::fps (fn [db _] (get-in db [:clip :fps])))
|
||||
;; The open symbol can have a local stage size; otherwise it follows the project.
|
||||
(rf/reg-sub ::stage-size
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@
|
|||
:tracing (rf/subscribe [::render/tracing])
|
||||
:frame (rf/subscribe [::sub/frame])
|
||||
:playing? (rf/subscribe [::sub/playing?])
|
||||
:range (rf/subscribe [::sub/range])
|
||||
;; The pen's draft is drawn INTO the picture, filled, so what is on screen
|
||||
;; while placing points is the pixels a finished shape will be.
|
||||
:draft (rf/subscribe [::ui-sub/draft])
|
||||
|
|
@ -449,13 +450,19 @@
|
|||
(atom nil))
|
||||
|
||||
(defn- tick! []
|
||||
(let [{:keys [fps frames frame playing?]} @snapshot
|
||||
(let [{:keys [fps frames frame playing? range]} @snapshot
|
||||
live? (clock/playing?)
|
||||
ready? (some? (:canvas @state))
|
||||
;; DERIVED, never counted. A slow frame drops the frames it missed and
|
||||
;; the next one lands where the audio already is, so the failure mode is
|
||||
;; a visible stutter rather than an invisible slide out of sync.
|
||||
f (if live? (clock/frame fps frames) frame)]
|
||||
f (if live? (clock/frame fps frames) frame)
|
||||
;; PAST THE OUT MARK, BACK TO THE IN, as Blender's preview range loops.
|
||||
;; Here rather than in either clock, so both backends loop the same
|
||||
;; way, and before the paint, so the frame after the out is never shown.
|
||||
wrap? (and live? range (< (or (:out range) (dec frames)) f))
|
||||
f (if wrap? (or (:in range) 0) f)]
|
||||
(when wrap? (rf/dispatch [::pb/seek f]))
|
||||
;; A paused scrub is an explicit seek, not a playback sample. Clear the
|
||||
;; meter before the next play so its first frame cannot count the seek as
|
||||
;; dropped frames or leave a stale low rate in the transport.
|
||||
|
|
@ -481,8 +488,9 @@
|
|||
(when live? (rf/dispatch [::pb/tick f])))
|
||||
;; The audio ending is the authority on playback having stopped; nothing
|
||||
;; counts frames to notice it.
|
||||
;; With marks, running off the end goes round again from the in.
|
||||
(when (and (not live?) playing?)
|
||||
(rf/dispatch [::pb/pause]))))
|
||||
(rf/dispatch (if range [::pb/play] [::pb/pause])))))
|
||||
|
||||
(defn- frame-loop []
|
||||
;; Scheduled BEFORE the tick, so nothing the tick does can end the loop.
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@
|
|||
:run #(some-> (first (subseq (stops %) > (frame %))) seek)}
|
||||
{:label "First frame" :keys ["Home" "shift+ArrowLeft" "shift+a"] :run (constantly (seek 0))}
|
||||
{:label "Last frame" :keys ["End" "shift+ArrowRight" "shift+d"] :run #(seek (dec (pb/frames %)))}
|
||||
{:label "Mark in" :keys ["i"] :run (constantly [::pb/mark :in])
|
||||
:note "playback loops between the marks"}
|
||||
{:label "Mark out" :keys ["o"] :run (constantly [::pb/mark :out])}
|
||||
{:label "Clear the marks" :keys ["alt+x"] :run (constantly [::pb/clear-marks])}
|
||||
{:label "Onion skin" :keys ["alt+o"]
|
||||
:run #(let [on? (get-in % [:ui :onion (:clip/current %) (get-in % [:ui :open]) :on?])]
|
||||
[::layout/onion :on? (not on?)])}]]
|
||||
|
|
|
|||
|
|
@ -1318,6 +1318,18 @@
|
|||
[tag frames]
|
||||
[tag {:style {:left (at% @(rf/subscribe [::render/open-frame]) frames)}}])
|
||||
|
||||
(defn- outside-marks
|
||||
"The frames playback leaves out, shaded, and the span it plays, banded on the
|
||||
ruler. Its own component, deref'ing the marks itself, as `playhead` does."
|
||||
[frames ruler?]
|
||||
(when-let [{:keys [in out]} @(rf/subscribe [::playback/range])]
|
||||
(let [lo (or in 0) hi (inc (min (dec frames) (or out (dec frames))))]
|
||||
(if ruler?
|
||||
[:div.tl-range {:style {:left (edge% lo frames) :width (edge% (- hi lo) frames)}}]
|
||||
[:<>
|
||||
(when (pos? lo) [:div.tl-outside {:style {:left 0 :width (edge% lo frames)}}])
|
||||
(when (< hi frames) [:div.tl-outside {:style {:left (edge% hi frames) :right 0}}])]))))
|
||||
|
||||
(defn- key-marquee [marquee]
|
||||
(when-let [{:keys [x y x2 y2]} @marquee]
|
||||
(when (and x2 y2)
|
||||
|
|
@ -1594,6 +1606,7 @@
|
|||
(doall
|
||||
(for [f (range 0 frames step)]
|
||||
^{:key f} [:div.tick {:style {:left (edge% f frames)}} f]))
|
||||
[outside-marks frames true]
|
||||
[playhead :div.tl-knob frames]]
|
||||
(if (seq visible)
|
||||
(doall (for [row visible]
|
||||
|
|
@ -1606,6 +1619,7 @@
|
|||
:key-anchor key-anchor :key-state key-state :key-elements key-elements :choose-row! choose-row!}])
|
||||
{:key (str (:path row))})))
|
||||
[:div.tl-empty "nothing in this symbol"])
|
||||
[outside-marks frames false]
|
||||
[playhead :div.tl-playhead frames]
|
||||
[key-marquee marquee]]]
|
||||
[cursor-hint hint]])))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue