From 4b780f9e91de17084fad5f065564bfb97531b465 Mon Sep 17 00:00:00 2001 From: Olive Vaughn Date: Sat, 10 Oct 2026 18:28:03 -0400 Subject: [PATCH] Inspector: one row per channel, names from symbols, tweens you can see MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The inspector shows what can be changed and nothing else. Ids, spans and the facts the fields below them already said are gone; explanations are hover text. Performance only appears for a face. Every animatable thing is one row: ◀ ◆ ▶, its name, its value, its gap. The arrows jump to the key before and after on every channel. A drawing's keys are an ordinary `shape` row, as are a palette placement's and a tracing layer's holds. The gap switch is about the gap the playhead is in, and on a key the one arriving at it, so keying B asks about A→B. The timeline draws every gap on a channel row, tween or hold, and a click switches it. An instance has no name of its own: it is called what it places, a rename renames the symbol, and `(n)` says how many places show it. Export numbers two placements of one symbol. Instance names in old documents are ignored. Co-Authored-By: Claude Opus 5.5 --- frontend/src/arthur/domain/clip.cljs | 36 +- frontend/src/arthur/domain/node.cljs | 14 +- frontend/src/arthur/events/export.cljs | 16 +- frontend/src/arthur/events/ui.cljs | 11 +- frontend/src/arthur/ui/icon.cljs | 12 +- frontend/src/arthur/ui/location.cljs | 16 +- frontend/src/arthur/ui/params.cljs | 788 +++++++++--------- frontend/src/arthur/ui/settings.cljs | 6 +- frontend/src/arthur/ui/timeline.cljs | 45 +- .../test/arthur/domain/instance_test.cljs | 7 +- frontend/test/arthur/events/export_test.cljs | 10 +- frontend/test/browser/take.mjs | 34 +- static/arthur/app.css | 84 +- 13 files changed, 569 insertions(+), 510 deletions(-) diff --git a/frontend/src/arthur/domain/clip.cljs b/frontend/src/arthur/domain/clip.cljs index 244938c..595bf97 100644 --- a/frontend/src/arthur/domain/clip.cljs +++ b/frontend/src/arthur/domain/clip.cljs @@ -74,28 +74,28 @@ (defn node-label "What to call node `n` on screen. - A NAME A PERSON TYPED WINS, and for an instance that is the ONLY thing `:name` - now means: `place-symbol` deliberately does not copy the symbol's name onto the - node it makes. Two instances of one symbol are told apart by what somebody - called them — `8625 left` and `8625 right` of one `face` — and reading through - in front of that would collapse them to the same word. + AN INSTANCE IS CALLED WHAT IT PLACES, read through on every render, and has + no name of its own. A name on the placement meant the same drawing could show + under two names, and that a rename in one place reached nowhere else; renaming + an instance renames its symbol (`::ui/rename-node`), so every placement of it + follows. How many places share it is `uses`. - OTHERWISE AN INSTANCE IS LABELLED BY WHAT IT PLACES, read through on every - render. A name copied at creation goes stale the moment the symbol is renamed, - and then the document shows one thing under two names: the symbol reads `bg` in - its tab while an instance of it still reads `symbol-18`, which is how a person - comes to paste a symbol into itself without being able to see that is what they - are doing. `problems` refuses that cycle; this is why it stops looking like a - reasonable thing to try. - - An id is a uuid for a placement and a keyword for an authored node, and neither - reads as a name, so the last resort is a legible stand-in rather than `(str - id)` — `:face-1` keeps its colon and a uuid pushes a column open." + Anything else is called by its own `:name`. An id is a uuid for a placement + and a keyword for an authored node, and neither reads as a name, so the last + resort is a legible stand-in — `:face-1` loses its colon and a uuid is cut." [clip id n] - (or (:name n) - (some->> (node/source n) (symbol-name clip)) + (or (some->> (node/source n) (symbol-name clip)) + (:name n) (if (keyword? id) (subs (str id) 1) (subs (str id) 0 8)))) +(defn uses + "How many nodes in the document place symbol `sid`." + [clip sid] + (count (for [[_ sym] (:symbols clip) + [_ n] (:nodes sym) + :when (= sid (node/source n))] + n))) + (defn frames "A symbol's length. Read off the symbol, never copied beside it." [clip sid] diff --git a/frontend/src/arthur/domain/node.cljs b/frontend/src/arthur/domain/node.cljs index dc118b6..0d65546 100644 --- a/frontend/src/arthur/domain/node.cljs +++ b/frontend/src/arthur/domain/node.cljs @@ -15,7 +15,8 @@ interpolating matrix entries is meaningless: a rotation tweened through its matrix shears on the way. Flat Float64Array for evaluation because at 30fps per-frame allocation is the only thing that will make this stutter." - (:require [arthur.domain.channel :as ch])) + (:require [arthur.domain.channel :as ch] + [clojure.string :as str])) (def kinds "`:bitmap` is in the vocabulary and not implemented; it is @@ -108,6 +109,17 @@ [:audio :pan] (ch/framed 0.0) [:audio :rate] (ch/framed 1.0)}) +(def ^:private channel-names + {[:xform :pos] "pos" [:xform :rot] "rot°" [:xform :scale] "scale" + [:xform :skew] "skew" [:xform :pivot] "pivot" [:geom :pts] "shape" + [:style :color] "color" [:vis] "vis" [:palette] "palette"}) + +(defn channel-name + "What to call channel `path` on screen: the same short word in the inspector + and the timeline." + [path] + (or (channel-names path) (str/join " " (map name path)))) + (defn defaults-of [n] (if (= :audio (:kind n)) audio-defaults defaults)) diff --git a/frontend/src/arthur/events/export.cljs b/frontend/src/arthur/events/export.cljs index 045a742..d0c5b5b 100644 --- a/frontend/src/arthur/events/export.cljs +++ b/frontend/src/arthur/events/export.cljs @@ -78,18 +78,22 @@ the other instances removed, which is why seven instances of one symbol are seven different exports rather than seven copies of one. - Instances are ordered and labelled by `clip/node-label`, never by id: a uuid - sorts at random and means nothing to read." + Instances are labelled by `clip/node-label` — the symbol they place — and + numbered in stacking order where one symbol is placed more than once, never + by id: a uuid sorts at random and means nothing to read." [clip open] (let [label #(clip/node-label clip %1 %2) instances (->> (get-in clip [:symbols open :nodes]) (filter (comp #{:instance} :kind val)) - (sort-by (fn [[id n]] [(label id n) (str id)])))] + (sort-by (fn [[id n]] [(label id n) (or (:z n) "") (str id)]))) + numbered (mapcat (fn [same] + (if (< 1 (count same)) + (map-indexed (fn [i [id n]] [id (str (label id n) " " (inc i))]) same) + (map (fn [[id n]] [id (label id n)]) same))) + (partition-by (fn [[id n]] (label id n)) instances))] (into (mapv (fn [sid] {:symbol sid :label (name sid)}) (sort-by str (keys (:symbols clip)))) - (mapv (fn [[id n]] - {:symbol open :isolate id :label (label id n)}) - instances)))) + (mapv (fn [[id l]] {:symbol open :isolate id :label l}) numbered)))) (defn target "What the export is pointed at. A nil symbol is whichever one is open, so a diff --git a/frontend/src/arthur/events/ui.cljs b/frontend/src/arthur/events/ui.cljs index 7f2670f..97a33ff 100644 --- a/frontend/src/arthur/events/ui.cljs +++ b/frontend/src/arthur/events/ui.cljs @@ -45,14 +45,19 @@ (rf/reg-event-db ::rename-node + ;; An instance has no name of its own — see `clip/node-label` — so renaming one + ;; renames the symbol it places, everywhere it is placed. Blank removes the + ;; name, which falls back to the id. (fn [db [_ sid id value]] (let [document (:clip (store/entry (:clip/current db))) + n (get-in document [:symbols sid :nodes id]) + path (if-let [of (node/source n)] [:symbols of] [:symbols sid :nodes id]) value (not-empty (str/trim (str value)))] - (if-not (get-in document [:symbols sid :nodes id]) + (if (or (nil? n) (nil? (get-in document path))) db (edit/transaction db #(if value - (assoc-in % [:symbols sid :nodes id :name] value) - (update-in % [:symbols sid :nodes id] dissoc :name))))))) + (assoc-in % (conj path :name) value) + (update-in % path dissoc :name))))))) (defn selected "`db` with `selection` as its primary active row. diff --git a/frontend/src/arthur/ui/icon.cljs b/frontend/src/arthur/ui/icon.cljs index bc7cb6b..7c986b4 100644 --- a/frontend/src/arthur/ui/icon.cljs +++ b/frontend/src/arthur/ui/icon.cljs @@ -50,7 +50,17 @@ ;; row out of a dozen says at a glance that its blocks follow one another in ;; time instead of being on screen together. Whole and half coordinates, so ;; the three dividers land on pixels at 11px. - :lane {:stroke ["M1.5 3.5h9v5h-9z" "M4.5 3.5v5" "M7.5 3.5v5"]}}) + :lane {:stroke ["M1.5 3.5h9v5h-9z" "M4.5 3.5v5" "M7.5 3.5v5"]} + ;; To the key before and after: the transport's step, without its bar. + :prev {:fill ["M8.5 3v6L4 6z"]} + :next {:fill ["M3.5 3v6L8 6z"]} + ;; The gap between two keys as a value graph draws it: a ramp from one to + ;; the other, or a step that holds and then jumps. + :tween {:fill ["M1.5 8h2v2h-2z" "M8.5 2h2v2h-2z"] :stroke ["M3 8.5 9 3.5"]} + :hold {:fill ["M1.5 8h2v2h-2z" "M8.5 2h2v2h-2z"] :stroke ["M3.5 9H9.5V4"]} + ;; How an instance plays: through once into a stop, round, or one frame. + :once {:fill ["M2.4 2.6 7.6 6 2.4 9.4z" "M8.4 2.6h1.4v6.8H8.4z"]} + :still {:stroke ["M3.5 2.5h5v7h-5z"] :fill ["M5 4.5h2v3H5z"]}}) (defn view "The glyph named `k`, sized by CSS and inked in `currentColor` — so a button's diff --git a/frontend/src/arthur/ui/location.cljs b/frontend/src/arthur/ui/location.cljs index 2af94c1..fd6595f 100644 --- a/frontend/src/arthur/ui/location.cljs +++ b/frontend/src/arthur/ui/location.cljs @@ -111,20 +111,6 @@ (when (and (nil? t) (not held?)) " · repeats; no single frame above")) :else nil))) -(defn- shared-with - "How many places in the document use the same drawing as `n`, or nil where it - places none. Counted rather than flagged, because \"used in 4 places\" is the - fact somebody needs before deciding to decouple one — and counted over every - node that places it, not only over cels, because a drawing reused as a plain - instance somewhere else is just as shared and `make unique` is just as much - the answer." - [clip n] - (when-let [of (and n (node/source n))] - (count (for [[_ sym] (:symbols clip) - [_ other] (:nodes sym) - :when (= of (node/source other))] - other)))) - (defn view [] (let [clip @(rf/subscribe [::render/clip]) open @(rf/subscribe [::render/open]) @@ -134,7 +120,7 @@ n (when (= :node kind) (get-in clip [:symbols sid :nodes id])) crumbs (trail clip open (if (and n (seq path)) path (when n [id]))) last-i (dec (count crumbs)) - shared (shared-with clip n) + shared (some->> n node/source (clip/uses clip)) says (whereabouts clip n inside)] [:section.loc [:nav.crumbs {:aria-label "editing location"} diff --git a/frontend/src/arthur/ui/params.cljs b/frontend/src/arthur/ui/params.cljs index ad1a0d6..b8ec41a 100644 --- a/frontend/src/arthur/ui/params.cljs +++ b/frontend/src/arthur/ui/params.cljs @@ -1,10 +1,12 @@ (ns arthur.ui.params "The right pane: what the selection is, and what can be changed about it. - Sections rather than a mode switch. The clip's facts are always true, so the - clip section is always there; node, footage, face and tracking sections follow - the thing actually selected. Nothing here computes — every control dispatches - an intent and every readout comes off a subscription." + ONLY WHAT CAN BE CHANGED. An id, a span, a count of nodes are either in the + timeline already or of no use to somebody drawing, so the pane shows controls + and nothing else, densely: a header naming the selection, then one row per + thing that can be keyed, then whatever else the selection has. Nothing here + computes — every control dispatches an intent and every readout comes off a + subscription." (:require [clojure.string :as str] [arthur.domain.clip :as clip-domain] [arthur.domain.channel :as channel] @@ -17,32 +19,24 @@ [arthur.domain.pose :as pose] [arthur.domain.symbol :as symbol] [arthur.events.history :as history] - [arthur.events.paint :as paint-events] [arthur.events.playback :as pb] [arthur.events.project :as project] [arthur.events.ui :as ui] [arthur.subs.playback :as playback] [arthur.subs.render :as render] [arthur.subs.ui :as sub] + [arthur.ui.icon :as icon] [arthur.ui.palette :as palette] [arthur.ui.settings :as settings] [re-frame.core :as rf] [reagent.core :as r])) (defn- brief - "A value that fits the column. The `facts` list puts the whole thing in a - `title`, so nothing is lost — but a node id is a uuid and a `:z` is a - timestamp joined to one, and either wrapped over three lines pushes every - parameter below it off the pane." + "A value that fits the column, for the few places an id is still the only name." [v] (let [s (str v)] (if (> (count s) 22) (str (subs s 0 20) "…") s))) -(defn- facts [& pairs] - (into [:dl.facts] - (mapcat (fn [[k v]] (when v [[:dt k] [:dd {:title (str v)} v]]))) - (partition 2 pairs))) - (defn- section [title & body] (into [:section.section [:h2 title]] body)) @@ -70,316 +64,349 @@ (when @draft (reset! draft s)) (when-not (js/isNaN n) (on-number n))))})]))) -(defn- number-field [label value on-change & [placeholder disabled?]] - [:label.inspector-field label - [number-input {:min 1 :step 1 :value value - :placeholder placeholder - :disabled disabled? - :parse #(if (seq %) (js/parseInt % 10) nil) - :on-number on-change}]]) +(defn- count-input + "A whole number of at least 1, blank meaning \"none of its own\"." + [value on-change & [{:keys [placeholder disabled label]}]] + [number-input {:min 1 :step 1 :value value :placeholder placeholder + :disabled disabled :aria-label label :title label + :parse #(if (seq %) (js/parseInt % 10) nil) + :on-number on-change}]) -(defn- name-field [label value commit!] - [:label.inspector-field label - [:input {:type "text" :default-value value - :key value - :on-key-down #(when (= "Enter" (.-key %)) (.. % -target blur)) - :on-blur #(commit! (.. % -target -value))}]]) +(defn- text-input [value commit! & [attrs]] + [:input (merge {:type "text" :default-value value + :key value + :on-key-down #(when (= "Enter" (.-key %)) (.. % -target blur)) + :on-blur #(commit! (.. % -target -value))} + attrs)]) + +(defn- prop + "One labelled row of a form: the label in the narrow column, controls after." + [label & controls] + (into [:div.prop [:span.prop-name label]] controls)) + +(defn- palette-select [value on-change & [disabled?]] + (let [clip @(rf/subscribe [::render/clip])] + [:select {:value (str (or value "")) :disabled disabled? + :on-change (fn [e] + (let [v (.. e -target -value)] + (on-change (first (filter #(= v (str %)) (keys (pal/palettes clip)))))))} + [:option {:value ""} "inherit"] + (for [[id p] (sort-by (comp str :name val) (pal/palettes clip))] + ^{:key (str id)} [:option {:value (str id)} (:name p)])])) ;; --------------------------------------------------------------------------- -;; the clip +;; the header -(defn- clip-section [] - (let [clip @(rf/subscribe [::render/clip]) - open @(rf/subscribe [::render/open]) - frames @(rf/subscribe [::render/frames]) - project @(rf/subscribe [::playback/project]) - busy? (:busy? project)] - [section "project" - [facts - "stage" (str (:width clip) "×" (:height clip)) - "open" (some-> open name) - "length" (str frames " frames")] - [:div.inspector-form - [name-field "name" (or (:name project) (:name clip) "") - #(rf/dispatch [::project/rename %])] - [number-field "width" (:width clip) - #(rf/dispatch [::project/project-setting :width %]) nil busy?] - [number-field "height" (:height clip) - #(rf/dispatch [::project/project-setting :height %]) nil busy?] - [settings/rate busy?]]])) +(defn- header + "What is selected, as its name — the one field that says which thing this is. + An instance is called what it places, so its name IS its symbol's and a rename + here reaches every placement; `(n)` says how many that is." + [kind value placeholder commit! uses] + [:div.inspect-head + [:span.inspect-kind kind] + [text-input value commit! {:class "inspect-name" :placeholder placeholder + :aria-label "name"}] + (when (and uses (< 1 uses)) + [:span.uses {:title (str "placed " uses " times · a rename reaches every one")} + (str "(" uses ")")])]) ;; --------------------------------------------------------------------------- -;; a node +;; one row per channel +;; +;; ◀ ◆ ▶, the name, the value, and the gap: the same row for a transform, a +;; colour, a drawing and a palette, as After Effects puts its key navigator by +;; every property. ◆ keys the channel here or takes the key here off; an edit +;; writes a key on a keyed channel or the one value on one that is not. ◀ ▶ go to +;; the key before and after. The gap switch is the same choice as clicking the +;; gap in the timeline. -(defn- channel-state - "One line saying how this channel is animated, which is the only thing about it - this pane can say without an editor for its values." - [ch] - (cond - (:dense ch) (str "dense · " (get-in ch [:dense :frames]) " frames") - (:keys ch) (str (count (:keys ch)) " keys · " (name (or (:interp ch) :hold))) - :else (let [v (:value ch)] - (str "framed · " (if (channel/nothing? v) "absent" (pr-str v)))))) +(def ^:private order + (zipmap [[:xform :pos] [:xform :rot] [:xform :scale] [:xform :skew] [:xform :pivot] + paint/geometry [:style :color] [:vis]] + (range))) -(defn- segment-select - "Hold or tween, for the gap after the key at `left` — the same choice on a - drawing as on a transform." - [sid id path ch left] - [:select.interp {:value (name (or (channel/segment-interp ch left) :hold)) - :on-change #(rf/dispatch [::project/set-segment-interp - sid id path left (keyword (.. % -target -value))])} - [:option {:value "hold"} "hold"] - [:option {:value "linear"} "tween"]]) +(defn- gap-at + "The key whose gap the switch is about, given the keys `ks` and frame `f`: the + gap the playhead is inside, and standing on a key, the gap ARRIVING at it — + keying B after A is asking about A→B. On the first key, the gap leaving it." + [ks f] + (when f + (let [left (or (last (filter #(< % f) ks)) (when (= f (first ks)) f))] + (when (and left (some #(< left %) ks)) left)))) -(defn- drawing-keys - "The polygon controls: jump to a drawing key, add one here, and choose what the - gap after the current one does. Lifted out of the old stage toolbar unchanged — - a drawing key is a parameter of the shape, and this is where the shape's - parameters are. +(defn- seek-own! + "Put the playhead on own frame `f` of something whose clock is `time`." + [time f] + (rf/dispatch [::pb/seek (js/Math.round (+ (:at time) (/ f (:rate time))))])) - Keys are in the shape's OWN frames — the symbol's it lives in, through every - instance above it — and `time` maps the open symbol's frames to them. `frame` - is nil when the shape is not on screen, where there is no here to key." - [sid id n {:keys [frame time]}] - (let [geom (get-in n [:channels paint/geometry]) - active (when geom (paint/active-frame geom frame)) - ks (when geom (sort (keys (:keys geom)))) - next-k (first (filter #(> % active) ks)) - [start end] (:span n)] - [:<> - [:div.row {:style {:margin "5px 0"}} - [:button {:disabled (or (nil? frame) (< frame start) (>= frame end) - (contains? (:keys geom) frame)) - :on-click #(rf/dispatch [::paint-events/add-key sid id frame])} - "drawing key here"]] - (when (seq ks) - [:div.row - [:span.dim "keys"] - (doall - (for [f ks] - ^{:key f} - [:button {:class (when (= frame f) "on") - :disabled (nil? time) - :on-click #(rf/dispatch [::pb/seek (js/Math.round - (+ (:at time) (/ f (:rate time))))])} - (str f)]))]) - (when next-k - [:div.row {:style {:margin-top "5px"}} - [:label.dim (str "key " active " → " next-k " ") - [segment-select sid id paint/geometry geom active]]])])) +(defn- key-nav + "◀ ◆ ▶ over keys `ks`: `frame` is the one being edited, nil off screen, and + `own` is `{:time :frame}`, the clock the jumps go through." + [ks frame {:keys [time] here :frame} on-key title] + (let [ks (sort ks) + here (or frame here) + before (when here (last (filter #(< % here) ks))) + after (when here (first (filter #(> % here) ks)))] + [:span.key-nav + [:button.nav {:disabled (or (nil? before) (nil? time)) + :title (if before (str "key at " before) "no key before") + :aria-label "previous key" + :on-click #(seek-own! time before)} + [icon/view :prev]] + [:button.key {:class (cond (some #{frame} ks) "on" (seq ks) "keyed") + :disabled (nil? frame) + :title title + :on-click on-key} + "◆"] + [:button.nav {:disabled (or (nil? after) (nil? time)) + :title (if after (str "key at " after) "no key after") + :aria-label "next key" + :on-click #(seek-own! time after)} + [icon/view :next]]])) -;; The transform and visibility, which every node has, as one row each: ◆ keys -;; the channel here or takes the key here off, and an edit writes a key on a -;; keyed channel or the one value on one that is not. `frame` is the node's own, -;; nil when it is not on screen, where a keyed channel has no here to write to. -;; Rotation is shown in degrees. Between two keys, the gap after the one here -;; holds or tweens, as a drawing's does. +(defn- gap-switch [ch path frame set-gap!] + (let [ks (sort (keys (:keys ch))) + left (when-not (node/hold-only? path (channel/value-at ch (or frame 0) nil)) + (gap-at ks frame)) + tween? (and left (= :linear (channel/segment-interp ch left)))] + (if left + [:button.gap {:class (when tween? "on") + :title (str (if tween? "tween" "hold") " from key " left + " · click to " (if tween? "hold" "tween")) + :aria-label (if tween? "tween" "hold") + :on-click #(set-gap! left (if tween? :hold :linear))} + [icon/view (if tween? :tween :hold)]] + [:span.gap]))) -(defn- channel-control [sid id path ch frame auto-key? node-path] +(defn- channel-row + "Channel `path`, `ch`, of whatever the row is about. `frame` is its own frame + being edited, nil where it is not on screen and a keyed channel has no here to + write to; `own` is its clock. `on-key` and `set-gap!` are the writes, `value` + the editor." + [{:keys [path ch frame own live? on-key set-gap!]} value] + (let [ks (keys (:keys ch))] + [:div.chan {:class (when live? "live") :data-channel (str/join " " (map name path))} + [key-nav ks frame own on-key + (if (seq ks) (str (count ks) " keys · key or unkey here") "key this here")] + [:span.chan-name (node/channel-name path)] + [:span.chan-value value] + [gap-switch ch path frame set-gap!]])) + +(defn- number-fields + "The value of a number or a vector of them, as boxes. Rotation is shown in + degrees." + [path v off? put] + (let [deg? (= path [:xform :rot]) + field (fn [i x on-number] + ^{:key i} + [number-input {:step "any" :disabled off? + :value (if deg? (/ (js/Math.round (* x (/ 18000 js/Math.PI))) 100) x) + :parse js/parseFloat + :on-number #(on-number (if deg? (* % (/ js/Math.PI 180)) %))}])] + (if (number? v) + (field 0 v put) + (doall (map-indexed (fn [i x] (field i x #(put (assoc (vec v) i %)))) v))))) + +(defn- swatches [value off? palette pick!] + [:span.chan-swatches + (doall + (for [[i {:keys [name hex]}] (map-indexed vector (:slots palette))] + ^{:key i} + [:button.swatch + {:class (when (= i value) "on") + :style {:background hex} + :disabled off? + :aria-label (str "color " i (when name (str " " (clojure.core/name name)))) + :aria-pressed (= i value) + :title (str i (when name (str " · " (clojure.core/name name))) " · " hex) + :on-click #(pick! i)}]))]) + +(defn- channel-value + "The editor for channel `path` of node `n`: boxes, a switch, swatches — or, + where there is nothing to type, what it is." + [sid id n path ch frame palette node-path] (let [keyed? (some? (:keys ch)) - ;; No store: the call site below hands this only channels that are not - ;; `:dense`, which are the only ones with anything in tier 2 to read. - v (channel/value-at ch (or frame 0) nil) off? (and keyed? (nil? frame)) - deg? (= path [:xform :rot]) - ;; A boolean has nothing between true and false to tween through. - left (when (and keyed? frame (not (boolean? v))) (paint/active-frame ch frame)) - gap? (and left (some #(< left %) (keys (:keys ch)))) - put #(rf/dispatch [::project/set-channel sid id path frame %]) - field (fn [i x on-number] - ^{:key i} - [number-input {:step "any" :disabled off? - :value (if deg? (/ (js/Math.round (* x (/ 18000 js/Math.PI))) 100) x) - :parse js/parseFloat - :on-number #(on-number (if deg? (* % (/ js/Math.PI 180)) %))}])] - [:dd.channel {:class (when auto-key? "live")} - [:button.key {:class (cond (contains? (:keys ch) frame) "on" keyed? "keyed") - :disabled (nil? frame) - :title (if keyed? (str (count (:keys ch)) " keys") "key this here") - :on-click #(rf/dispatch [::project/toggle-key sid id path frame])} - "◆"] - (cond - (boolean? v) [:input {:type "checkbox" :checked v :disabled off? - :on-change #(put (.. % -target -checked))}] - (number? v) (field 0 v put) - :else (doall (map-indexed (fn [i x] (field i x #(put (assoc (vec v) i %)))) - v))) - ;; THE WAY BACK TO THE MIDDLE, on the pivot row and nowhere else. A pivot is - ;; a choice and does not follow the drawing, which is what keeps a keyed spin - ;; from being re-aimed by somebody drawing one more shape inside the symbol — - ;; so "put it back in the middle of what is there now" has to be something - ;; you can ask for. `::ui/centre-pivot` moves nothing while it does it. - (when (and (= path [:xform :pivot]) (seq node-path)) - [:button.key {:title "centre the pivot on the middle of what it draws now" - :aria-label "centre pivot" - :on-click #(rf/dispatch [::ui/centre-pivot node-path])} - "⌖"]) - (when gap? [segment-select sid id path ch left])])) + v (when-not (:dense ch) (channel/value-at ch (or frame 0) nil)) + put #(rf/dispatch [::project/set-channel sid id path frame %])] + (cond + (:dense ch) + [:span.dim {:title "measured from the footage · regenerate to change it"} + (str "measured · " (get-in ch [:dense :frames]) "f")] -(defn- color-control [sid id ch frame auto-key? palette] - (let [keyed? (some? (:keys ch)) - value (channel/value-at ch (or frame 0) nil) - ;; A knockout or a remap is no slot, and none is marked. - value (cond - (integer? value) value - (keyword? value) (or (first (keep-indexed #(when (= value (:name %2)) %1) - (:slots palette))) 0)) - off? (and keyed? (nil? frame))] - [:dd.channel {:class (when auto-key? "live")} - [:button.key {:class (cond (contains? (:keys ch) frame) "on" keyed? "keyed") - :disabled (nil? frame) - :title (if keyed? (str (count (:keys ch)) " held keys") "key color here") - :on-click #(rf/dispatch [::project/toggle-key sid id [:style :color] frame])} - "◆"] - [:div.channel-swatches - (doall - (for [[i {:keys [name hex]}] (map-indexed vector (:slots palette))] - ^{:key i} - [:button.swatch - {:class (when (= i value) "on") - :style {:background hex} - :disabled off? - :aria-label (str "color " i (when name (str " " (clojure.core/name name)))) - :aria-pressed (= i value) - :title (str i (when name (str " · " (clojure.core/name name))) " · " hex) - :on-click #(rf/dispatch [::project/set-channel sid id [:style :color] frame i])}]))] - (when keyed? [:span.dim "hold"])])) + (= path paint/geometry) + [:span.dim {:title "double-click the shape on the stage to edit its points"} + (str (quot (count v) 2) " points")] -(defn- instance-playback [[sid id n]] + (= path [:style :color]) + (if (symbol/remap? v) + [:span.dim "remap ↓"] + ;; A slot by name is the slot of that name; a knockout is none. + (swatches (if (keyword? v) + (first (keep-indexed #(when (= v (:name %2)) %1) (:slots palette))) + (when (integer? v) v)) + off? palette put)) + + (boolean? v) + [:input {:type "checkbox" :checked v :disabled off? + :on-change #(put (.. % -target -checked))}] + + (or (number? v) (and (sequential? v) (every? number? v))) + [:<> + (number-fields path v off? put) + ;; A pivot does not follow the drawing, so "put it back in the middle of + ;; what is there now" has to be something you can ask for. Moves nothing. + (when (and (= path [:xform :pivot]) (seq node-path)) + [:button.icon {:title "centre the pivot on what it draws now" + :aria-label "centre pivot" + :on-click #(rf/dispatch [::ui/centre-pivot node-path])} + "⌖"])] + + :else [:span.dim (brief (pr-str v))]))) + +(defn- channels + "Every channel of node `n`, transform first." + [[sid id n] node-path] + (let [auto-key? @(rf/subscribe [::sub/auto-key?]) + clip @(rf/subscribe [::render/clip]) + frame (:frame @(rf/subscribe [::sub/selected-placement])) + own @(rf/subscribe [::sub/own-time node-path]) + palette (get (pal/palettes clip) + (or (get-in clip [:symbols sid :palette]) (pal/default-palette-id clip)))] + [:div.chans + (doall + (for [[path ch] (sort-by (fn [[path]] [(get order path 99) (str path)]) (node/channels n))] + ^{:key (str path)} + [channel-row {:path path :ch ch :frame frame :own own + :live? (and auto-key? (not (:dense ch))) + :on-key #(rf/dispatch [::project/toggle-key sid id path frame]) + :set-gap! #(rf/dispatch [::project/set-segment-interp sid id path %1 %2])} + [channel-value sid id n path ch frame palette node-path]]))])) + +;; --------------------------------------------------------------------------- +;; an instance's playback, and a symbol's own settings + +(def ^:private modes + [[:once :once "play once"] [:loop :loop "loop"] [:frame :still "hold one frame"]]) + +(defn- playback-row [[sid id n]] (let [{:keys [in speed end]} (node/playback-of n) mode (cond (zero? speed) :frame (or (= :loop end) (get-in n [:time :loop?])) :loop :else :once) - change! (fn [field value] - (rf/dispatch [::project/instance-playback sid id field value]))] - [section "playback" - [:div.inspector-form - [:label.inspector-field "mode" - [:select {:value (name mode) - :aria-label "instance playback mode" - :on-change #(change! :mode (keyword (.. % -target -value)))} - [:option {:value "once"} "play once"] - [:option {:value "loop"} "loop"] - [:option {:value "frame"} "hold frame"]]] - [:label.inspector-field "start frame" - [number-input {:min 0 :step 1 :value in - :aria-label "instance start frame" - :parse #(js/parseInt % 10) - :on-number #(change! :in %)}]] - [:label.inspector-field "speed" - [number-input {:min 0 :step 0.1 :value speed - :disabled (= :frame mode) - :aria-label "instance playback speed" - :parse js/parseFloat - :on-number #(change! :speed %)}]]]])) + change! #(rf/dispatch [::project/instance-playback sid id %1 %2])] + (prop "play" + [:span.seg + (doall + (for [[m glyph title] modes] + ^{:key m} + [:button {:class (when (= m mode) "on") :title title :aria-label title + :aria-pressed (= m mode) + :on-click #(change! :mode m)} + [icon/view glyph]]))] + [:span.dim "from"] + [number-input {:min 0 :step 1 :value in + :title "the frame of its symbol it starts on" + :aria-label "instance start frame" + :parse #(js/parseInt % 10) + :on-number #(change! :in %)}] + [:span.dim "×"] + [number-input {:min 0 :step 0.1 :value speed + :disabled (= :frame mode) + :title "speed" :aria-label "instance playback speed" + :parse js/parseFloat + :on-number #(change! :speed %)}]))) -(defn- node-section [[sid id n]] - (let [[start end] (:span n) - ;; The selected row path, for the one control that needs to name the node - ;; the way a stage gesture does rather than by `[sid id]`: ⌖ re-centres a - ;; pivot, and finding the middle of what a node draws means resolving it - ;; where it is placed. - node-path (nth @(rf/subscribe [::sub/selection]) 3 nil) - auto-key? @(rf/subscribe [::sub/auto-key?]) - clip @(rf/subscribe [::render/clip]) - placement @(rf/subscribe [::sub/selected-placement]) - frame (:frame placement) - palette-id (or (get-in clip [:symbols sid :palette]) (pal/default-palette-id clip)) - palette (get (pal/palettes clip) palette-id)] - [section (str (name (:kind n)) " · in " (name sid)) - [facts - "id" (brief id) - ;; Which symbol a cel places. The one fact that makes an instance - ;; legible as an instance rather than as a node. - "of" (when (= :instance (:kind n)) (str (node/source n))) - ;; A span is in the node's OWN frames and `at` is where its frame 0 sits - ;; in this symbol. See `node/placed-span`. - "span" (when start (str start " … " end)) - "at" (when (node/mapped-time? n) (str (get-in n [:time :at] 0)))] - [:div.inspector-form - [name-field "name" (or (:name n) "") - #(rf/dispatch [::ui/rename-node sid id %])]] - (when (:paint? n) [drawing-keys sid id n @(rf/subscribe [::sub/selected-local])]) - [:div.row {:style {:margin-top "6px"}} [:span.dim "channels"]] - ;; Channels belong to the placement, before its source playback clock. - ;; Entering the source would wrap keys on loops and pin them on holds. - (let [{:keys [frame]} placement] - [:dl.facts - (doall - (for [[path ch] (sort-by (fn [[path]] - [(cond - (= :xform (first path)) 0 - (= path [:style :color]) 1 - :else 2) - (str path)]) - (node/channels n))] - ^{:key (str path)} - [:<> - [:dt (str/join " " (map name path))] - (cond - (and (= path [:style :color]) (not (:dense ch))) - [color-control sid id ch frame auto-key? palette] +(defn- symbol-fields + "A symbol's length, stage and authoring palette." + [sid] + (let [clip @(rf/subscribe [::render/clip]) + sym (get-in clip [:symbols sid]) + busy? (:busy? @(rf/subscribe [::playback/project])) + put! #(rf/dispatch [::project/symbol-setting sid %1 %2])] + [:<> + (prop "length" + [count-input (:frames sym) #(put! :frames %) {:disabled busy? :label "length in frames"}] + [:span.dim "f"]) + (prop "size" + [count-input (:width sym) #(put! :width %) + {:placeholder (str (:width clip)) :disabled busy? :label "width"}] + [:span.dim "×"] + [count-input (:height sym) #(put! :height %) + {:placeholder (str (:height clip)) :disabled busy? :label "height"}] + (when (or (:width sym) (:height sym)) + [:button.icon {:disabled busy? :title "use the project's stage size" + :aria-label "use project stage" + :on-click #(do (put! :width nil) (put! :height nil))} + "↺"])) + (prop "palette" + [palette-select (:palette sym) #(rf/dispatch [::project/symbol-palette sid %]) busy?])])) - (and (contains? (node/defaults-of n) path) (not (:dense ch))) - [channel-control sid id path ch frame auto-key? node-path] +(defn- project-fields [] + (let [clip @(rf/subscribe [::render/clip]) + project @(rf/subscribe [::playback/project]) + busy? (:busy? project)] + [section "project" + (prop "name" [text-input (or (:name project) (:name clip) "") + #(rf/dispatch [::project/rename %]) {:aria-label "project name"}]) + (prop "stage" + [count-input (:width clip) #(rf/dispatch [::project/project-setting :width %]) + {:disabled busy? :label "width"}] + [:span.dim "×"] + [count-input (:height clip) #(rf/dispatch [::project/project-setting :height %]) + {:disabled busy? :label "height"}]) + (prop "rate" [settings/rate busy?])])) - :else [:dd (channel-state ch)])]))])])) +;; --------------------------------------------------------------------------- +;; a node -(defn- palette-placement-section [[sid id n]] +(defn- node-view + "A selected node: its name, its channels, and for an instance how it plays + and the settings of the symbol it places." + [[sid id n :as selected]] + (let [clip @(rf/subscribe [::render/clip]) + ;; The row path, which names the node the way a stage gesture does: its + ;; clock and its pivot are found where it is placed. + node-path (or (nth @(rf/subscribe [::sub/selection]) 3 nil) [id]) + of (node/source n)] + [:<> + (if of + [header (if (symbol/lane? (clip-domain/symbol clip of)) "lane" "instance") + (clip-domain/symbol-name clip of) (name of) + #(rf/dispatch [::ui/rename-node sid id %]) (clip-domain/uses clip of)] + [header (name (:kind n)) (or (:name n) "") (clip-domain/node-label clip id n) + #(rf/dispatch [::ui/rename-node sid id %]) nil]) + [channels selected node-path] + (when of + [:div.props + [playback-row selected] + [symbol-fields of]])])) + +(defn- palette-placement-view + "A placement on the palette lane: which palette it switches to, keyed and + tweened like any channel." + [[sid id n]] (let [clip @(rf/subscribe [::render/clip]) transition (node/source n) open-frame @(rf/subscribe [::render/open-frame]) [start _] (node/placed-span n) frame (max 0 (- open-frame (or start 0))) + own {:time {:at (or start 0) :rate 1} :frame frame} ch (or (get-in n [:channels [:palette]]) (assoc (channel/framed - (get-in clip [:symbols (node/source n) :palette-ref])) + (get-in clip [:symbols transition :palette-ref])) :semantic :palette)) value (channel/value-at ch frame nil) - chosen (if (map? value) (:from value) value) - keyframes (sort (keys (:keys ch))) - left (when (seq keyframes) - (or (last (filter #(<= % frame) keyframes)) (first keyframes))) - right (when left (first (filter #(< left %) keyframes))) - palettes (sort-by (comp str :name val) (pal/palettes clip))] - [section "palette transition" - [:div.inspector-form - [name-field "name" (clip-domain/symbol-name clip transition) - #(rf/dispatch [::project/rename-symbol transition %])]] - [:div.inspector-form - [:label.inspector-field "palette" - [:span.row - [:button.key {:class (cond (contains? (:keys ch) frame) "on" (:keys ch) "keyed") - :title (if (:keys ch) (str (count (:keys ch)) " keys") "key this here") - :on-click #(rf/dispatch [::project/toggle-palette-key sid id frame])} - "◆"] - [:select {:value (if (= pal/inherit chosen) "" (str chosen)) - :on-change - (fn [e] - (let [v (.. e -target -value) - palette-id (or (first (filter #(= v (str %)) - (keys (pal/palettes clip)))) - pal/inherit)] - (rf/dispatch [::project/set-palette-choice sid id frame palette-id])))} - [:option {:value ""} "inherit"] - (for [[palette-id p] palettes] - ^{:key (str palette-id)} - [:option {:value (str palette-id)} (:name p)])]]] - (when right - [:label.inspector-field (str "key " left " → " right) - [segment-select sid id [:palette] ch left]])]])) - -(defn- palette-symbol-section [sid] - (let [clip @(rf/subscribe [::render/clip]) - sym (get-in clip [:symbols sid])] - [section "palette transition" - [:div.inspector-form - [name-field "name" (clip-domain/symbol-name clip sid) - #(rf/dispatch [::project/rename-symbol sid %])]] - [facts "palette" (or (get-in clip [:palettes (:palette-ref sym) :name]) - (:palette-ref sym))] - [:div.dim "Keyframes and cut/tween interpolation are edited on a placement in the palette lane."]])) - + chosen (if (map? value) (:from value) value)] + [:<> + [header "palette" (clip-domain/symbol-name clip transition) (name transition) + #(rf/dispatch [::ui/rename-node sid id %]) nil] + [:div.chans + [channel-row {:path [:palette] :ch ch :frame frame :own own + :on-key #(rf/dispatch [::project/toggle-palette-key sid id frame]) + :set-gap! #(rf/dispatch [::project/set-segment-interp sid id [:palette] %1 %2])} + [palette-select (when-not (= pal/inherit chosen) chosen) + #(rf/dispatch [::project/set-palette-choice sid id frame (or % pal/inherit)])]]]])) ;; --------------------------------------------------------------------------- ;; corrections @@ -439,8 +466,8 @@ lane-context? (or (symbol/lane? (clip-domain/symbol clip sid)) (and (= :instance (:kind selected)) (symbol/lane? (clip-domain/symbol clip (node/source selected))))) - targets (if lane-context? [selected-id] [])] - (when (seq targets) +] + (when lane-context? (r/with-let [draft (r/atom (correction-initial clip sid selected-id))] (let [target (:target @draft) motion (:motion @draft) @@ -448,16 +475,6 @@ layers (correction-layers clip sid target)] [section "corrections" [:div.correction-grid - [:label.inspector-field "owner" - [:select {:value (or (first (keep-indexed #(when (= %2 target) %1) targets)) 0) - :on-change (fn [e] - (let [i (js/parseInt (.. e -target -value) 10) - id (nth targets i)] - (reset! draft (correction-initial clip sid id))))} - (doall (for [[i id] (map-indexed vector targets)] - ^{:key (str id)} - [:option {:value i} - (str "selected · " (brief id))]))]] [:label.inspector-field "property" [:select {:value (if (= [:xform :rot] (:path @draft)) "rotation" "position") :on-change #(swap! draft assoc :path @@ -471,7 +488,6 @@ [:option {:value "constant"} "constant"] [:option {:value "ramp"} "ramp"] [:option {:value "return"} "return"]]] - [:div] [draft-number draft :from "from owner frame" true] [draft-number draft :through "through owner frame" true] (case motion @@ -524,39 +540,28 @@ (defn- layer-section "Tracing layer `id` of symbol `sid`, at row `path` from the open symbol, under - `title`, with `more` appended." + `title`, with `more` appended. Its holds are keys like any other: ◆ holds the + picture here until the next one, ◀ ▶ go between them." [title sid id path & more] (let [n (get-in @(rf/subscribe [::render/clip]) [:symbols sid :nodes id]) {:keys [on? hidden]} @(rf/subscribe [::render/tracing]) shown? (and on? (not (contains? hidden [sid id]))) - {:keys [frame time]} @(rf/subscribe [::sub/own-time path]) - holds (get-in n [:time :holds] []) - seek! #(rf/dispatch [::pb/seek (js/Math.round (+ (:at time) (/ % (:rate time))))])] + {:keys [frame] :as own} @(rf/subscribe [::sub/own-time path]) + holds (get-in n [:time :holds] [])] (into [section title - [:div.row - [:label.dim {:title "show it over the picture · a reference, never exported"} - [:input {:type "checkbox" :checked (boolean shown?) - :on-change #(rf/dispatch [::ui/show-trace [sid id] (not shown?)])}] - " show"]] - [:div.row {:style {:margin "5px 0"}} - ;; A DEAD BUTTON WITH NO REASON GIVEN is what reads as the feature not - ;; working, so say why there is nothing to hold. - (if (nil? frame) - [:span.dim "move the playhead over this layer to hold a frame"] - [:button {:title "hold the picture on this frame until the next hold" - :on-click #(rf/dispatch [::project/toggle-hold sid id frame])} - (if (some #{frame} holds) (str "remove hold at " frame) (str "hold at " frame))])] - (when (seq holds) - [:div.row - [:span.dim "holds"] - (doall - (for [f holds] - ^{:key f} - [:button {:class (when (= frame f) "on") - :disabled (nil? time) - :on-click #(seek! f)} - (str f)]))])] + [:div.chan + [key-nav holds frame own #(rf/dispatch [::project/toggle-hold sid id frame]) + (if (nil? frame) + "move the playhead over this layer to hold a frame" + "hold the picture on this frame until the next hold")] + [:span.chan-name "hold"] + [:span.chan-value + [:label.dim {:title "show it over the picture · a reference, never exported"} + [:input {:type "checkbox" :checked (boolean shown?) + :on-change #(rf/dispatch [::ui/show-trace [sid id] (not shown?)])}] + " show"]] + [:span.gap]]] more))) (def ^:private origins @@ -571,8 +576,8 @@ [face path] (let [reads (get-in @(rf/subscribe [::render/clip]) [:symbols face :nodes :head :reads])] [layer-section (str "tracing · " (name face)) face :plate (conj path :plate) - [:div.row {:style {:margin-top "5px"}} - [:span.dim "head"] + [:div.prop + [:span.prop-name "head"] (doall (for [[label r title] origins] ^{:key label} @@ -604,9 +609,10 @@ marks (pose/marks (:nodes sym) (:frames sym) store) on? (contains? smart face)] [section (str "performance \u00b7 " (name face)) - [:div.row {:style {:margin "5px 0"}} - [:label.dim {:title (str "let a closure the grid drops move the frame a slot " - "reads \u2014 backward, and only within that slot's own gap")} + [:div.row + [:label {:title (str "let a closure the grid drops move the frame a slot " + "reads \u2014 backward, and only within that slot's own gap" + " \u00b7 the stage only: an export is unaffected until this is a saved setting")} [:input {:type "checkbox" :checked on? :on-change #(rf/dispatch [::ui/smart-picking face (not on?)])}] " smart frame picking"]] @@ -622,48 +628,7 @@ (str/join " " (take 24 fs)) (when (> (count fs) 24) " \u2026"))} (str (if (vector? group) (str/join "/" (map name group)) (name group)) - " " (count fs))]))]) - [:div.row - [:span.dim "the stage only \u00b7 an export is unaffected until this is a saved setting"]]])) - -;; --------------------------------------------------------------------------- -;; a symbol - -(defn- symbol-section [sid & [title]] - (let [clip @(rf/subscribe [::render/clip]) - sym (get-in clip [:symbols sid]) - frame @(rf/subscribe [::render/open-frame]) - busy? (:busy? @(rf/subscribe [::playback/project]))] - [section (or title "symbol") - [facts - "id" (str sid) - "length" (str (:frames sym) " frames") - "stage" (let [[w h] (clip-domain/stage clip sid)] (str w "×" h)) - "nodes" (str (count (:nodes sym)))] - [:div.inspector-form - [name-field "name" (clip-domain/symbol-name clip sid) - #(rf/dispatch [::project/rename-symbol sid %])] - [number-field "length (frames)" (:frames sym) - #(rf/dispatch [::project/symbol-setting sid :frames %]) nil busy?] - [number-field "width" (:width sym) - #(rf/dispatch [::project/symbol-setting sid :width %]) "project default" busy?] - [number-field "height" (:height sym) - #(rf/dispatch [::project/symbol-setting sid :height %]) "project default" busy?] - [:label.inspector-field "authoring palette" - [:select {:value (str (or (:palette sym) "")) :disabled busy? - :on-change (fn [e] - (let [v (.. e -target -value) - id (first (filter #(= v (str %)) (keys (pal/palettes clip))))] - (rf/dispatch [::project/symbol-palette sid id])))} - [:option {:value ""} "inherit"] - (for [[id p] (sort-by (comp str :name val) (pal/palettes clip))] - ^{:key (str id)} [:option {:value (str id)} (:name p)])]] - (when (or (:width sym) (:height sym)) - [:div.row - [:button {:disabled busy? :on-click #(do - (rf/dispatch [::project/symbol-setting sid :width nil]) - (rf/dispatch [::project/symbol-setting sid :height nil]))} - "use project stage"]])]])) + " " (count fs))]))])])) ;; --------------------------------------------------------------------------- ;; tracked objects @@ -809,8 +774,8 @@ offset (if gaze (channel/value-at (:values gaze) current nil) [0 0])] (swap! draft assoc :opening opening :gaze-x (* 100 (first offset)) :gaze-y (* 100 (second offset))))))] - [:div {:style {:margin-top "8px"}} - [:div.dim "Eye adjustments · key a pose, then scrub and key another. Adjustments tween within this interval."] + [:div {:style {:margin-top "8px"} + :title "eye adjustments · key a pose, then scrub and key another; they tween within this interval"} [:label.inspector-field "eye" [:select {:value (name side) :on-change #(swap! draft assoc :side (keyword (.. % -target -value)))} @@ -846,8 +811,8 @@ repairs (distinct (for [[_ n] (get-in clip [:symbols sid :nodes]) [_ c] (:channels n) r (:repairs c)] r))] (r/with-let [draft (r/atom {:from 0 :through 1 :donor 2 :head? false})] - [section "repair intervals" - [:div.dim "Hold a clean pose across damaged frames. Face settings still apply. Frame numbers are local to this face, starting at 0."] + [section [:span {:title "hold a clean pose across damaged frames · face settings still apply · frames are this face's own, from 0"} + "repair intervals"] (for [[field label] [[:from "from face frame"] [:through "through face frame"] [:donor "clean donor frame"]]] @@ -874,6 +839,24 @@ [:button {:on-click #(rf/dispatch [::ui/remove-repair sid id])} "remove"]] [eye-repair-controls sid repair current]])]))) +;; --------------------------------------------------------------------------- + +(defn- symbol-view + "A symbol, selected or open with nothing selected: its name and settings." + [sid] + (let [clip @(rf/subscribe [::render/clip]) + sym (get-in clip [:symbols sid])] + [:<> + [header (if (= :palette (:type sym)) "palette" "symbol") + (clip-domain/symbol-name clip sid) (name sid) + #(rf/dispatch [::project/rename-symbol sid %]) (clip-domain/uses clip sid)] + [:div.props + (if (= :palette (:type sym)) + (prop "palette" + [:span {:title "keys and tweens are set on a placement in the palette lane"} + (or (get-in clip [:palettes (:palette-ref sym) :name]) (str (:palette-ref sym)))]) + [symbol-fields sid])]])) + (defn view [] (let [clip @(rf/subscribe [::render/clip]) open @(rf/subscribe [::render/open]) @@ -882,49 +865,40 @@ ;; tab would. inspected (or selection [:symbol open]) node @(rf/subscribe [::sub/selected-node]) - ;; The face the tracing section is about: the SELECTED PLACEMENT's symbol, - ;; or, when the selection is not an instance or there is none, the OPEN - ;; symbol — which is the face itself when a face is open to be drawn over. - ;; That last case had no section at all before, and it is the one where - ;; the keys are actually being set. - ;; The symbol this cel places, or nil for a lane: which face a - ;; lane traces is not a question with one answer, and naming the drawing - ;; showing now would move the section under the playhead. + ;; The symbol the selected node places, or nil. placed (node/source (peek node)) - footage-faces (footage-faces clip selection node) tracking-owners (tracking-owners clip selection node) palette-placement? (and node (= :palette-track (get-in clip [:symbols (first node) :type]))) palette-symbol? (and (= :symbol (first inspected)) (= :palette (get-in clip [:symbols (second inspected) :type]))) + ;; The face the face sections are about: the selected placement's symbol, + ;; or the open symbol when that is a face being drawn over. face (or placed (when (face? clip open) open)) layer? (and placed (clip-domain/trace? (clip-domain/symbol clip placed))) ;; Where that face or layer sits, as a row path from the open symbol. A ;; selection made on the stage has no path and names a node directly in ;; 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?))] [:section.pane.params [:div.pane-head "inspector"] - [:div {:style {:min-height 0}} - (when palette-placement? [palette-placement-section node]) - (when (= [:symbol (clip-domain/opens-on clip)] inspected) - [clip-section]) - (when (and node (not palette-placement?)) [node-section node]) - (when (and placed (not palette-placement?)) [instance-playback node]) + [:div.inspect + (cond + palette-placement? [palette-placement-view node] + node [node-view node] + (= :symbol (first inspected)) [symbol-view (second inspected)]) (when (and node (not palette-placement?)) [palette/remap-section]) - (when (and placed (not palette-placement?)) [symbol-section placed "source symbol"]) (when (and node (not palette-placement?)) ^{:key (str (first node) "/" (second node))} [correction-section node]) (when layer? - [layer-section (str "tracing · " (clip-domain/symbol-name clip placed)) - (first node) (second node) path]) + [layer-section "tracing" (first node) (second node) path]) (when (get-in clip [:symbols face :nodes :plate]) [face-section face path]) - (when (and face (face? clip face) (not layer?)) ^{:key (str "repair/" face)} [repair-section face path]) - (when (and face (not layer?)) ^{:key (str "perf/" face)} [performance-section face]) - (when palette-symbol? [palette-symbol-section (second inspected)]) - (when (and (= :symbol (first inspected)) (not palette-symbol?)) - [symbol-section (second inspected)]) + (when a-face? ^{:key (str "repair/" face)} [repair-section face path]) + (when a-face? ^{:key (str "perf/" face)} [performance-section face]) (when (and (seq tracking-owners) (not palette-placement?) (not palette-symbol?)) - [tracking-section tracking-owners])]])) + [tracking-section tracking-owners]) + (when (= [:symbol (clip-domain/opens-on clip)] inspected) + [project-fields])]])) diff --git a/frontend/src/arthur/ui/settings.cljs b/frontend/src/arthur/ui/settings.cljs index 35e25d5..e1a6e53 100644 --- a/frontend/src/arthur/ui/settings.cljs +++ b/frontend/src/arthur/ui/settings.cljs @@ -92,9 +92,9 @@ apply! (fn [mode] (close!) (rf/dispatch [::project/set-fps to mode])) changed? (and to (not= to fps))] [:<> - [:label.inspector-field "frame rate" - [:button {:disabled disabled? :on-click #(do (reset! draft fps) (reset! open? true))} - (str fps " fps")]] + [:button {:disabled disabled? :title "frame rate · change it" + :on-click #(do (reset! draft fps) (reset! open? true))} + (str fps " fps")] (when @open? [dialog "Frame rate" close! [chips (str "from " fps " fps to") rates to #(str % " fps") #(reset! draft %) diff --git a/frontend/src/arthur/ui/timeline.cljs b/frontend/src/arthur/ui/timeline.cljs index 0c315ce..aac831a 100644 --- a/frontend/src/arthur/ui/timeline.cljs +++ b/frontend/src/arthur/ui/timeline.cljs @@ -21,6 +21,7 @@ first pass is drawn. An expanded loop therefore shows keys where they first happen and not where they happen again." (:require [clojure.string :as str] + [arthur.domain.channel :as channel] [arthur.domain.node :as node] [arthur.domain.keyframes :as keyframes] [arthur.domain.clipboard :as clipboard] @@ -29,6 +30,7 @@ [arthur.domain.span :as span] [arthur.domain.symbol :as symbol] [arthur.events.playback :as pb] + [arthur.events.project :as project] [arthur.events.ui :as ui] [arthur.footage.store :as store] [arthur.ui.icon :as icon] @@ -89,6 +91,19 @@ {:sid sid :id (:id n) :channel channel :frame f :at (->open f) :scale (- (->open 1) (->open 0))}))) +(defn- gaps + "The stretches between one key of a channel and the next, each holding or + tweening, as Flash draws a classic tween between two keyframes. Nil for a + channel whose values are choices — a colour, a switch — which only ever hold." + [n sid path ch ->open] + (let [fs (keyed-frames ch)] + (when-not (node/hold-only? path (val (first (:keys ch)))) + (mapv (fn [[a b]] + {:sid sid :id (:id n) :channel path :left a + :from (->open a) :to (->open b) + :tween? (= :linear (channel/segment-interp ch a))}) + (partition 2 1 fs))))) + (defn- channel-rows [n sid path depth ->open span] (let [keyed (filter (comp seq :keys val) (sort-by (comp str key) (node/channels n)))] @@ -96,12 +111,13 @@ (for [[cpath ch] keyed] {:path (conj path cpath) :depth depth - :label (str/join " " (map name cpath)) + :label (node/channel-name cpath) :kind :channel :select nil :span span :keys (mapv ->open (keyed-frames ch)) :key-items (filterv #(= cpath (:channel %)) (key-items n sid ->open)) + :gaps (gaps n sid cpath ch ->open) :dense? (boolean (:dense ch))}) [{:path (conj path ::automation-hint) :depth depth @@ -171,6 +187,7 @@ :kind :node :node-kind (:kind child) :of (node/source child) + :uses (some->> (node/source child) (clip/uses clip)) :portal? true :select [:node sid (:id child) cpath] :expandable? true @@ -283,6 +300,7 @@ :node-kind (:kind n) :lane? lane? :of (node/source n) + :uses (some->> (node/source n) (clip/uses clip)) :select [:node sid id rpath] :expandable? true :expanded? open? @@ -623,7 +641,7 @@ on every render after, which would fight a person scrolling away." (memoize (fn [_selection] (fn [el] (some-> el (.scrollIntoView #js {:block "nearest"})))))) -(defn- label-cell [{:keys [path depth label kind node-kind lane? span select expandable? expanded? of via]} +(defn- label-cell [{:keys [path depth label kind node-kind lane? span select expandable? expanded? of via uses]} selection selections target-path over solo tracing renaming draft choose-row!] (let [node? (= :node kind) selected? (contains? selections select) @@ -639,6 +657,7 @@ (when (and select (= select selection)) " primary") (when (= path target-path) " target") (when lane? " lane") + (when (= :palette kind) " palette") (when (= :ghost kind) " ghost") (when (= path over-path) (case where @@ -726,6 +745,11 @@ "Escape" (do (.preventDefault e) (reset! renaming nil)) nil))}] [:span.name label]) + ;; How many places show this same drawing: rename it here and every one + ;; of them changes, and `make unique` is how to stop that. + (when (and uses (< 1 uses) (not editing?)) + [:span.uses {:title (str "placed " uses " times · a rename reaches every one")} + (str "(" uses ")")]) (cond lane? [:span.kind "·lane"] node? [:span.kind (if via (str "· in " via) (str "·" (name node-kind)))]) @@ -875,7 +899,7 @@ `: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 every row and the stage are drawn from already has in it." - [{:keys [path span keys key-items 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!]}] (let [selected-set (set selections) active-row (:row @sliding) @@ -1224,6 +1248,21 @@ (when select [:span.tl-edge.out {:title "Drag endpoint · Shift-drag ripples later clips" :on-pointer-down #(begin! % (nth select 3) :out select nil nil)}])])) + ;; Click a gap between two keys to switch it between holding and tweening. + (doall + (for [{:keys [sid id channel left from to tween?]} gaps + :when (and (< from frames) (< 0 to))] + ^{:key left} + [:button.tl-gap + {:type "button" :class (when tween? "tween") + :title (if tween? "tween · click to hold" "hold · click to tween") + :style {:left (at% from frames) + :width (str (* 100 (/ (- to from) (max 1 frames))) "%")} + :on-pointer-down #(.stopPropagation %) + :on-click (fn [^js e] + (.stopPropagation e) + (rf/dispatch [::project/set-segment-interp sid id channel left + (if tween? :hold :linear)]))}])) ;; A dense channel has a value on every frame, so ticking each one is a solid ;; block that says less than the bar behind it already does. ;; The lane's own keys, and those of the clips on it drawn after the diff --git a/frontend/test/arthur/domain/instance_test.cljs b/frontend/test/arthur/domain/instance_test.cljs index 6667c84..9f715cb 100644 --- a/frontend/test/arthur/domain/instance_test.cljs +++ b/frontend/test/arthur/domain/instance_test.cljs @@ -281,9 +281,10 @@ (testing "an unnamed symbol falls back to its id, not to the node's uuid" (is (= "inner" (clip/node-label (update-in c [:symbols :inner] dissoc :name) id n)))) - (testing "but a name somebody typed on the instance still wins" - ;; Two instances of one symbol are told apart only by this. - (is (= "left eye" (clip/node-label c id (assoc n :name "left eye"))))) + (testing "and a name left on the instance is not read: it has none of its own" + (is (= "mouth" (clip/node-label c id (assoc n :name "left eye"))))) + (testing "every placement of a symbol is counted" + (is (= 1 (clip/uses c :inner)))) (testing "and a node that places nothing is labelled by its own name or id" (is (= "lid" (clip/node-label c :lid {:id :lid :kind :rect :name "lid"}))) (is (= "lid" (clip/node-label c :lid {:id :lid :kind :rect})))))) diff --git a/frontend/test/arthur/events/export_test.cljs b/frontend/test/arthur/events/export_test.cljs index 13d3ec7..a92c334 100644 --- a/frontend/test/arthur/events/export_test.cljs +++ b/frontend/test/arthur/events/export_test.cljs @@ -61,26 +61,26 @@ #uuid "22222222-2222-4222-8222-222222222222" {:id #uuid "22222222-2222-4222-8222-222222222222" :kind :instance :parent :root :z "a2" - :name "8625 right" :source {:symbol :sym/face}} #uuid "11111111-1111-4111-8111-111111111111" {:id #uuid "11111111-1111-4111-8111-111111111111" :kind :instance :parent :root :z "a1" - :name "8625 left" :source {:symbol :sym/face}} :a-rect {:id :a-rect :kind :rect :parent :root :z "a3"}}} :sym/face {:frames 40 :nodes {:root {:id :root :kind :group :z "a1"}}}}}) (deftest the-picker-offers-every-symbol-then-every-instance-in-the-open-one (let [ts (export/targets clip :main)] - (is (= ["main" "face" "8625 left" "8625 right"] (mapv :label ts)) + (is (= ["main" "face" "face 1" "face 2"] (mapv :label ts)) "every symbol, then the instances in the open one") (testing "the instances isolate a node in the open symbol and the symbols do not" (is (= [nil nil] (mapv :isolate (take 2 ts)))) (is (every? uuid? (mapv :isolate (drop 2 ts)))) (is (every? #(= :main (:symbol %)) (drop 2 ts)))) - (testing "ordered by label, because a uuid sorts at random" - (is (= ["8625 left" "8625 right"] (mapv :label (drop 2 ts))))) + (testing "one symbol placed twice is numbered in stacking order, because a uuid sorts at random" + (is (= [#uuid "11111111-1111-4111-8111-111111111111" + #uuid "22222222-2222-4222-8222-222222222222"] + (mapv :isolate (drop 2 ts))))) (testing "and a node that is not an instance is not offered" (is (not-any? #{"a-rect"} (map :label ts)))))) diff --git a/frontend/test/browser/take.mjs b/frontend/test/browser/take.mjs index 93d3721..6b3162c 100644 --- a/frontend/test/browser/take.mjs +++ b/frontend/test/browser/take.mjs @@ -562,31 +562,26 @@ async function main() { await page.eval(SEEK(f)); await sleep(100); check(await page.eval(`(() => { - const button = [...document.querySelectorAll('.params button')] - .find(b => b.textContent === 'drawing key here'); - if (!button || button.disabled) return false; + const button = document.querySelector('.params .chan[data-channel="geom pts"] button.key'); + if (!button || button.disabled || button.classList.contains('on')) return false; button.click(); return true; })()`), `a drawing key can be added at frame ${f}`); await sleep(100); } - await page.eval(SEEK(8)); + // Standing on key 16, the gap switch is about the gap arriving at it, 8 → 16. + const GAP = `document.querySelector('.params .chan[data-channel="geom pts"] button.gap')`; + await page.eval(SEEK(16)); await sleep(100); const tweenSelected = await page.eval(`(() => { - const label = [...document.querySelectorAll('.params label')] - .find(el => el.textContent.startsWith('key 8 → 16')); - const select = label?.querySelector('select'); - if (!select) return false; - select.value = 'linear'; - select.dispatchEvent(new Event('change', { bubbles: true })); + const gap = ${GAP}; + if (!gap || gap.getAttribute('aria-label') !== 'hold') return false; + gap.click(); return true; })()`); await sleep(100); - check(tweenSelected && await page.eval(`(() => { - const label = [...document.querySelectorAll('.params label')] - .find(el => el.textContent.startsWith('key 8 → 16')); - return label?.querySelector('select')?.value === 'linear'; - })()`), 'the second drawing gap can be set to tween'); + check(tweenSelected && await page.eval(`${GAP}?.getAttribute('aria-label') === 'tween'`), + 'the second drawing gap can be set to tween'); check((await statusMatching(/saved r\d+/)) !== null, 'the painted shape saves by itself', await page.eval(STATUS)); check(await fromMenu(MENU_PICK_NEWEST), 'the painted document can be reopened'); @@ -610,13 +605,10 @@ async function main() { re_frame.core.dispatch_sync(c.vector(k('arthur.events.ui/select'), c.vector(k('node'), k('main'), id, c.vector(id)))); })()`); - await page.eval(SEEK(8)); + await page.eval(SEEK(16)); await sleep(100); - check(await page.eval(`(() => { - const label = [...document.querySelectorAll('.params label')] - .find(el => el.textContent.startsWith('key 8 → 16')); - return label?.querySelector('select')?.value === 'linear'; - })()`), 'the per-gap tween setting survives the project round trip'); + check(await page.eval(`${GAP}?.getAttribute('aria-label') === 'tween'`), + 'the per-gap tween setting survives the project round trip'); // The local 8625 study is optional in a fresh test database. When present, // tune its shared symbol while its stage is playing. diff --git a/static/arthur/app.css b/static/arthur/app.css index dd5267f..6fe786e 100644 --- a/static/arthur/app.css +++ b/static/arthur/app.css @@ -926,7 +926,6 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); } letter-spacing: .07em; } -.inspector-form { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 7px; } .inspector-field { display: grid; gap: 2px; color: var(--dim); } .inspector-field input { width: 100%; color: var(--fg); } @@ -936,11 +935,6 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); } .correction-item { display: flex; align-items: center; gap: 4px; min-width: 0; } .correction-item > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -/* Label / value, once, for every read-only fact in the pane. */ -.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 0; } -.facts dt { color: var(--dim); } -.facts dd { margin: 0; overflow: hidden; text-overflow: ellipsis; } - .knob { display: grid; gap: 1px; margin-bottom: 6px; } .knob .top-line { display: flex; justify-content: space-between; gap: 8px; } .knob .top-line .name { color: var(--dim); } @@ -1402,28 +1396,70 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); } border-top: 1px solid var(--hair); } -/* A transform or visibility channel: its key button, then a field per component. */ -.facts dd.channel { display: flex; gap: 3px; align-items: center; overflow: visible; } -.facts dd.channel input[type=number] { width: 0; flex: 1; min-width: 0; } -.facts dd.channel .key { padding: 0 3px; color: var(--dim); } -.facts dd.channel .key.keyed { color: var(--fg); } -.facts dd.channel .key.on { color: var(--sel); } -.facts dd.channel .channel-swatches { - display: flex; - flex: 1; - flex-wrap: wrap; - gap: 3px; - min-width: 0; +/* The inspector. One column of names, 46px, and controls after it: the + header, then a row per channel, then labelled rows. */ +.inspect-head { + display: flex; align-items: center; gap: 5px; + padding: 6px; border-bottom: 1px solid var(--hair); + position: sticky; top: 0; z-index: 1; background: var(--pane); } -.facts dd.channel .channel-swatches .swatch { flex: 0 0 15px; } -.facts dd.channel.live { - margin: -2px; - padding: 2px; +.inspect-kind { color: var(--dim); flex: 0 0 auto; } +.inspect-name { flex: 1; min-width: 0; font-weight: 600; } +.uses, .tl-label .uses { color: var(--dim); flex: 0 0 auto; } + +.chans, .props { padding: 4px 6px; display: grid; gap: 3px; border-bottom: 1px solid var(--hair); } + +/* ◀ ◆ ▶ · name · value · gap */ +.chan { display: grid; grid-template-columns: auto 38px 1fr 16px; gap: 4px; align-items: center; min-height: 20px; } +.chan-name, .prop-name { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.chan-value { display: flex; gap: 3px; align-items: center; min-width: 0; } +.chan-value input[type=number], .prop input[type=number] { width: 0; flex: 1; min-width: 0; } +.chan-value select, .prop select { flex: 1; min-width: 0; } +.chan.live { + margin: -1px -3px; padding: 1px 3px; border-radius: 3px; background: var(--live-bg); - box-shadow: 0 0 0 1px rgba(35, 148, 71, .45), 0 0 6px rgba(35, 148, 71, .28); + box-shadow: 0 0 0 1px rgba(35, 148, 71, .45); } -.facts dd.channel.live input { border-color: var(--live); } +.chan.live input { border-color: var(--live); } + +.key-nav { display: flex; align-items: center; } +.key-nav button, .chan .gap, .prop .icon, .chan-value .icon { + padding: 0; border: 0; background: none; width: 14px; height: 18px; + display: inline-flex; align-items: center; justify-content: center; + color: var(--dim); +} +.key-nav button:disabled { opacity: .3; } +.key-nav .key { width: 16px; } +.key-nav .key.keyed { color: var(--fg); } +.key-nav .key.on { color: var(--sel); } +.key-nav svg, .chan .gap svg, .prop .seg svg { width: 11px; height: 11px; } +.key-nav button:hover:not(:disabled), .chan button.gap:hover, .icon:hover:not(:disabled) { color: var(--fg); } +.chan .gap.on { color: var(--sel); } + +.chan-swatches { display: flex; flex-wrap: wrap; gap: 2px; min-width: 0; } +.chan-swatches .swatch { flex: 0 0 11px; width: 11px; height: 11px; } + +.prop { display: flex; gap: 4px; align-items: center; min-height: 20px; } +.prop > .prop-name { flex: 0 0 46px; } +.prop input[type=text] { flex: 1; min-width: 0; } + +.prop .seg button { padding: 1px 4px; display: inline-flex; align-items: center; } + +/* A gap between two keys of a channel row: empty where it holds, a ramp where + it tweens, as Flash draws a classic tween. Click to switch. */ +button.tl-gap { + position: absolute; top: 50%; height: 9px; margin-top: -4.5px; + padding: 0; border: 0; border-radius: 0; background: transparent; + cursor: pointer; z-index: 3; +} +button.tl-gap::after { + content: ""; position: absolute; left: 6px; right: 6px; top: 4px; height: 1px; + background: var(--line); +} +button.tl-gap.tween { background: rgba(47, 111, 192, .22); } +button.tl-gap.tween::after { top: 3px; height: 3px; background: var(--sel); } +button.tl-gap:hover { background: rgba(47, 111, 192, .28); } /* The selected node's transform box, in stage pixels (the SVG's viewBox). */ .paint-overlay .handles .box { fill: none; stroke: #e6ca8b; stroke-width: 0.5; stroke-dasharray: 2 1; pointer-events: none; }