Compare commits
No commits in common. "2eb5944a78f6153a75488e9d5a3e31f884f9f181" and "0919bdcbb5d731a9aee719a0c9625bd5844be2a3" have entirely different histories.
2eb5944a78
...
0919bdcbb5
8 changed files with 59 additions and 178 deletions
|
|
@ -665,17 +665,16 @@
|
||||||
|
|
||||||
(declare finishing-polygon)
|
(declare finishing-polygon)
|
||||||
|
|
||||||
(defn with-tool
|
(rf/reg-event-db
|
||||||
"`db` on `tool`. Leaving the pen commits what it was drawing, as Esc does: an
|
::set-tool
|
||||||
unfinished polygon is not a thing the document can hold."
|
;; Leaving the pen commits what it was drawing, as Esc does: an unfinished
|
||||||
[db tool]
|
;; polygon is not a thing the document can hold.
|
||||||
(if (contains? tools tool)
|
(fn [db [_ tool]]
|
||||||
(-> (if (= tool (get-in db [:ui :tool])) db (finishing-polygon db))
|
(if (contains? tools tool)
|
||||||
(update :ui merge {:tool tool :draft []})
|
(-> (if (= tool (get-in db [:ui :tool])) db (finishing-polygon db))
|
||||||
(update :ui dissoc :hover))
|
(update :ui merge {:tool tool :draft []})
|
||||||
db))
|
(update :ui dissoc :hover))
|
||||||
|
db)))
|
||||||
(rf/reg-event-db ::set-tool (fn [db [_ tool]] (with-tool db tool)))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::cancel-polygon
|
::cancel-polygon
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
own clock, and a play goes out once with its frame rather than streamed."
|
own clock, and a play goes out once with its frame rather than streamed."
|
||||||
(:require [arthur.events.collab :as collab]
|
(:require [arthur.events.collab :as collab]
|
||||||
[arthur.events.playback :as pb]
|
[arthur.events.playback :as pb]
|
||||||
[arthur.events.ui :as ui]
|
|
||||||
[arthur.follow.page :as page]
|
[arthur.follow.page :as page]
|
||||||
[arthur.follow.party :as party]
|
[arthur.follow.party :as party]
|
||||||
[arthur.ui.menu :as menu]
|
[arthur.ui.menu :as menu]
|
||||||
|
|
@ -53,23 +52,14 @@
|
||||||
[:scroll "panel scroll" nil]
|
[:scroll "panel scroll" nil]
|
||||||
[:pointers "pointers" nil]])
|
[:pointers "pointers" nil]])
|
||||||
|
|
||||||
(defn- facet-paths [k] (some (fn [[fk _ ps]] (when (= fk k) ps)) facets))
|
|
||||||
|
|
||||||
(def ^:private takes
|
|
||||||
"Values taken the way the app takes them, not written over, because writing
|
|
||||||
would skip what it does on the way: a new tool commits the pen's unfinished
|
|
||||||
polygon, and a selection carries the multi-selection along with it."
|
|
||||||
{[:ui :tool] ui/with-tool
|
|
||||||
[:ui :selection] ui/selected})
|
|
||||||
|
|
||||||
;; ---------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------
|
||||||
;; what we keep
|
;; what we keep
|
||||||
;;
|
;;
|
||||||
;; `[:presence :party]` and `[:presence :joinable]` are what we tell the room;
|
;; `[:presence :party]` and `[:presence :joinable]` are what we tell the room;
|
||||||
;; `collab` says them again when the socket comes back, which is the rejoin.
|
;; `collab` says them again when the socket comes back, which is the rejoin.
|
||||||
;; `:follow` is ours alone: the facets let go of, a move we could not take yet
|
;; `:follow` is ours alone: the facets let go of, a move we could not take yet
|
||||||
;; (`:parked`), and `:last`, everything mates have said of where they are, to
|
;; (`:parked`), and the last move a mate made, to catch up to on taking a facet
|
||||||
;; catch up to on taking a facet back.
|
;; back.
|
||||||
|
|
||||||
(def ^:private stored {:joinable "arthur/followable" :off "arthur/follow-off"})
|
(def ^:private stored {:joinable "arthur/followable" :off "arthur/follow-off"})
|
||||||
|
|
||||||
|
|
@ -129,26 +119,19 @@
|
||||||
;; taken only on the tab it was made on.
|
;; taken only on the tab it was made on.
|
||||||
(fn [{:keys [db]} [_ cid v]]
|
(fn [{:keys [db]} [_ cid v]]
|
||||||
(let [open (get v [:ui :open])
|
(let [open (get v [:ui :open])
|
||||||
last (second (get-in db [:follow :last]))
|
|
||||||
place? (and (contains? v [:ui :open]) (not (contains? (off db) :place)))
|
place? (and (contains? v [:ui :open]) (not (contains? (off db) :place)))
|
||||||
taken (select-keys v (remove #{[:ui :open]} (paths db)))]
|
taken (select-keys v (remove #{[:ui :open]} (paths db)))]
|
||||||
(cond
|
(cond
|
||||||
(not (party/mirrors? (:peers db) (me db) cid)) {}
|
(not (party/mirrors? (:peers db) (me db) cid)) {}
|
||||||
(and place? (not (pb/openable? db open)))
|
(and place? (not (pb/openable? db open)))
|
||||||
{:db (update db :follow assoc :parked [cid v] :last [cid (merge last v)])}
|
{:db (update db :follow assoc :parked [cid v] :last [cid v])}
|
||||||
:else
|
:else
|
||||||
(let [switch? (and place? (not= open (get-in db [:ui :open])))
|
(let [switch? (and place? (not= open (get-in db [:ui :open])))
|
||||||
db (cond-> (update db :follow assoc :parked nil :last [cid (merge last v)])
|
db (cond-> (update db :follow assoc :parked nil :last [cid v])
|
||||||
switch? (pb/open open))
|
switch? (pb/open open))
|
||||||
;; In facet order, so `:selections` lands after the `:selection`
|
|
||||||
;; it belongs to.
|
|
||||||
db (cond-> db
|
db (cond-> db
|
||||||
(= (get v ::tab) (get-in db [:ui :open]))
|
(= (get v ::tab) (get-in db [:ui :open]))
|
||||||
(as-> db (reduce (fn [db p]
|
(as-> db (reduce-kv #(assoc-in %1 (at %1 %2) %3) db taken)))
|
||||||
(if (contains? taken p)
|
|
||||||
((takes p #(assoc-in %1 (at %1 p) %2)) db (taken p))
|
|
||||||
db))
|
|
||||||
db (paths db))))
|
|
||||||
n (pb/frames db)
|
n (pb/frames db)
|
||||||
f (-> (get-in db [:playback :frame] 0) (max 0) (min (dec n)))
|
f (-> (get-in db [:playback :frame] 0) (max 0) (min (dec n)))
|
||||||
db (assoc-in db [:playback :frame] f)]
|
db (assoc-in db [:playback :frame] f)]
|
||||||
|
|
@ -174,22 +157,19 @@
|
||||||
(rf/->interceptor
|
(rf/->interceptor
|
||||||
:id ::steer
|
:id ::steer
|
||||||
:after (fn [ctx]
|
:after (fn [ctx]
|
||||||
(let [after (get-in ctx [:effects :db])]
|
(let [event (first (get-in ctx [:coeffects :event]))
|
||||||
;; On your own, which is nearly always, an event costs this and
|
before (get-in ctx [:coeffects :db])
|
||||||
;; nothing more.
|
after (get-in ctx [:effects :db])
|
||||||
(if-not (and after (together? after))
|
[_ v :as parked] (get-in after [:follow :parked])]
|
||||||
ctx
|
(cond-> ctx
|
||||||
(let [event (first (get-in ctx [:coeffects :event]))
|
(and parked (pb/openable? after (get v [:ui :open])))
|
||||||
before (get-in ctx [:coeffects :db])
|
(update-in [:effects :fx] (fnil conj []) [:dispatch (into [::moved] parked)])
|
||||||
[_ v :as parked] (get-in after [:follow :parked])]
|
|
||||||
(cond-> ctx
|
|
||||||
(and parked (pb/openable? after (get v [:ui :open])))
|
|
||||||
(update-in [:effects :fx] (fnil conj []) [:dispatch (into [::moved] parked)])
|
|
||||||
|
|
||||||
(not (or (#{::pb/tick ::moved} event)
|
(not (or (nil? after) (#{::pb/tick ::moved} event)
|
||||||
(not= (get-in before [:project :id]) (get-in after [:project :id]))
|
(= (view before (paths after)) (view after))
|
||||||
(= (view before (paths after)) (view after))))
|
(not= (get-in before [:project :id]) (get-in after [:project :id]))
|
||||||
(update-in [:effects :fx] (fnil conj []) [::nav! (view-msg after)]))))))))
|
(not (together? after))))
|
||||||
|
(update-in [:effects :fx] (fnil conj []) [::nav! (view-msg after)]))))))
|
||||||
|
|
||||||
;; ---------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------
|
||||||
;; the room
|
;; the room
|
||||||
|
|
@ -263,18 +243,15 @@
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
::toggle
|
::toggle
|
||||||
;; Taking a facet back catches up on that facet — and only that one: the rest
|
;; Taking a facet back catches up to where the party last was.
|
||||||
;; of what they last said is as old as it is, and their frame, say, has moved
|
|
||||||
;; on since if they are playing.
|
|
||||||
(fn [{:keys [db]} [_ k]]
|
(fn [{:keys [db]} [_ k]]
|
||||||
(let [was (off db)
|
(let [was (off db)
|
||||||
now (if (contains? was k) (disj was k) (conj was k))
|
now (if (contains? was k) (disj was k) (conj was k))
|
||||||
db (assoc-in db [:follow :off] now)
|
db (assoc-in db [:follow :off] now)]
|
||||||
[cid v] (get-in db [:follow :last])]
|
|
||||||
(cond-> {:db db ::remember [:off (.join (to-array (map name now)) ",")]}
|
(cond-> {:db db ::remember [:off (.join (to-array (map name now)) ",")]}
|
||||||
(= :pointers k) (assoc ::forget :all)
|
(= :pointers k) (assoc ::forget :all)
|
||||||
(and (contains? was k) cid (facet-paths k))
|
(and (contains? was k) (get-in db [:follow :last]))
|
||||||
(assoc :dispatch [::moved cid (select-keys v (conj (facet-paths k) ::tab))])))))
|
(assoc :dispatch (into [::moved] (get-in db [:follow :last])))))))
|
||||||
|
|
||||||
(rf/reg-sub ::joinable? (fn [db _] (get-in db [:presence :joinable] true)))
|
(rf/reg-sub ::joinable? (fn [db _] (get-in db [:presence :joinable] true)))
|
||||||
(rf/reg-sub ::together? (fn [db _] (together? db)))
|
(rf/reg-sub ::together? (fn [db _] (together? db)))
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,6 @@
|
||||||
(defn- classes [^js el] (.getAttribute el "class"))
|
(defn- classes [^js el] (.getAttribute el "class"))
|
||||||
(defn- kind [^js el] [(.-localName el) (.. el -classList (item 0))])
|
(defn- kind [^js el] [(.-localName el) (.. el -classList (item 0))])
|
||||||
|
|
||||||
(defn- label
|
|
||||||
"What `el` is called, if anything says: an id, an aria-label, a field's name.
|
|
||||||
Written for people and screen readers, so it says WHICH thing it is — the
|
|
||||||
inspector, not the second `section.pane` — and it does not change when the
|
|
||||||
layout does."
|
|
||||||
[^js el]
|
|
||||||
(some (fn [a] (some->> (.getAttribute el a) not-empty (str a "="))) ["id" "aria-label" "name"]))
|
|
||||||
|
|
||||||
(defn- nth-like
|
(defn- nth-like
|
||||||
"Which of `el`'s siblings that `same?` says are like it, it is."
|
"Which of `el`'s siblings that `same?` says are like it, it is."
|
||||||
[^js el same?]
|
[^js el same?]
|
||||||
|
|
@ -42,22 +34,22 @@
|
||||||
(filter same? (array-seq (.. el -parentElement -children))))))
|
(filter same? (array-seq (.. el -parentElement -children))))))
|
||||||
|
|
||||||
(defn- step
|
(defn- step
|
||||||
"`el` as one step of a path, three ways from surest to least: by what it is
|
"`el` as one step of a path: its tag and classes, which of its siblings with
|
||||||
called, among its siblings called that; by its tag and classes; and by its tag
|
those it is, and which of those with its tag and FIRST class. The pool and the
|
||||||
and FIRST class, because the rest come and go with state — `on`, `selected` —
|
inspector are both a `section.pane`, so the first class alone takes one for
|
||||||
and a row lit on one page is still the same row on the other."
|
the other whenever a pane is shut on one page and not the other; but the rest
|
||||||
|
come and go with state — `on`, `selected` — and a row lit on one page is still
|
||||||
|
the same row on the other, so that is what a step falls back to."
|
||||||
[^js el]
|
[^js el]
|
||||||
(let [tag (.-localName el) cls (classes el) k (kind el) l (label el)]
|
(let [tag (.-localName el) cls (classes el) k (kind el)]
|
||||||
[tag cls
|
[tag cls
|
||||||
(nth-like el #(and (= tag (.-localName %)) (= cls (classes %))))
|
(nth-like el #(and (= tag (.-localName %)) (= cls (classes %))))
|
||||||
(nth-like el #(= k (kind %)))
|
(nth-like el #(= k (kind %)))]))
|
||||||
l (when l (nth-like el #(= l (label %))))]))
|
|
||||||
|
|
||||||
(defn- child [^js parent [tag cls n m l i]]
|
(defn- child [^js parent [tag cls n m]]
|
||||||
(let [kids (array-seq (.-children parent))
|
(let [kids (array-seq (.-children parent))
|
||||||
k [tag (not-empty (first (some-> cls (.split " "))))]]
|
k [tag (not-empty (first (some-> cls (.split " "))))]]
|
||||||
(or (when l (nth (filter #(= l (label %)) kids) i nil))
|
(or (nth (filter #(and (= tag (.-localName %)) (= cls (classes %))) kids) n nil)
|
||||||
(nth (filter #(and (= tag (.-localName %)) (= cls (classes %))) kids) n nil)
|
|
||||||
(nth (filter #(= k (kind %)) kids) m nil))))
|
(nth (filter #(= k (kind %)) kids) m nil))))
|
||||||
|
|
||||||
(defn- lineage
|
(defn- lineage
|
||||||
|
|
@ -102,7 +94,7 @@
|
||||||
;; drawing them
|
;; drawing them
|
||||||
|
|
||||||
(defonce ^:private shown (atom {})) ; cid → {:msg :found :clip :xy :el}
|
(defonce ^:private shown (atom {})) ; cid → {:msg :found :clip :xy :el}
|
||||||
(defonce ^:private ticking (atom nil)) ; [:frame id] or [:idle id]
|
(defonce ^:private raf (atom nil))
|
||||||
|
|
||||||
(defn- layer []
|
(defn- layer []
|
||||||
(or (.getElementById js/document "follow-layer")
|
(or (.getElementById js/document "follow-layer")
|
||||||
|
|
@ -149,36 +141,18 @@
|
||||||
cx (max l (min r x)) cy (max t (min b y))]
|
cx (max l (min r x)) cy (max t (min b y))]
|
||||||
{:xy [cx cy] :lost? (< d (count path)) :away? (not= [x y] [cx cy])}))
|
{:xy [cx cy] :lost? (< d (count path)) :away? (not= [x y] [cx cy])}))
|
||||||
|
|
||||||
(declare frame!)
|
|
||||||
|
|
||||||
(defn- tick!
|
|
||||||
"Draw again: next frame while a pointer is on its way, and four times a
|
|
||||||
second once they have all arrived — only to notice a layout that moved
|
|
||||||
under one, a pane opened or a list scrolled, which no message announces."
|
|
||||||
[moving?]
|
|
||||||
(reset! ticking (cond (empty? @shown) nil
|
|
||||||
moving? [:frame (js/requestAnimationFrame frame!)]
|
|
||||||
:else [:idle (js/setTimeout frame! 250)])))
|
|
||||||
|
|
||||||
(defn- frame! [_]
|
(defn- frame! [_]
|
||||||
(tick!
|
(doseq [[cid {:keys [found xy ^js el] :as s}] @shown]
|
||||||
(reduce
|
(let [s (cond-> s (not (.-isConnected ^js (peek found))) resolved)
|
||||||
(fn [moving? [cid {:keys [found xy ^js el] :as s}]]
|
{[tx ty] :xy :keys [lost? away?]} (target s)
|
||||||
(let [s (cond-> s (not (.-isConnected ^js (peek found))) resolved)
|
;; Halfway there each frame: messages come every 40ms, frames every
|
||||||
{[tx ty] :xy :keys [lost? away?]} (target s)
|
;; 16, and a pointer that jumps between them looks like it stutters.
|
||||||
;; Halfway there each frame: messages come every 40ms, frames every
|
[x y] (if xy [(+ (xy 0) (* 0.5 (- tx (xy 0)))) (+ (xy 1) (* 0.5 (- ty (xy 1))))] [tx ty])]
|
||||||
;; 16, and a pointer that jumps between them looks like it stutters.
|
(set! (.. el -style -transform) (str "translate(" x "px," y "px)"))
|
||||||
;; Within half a pixel, there.
|
(.toggle (.-classList el) "lost" lost?)
|
||||||
[x y] (if (and xy (< 0.5 (js/Math.hypot (- tx (xy 0)) (- ty (xy 1)))))
|
(.toggle (.-classList el) "away" away?)
|
||||||
[(+ (xy 0) (* 0.5 (- tx (xy 0)))) (+ (xy 1) (* 0.5 (- ty (xy 1))))]
|
(swap! shown assoc cid (assoc s :xy [x y]))))
|
||||||
[tx ty])]
|
(reset! raf (when (seq @shown) (js/requestAnimationFrame frame!))))
|
||||||
(when (not= xy [x y])
|
|
||||||
(set! (.. el -style -transform) (str "translate(" x "px," y "px)")))
|
|
||||||
(.toggle (.-classList el) "lost" lost?)
|
|
||||||
(.toggle (.-classList el) "away" away?)
|
|
||||||
(swap! shown assoc cid (assoc s :xy [x y]))
|
|
||||||
(or moving? (not= [x y] [tx ty]))))
|
|
||||||
false @shown)))
|
|
||||||
|
|
||||||
(defn gone! [cid]
|
(defn gone! [cid]
|
||||||
(some-> (get-in @shown [cid :el]) .remove)
|
(some-> (get-in @shown [cid :el]) .remove)
|
||||||
|
|
@ -200,10 +174,7 @@
|
||||||
#js [#js {:transform "scale(.3)" :opacity 1} #js {:transform "scale(1.6)" :opacity 0}]
|
#js [#js {:transform "scale(.3)" :opacity 1} #js {:transform "scale(1.6)" :opacity 0}]
|
||||||
450))
|
450))
|
||||||
(swap! shown assoc cid (-> (resolved m) (assoc :msg m :el el :xy (:xy was))))
|
(swap! shown assoc cid (-> (resolved m) (assoc :msg m :el el :xy (:xy was))))
|
||||||
(let [[how id] @ticking]
|
(when-not @raf (reset! raf (js/requestAnimationFrame frame!))))))
|
||||||
(when-not (= :frame how)
|
|
||||||
(some-> id js/clearTimeout)
|
|
||||||
(tick! true))))))
|
|
||||||
|
|
||||||
;; ---------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------
|
||||||
;; scroll
|
;; scroll
|
||||||
|
|
|
||||||
|
|
@ -937,7 +937,7 @@
|
||||||
;; the open symbol; the open symbol itself is at no path at all.
|
;; the open symbol; the open symbol itself is at no path at all.
|
||||||
path (if placed (or (nth selection 3 nil) [(second node)]) [])
|
path (if placed (or (nth selection 3 nil) [(second node)]) [])
|
||||||
a-face? (and face (face? clip face) (not layer?))]
|
a-face? (and face (face? clip face) (not layer?))]
|
||||||
[:section.pane.params {:aria-label "inspector"}
|
[:section.pane.params
|
||||||
[:div.pane-head "inspector"]
|
[:div.pane-head "inspector"]
|
||||||
[:div.inspect
|
[:div.inspect
|
||||||
(cond
|
(cond
|
||||||
|
|
|
||||||
|
|
@ -698,8 +698,7 @@
|
||||||
tallies (counts ctx)
|
tallies (counts ctx)
|
||||||
files? (fn [^js e] (some #{"Files"} (array-seq (.. e -dataTransfer -types))))]
|
files? (fn [^js e] (some #{"Files"} (array-seq (.. e -dataTransfer -types))))]
|
||||||
[:section.pane.pool
|
[:section.pane.pool
|
||||||
{:aria-label "media pool"
|
{:class (when (pos? @depth) "dropping")
|
||||||
:class (when (pos? @depth) "dropping")
|
|
||||||
;; Only a FILE lights the pane up: a row dragged out of the pool is on
|
;; Only a FILE lights the pane up: a row dragged out of the pool is on
|
||||||
;; its way somewhere else.
|
;; its way somewhere else.
|
||||||
:on-drag-enter (fn [^js e] (when (files? e) (.preventDefault e) (swap! depth inc)))
|
:on-drag-enter (fn [^js e] (when (files? e) (.preventDefault e) (swap! depth inc)))
|
||||||
|
|
|
||||||
|
|
@ -79,20 +79,6 @@
|
||||||
(+ at (/ (or (clip/frames clip (node/source n)) 0) rate))
|
(+ at (/ (or (clip/frames clip (node/source n)) 0) rate))
|
||||||
(clip/frames clip sid)))
|
(clip/frames clip sid)))
|
||||||
|
|
||||||
(defn- shows
|
|
||||||
"Where on the ruler `n` has something to show, as `[from to)`, given `->open`
|
|
||||||
from its own frames to the ruler's; nil where it places nothing or shows
|
|
||||||
something across all of its span.
|
|
||||||
|
|
||||||
A SPAN IS NOT CONTENT. Lengthening a placement past the end of the symbol it
|
|
||||||
plays leaves the bar longer and the picture empty — `node/placed-frame` runs
|
|
||||||
out — so the row has to say where the symbol does. A held or looping
|
|
||||||
placement always has a frame to show, so only a playing one answers."
|
|
||||||
[clip n ->open]
|
|
||||||
(when-let [t (and (node/source n) (node/source-time n))]
|
|
||||||
(mapv (comp ->open (time->parent t))
|
|
||||||
[0 (or (clip/frames clip (node/source n)) 0)])))
|
|
||||||
|
|
||||||
(defn- node-label
|
(defn- node-label
|
||||||
"What to call a node in the label column.
|
"What to call a node in the label column.
|
||||||
|
|
||||||
|
|
@ -208,7 +194,6 @@
|
||||||
:expandable? true
|
:expandable? true
|
||||||
:expanded? open?
|
:expanded? open?
|
||||||
:span cspan
|
:span cspan
|
||||||
:shows (shows clip child cself)
|
|
||||||
:key-items (key-items child sid cself)
|
:key-items (key-items child sid cself)
|
||||||
:keys (into [] (comp (mapcat keyed-frames)
|
:keys (into [] (comp (mapcat keyed-frames)
|
||||||
(map cself)
|
(map cself)
|
||||||
|
|
@ -257,7 +242,6 @@
|
||||||
(node-label clip (:id child) child))
|
(node-label clip (:id child) child))
|
||||||
:source (node/source child)
|
:source (node/source child)
|
||||||
:span (mapv ->open (node/placed-span child))
|
:span (mapv ->open (node/placed-span child))
|
||||||
:shows (shows clip child (comp ->open (local->parent child)))
|
|
||||||
:key-items (key-items child sid (comp ->open (local->parent child)))
|
:key-items (key-items child sid (comp ->open (local->parent child)))
|
||||||
:keys (into []
|
:keys (into []
|
||||||
(comp (mapcat keyed-frames)
|
(comp (mapcat keyed-frames)
|
||||||
|
|
@ -322,7 +306,6 @@
|
||||||
:expandable? true
|
:expandable? true
|
||||||
:expanded? open?
|
:expanded? open?
|
||||||
:span span
|
:span span
|
||||||
:shows (shows clip n self)
|
|
||||||
:key-items (key-items n sid self)
|
:key-items (key-items n sid self)
|
||||||
:keys (into [] (comp (mapcat keyed-frames)
|
:keys (into [] (comp (mapcat keyed-frames)
|
||||||
(map self)
|
(map self)
|
||||||
|
|
@ -345,7 +328,6 @@
|
||||||
(some-> (node/source child) name))
|
(some-> (node/source child) name))
|
||||||
:source (node/source child)
|
:source (node/source child)
|
||||||
:span (mapv source-self (node/placed-span child))
|
:span (mapv source-self (node/placed-span child))
|
||||||
:shows (shows clip child (comp source-self (local->parent child)))
|
|
||||||
;; The clip's own keys, on the
|
;; The clip's own keys, on the
|
||||||
;; block, so a collapsed lane
|
;; block, so a collapsed lane
|
||||||
;; still says where it changes.
|
;; still says where it changes.
|
||||||
|
|
@ -1064,24 +1046,12 @@
|
||||||
(reset! gesture nil) (when @preview (reset! preview nil)))
|
(reset! gesture nil) (when @preview (reset! preview nil)))
|
||||||
:on-pointer-cancel (fn [e] (.stopPropagation e) (reset! gesture nil) (reset! preview nil))}])))
|
:on-pointer-cancel (fn [e] (.stopPropagation e) (reset! gesture nil) (reset! preview nil))}])))
|
||||||
|
|
||||||
(defn- runout
|
|
||||||
"The stretches of a bar drawn from `in` to `out` where what it places has
|
|
||||||
nothing to show — see `shows` — as Flash draws empty frames: unfilled, inside
|
|
||||||
the outline of a clip that still lasts there."
|
|
||||||
[in out shows]
|
|
||||||
(when-let [[from to] shows]
|
|
||||||
(for [[a b] [[in (min out from)] [(max in to) out]]
|
|
||||||
:when (< a b)]
|
|
||||||
^{:key a}
|
|
||||||
[:span.tl-runout {:style {:left (str (* 100 (/ (- a in) (- out in))) "%")
|
|
||||||
:width (str (* 100 (/ (- b a) (- out in))) "%")}}])))
|
|
||||||
|
|
||||||
(defn- track-cell
|
(defn- track-cell
|
||||||
"`sliding` is the gesture in flight: `{:row :path :kind :from :df}`, where
|
"`sliding` is the gesture in flight: `{:row :path :kind :from :df}`, where
|
||||||
`:from` is the frame the press was on and `:df` how many frames the pointer has
|
`:from` is the frame the press was on and `:df` how many frames the pointer has
|
||||||
moved since. What it looks like mid-drag is `[:ui :sliding]`, which the clip
|
moved since. What it looks like mid-drag is `[:ui :sliding]`, which the clip
|
||||||
every row and the stage are drawn from already has in it."
|
every row and the stage are drawn from already has in it."
|
||||||
[{:keys [path span shows keys key-items gaps dense? kind node-kind select slides cels lane? of unmapped? owner]}
|
[{:keys [path span keys key-items gaps dense? kind node-kind select slides cels lane? of unmapped? owner]}
|
||||||
frames sliding hint {:keys [clip store open selection selections target-path key-selection key-preview key-anchor key-state key-elements choose-row!]}]
|
frames sliding hint {:keys [clip store open selection selections target-path key-selection key-preview key-anchor key-state key-elements choose-row!]}]
|
||||||
(let [selected-set (set selections)
|
(let [selected-set (set selections)
|
||||||
active-row (:row @sliding)
|
active-row (:row @sliding)
|
||||||
|
|
@ -1343,7 +1313,6 @@
|
||||||
:on-pointer-down
|
:on-pointer-down
|
||||||
(when (and select (not unmapped?))
|
(when (and select (not unmapped?))
|
||||||
#(begin! % (or slides path) :slide select nil nil))}
|
#(begin! % (or slides path) :slide select nil nil))}
|
||||||
(runout in out shows)
|
|
||||||
(when (and select (not unmapped?))
|
(when (and select (not unmapped?))
|
||||||
[:span.tl-edge.in {:title "Drag start"
|
[:span.tl-edge.in {:title "Drag start"
|
||||||
:on-pointer-down #(begin! % path :in select nil nil)}])
|
:on-pointer-down #(begin! % path :in select nil nil)}])
|
||||||
|
|
@ -1351,7 +1320,7 @@
|
||||||
[:span.tl-edge.out {:title "Drag endpoint · Shift-drag ripples later clips"
|
[:span.tl-edge.out {:title "Drag endpoint · Shift-drag ripples later clips"
|
||||||
:on-pointer-down #(begin! % path :out select nil nil)}])]))
|
:on-pointer-down #(begin! % path :out select nil nil)}])]))
|
||||||
(doall
|
(doall
|
||||||
(for [[i {:keys [id label source span shows select ghost?]}]
|
(for [[i {:keys [id label source span select ghost?]}]
|
||||||
(map-indexed vector
|
(map-indexed vector
|
||||||
(cond-> (vec cels)
|
(cond-> (vec cels)
|
||||||
(= select (:target-lane @sliding))
|
(= select (:target-lane @sliding))
|
||||||
|
|
@ -1408,7 +1377,6 @@
|
||||||
{:selection select :label label
|
{:selection select :label label
|
||||||
:in (js/Math.floor in)
|
:in (js/Math.floor in)
|
||||||
:duration (- out in)}))}
|
:duration (- out in)}))}
|
||||||
(runout in out shows)
|
|
||||||
[:span.tl-cel-label label]
|
[:span.tl-cel-label label]
|
||||||
(when select
|
(when select
|
||||||
(if joined?
|
(if joined?
|
||||||
|
|
@ -1699,8 +1667,7 @@
|
||||||
(when (not= [clip-id open] @key-context)
|
(when (not= [clip-id open] @key-context)
|
||||||
(reset! key-context [clip-id open]) (reset! key-selection []) (reset! key-preview nil) (reset! key-anchor nil) (reset! row-anchor nil))
|
(reset! key-context [clip-id open]) (reset! key-selection []) (reset! key-preview nil) (reset! key-anchor nil) (reset! row-anchor nil))
|
||||||
[:section.pane.time
|
[:section.pane.time
|
||||||
{:aria-label "timeline"
|
{:tab-index -1
|
||||||
:tab-index -1
|
|
||||||
:on-key-down (fn [e]
|
:on-key-down (fn [e]
|
||||||
(when (and (= (.-target e) (.-currentTarget e))
|
(when (and (= (.-target e) (.-currentTarget e))
|
||||||
(#{"Delete" "Backspace"} (.-key e)))
|
(#{"Delete" "Backspace"} (.-key e)))
|
||||||
|
|
|
||||||
|
|
@ -225,28 +225,6 @@
|
||||||
(is (= [[2 3]] (mapv :span (:cels lane)))
|
(is (= [[2 3]] (mapv :span (:cels lane)))
|
||||||
"a lane placed at twice the speed draws its frames 4–6 on ruler frames 2–3")))
|
"a lane placed at twice the speed draws its frames 4–6 on ruler frames 2–3")))
|
||||||
|
|
||||||
(deftest a-bar-says-where-what-it-plays-runs-out
|
|
||||||
(let [placed {:id :short :kind :instance :z "a" :span [0 10]
|
|
||||||
:time {:at 6 :rate 1}
|
|
||||||
:source {:symbol :short}
|
|
||||||
:playback {:in 0 :speed 1 :end :stop}}
|
|
||||||
doc (-> (clip/blank)
|
|
||||||
(assoc-in [:symbols :main :frames] 24)
|
|
||||||
(assoc-in [:symbols :main :nodes] {:short placed})
|
|
||||||
(assoc-in [:symbols :short] {:id :short :frames 4 :nodes {}}))
|
|
||||||
row #(first (timeline/rows % :main #{}))]
|
|
||||||
(is (= [6 16] (:span (row doc))))
|
|
||||||
(is (= [6 10] (:shows (row doc)))
|
|
||||||
"four frames of symbol, stretched to ten, show from 6 to 10 only")
|
|
||||||
(is (nil? (:shows (row (assoc-in doc [:symbols :main :nodes :short :playback :speed] 0))))
|
|
||||||
"a held placement shows its frame across the whole span")
|
|
||||||
(let [lane (-> (assoc-in doc [:symbols :main :display] :lane)
|
|
||||||
(assoc-in [:symbols :main :nodes :short :playback :speed] 2)
|
|
||||||
(timeline/rows :main #{})
|
|
||||||
first)]
|
|
||||||
(is (= [[6 8]] (mapv :shows (:cels lane)))
|
|
||||||
"a clip in a lane says it too, at its own speed"))))
|
|
||||||
|
|
||||||
(deftest an-ordinary-symbol-keeps-a-row-per-node
|
(deftest an-ordinary-symbol-keeps-a-row-per-node
|
||||||
(let [doc (update-in (fixture/document) [:symbols :main] dissoc :display)
|
(let [doc (update-in (fixture/document) [:symbols :main] dissoc :display)
|
||||||
rows (timeline/rows doc :main #{})]
|
rows (timeline/rows doc :main #{})]
|
||||||
|
|
|
||||||
|
|
@ -1372,16 +1372,6 @@ button.followable svg { width: 12px; height: 12px; display: block; }
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
/* Frames of a clip past the end of what it plays: still the clip's — the outline
|
|
||||||
and the handles go on — but empty, as Flash leaves an empty frame unfilled. */
|
|
||||||
.tl-runout {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
background: repeating-linear-gradient(135deg, var(--pane) 0 3px, var(--sunk) 3px 6px);
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
.tl-cel-label { position: relative; }
|
|
||||||
.tl-span.ghost {
|
.tl-span.ghost {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: 1px dashed var(--sel);
|
border: 1px dashed var(--sel);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue