Compare commits
No commits in common. "4fe620f50a05f6263add1305a7a1c5a34907fac7" and "e2ca251ef4a1293ecda5e64cce185fe7af49571c" have entirely different histories.
4fe620f50a
...
e2ca251ef4
46 changed files with 1156 additions and 2399 deletions
|
|
@ -436,8 +436,8 @@ class DocumentTests(TestCase):
|
||||||
self.assertEqual(200, self.save(leaves).status_code)
|
self.assertEqual(200, self.save(leaves).status_code)
|
||||||
rows = self.client.get("/api/symbols").json()["palettes"]
|
rows = self.client.get("/api/symbols").json()["palettes"]
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[("Moonlit", "night", "c1", ["#001122"])],
|
[("Moonlit", "night", "c1")],
|
||||||
[(r["name"], r["palette"], r["cid"], r["hexes"]) for r in rows],
|
[(r["name"], r["palette"], r["cid"]) for r in rows],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_a_document_comes_back_exactly(self):
|
def test_a_document_comes_back_exactly(self):
|
||||||
|
|
|
||||||
|
|
@ -413,26 +413,6 @@ def footage_list(request):
|
||||||
|
|
||||||
_SYMBOL_LEAF = re.compile(r"^clip/([^/]+)/symbol/([^/]+)$")
|
_SYMBOL_LEAF = re.compile(r"^clip/([^/]+)/symbol/([^/]+)$")
|
||||||
_PALETTE_LEAF = re.compile(r"^clip/([^/]+)/palette/([^/]+)$")
|
_PALETTE_LEAF = re.compile(r"^clip/([^/]+)/palette/([^/]+)$")
|
||||||
_HEX = re.compile(r"#[0-9a-fA-F]{6}")
|
|
||||||
|
|
||||||
|
|
||||||
def _slot_hexes(value):
|
|
||||||
"""A palette leaf's slot colours, in order. Every slot carries exactly one
|
|
||||||
hex, so they are read off whatever follows `:slots` without decoding
|
|
||||||
transit's caches."""
|
|
||||||
if not isinstance(value, list) or "~:slots" not in value:
|
|
||||||
return []
|
|
||||||
out = []
|
|
||||||
|
|
||||||
def walk(x):
|
|
||||||
if isinstance(x, list):
|
|
||||||
for y in x:
|
|
||||||
walk(y)
|
|
||||||
elif isinstance(x, str) and _HEX.fullmatch(x):
|
|
||||||
out.append(x.lower())
|
|
||||||
|
|
||||||
walk(value[value.index("~:slots") + 1])
|
|
||||||
return out
|
|
||||||
|
|
||||||
|
|
||||||
def _transit_fields(value, *keys):
|
def _transit_fields(value, *keys):
|
||||||
|
|
@ -479,9 +459,6 @@ def symbols(request):
|
||||||
"cid": m.group(1),
|
"cid": m.group(1),
|
||||||
"palette": m.group(2),
|
"palette": m.group(2),
|
||||||
"name": fields.get("name") or m.group(2).replace("~", "/"),
|
"name": fields.get("name") or m.group(2).replace("~", "/"),
|
||||||
# Every slot carries exactly one hex, in order, so the strip is
|
|
||||||
# read off the value without decoding transit's caches.
|
|
||||||
"hexes": _slot_hexes(leaf.value),
|
|
||||||
})
|
})
|
||||||
palettes.sort(key=lambda r: (r["project_name"], r["project"], r["name"]))
|
palettes.sort(key=lambda r: (r["project_name"], r["project"], r["name"]))
|
||||||
return JsonResponse({"symbols": rows, "palettes": palettes})
|
return JsonResponse({"symbols": rows, "palettes": palettes})
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
[arthur.ui.index :as index]
|
[arthur.ui.index :as index]
|
||||||
[arthur.ui.player :as player]
|
[arthur.ui.player :as player]
|
||||||
[arthur.ui.shell :as shell]
|
[arthur.ui.shell :as shell]
|
||||||
[arthur.ui.shortcuts :as shortcuts]
|
[arthur.ui.tools :as tools]
|
||||||
[re-frame.core :as rf]
|
[re-frame.core :as rf]
|
||||||
[reagent.dom.client :as rdc]))
|
[reagent.dom.client :as rdc]))
|
||||||
|
|
||||||
|
|
@ -46,7 +46,8 @@
|
||||||
;; After the blank document, so an address that names a project opens it over
|
;; After the blank document, so an address that names a project opens it over
|
||||||
;; the blank one, and the blank one is what a bad address leaves on screen.
|
;; the blank one, and the blank one is what a bad address leaves on screen.
|
||||||
(collab/start!)
|
(collab/start!)
|
||||||
(shortcuts/install!)
|
(history/install-keys!)
|
||||||
|
(tools/install-keys!)
|
||||||
(reset! root (rdc/create-root (js/document.getElementById "app")))
|
(reset! root (rdc/create-root (js/document.getElementById "app")))
|
||||||
(mount)
|
(mount)
|
||||||
(player/start!))
|
(player/start!))
|
||||||
|
|
|
||||||
|
|
@ -74,28 +74,28 @@
|
||||||
(defn node-label
|
(defn node-label
|
||||||
"What to call node `n` on screen.
|
"What to call node `n` on screen.
|
||||||
|
|
||||||
AN INSTANCE IS CALLED WHAT IT PLACES, read through on every render, and has
|
A NAME A PERSON TYPED WINS, and for an instance that is the ONLY thing `:name`
|
||||||
no name of its own. A name on the placement meant the same drawing could show
|
now means: `place-symbol` deliberately does not copy the symbol's name onto the
|
||||||
under two names, and that a rename in one place reached nowhere else; renaming
|
node it makes. Two instances of one symbol are told apart by what somebody
|
||||||
an instance renames its symbol (`::ui/rename-node`), so every placement of it
|
called them — `8625 left` and `8625 right` of one `face` — and reading through
|
||||||
follows. How many places share it is `uses`.
|
in front of that would collapse them to the same word.
|
||||||
|
|
||||||
Anything else is called by its own `:name`. An id is a uuid for a placement
|
OTHERWISE AN INSTANCE IS LABELLED BY WHAT IT PLACES, read through on every
|
||||||
and a keyword for an authored node, and neither reads as a name, so the last
|
render. A name copied at creation goes stale the moment the symbol is renamed,
|
||||||
resort is a legible stand-in — `:face-1` loses its colon and a uuid is cut."
|
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."
|
||||||
[clip id n]
|
[clip id n]
|
||||||
(or (some->> (node/source n) (symbol-name clip))
|
(or (:name n)
|
||||||
(:name n)
|
(some->> (node/source n) (symbol-name clip))
|
||||||
(if (keyword? id) (subs (str id) 1) (subs (str id) 0 8))))
|
(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
|
(defn frames
|
||||||
"A symbol's length. Read off the symbol, never copied beside it."
|
"A symbol's length. Read off the symbol, never copied beside it."
|
||||||
[clip sid]
|
[clip sid]
|
||||||
|
|
@ -188,18 +188,17 @@
|
||||||
and the swarm carry no `:subjects` — so every reader already reads absence as
|
and the swarm carry no `:subjects` — so every reader already reads absence as
|
||||||
none, and `clip-keys` says which fields MAY be here, not which must.
|
none, and `clip-keys` says which fields MAY be here, not which must.
|
||||||
|
|
||||||
`settings` overrides any of `blank-settings`. `:palette` names the preset it
|
`settings` overrides any of `blank-settings`. It starts with every one of
|
||||||
draws with, and that one is the project's only palette until more are added."
|
`palette/presets`, and `:palette` is the id of the one it draws with."
|
||||||
([] (blank {}))
|
([] (blank {}))
|
||||||
([settings]
|
([settings]
|
||||||
(let [{:keys [fps seconds width height palette] :as s} (merge blank-settings (into {} (remove (comp nil? val)) settings))
|
(let [{:keys [fps seconds width height palette] :as s} (merge blank-settings (into {} (remove (comp nil? val)) settings))
|
||||||
presets (into {} (map (juxt :id identity)) pal/presets)
|
presets (into {} (map (juxt :id identity)) pal/presets)]
|
||||||
palette (if (contains? presets palette) palette pal/default-id)]
|
|
||||||
{:name (:name s)
|
{:name (:name s)
|
||||||
:fps fps
|
:fps fps
|
||||||
:width width :height height
|
:width width :height height
|
||||||
:palettes (select-keys presets [palette])
|
:palettes presets
|
||||||
:default-palette palette
|
:default-palette (if (contains? presets palette) palette pal/default-id)
|
||||||
:root :main
|
:root :main
|
||||||
:symbols {:main {:id :main :frames (max 1 (js/Math.round (* seconds fps))) :nodes {}}}})))
|
:symbols {:main {:id :main :frames (max 1 (js/Math.round (* seconds fps))) :nodes {}}}})))
|
||||||
|
|
||||||
|
|
@ -307,115 +306,80 @@
|
||||||
(ch/value-at selection frame store)
|
(ch/value-at selection frame store)
|
||||||
:else selection))
|
:else selection))
|
||||||
|
|
||||||
(defn- own-palette
|
(defn palette-at
|
||||||
"The palette symbol `owner` itself chooses at `frame`, or nil when it chooses
|
"The palette symbol `owner` draws in at `frame`, as the stage's root does: a
|
||||||
none and takes what it is in: its palette lane where a segment covers the
|
palette id, or `{:from :to :t}` while its palette lane blends from one to the
|
||||||
frame, else its own `:palette` (which an instance's palette stands in for).
|
next. `inherited` is what an unset palette falls back to, then `default`."
|
||||||
A lane's `inherit` end means the symbol's own palette when it has one, and
|
[clip store default owner frame inherited]
|
||||||
stays `inherit` — whatever the frame is in without this lane — when not.
|
;; A palette track has meaningful uncovered time. Ordinary held
|
||||||
A palette lane has meaningful uncovered time: ordinary held channels clamp to
|
;; channels clamp to their first key before it, but doing that
|
||||||
their first key before it, which here would erase the gap before the first
|
;; here would erase the gap before the first palette segment.
|
||||||
segment."
|
(let [channel-value (partial channel-value store)
|
||||||
[clip store owner frame]
|
fallback (or (channel-value (:palette owner) frame)
|
||||||
(let [own (channel-value store (:palette owner) frame)
|
inherited default)
|
||||||
fill #(if (and own (= pal/inherit %)) own %)
|
materialize (fn [choice]
|
||||||
settle (fn [choice] (if (map? choice) (-> choice (update :from fill) (update :to fill)) (fill choice)))
|
(cond
|
||||||
track (:palette-channel owner)]
|
(= pal/inherit choice) fallback
|
||||||
(or (when-let [track-symbol (some->> (:palette-track owner) (symbol clip))]
|
(map? choice) (-> choice
|
||||||
(let [palette-clip (first
|
(update :from #(if (= pal/inherit %) fallback %))
|
||||||
|
(update :to #(if (= pal/inherit %) fallback %)))
|
||||||
|
:else choice))
|
||||||
|
track (:palette-channel owner)
|
||||||
|
track-value (if-let [ks (:keys track)]
|
||||||
|
(some->> (keys ks)
|
||||||
|
(filter #(<= % frame))
|
||||||
|
sort last
|
||||||
|
(get ks))
|
||||||
|
(channel-value track frame))]
|
||||||
|
(or (when-let [track-sid (and (keyword? (:palette-track owner))
|
||||||
|
(:palette-track owner))]
|
||||||
|
(let [track-symbol (symbol clip track-sid)
|
||||||
|
palette-clip (first
|
||||||
(filter (fn [n]
|
(filter (fn [n]
|
||||||
(let [[a b] (node/placed-span n)]
|
(let [[a b] (node/placed-span n)]
|
||||||
(and a (<= a frame) (< frame b))))
|
(and a (<= a frame) (< frame b))))
|
||||||
(symbol/children (:nodes track-symbol))))
|
(symbol/children (:nodes track-symbol))))
|
||||||
palette-symbol (some-> palette-clip node/source (#(symbol clip %)))
|
palette-symbol (some-> palette-clip node/source
|
||||||
|
(#(symbol clip %)))
|
||||||
|
fallback (when (= :palette (:type palette-symbol))
|
||||||
|
(:palette-ref palette-symbol))
|
||||||
choice (get-in palette-clip [:channels [:palette]])
|
choice (get-in palette-clip [:channels [:palette]])
|
||||||
start (some-> palette-clip node/placed-span first)]
|
start (some-> palette-clip node/placed-span first)]
|
||||||
(or (when (and choice start)
|
(or (when (and choice start)
|
||||||
(settle (channel-value store choice (- frame start))))
|
(materialize (channel-value choice (- frame start))))
|
||||||
(when (= :palette (:type palette-symbol))
|
fallback)))
|
||||||
(:palette-ref palette-symbol)))))
|
track-value
|
||||||
(if-let [ks (:keys track)]
|
fallback)))
|
||||||
(some->> (keys ks) (filter #(<= % frame)) sort last (get ks))
|
|
||||||
(channel-value store track frame))
|
|
||||||
own)))
|
|
||||||
|
|
||||||
(defn- settle
|
|
||||||
"`choice` with an `inherit` end standing for `under`, what the frame would be
|
|
||||||
in without it."
|
|
||||||
[choice under]
|
|
||||||
(let [under (if (map? under) (:from under) under)
|
|
||||||
fill #(if (= pal/inherit %) under %)]
|
|
||||||
(cond
|
|
||||||
(nil? choice) under
|
|
||||||
(map? choice) (-> choice (update :from fill) (update :to fill))
|
|
||||||
:else (fill choice))))
|
|
||||||
|
|
||||||
(defn palette-at
|
|
||||||
"The palette symbol `owner` chooses at `frame`, with what it does not choose
|
|
||||||
standing for `inherited`, then `default`: an id, or `{:from :to :t}` while
|
|
||||||
its palette lane blends."
|
|
||||||
[clip store default owner frame inherited]
|
|
||||||
(settle (own-palette clip store owner frame) (or inherited default)))
|
|
||||||
|
|
||||||
(defn frame-palette
|
|
||||||
"THE ONE PALETTE A FRAME IS IN, from what each symbol drawn in it chooses:
|
|
||||||
`choices` is `[depth choice]` in draw order, the open symbol at depth 0.
|
|
||||||
The SHALLOWEST choice wins — a palette set on the open symbol overrides
|
|
||||||
anything inside it — and between two at one depth the one drawn last, on
|
|
||||||
top. What the winner leaves to `inherit` is the next choice down, and under
|
|
||||||
them all the project's."
|
|
||||||
[default choices]
|
|
||||||
(reduce (fn [under [_ choice]] (settle choice under))
|
|
||||||
default
|
|
||||||
;; Deepest first, so the shallowest settles last; `sort-by` is
|
|
||||||
;; stable, so at one depth the one drawn last does.
|
|
||||||
(sort-by (comp - first) choices)))
|
|
||||||
|
|
||||||
(defn palette-uses
|
|
||||||
"Every palette symbol `sid` and what it places choose, and where:
|
|
||||||
`{:palette :sid :via}`, `:via` being `:symbol` for a symbol's own, `:lane` for
|
|
||||||
its palette lane and `:instance` for an instance set to one. Outermost first,
|
|
||||||
each once. A palette nothing chooses is the one inherited, so is not here."
|
|
||||||
[clip sid]
|
|
||||||
(loop [todo [sid] seen #{} out []]
|
|
||||||
(if-let [s (first todo)]
|
|
||||||
(if (contains? seen s)
|
|
||||||
(recur (rest todo) seen out)
|
|
||||||
(let [sym (symbol clip s)
|
|
||||||
lane (symbol clip (:palette-track sym))
|
|
||||||
use (fn [via x] (map (fn [p] {:palette p :sid s :via via}) (pal/choices x)))
|
|
||||||
nodes (vals (:nodes sym))]
|
|
||||||
(recur (concat (rest todo) (mapcat node/sources (filter #(= :instance (:kind %)) nodes)))
|
|
||||||
(conj seen s)
|
|
||||||
(into out (distinct)
|
|
||||||
(concat (use :symbol (:palette sym))
|
|
||||||
(use :lane (:palette-channel sym))
|
|
||||||
(mapcat (fn [n]
|
|
||||||
(concat (use :lane (:palette-ref (some->> (node/source n) (symbol clip))))
|
|
||||||
(use :lane (get-in n [:channels [:palette]]))))
|
|
||||||
(vals (:nodes lane)))
|
|
||||||
(mapcat #(use :instance (:palette %)) nodes))))))
|
|
||||||
(vec (distinct out)))))
|
|
||||||
|
|
||||||
(defn resolver
|
(defn resolver
|
||||||
"Resolve an output frame, selecting native content at each symbol boundary.
|
"Resolve an output frame, selecting native content at each symbol boundary.
|
||||||
Every instance owns its cursors and buffers. The IResolver queries return
|
Every instance owns its cursors and buffers. The IResolver queries return
|
||||||
native node frames and world matrices for the last rendered output frame."
|
native node frames and world matrices for the last rendered output frame."
|
||||||
[clip sid store palette opts]
|
[clip sid store palette opts]
|
||||||
(let [context? (and (map? palette) (contains? palette :palettes))
|
(let [context? (and (map? palette) (:palettes palette) (:offsets palette))
|
||||||
active-palette-state (atom (:default palette))
|
active-palette-state (atom (:default palette))]
|
||||||
;; What each symbol drawn this frame chooses, as `[depth choice]`.
|
(letfn [(root-selection-at [owner frame inherited]
|
||||||
chosen (volatile! [])]
|
(palette-at clip store (:default palette) owner frame inherited))
|
||||||
(letfn [(build [sid chain pose-tracks root?]
|
(selection-at [owner frame inherited]
|
||||||
|
(let [selection (:palette owner)
|
||||||
|
chosen (cond
|
||||||
|
(nil? selection) nil
|
||||||
|
(and (map? selection) (contains? selection :animated?))
|
||||||
|
(ch/value-at selection frame store)
|
||||||
|
:else selection)]
|
||||||
|
(or chosen inherited (:default palette))))
|
||||||
|
(build [sid chain pose-tracks root?]
|
||||||
(when (some #{sid} chain)
|
(when (some #{sid} chain)
|
||||||
(throw (ex-info "symbol cycle" {:chain (conj chain sid)})))
|
(throw (ex-info "symbol cycle" {:chain (conj chain sid)})))
|
||||||
(let [sym (or (symbol clip sid)
|
(let [sym (or (symbol clip sid)
|
||||||
(throw (ex-info "an instance names a missing symbol" {:symbol sid})))
|
(throw (ex-info "an instance names a missing symbol" {:symbol sid})))
|
||||||
depth (count chain)
|
active (volatile! (when context? (:default palette)))
|
||||||
nodes (:nodes sym)
|
nodes (:nodes sym)
|
||||||
rank (symbol/draw-rank nodes (symbol/order nodes))
|
rank (symbol/draw-rank nodes (symbol/order nodes))
|
||||||
ids (sort-by rank (keys nodes))
|
ids (sort-by rank (keys nodes))
|
||||||
own (symbol/resolver sym store (if context? pal/slot palette)
|
own (symbol/resolver sym store (if context?
|
||||||
|
#(pal/render-index palette @active %)
|
||||||
|
palette)
|
||||||
(assoc opts :pose-tracks pose-tracks))
|
(assoc opts :pose-tracks pose-tracks))
|
||||||
;; Each cel owns its source resolver and mutable buffers. A
|
;; Each cel owns its source resolver and mutable buffers. A
|
||||||
;; tracing symbol has nothing to resolve: it is one op.
|
;; tracing symbol has nothing to resolve: it is one op.
|
||||||
|
|
@ -435,18 +399,16 @@
|
||||||
;; A symbol that knocks out is drawn into a layer of its own,
|
;; A symbol that knocks out is drawn into a layer of its own,
|
||||||
;; so what it clears is only ever its own.
|
;; so what it clears is only ever its own.
|
||||||
layered? (symbol/knocks? nodes)
|
layered? (symbol/knocks? nodes)
|
||||||
;; Each symbol drawn says which palette it chooses, if any;
|
step (fn [f pre inherited forced]
|
||||||
;; the root, once all are drawn, makes the frame's ONE
|
|
||||||
;; palette of them. Shapes draw slots, so nothing drawn
|
|
||||||
;; depends on which. An instance's palette stands in for the
|
|
||||||
;; symbol's own, so its lane still plays.
|
|
||||||
step (fn [f pre override]
|
|
||||||
(when root? (vreset! chosen []))
|
|
||||||
(when context?
|
(when context?
|
||||||
(when-let [c (own-palette clip store
|
(vreset! active (or forced
|
||||||
(cond-> sym override (assoc :palette override))
|
(if root?
|
||||||
(js/Math.floor f))]
|
(root-selection-at sym (js/Math.floor f) inherited)
|
||||||
(vswap! chosen conj [depth c])))
|
inherited)
|
||||||
|
(:default palette))))
|
||||||
|
;; The same decision that maps local drawing slots to
|
||||||
|
;; the active bank also names the clear colour.
|
||||||
|
(when root? (reset! active-palette-state @active))
|
||||||
(vreset! entered {})
|
(vreset! entered {})
|
||||||
(let [by-id (into {} (map (juxt :node identity))
|
(let [by-id (into {} (map (juxt :node identity))
|
||||||
(own (js/Math.floor f) (js/Math.floor pre)))]
|
(own (js/Math.floor f) (js/Math.floor pre)))]
|
||||||
|
|
@ -488,15 +450,17 @@
|
||||||
(or (:frame (when (number? prior)
|
(or (:frame (when (number? prior)
|
||||||
(placed-frame clip n prior)))
|
(placed-frame clip n prior)))
|
||||||
(dec frame))
|
(dec frame))
|
||||||
(:palette n))))))
|
@active
|
||||||
|
(when (and context? (:palette n))
|
||||||
|
(selection-at n frame nil)))))))
|
||||||
(when-let [op (get by-id id)] [op]))))
|
(when-let [op (get by-id id)] [op]))))
|
||||||
ids))
|
ids))
|
||||||
layered? (conj {:kind :end :node []}))))]
|
layered? (conj {:kind :end :node []}))))]
|
||||||
(reify
|
(reify
|
||||||
IFn
|
IFn
|
||||||
(-invoke [_ f] (step f (dec f) nil))
|
(-invoke [_ f] (step f (dec f) nil nil))
|
||||||
(-invoke [_ f pre] (step f pre nil))
|
(-invoke [_ f pre] (step f pre nil nil))
|
||||||
(-invoke [_ f pre override] (step f pre override))
|
(-invoke [_ f pre inherited forced] (step f pre inherited forced))
|
||||||
symbol/IResolver
|
symbol/IResolver
|
||||||
(world-of [_ [id & more]]
|
(world-of [_ [id & more]]
|
||||||
(if more
|
(if more
|
||||||
|
|
@ -520,11 +484,7 @@
|
||||||
IFn
|
IFn
|
||||||
;; `pre` is the frame before, so a child placed at a speed is handed
|
;; `pre` is the frame before, so a child placed at a speed is handed
|
||||||
;; the interval `(pre, f]` its preserve-snap may reach back into.
|
;; the interval `(pre, f]` its preserve-snap may reach back into.
|
||||||
(-invoke [_ f]
|
(-invoke [_ f] (r f (dec f) (when context? (:default palette)) nil))
|
||||||
(let [ops (r f (dec f))]
|
|
||||||
(when context?
|
|
||||||
(reset! active-palette-state (frame-palette (:default palette) @chosen)))
|
|
||||||
ops))
|
|
||||||
symbol/IResolver
|
symbol/IResolver
|
||||||
(world-of [_ path] (symbol/world-of r path))
|
(world-of [_ path] (symbol/world-of r path))
|
||||||
(frame-of [_ path] (symbol/frame-of r path))
|
(frame-of [_ path] (symbol/frame-of r path))
|
||||||
|
|
@ -595,9 +555,7 @@
|
||||||
of the symbol plays on `frame` of `host`, which is what dragging something onto
|
of the symbol plays on `frame` of `host`, which is what dragging something onto
|
||||||
a playhead is asking for. Its `:span` is in its OWN frames — the whole symbol,
|
a playhead is asking for. Its `:span` is in its OWN frames — the whole symbol,
|
||||||
0 to its length at `speed` — wherever it was dropped; see `node/placed-span`.
|
0 to its length at `speed` — wherever it was dropped; see `node/placed-span`.
|
||||||
`speed` is 1 unless the symbol's frames are footage's at another rate, and 0
|
`speed` is 1 unless the symbol's frames are footage's at another rate.
|
||||||
for a held cel, which shows its symbol's first frame and so starts one frame
|
|
||||||
long, as `span/held` does.
|
|
||||||
|
|
||||||
Refused, returning the clip unchanged, when it would make a cycle: a symbol
|
Refused, returning the clip unchanged, when it would make a cycle: a symbol
|
||||||
cannot be placed inside itself or inside anything it places."
|
cannot be placed inside itself or inside anything it places."
|
||||||
|
|
@ -617,7 +575,7 @@
|
||||||
;; Lexicographic draw order, as `domain/paint` does it: an instance made
|
;; Lexicographic draw order, as `domain/paint` does it: an instance made
|
||||||
;; later sits above one made earlier, and neither has to renumber.
|
;; later sits above one made earlier, and neither has to renumber.
|
||||||
:z (str "z" (js/Date.now) "-" (name sid))
|
:z (str "z" (js/Date.now) "-" (name sid))
|
||||||
:span [0 (if (pos? speed) (js/Math.ceil (/ (:frames target) speed)) 1)]
|
:span [0 (js/Math.ceil (/ (:frames target) speed))]
|
||||||
:time {:mode :map :at frame :rate 1}
|
:time {:mode :map :at frame :rate 1}
|
||||||
:source {:symbol sid}
|
:source {:symbol sid}
|
||||||
:playback {:in 0 :speed speed :end :stop}
|
:playback {:in 0 :speed speed :end :stop}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,7 @@
|
||||||
interpolating matrix entries is meaningless: a rotation tweened through its
|
interpolating matrix entries is meaningless: a rotation tweened through its
|
||||||
matrix shears on the way. Flat Float64Array for evaluation because at 30fps
|
matrix shears on the way. Flat Float64Array for evaluation because at 30fps
|
||||||
per-frame allocation is the only thing that will make this stutter."
|
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
|
(def kinds
|
||||||
"`:bitmap` is in the vocabulary and not implemented; it is
|
"`:bitmap` is in the vocabulary and not implemented; it is
|
||||||
|
|
@ -109,17 +108,6 @@
|
||||||
[:audio :pan] (ch/framed 0.0)
|
[:audio :pan] (ch/framed 0.0)
|
||||||
[:audio :rate] (ch/framed 1.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]
|
(defn defaults-of [n]
|
||||||
(if (= :audio (:kind n)) audio-defaults defaults))
|
(if (= :audio (:kind n)) audio-defaults defaults))
|
||||||
|
|
||||||
|
|
@ -210,19 +198,6 @@
|
||||||
(:segments c) (update :segments dissoc f))
|
(:segments c) (update :segments dissoc f))
|
||||||
:else (ch/framed v))))))
|
:else (ch/framed v))))))
|
||||||
|
|
||||||
(defn key-at
|
|
||||||
"Key `n` on its own frame `f` with the values it has there: every channel
|
|
||||||
already keyed, or its position, turn and scale when none is — Blender's I.
|
|
||||||
A channel with a key at `f` already keeps it."
|
|
||||||
[n f store]
|
|
||||||
(let [chs (channels n)
|
|
||||||
keyed (keep (fn [[path c]] (when (:keys c) path)) chs)]
|
|
||||||
(reduce (fn [n path]
|
|
||||||
(if (contains? (:keys (get (channels n) path)) f) n (toggle-key n path f store)))
|
|
||||||
n
|
|
||||||
(or (seq keyed)
|
|
||||||
(filter #(contains? chs %) [[:xform :pos] [:xform :rot] [:xform :scale]])))))
|
|
||||||
|
|
||||||
(defn set-segment-interp
|
(defn set-segment-interp
|
||||||
"Choose how channel `path`'s key at `left` leads to the next one: `:hold` cuts
|
"Choose how channel `path`'s key at `left` leads to the next one: `:hold` cuts
|
||||||
there, `:linear` tweens. The same for a drawing's points as for a transform —
|
there, `:linear` tweens. The same for a drawing's points as for a transform —
|
||||||
|
|
|
||||||
|
|
@ -64,30 +64,10 @@
|
||||||
free)})
|
free)})
|
||||||
|
|
||||||
(def presets
|
(def presets
|
||||||
"Palettes borrowed from worlds that already work in sixteen colours or fewer:
|
"Palettes a new project starts with, borrowed from worlds that already work
|
||||||
a shelf to start a project from or add to one, kept out of the project until
|
in sixteen colours or fewer. Only the one a project draws with costs it
|
||||||
then. A sixteen-colour machine's palette is all sixteen of its colours, each
|
anything; the rest are there to switch to."
|
||||||
once, the face tones picked from them; a four-colour one repeats, and a face
|
|
||||||
in it reads by value alone, as on a Game Boy."
|
|
||||||
[default-palette
|
[default-palette
|
||||||
;; The sixteen colours of the IBM PC's text modes, which VGA kept from EGA
|
|
||||||
;; and CGA: the DOS blue behind, the light red and brown every EGA face was.
|
|
||||||
(preset :arthur/vga "VGA"
|
|
||||||
["#0000aa" "#ff5555" "#aa5500" "#aa0000" "#ffffff" "#aaaaaa" "#00aaaa" "#000000" "#555555"]
|
|
||||||
["#00aa00" "#aa00aa" "#55ff55" "#55ffff" "#ff55ff" "#ffff55" "#5555ff"])
|
|
||||||
;; The Commodore 64's VIC-II as Pepto measured it, on its own blue screen.
|
|
||||||
(preset :arthur/c64 "Commodore 64"
|
|
||||||
["#352879" "#9a6759" "#6f4f25" "#68372b" "#ffffff" "#959595" "#70a4b2" "#000000" "#433900"]
|
|
||||||
["#6f3d86" "#588d43" "#b8c76f" "#444444" "#6c6c6c" "#9ad284" "#6c5eb5"])
|
|
||||||
;; CGA's four-colour mode, palette 1 at high intensity: magenta skin shaded
|
|
||||||
;; in cyan, as it was.
|
|
||||||
(preset :arthur/cga "CGA"
|
|
||||||
["#000000" "#ff55ff" "#55ffff" "#000000" "#ffffff" "#ffffff" "#55ffff" "#000000" "#000000"]
|
|
||||||
["#ff55ff" "#55ffff" "#ffffff" "#000000" "#ff55ff" "#55ffff" "#ffffff"])
|
|
||||||
;; The Amiga's Workbench 1.3: four colours, blue, white, black and orange.
|
|
||||||
(preset :arthur/workbench "Workbench 1.3"
|
|
||||||
["#0055aa" "#ff8800" "#000022" "#000022" "#ffffff" "#ffffff" "#0055aa" "#000022" "#000022"]
|
|
||||||
["#0055aa" "#ffffff" "#000022" "#ff8800" "#0055aa" "#ffffff" "#ff8800"])
|
|
||||||
;; Lexaloffle's PICO-8, all sixteen, its peach and brown as the skin ramp.
|
;; Lexaloffle's PICO-8, all sixteen, its peach and brown as the skin ramp.
|
||||||
(preset :arthur/pico-8 "PICO-8"
|
(preset :arthur/pico-8 "PICO-8"
|
||||||
["#1d2b53" "#ffccaa" "#ab5236" "#7e2553" "#fff1e8" "#c2c3c7" "#29adff" "#000000" "#5f574f"]
|
["#1d2b53" "#ffccaa" "#ab5236" "#7e2553" "#fff1e8" "#c2c3c7" "#29adff" "#000000" "#5f574f"]
|
||||||
|
|
@ -119,133 +99,89 @@
|
||||||
(when (contains? ps default-id) default-id)
|
(when (contains? ps default-id) default-id)
|
||||||
(first (sort-by str (keys ps))))))
|
(first (sort-by str (keys ps))))))
|
||||||
|
|
||||||
;; ONE PALETTE PER FRAME
|
(defn- slot-index [p value]
|
||||||
;;
|
|
||||||
;; A frame is drawn in exactly one palette, or one blend of two while a palette
|
|
||||||
;; lane tweens. Drawing data stores slot numbers, so the raster index IS the
|
|
||||||
;; slot, and the palette is only the ramp the raster is expanded through. Which
|
|
||||||
;; palette a frame is in is decided by the open symbol's tree; see
|
|
||||||
;; `clip/resolver`.
|
|
||||||
|
|
||||||
(def bg-slot
|
|
||||||
"Slot zero is what a frame is cleared to, in whichever palette it is in."
|
|
||||||
0)
|
|
||||||
|
|
||||||
(defn slot
|
|
||||||
"A shape's colour as a raster index: its slot number, or a legacy tone
|
|
||||||
keyword's place in `entries`. Anything else is 255, the conspicuous
|
|
||||||
bad-data sentinel, which the ramp has no colour for and so shows MAGENTA."
|
|
||||||
[value]
|
|
||||||
(cond
|
(cond
|
||||||
(and (integer? value) (<= 0 value) (< value 255)) value
|
(and (integer? value) (<= 0 value) (< value (count (:slots p)))) value
|
||||||
;; Compatibility for existing documents. New drawing data is numeric.
|
;; Compatibility for existing documents. New drawing data is numeric.
|
||||||
(keyword? value) (get index-of value 255)
|
(keyword? value) (first (keep-indexed #(when (= value (:name %2)) %1) (:slots p)))
|
||||||
:else 255))
|
:else nil))
|
||||||
|
|
||||||
(defn choices
|
(defn compile
|
||||||
"The palette ids a palette setting can name: the one it holds, or each its
|
"Compile the project's palette assets into the one ramp used by the raster.
|
||||||
keys do. `inherit` is not one."
|
Index 255 remains the conspicuous bad-data sentinel."
|
||||||
[x]
|
[clip]
|
||||||
(remove #(= inherit %)
|
(let [selection-values (fn [x]
|
||||||
(cond
|
(cond
|
||||||
(nil? x) []
|
(nil? x) []
|
||||||
(and (map? x) (:keys x)) (vals (:keys x))
|
(and (map? x) (:keys x)) (vals (:keys x))
|
||||||
(and (map? x) (contains? x :value)) [(:value x)]
|
(and (map? x) (contains? x :value)) [(:value x)]
|
||||||
:else [x])))
|
:else [x]))
|
||||||
|
used (into #{(default-palette-id clip)}
|
||||||
|
(mapcat selection-values)
|
||||||
|
(concat (map :palette (vals (:symbols clip)))
|
||||||
|
(map :palette-channel (vals (:symbols clip)))
|
||||||
|
(map (fn [sym]
|
||||||
|
(when (= :palette (:type sym)) (:palette-ref sym)))
|
||||||
|
(vals (:symbols clip)))
|
||||||
|
(for [sym (vals (:symbols clip))
|
||||||
|
n (vals (:nodes sym))]
|
||||||
|
(:palette n))
|
||||||
|
(for [sym (vals (:symbols clip))
|
||||||
|
n (vals (:nodes sym))]
|
||||||
|
(get-in n [:channels [:palette]]))))
|
||||||
|
ps (select-keys (palettes clip) used)
|
||||||
|
ordered (sort-by (comp str key) ps)
|
||||||
|
offsets (loop [xs ordered at 0 out {}]
|
||||||
|
(if-let [[id p] (first xs)]
|
||||||
|
(recur (next xs) (+ at (count (:slots p))) (assoc out id at))
|
||||||
|
out))
|
||||||
|
total (reduce + (map #(count (:slots (val %))) ordered))]
|
||||||
|
(when (> total 255)
|
||||||
|
(throw (ex-info "palettes visible in one render use more than 255 slots"
|
||||||
|
{:slots total :palettes (count ps)})))
|
||||||
|
{:palettes ps
|
||||||
|
:default (default-palette-id clip)
|
||||||
|
:offsets offsets
|
||||||
|
:ramp (vec (mapcat (fn [[_ p]] (map #(hex->rgb (:hex %)) (:slots p))) ordered))
|
||||||
|
:bg (get offsets (default-palette-id clip) 0)}))
|
||||||
|
|
||||||
(defn compile
|
(defn render-index
|
||||||
"The project's palettes and the one a frame falls back to, for a renderer."
|
"A local slot (or a legacy tone keyword) in palette `id` -> raster index."
|
||||||
[clip]
|
[{:keys [palettes offsets]} id value]
|
||||||
{:palettes (palettes clip)
|
(let [id (if (map? id) (:from id) id)
|
||||||
:default (default-palette-id clip)})
|
p (get palettes id)
|
||||||
|
i (and p (slot-index p value))]
|
||||||
|
(if (some? i) (+ (get offsets id 0) i) 255)))
|
||||||
|
|
||||||
(defn ramp-of
|
(defn background-index
|
||||||
"A strip of hex colours as the ramp a raster is expanded through."
|
"The raster index of slot zero in the resolver's active palette.
|
||||||
[hexes]
|
|
||||||
(mapv hex->rgb hexes))
|
`index-of` remains a supported legacy palette map for domain callers; it has
|
||||||
|
no palette banks or active selection, so its established `:bg` index applies."
|
||||||
|
[palette active]
|
||||||
|
(if (and (:palettes palette) (:offsets palette))
|
||||||
|
(render-index palette active 0)
|
||||||
|
(get palette :bg 0)))
|
||||||
|
|
||||||
(defn effective-ramp
|
(defn effective-ramp
|
||||||
"The ramp of the active palette: an id, or `{:from :to :t}` while a palette
|
"The compiled ramp with the active palette blend applied. A hold returns the
|
||||||
lane blends, which is one pseudopalette mixed slot by slot. A slot only one
|
original vector; a linear palette segment rewrites only the left palette's
|
||||||
end has keeps its colour."
|
bank, which is the bank the indexed raster was drawn into."
|
||||||
[{:keys [palettes default]} active]
|
[{:keys [palettes offsets ramp]} active]
|
||||||
(let [ramp #(ramp-of (map :hex (:slots (get palettes %))))]
|
|
||||||
(if-let [{:keys [from to t]} (when (map? active) active)]
|
(if-let [{:keys [from to t]} (when (map? active) active)]
|
||||||
(let [a (ramp from) b (ramp to)]
|
(let [a (get palettes from)
|
||||||
(if (number? t)
|
b (get palettes to)
|
||||||
(into (mapv (fn [x y] (mapv #(js/Math.round (+ %1 (* t (- %2 %1)))) x y)) a b)
|
at (get offsets from)
|
||||||
(drop (count b) a))
|
n (min (count (:slots a)) (count (:slots b)))]
|
||||||
a))
|
(if (and a b (number? at) (number? t))
|
||||||
(ramp (if (contains? palettes active) active default)))))
|
(reduce (fn [out i]
|
||||||
|
(let [x (hex->rgb (get-in a [:slots i :hex]))
|
||||||
(defn solo-ramp
|
y (hex->rgb (get-in b [:slots i :hex]))]
|
||||||
"`ramp` with every slot but `shown` faded most of the way to the background,
|
(assoc out (+ at i)
|
||||||
so what is drawn in `shown` is all that stands out."
|
(mapv #(js/Math.round (+ %1 (* t (- %2 %1)))) x y))))
|
||||||
[ramp shown]
|
ramp (range n))
|
||||||
(let [bg (get ramp bg-slot [0 0 0])
|
ramp))
|
||||||
fade (fn [c] (mapv (fn [x b] (js/Math.round (+ b (* 0.2 (- x b))))) c bg))]
|
ramp))
|
||||||
(into [] (map-indexed (fn [i c] (if (= i shown) c (fade c)))) ramp)))
|
|
||||||
|
|
||||||
;; ---------------------------------------------------------------------------
|
|
||||||
;; which slots drawing uses
|
|
||||||
;;
|
|
||||||
;; A slot number means the same place in EVERY palette — that is what lets one
|
|
||||||
;; drawing be shown in any of them — so a slot is in use when any shape names
|
|
||||||
;; it, whichever palette it is seen in.
|
|
||||||
|
|
||||||
(defn- colour-slots
|
|
||||||
"The slots a colour channel names at any key: a slot, a legacy tone, or both
|
|
||||||
sides of a remap's map. A knockout names none."
|
|
||||||
[ch]
|
|
||||||
(let [values (if (:keys ch) (vals (:keys ch)) [(:value ch)])]
|
|
||||||
(into #{}
|
|
||||||
(comp (mapcat (fn [v]
|
|
||||||
(cond
|
|
||||||
(and (vector? v) (= :remap (first v))) (mapcat identity (second v))
|
|
||||||
(= :clear v) []
|
|
||||||
:else [v])))
|
|
||||||
(map slot)
|
|
||||||
(remove #{255}))
|
|
||||||
values)))
|
|
||||||
|
|
||||||
(defn slots-used
|
|
||||||
"Every slot a shape in `symbols` names."
|
|
||||||
[symbols]
|
|
||||||
(into #{}
|
|
||||||
(mapcat #(some-> (get-in % [:channels [:style :color]]) colour-slots))
|
|
||||||
(mapcat (comp vals :nodes) symbols)))
|
|
||||||
|
|
||||||
(def empty-slot
|
|
||||||
"A slot with nothing in it: black, unnamed, as a new palette's free ones are."
|
|
||||||
{:hex "#000000"})
|
|
||||||
|
|
||||||
(defn emptyable
|
|
||||||
"The slots of palette `p` that can be emptied: none of `used` names them, and
|
|
||||||
they are not already empty. Slot zero is the background, and a NAMED slot is
|
|
||||||
a face tone measurement draws in whether or not anything uses it yet."
|
|
||||||
[p used]
|
|
||||||
(into []
|
|
||||||
(keep-indexed (fn [i s] (when-not (or (contains? used i) (= bg-slot i) (:name s)
|
|
||||||
(= empty-slot (select-keys s [:hex :name])))
|
|
||||||
i)))
|
|
||||||
(:slots p)))
|
|
||||||
|
|
||||||
(defn empty-slots
|
|
||||||
"Palette `p` with slots `is` emptied. They stay where they are, so no
|
|
||||||
drawing's slot number changes and the palette keeps its size."
|
|
||||||
[p is]
|
|
||||||
(reduce #(assoc-in %1 [:slots %2] empty-slot) p is))
|
|
||||||
|
|
||||||
(defn hexes-of [p] (mapv :hex (:slots p)))
|
|
||||||
|
|
||||||
(defn from-hexes
|
|
||||||
"A palette asset from a strip of colours, its slots named as `entries` are so
|
|
||||||
a legacy tone keyword still finds its slot."
|
|
||||||
[id label hexes]
|
|
||||||
{:id id :name label
|
|
||||||
:slots (into (mapv (fn [e hex] {:name (:name e) :hex hex}) entries hexes)
|
|
||||||
(map (fn [hex] {:hex hex}))
|
|
||||||
(drop (count entries) hexes))})
|
|
||||||
|
|
||||||
(defn valid-palette? [{:keys [id name slots]}]
|
(defn valid-palette? [{:keys [id name slots]}]
|
||||||
(and id (string? name) (seq name) (vector? slots) (pos? (count slots))
|
(and id (string? name) (seq name) (vector? slots) (pos? (count slots))
|
||||||
|
|
|
||||||
|
|
@ -778,51 +778,6 @@
|
||||||
nodes (assoc nodes id (held id drawing-id at))]
|
nodes (assoc nodes id (held id drawing-id at))]
|
||||||
(claim c sid nodes id extent remainder-id)))))
|
(claim c sid nodes id extent remainder-id)))))
|
||||||
|
|
||||||
(defn drawing-at
|
|
||||||
"A new drawing in lane `sid` from frame `f`, as Flash's F6 and F7 make one:
|
|
||||||
a copy of the drawing showing there when `copy?`, an empty one when not.
|
|
||||||
|
|
||||||
IT TAKES OVER FROM `f`. Inside a hold, the held cel ends at `f` and the new
|
|
||||||
one has the rest of it, so the timing already there is kept and only the
|
|
||||||
drawing changes. In a gap it runs to the next cel; past the last one it is one
|
|
||||||
frame. On a cel's first frame there is a drawing starting there already, so
|
|
||||||
the new one goes on the frame after — pressing F6 again and again draws on,
|
|
||||||
one frame at a time — and shows the drawing it came after.
|
|
||||||
|
|
||||||
The copy is of the content, shallow, as `duplicate-drawing`'s is, under a name
|
|
||||||
of its own. `:frame` in the result is where it landed."
|
|
||||||
[clip sid f new-id drawing-id {:keys [copy? extent] :or {extent :keep}}]
|
|
||||||
(let [nodes (get-in clip [:symbols sid :nodes])
|
|
||||||
cels (symbol/children nodes)
|
|
||||||
lo-of #(first (node/placed-span %))
|
|
||||||
hi-of #(second (node/placed-span %))
|
|
||||||
on (some #(when (= f (lo-of %)) %) cels)
|
|
||||||
f (if on (inc f) f)
|
|
||||||
holding (some #(when (< (lo-of %) f (hi-of %)) %) cels)
|
|
||||||
shown (or holding on (last (filter #(<= (hi-of %) f) cels)))
|
|
||||||
next-lo (some #(when (<= f (lo-of %)) (lo-of %)) cels)
|
|
||||||
from (when copy? (some-> shown node/source))]
|
|
||||||
(cond
|
|
||||||
(not (and (integer? f) (not (neg? f)))) {:refused "a position is a nonnegative whole frame"}
|
|
||||||
(contains? nodes new-id) {:refused "the new clip ID is already used"}
|
|
||||||
(clip/symbol clip drawing-id) {:refused "the new drawing ID is already used"}
|
|
||||||
(and copy? (not (clip/symbol clip from))) {:refused "there is no drawing here to copy"}
|
|
||||||
:else
|
|
||||||
(let [c (assoc-in clip [:symbols drawing-id]
|
|
||||||
(if from
|
|
||||||
;; Its own name: it is a new drawing, and two of one
|
|
||||||
;; name in the library is a question nobody asked.
|
|
||||||
(assoc (clip/symbol clip from) :id drawing-id :name (name drawing-id))
|
|
||||||
{:id drawing-id :name (name drawing-id) :frames 1 :nodes {}}))]
|
|
||||||
(if (= f next-lo)
|
|
||||||
;; A cel starts right here, so there is no room: make some.
|
|
||||||
(place c sid new-id drawing-id f extent true)
|
|
||||||
(let [end (cond holding (hi-of holding) next-lo next-lo :else (inc f))
|
|
||||||
nodes (cond-> (assoc nodes new-id (assoc (held new-id drawing-id f) :span [0 (- end f)]))
|
|
||||||
holding (assoc (:id holding) (edged holding :out f)))]
|
|
||||||
(let [result (finish c sid nodes new-id extent)]
|
|
||||||
(cond-> result (:clip result) (assoc :frame f)))))))))
|
|
||||||
|
|
||||||
(defn make-unique
|
(defn make-unique
|
||||||
"Point clip `id` at a private copy of its content, leaving every other
|
"Point clip `id` at a private copy of its content, leaving every other
|
||||||
clip of that drawing sharing the original.
|
clip of that drawing sharing the original.
|
||||||
|
|
|
||||||
|
|
@ -78,22 +78,18 @@
|
||||||
the other instances removed, which is why seven instances of one symbol are
|
the other instances removed, which is why seven instances of one symbol are
|
||||||
seven different exports rather than seven copies of one.
|
seven different exports rather than seven copies of one.
|
||||||
|
|
||||||
Instances are labelled by `clip/node-label` — the symbol they place — and
|
Instances are ordered and labelled by `clip/node-label`, never by id: a uuid
|
||||||
numbered in stacking order where one symbol is placed more than once, never
|
sorts at random and means nothing to read."
|
||||||
by id: a uuid sorts at random and means nothing to read."
|
|
||||||
[clip open]
|
[clip open]
|
||||||
(let [label #(clip/node-label clip %1 %2)
|
(let [label #(clip/node-label clip %1 %2)
|
||||||
instances (->> (get-in clip [:symbols open :nodes])
|
instances (->> (get-in clip [:symbols open :nodes])
|
||||||
(filter (comp #{:instance} :kind val))
|
(filter (comp #{:instance} :kind val))
|
||||||
(sort-by (fn [[id n]] [(label id n) (or (:z n) "") (str id)])))
|
(sort-by (fn [[id n]] [(label id 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)})
|
(into (mapv (fn [sid] {:symbol sid :label (name sid)})
|
||||||
(sort-by str (keys (:symbols clip))))
|
(sort-by str (keys (:symbols clip))))
|
||||||
(mapv (fn [[id l]] {:symbol open :isolate id :label l}) numbered))))
|
(mapv (fn [[id n]]
|
||||||
|
{:symbol open :isolate id :label (label id n)})
|
||||||
|
instances))))
|
||||||
|
|
||||||
(defn target
|
(defn target
|
||||||
"What the export is pointed at. A nil symbol is whichever one is open, so a
|
"What the export is pointed at. A nil symbol is whichever one is open, so a
|
||||||
|
|
@ -159,7 +155,7 @@
|
||||||
;; through. Read here rather than in the fx so that the effect
|
;; through. Read here rather than in the fx so that the effect
|
||||||
;; takes data and nothing else.
|
;; takes data and nothing else.
|
||||||
:palette (pal/compile (:clip entry))
|
:palette (pal/compile (:clip entry))
|
||||||
:ramp (let [p (pal/compile (:clip entry))] (pal/effective-ramp p (:default p)))
|
:ramp (:ramp (pal/compile (:clip entry)))
|
||||||
:zoom zoom
|
:zoom zoom
|
||||||
:audio-url (:audio entry)
|
:audio-url (:audio entry)
|
||||||
:name (stem (:label entry)
|
:name (stem (:label entry)
|
||||||
|
|
|
||||||
|
|
@ -71,3 +71,28 @@
|
||||||
(:paint/revision db)
|
(:paint/revision db)
|
||||||
(history/steps (:history (store/entry (:clip/current db))))))
|
(history/steps (:history (store/entry (:clip/current db))))))
|
||||||
|
|
||||||
|
(defn- typing? [^js target]
|
||||||
|
(or (#{"INPUT" "TEXTAREA" "SELECT"} (.-tagName target)) (.-isContentEditable target)))
|
||||||
|
|
||||||
|
(defn install-keys!
|
||||||
|
"The document edit keys. Not while typing in a field, where the browser's own
|
||||||
|
clipboard and undo stack are the ones wanted."
|
||||||
|
[]
|
||||||
|
(.addEventListener
|
||||||
|
js/window "keydown"
|
||||||
|
(fn [^js e]
|
||||||
|
(when-not (typing? (.-target e))
|
||||||
|
(let [k (.toLowerCase (.-key e))]
|
||||||
|
(when-let [ev (if (and (or (.-metaKey e) (.-ctrlKey e))
|
||||||
|
(not (.-altKey e)))
|
||||||
|
(cond (and (= k "z") (.-shiftKey e)) ::redo
|
||||||
|
(= k "z") ::undo
|
||||||
|
(= k "y") ::redo
|
||||||
|
(= k "c") ::ui/copy
|
||||||
|
(= k "x") ::ui/cut
|
||||||
|
(= k "v") ::ui/paste
|
||||||
|
(and (= k "d") (.-shiftKey e)) ::ui/duplicate-unique
|
||||||
|
(= k "d") ::ui/duplicate)
|
||||||
|
(when (#{"delete" "backspace"} k) ::ui/delete-selected))]
|
||||||
|
(.preventDefault e)
|
||||||
|
(rf/dispatch [ev])))))))
|
||||||
|
|
|
||||||
|
|
@ -63,28 +63,11 @@
|
||||||
(get-in db [:ui :gesture :auto-key?])
|
(get-in db [:ui :gesture :auto-key?])
|
||||||
(assoc :dispatch [:arthur.events.ui/record-gesture f])))))
|
(assoc :dispatch [:arthur.events.ui/record-gesture f])))))
|
||||||
|
|
||||||
(defn bounds
|
(rf/reg-event-fx
|
||||||
"The frames playback runs between, both included: the open tab's in and out
|
::play
|
||||||
marks, or the whole symbol where one is not set."
|
(fn [{:keys [db]} _]
|
||||||
[db]
|
{:db (assoc-in db [:playback :playing?] true)
|
||||||
(let [n (frames db)
|
::play-from! [(fps db) (frames db) (get-in db [:playback :frame] 0)]}))
|
||||||
{:keys [in out]} (get-in db [:playback :range (get-in db [:ui :open])])]
|
|
||||||
[(or in 0) (min (dec n) (or out (dec n)))]))
|
|
||||||
|
|
||||||
(defn- start
|
|
||||||
"Play from the playhead, wherever it is — before the in mark or past the out
|
|
||||||
— or from the in mark when it is on the last frame. Playing the last frame
|
|
||||||
alone is a twenty-fourth of a second and then silence, so play there looked
|
|
||||||
like a button that did nothing."
|
|
||||||
[db]
|
|
||||||
(let [n (frames db)
|
|
||||||
[lo] (bounds db)
|
|
||||||
f (get-in db [:playback :frame] 0)
|
|
||||||
f (if (< f (dec n)) f lo)]
|
|
||||||
{:db (update db :playback assoc :playing? true :frame f)
|
|
||||||
::play-from! [(fps db) n f]}))
|
|
||||||
|
|
||||||
(rf/reg-event-fx ::play (fn [{:keys [db]} _] (start db)))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
::pause
|
::pause
|
||||||
|
|
@ -97,7 +80,8 @@
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
(if (get-in db [:playback :playing?])
|
(if (get-in db [:playback :playing?])
|
||||||
{:db (assoc-in db [:playback :playing?] false) ::pause! nil}
|
{:db (assoc-in db [:playback :playing?] false) ::pause! nil}
|
||||||
(start db))))
|
{:db (assoc-in db [:playback :playing?] true)
|
||||||
|
::play-from! [(fps db) (frames db) (get-in db [:playback :frame] 0)]})))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
::seek
|
::seek
|
||||||
|
|
@ -111,37 +95,6 @@
|
||||||
(fn [{:keys [db]} [_ delta]]
|
(fn [{:keys [db]} [_ delta]]
|
||||||
{:fx [[:dispatch [::seek (+ (get-in db [:playback :frame]) delta)]]]}))
|
{:fx [[:dispatch [::seek (+ (get-in db [:playback :frame]) delta)]]]}))
|
||||||
|
|
||||||
(rf/reg-event-db
|
|
||||||
::mark
|
|
||||||
;; Resolve's I and O, on the open tab. A mark the other one has passed goes,
|
|
||||||
;; rather than leaving a range that ends before it starts.
|
|
||||||
(fn [db [_ which]]
|
|
||||||
(let [f (get-in db [:playback :frame] 0)]
|
|
||||||
(update-in db [:playback :range (get-in db [:ui :open])]
|
|
||||||
(fn [{:keys [in out] :as marks}]
|
|
||||||
(case which
|
|
||||||
:in (cond-> (assoc marks :in f) (and out (< out f)) (dissoc :out))
|
|
||||||
:out (cond-> (assoc marks :out f) (and in (< f in)) (dissoc :in))))))))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
|
||||||
::drag-mark
|
|
||||||
;; A mark's handle dragged on the ruler: held short of the other mark rather
|
|
||||||
;; than pushing it off, as a key does.
|
|
||||||
(fn [db [_ which f]]
|
|
||||||
(update-in db [:playback :range (get-in db [:ui :open])]
|
|
||||||
(fn [{:keys [in out] :as marks}]
|
|
||||||
(case which
|
|
||||||
:in (assoc marks :in (cond-> f out (min out)))
|
|
||||||
:out (assoc marks :out (cond-> f in (max in))))))))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
|
||||||
::clear-mark
|
|
||||||
;; ⇧I and ⇧O. With neither mark left, the tab plays as it did before marks.
|
|
||||||
(fn [db [_ which]]
|
|
||||||
(let [path [:playback :range (get-in db [:ui :open])]
|
|
||||||
marks (dissoc (get-in db path) which)]
|
|
||||||
(if (seq marks) (assoc-in db path marks) (update-in db (pop path) dissoc (peek path))))))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
::set-rate
|
::set-rate
|
||||||
(fn [{:keys [db]} [_ r]]
|
(fn [{:keys [db]} [_ r]]
|
||||||
|
|
@ -299,8 +252,3 @@
|
||||||
:else (let [i (.indexOf tabs sid)]
|
:else (let [i (.indexOf tabs sid)]
|
||||||
{:db (assoc-in db [:ui :tabs] left)
|
{:db (assoc-in db [:ui :tabs] left)
|
||||||
:dispatch [::open-symbol (get left (min i (dec (count left))))]})))))
|
:dispatch [::open-symbol (get left (min i (dec (count left))))]})))))
|
||||||
|
|
||||||
(rf/reg-event-db
|
|
||||||
::frame-palette
|
|
||||||
;; Written by the player as it paints: see `subs.render/frame-palette`.
|
|
||||||
(fn [db [_ active]] (assoc-in db [:ui :frame-palette (get-in db [:ui :open])] active)))
|
|
||||||
|
|
|
||||||
|
|
@ -162,12 +162,6 @@
|
||||||
:host (get-in db [:ui :open]) :frame frame :point point
|
:host (get-in db [:ui :open]) :frame frame :point point
|
||||||
:target target)}))
|
:target target)}))
|
||||||
|
|
||||||
(defn choose-palette
|
|
||||||
"Show palette `id` in the open tab's palette grid, rather than the one the
|
|
||||||
tab draws in. Each tab keeps its own."
|
|
||||||
[db id]
|
|
||||||
(assoc-in db [:ui :palette (get-in db [:ui :open])] id))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
::import-palette
|
::import-palette
|
||||||
(fn [{:keys [db]} [_ {:keys [project cid palette name]}]]
|
(fn [{:keys [db]} [_ {:keys [project cid palette name]}]]
|
||||||
|
|
@ -193,7 +187,7 @@
|
||||||
(let [id (random-uuid)]
|
(let [id (random-uuid)]
|
||||||
(-> (edit/edit db #(assoc-in % [:palettes id]
|
(-> (edit/edit db #(assoc-in % [:palettes id]
|
||||||
(assoc palette :id id :name (str (:name palette) " copy"))))
|
(assoc palette :id id :name (str (:name palette) " copy"))))
|
||||||
(choose-palette id)
|
(assoc-in [:ui :palette] id)
|
||||||
(assoc-in [:project :status] (str "imported " (:name palette)))))))
|
(assoc-in [:project :status] (str "imported " (:name palette)))))))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
|
|
@ -347,8 +341,7 @@
|
||||||
(array-seq (.-symbols listed)))
|
(array-seq (.-symbols listed)))
|
||||||
(mapv (fn [^js r]
|
(mapv (fn [^js r]
|
||||||
{:project (.-project r) :project-name (.-project_name r)
|
{:project (.-project r) :project-name (.-project_name r)
|
||||||
:cid (.-cid r) :palette (.-palette r) :name (.-name r)
|
:cid (.-cid r) :palette (.-palette r) :name (.-name r)})
|
||||||
:hexes (vec (or (.-hexes r) #js []))})
|
|
||||||
(array-seq (.-palettes listed)))])))
|
(array-seq (.-palettes listed)))])))
|
||||||
(.catch (fn [error]
|
(.catch (fn [error]
|
||||||
(rf/dispatch [::failed (or (ex-message error) (str error))]))))))
|
(rf/dispatch [::failed (or (ex-message error) (str error))]))))))
|
||||||
|
|
@ -704,17 +697,6 @@
|
||||||
(assoc-in % [:symbols sid :name] value)
|
(assoc-in % [:symbols sid :name] value)
|
||||||
(update-in % [:symbols sid] dissoc :name)))))))
|
(update-in % [:symbols sid] dissoc :name)))))))
|
||||||
|
|
||||||
(rf/reg-event-db
|
|
||||||
::add-symbol
|
|
||||||
(fn [db [_ sid]]
|
|
||||||
;; Into the library and nowhere else, as Flash's New Symbol: one empty
|
|
||||||
;; frame, placed in nothing until it is dragged somewhere. `sid` comes from
|
|
||||||
;; the caller so the pool can open the new row's name for editing.
|
|
||||||
(if (clip/symbol (:clip (store/entry (:clip/current db))) sid)
|
|
||||||
db
|
|
||||||
(edit/transaction db #(assoc-in % [:symbols sid]
|
|
||||||
{:id sid :name (name sid) :frames 1 :nodes {}})))))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::symbol-setting
|
::symbol-setting
|
||||||
(fn [db [_ sid key value]]
|
(fn [db [_ sid key value]]
|
||||||
|
|
@ -734,41 +716,14 @@
|
||||||
p {:id id :name "Untitled palette"
|
p {:id id :name "Untitled palette"
|
||||||
:slots (mapv #(select-keys % [:name :hex]) (:slots pal/default-palette))}]
|
:slots (mapv #(select-keys % [:name :hex]) (:slots pal/default-palette))}]
|
||||||
(-> (edit/edit db #(assoc-in % [:palettes id] p))
|
(-> (edit/edit db #(assoc-in % [:palettes id] p))
|
||||||
(choose-palette id)))))
|
(assoc-in [:ui :palette] id)))))
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::add-palette
|
::add-palette
|
||||||
;; One of `palette/presets` into a project that does not have it yet.
|
;; One of `palette/presets` into a project that does not have it yet.
|
||||||
(fn [db [_ p]]
|
(fn [db [_ p]]
|
||||||
(-> (edit/edit db #(assoc-in % [:palettes (:id p)] p))
|
(-> (edit/edit db #(assoc-in % [:palettes (:id p)] p))
|
||||||
(choose-palette (:id p)))))
|
(assoc-in [:ui :palette] (:id p)))))
|
||||||
|
|
||||||
(rf/reg-event-db
|
|
||||||
::use-palette
|
|
||||||
;; Symbol `sid` draws in palette `p`, adding it to the project first when it
|
|
||||||
;; is from the shelf or another project: one edit, so one undo. The grid goes
|
|
||||||
;; back to following the tab, which now draws in it.
|
|
||||||
(fn [db [_ sid p]]
|
|
||||||
(-> (edit/edit db #(-> %
|
|
||||||
(update-in [:palettes (:id p)] (fn [had] (or had p)))
|
|
||||||
(assoc-in [:symbols sid :palette] (:id p))))
|
|
||||||
(update-in [:ui :palette] dissoc (get-in db [:ui :open])))))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
|
||||||
::empty-unused-slots
|
|
||||||
;; Every slot of palette `id` no shape in the project names goes back to
|
|
||||||
;; empty, in place: slot numbers are shared by every palette and every drawing,
|
|
||||||
;; so nothing moves. One edit, so one undo.
|
|
||||||
(fn [db [_ id]]
|
|
||||||
(let [clip (:clip (store/entry (:clip/current db)))
|
|
||||||
p (get (pal/palettes clip) id)
|
|
||||||
gone (pal/emptyable p (pal/slots-used (vals (:symbols clip))))]
|
|
||||||
(if (empty? gone)
|
|
||||||
(assoc-in db [:project :status] "no unused colours to empty")
|
|
||||||
(-> (edit/edit db #(assoc-in % [:palettes id] (pal/empty-slots p gone)))
|
|
||||||
(assoc-in [:project :status]
|
|
||||||
(str "emptied " (count gone) " unused colour" (when (< 1 (count gone)) "s")
|
|
||||||
" in " (:name p))))))))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::duplicate-palette
|
::duplicate-palette
|
||||||
|
|
@ -786,7 +741,7 @@
|
||||||
(-> (edit/edit db #(assoc-in % [:palettes new-id]
|
(-> (edit/edit db #(assoc-in % [:palettes new-id]
|
||||||
(assoc p :id new-id
|
(assoc p :id new-id
|
||||||
:name (str (:name p) " copy"))))
|
:name (str (:name p) " copy"))))
|
||||||
(choose-palette new-id)))))))
|
(assoc-in [:ui :palette] new-id)))))))
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::palette-name
|
::palette-name
|
||||||
|
|
@ -915,16 +870,6 @@
|
||||||
(fn [n] (if reads (assoc n :reads reads) (dissoc n :reads)))))))
|
(fn [n] (if reads (assoc n :reads reads) (dissoc n :reads)))))))
|
||||||
|
|
||||||
|
|
||||||
;; How far node `id` reads ahead of its parent — a mouth's lead — in its own
|
|
||||||
;; frames. Zero is no offset at all rather than an offset of zero.
|
|
||||||
(rf/reg-event-db
|
|
||||||
::set-lead
|
|
||||||
(fn [db [_ sid id frames]]
|
|
||||||
(edit/edit db #(update-in % [:symbols sid :nodes id]
|
|
||||||
(fn [n] (if (zero? frames)
|
|
||||||
(update n :time dissoc :offset)
|
|
||||||
(assoc-in n [:time :offset] frames)))))))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::set-segment-interp
|
::set-segment-interp
|
||||||
(fn [db [_ sid id path left interp]]
|
(fn [db [_ sid id path left interp]]
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
[arthur.domain.palette :as pal]
|
[arthur.domain.palette :as pal]
|
||||||
[arthur.domain.pick :as pick]
|
[arthur.domain.pick :as pick]
|
||||||
[arthur.domain.span :as span]
|
[arthur.domain.span :as span]
|
||||||
[arthur.domain.symbol :as symbol]
|
|
||||||
[arthur.events.edit :as edit]
|
[arthur.events.edit :as edit]
|
||||||
[arthur.domain.paint :as paint]
|
[arthur.domain.paint :as paint]
|
||||||
[arthur.events.playback :as playback]
|
[arthur.events.playback :as playback]
|
||||||
|
|
@ -46,19 +45,14 @@
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::rename-node
|
::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]]
|
(fn [db [_ sid id value]]
|
||||||
(let [document (:clip (store/entry (:clip/current db)))
|
(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)))]
|
value (not-empty (str/trim (str value)))]
|
||||||
(if (or (nil? n) (nil? (get-in document path)))
|
(if-not (get-in document [:symbols sid :nodes id])
|
||||||
db
|
db
|
||||||
(edit/transaction db #(if value
|
(edit/transaction db #(if value
|
||||||
(assoc-in % (conj path :name) value)
|
(assoc-in % [:symbols sid :nodes id :name] value)
|
||||||
(update-in % path dissoc :name)))))))
|
(update-in % [:symbols sid :nodes id] dissoc :name)))))))
|
||||||
|
|
||||||
(defn selected
|
(defn selected
|
||||||
"`db` with `selection` as its primary active row.
|
"`db` with `selection` as its primary active row.
|
||||||
|
|
@ -363,73 +357,6 @@
|
||||||
result (span/extend-hold clip sid id delta {:extent (or extent :keep)})]
|
result (span/extend-hold clip sid id delta {:extent (or extent :keep)})]
|
||||||
(apply-command db sid result [::extend-hold delta :grow-symbol]))))
|
(apply-command db sid result [::extend-hold delta :grow-symbol]))))
|
||||||
|
|
||||||
(defn lane-here
|
|
||||||
"The lane the playhead is in, as `nest/inside` answers it with its `:path`
|
|
||||||
from the open symbol: the nearest lane the selection is in, at any depth —
|
|
||||||
so a stroke just drawn in a cel counts as being in that cel's lane — or else
|
|
||||||
the lane the selection would draw into. Nil where there is none."
|
|
||||||
[db]
|
|
||||||
(let [{clip :clip st :store} (store/entry (:clip/current db))
|
|
||||||
open (get-in db [:ui :open])
|
|
||||||
f (editing-frame db clip)
|
|
||||||
[kind _ _ path :as selection] (get-in db [:ui :selection])
|
|
||||||
lane-at (fn [p]
|
|
||||||
(when-let [in (nest/inside clip st open p f)]
|
|
||||||
(when (symbol/lane? (clip/symbol clip (:sid in)))
|
|
||||||
(assoc in :path p))))]
|
|
||||||
(or (when (= :node kind)
|
|
||||||
(some #(lane-at (pop %)) (take-while seq (iterate pop (vec path)))))
|
|
||||||
(let [t (creation/target clip st open selection f)]
|
|
||||||
(when (= :lane (:kind t)) (lane-at (:path t)))))))
|
|
||||||
|
|
||||||
(defn span-path
|
|
||||||
"The row whose span = and − move: the selection's, or — inside a lane — the
|
|
||||||
cel the selection is in, so a stroke just drawn holds its drawing longer."
|
|
||||||
[db]
|
|
||||||
(let [path (vec (nth (get-in db [:ui :selection]) 3 nil))
|
|
||||||
lane (some-> (lane-here db) :path count)]
|
|
||||||
(when (seq path)
|
|
||||||
(if (and lane (< lane (count path))) (subvec path 0 (inc lane)) path))))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
|
||||||
::drawing-here
|
|
||||||
;; K and ⇧K in a lane: see `span/drawing-at`. The new cel is selected and the
|
|
||||||
;; playhead put on it, because it is there to be drawn in. `lane` is
|
|
||||||
;; `lane-here`'s answer unless the caller has already chosen one.
|
|
||||||
(fn [{:keys [db]} [_ copy? lane]]
|
|
||||||
(let [clip (:clip (store/entry (:clip/current db)))
|
|
||||||
{:keys [sid frame path time]} (or lane (lane-here db))
|
|
||||||
id (random-uuid)
|
|
||||||
result (if sid
|
|
||||||
(span/drawing-at clip sid frame id (clip/fresh-id clip)
|
|
||||||
{:copy? copy? :extent :grow-symbol})
|
|
||||||
{:refused "select a lane, or a drawing in one"})]
|
|
||||||
(if-let [why (:refused result)]
|
|
||||||
{:db (assoc-in db [:project :status] why)}
|
|
||||||
(cond-> {:db (-> db
|
|
||||||
(edit/transaction (constantly (:clip result)))
|
|
||||||
(selected [:node sid id (conj path id)]))}
|
|
||||||
time (assoc :dispatch [::playback/seek
|
|
||||||
(js/Math.ceil (+ (:at time) (/ (:frame result) (:rate time))))]))))))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
|
||||||
::key-selected
|
|
||||||
;; K on anything that is not in a lane: Blender's I.
|
|
||||||
(fn [db _]
|
|
||||||
(let [{clip :clip st :store} (store/entry (:clip/current db))
|
|
||||||
f (editing-frame db clip)
|
|
||||||
places (keep (fn [[kind _ _ path]]
|
|
||||||
(when (and (= :node kind) (seq path))
|
|
||||||
(nest/placement clip st (get-in db [:ui :open]) path f)))
|
|
||||||
(get-in db [:ui :selections]))]
|
|
||||||
(if (empty? places)
|
|
||||||
(assoc-in db [:project :status] (if (seq (get-in db [:ui :selections]))
|
|
||||||
"what is selected is not on screen at this frame"
|
|
||||||
"select something to key"))
|
|
||||||
(edit/edit db #(reduce (fn [c {:keys [sid id frame]}]
|
|
||||||
(update-in c [:symbols sid :nodes id] node/key-at frame st))
|
|
||||||
% places))))))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
::retry
|
::retry
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
|
|
@ -477,39 +404,6 @@
|
||||||
#(cond-> (update % :hidden (fnil (if on? disj conj) #{}) layer)
|
#(cond-> (update % :hidden (fnil (if on? disj conj) #{}) layer)
|
||||||
on? (assoc :on? true)))))
|
on? (assoc :on? true)))))
|
||||||
|
|
||||||
(defn- trace-layers
|
|
||||||
"The tracing layers in symbol `sid` and everything it places, as
|
|
||||||
`arthur.db/tracing` names them: a placement of a tracing symbol is
|
|
||||||
`[sid id]`, a face's footage `[face :plate]`. Only nodes `keep?` says yes to
|
|
||||||
are looked in at the top; below that, everything is."
|
|
||||||
[clip sid keep?]
|
|
||||||
(let [nodes (:nodes (clip/symbol clip sid))]
|
|
||||||
(into (if (get nodes :plate) #{[sid :plate]} #{})
|
|
||||||
(mapcat (fn [[id n]]
|
|
||||||
(when (keep? id)
|
|
||||||
(let [src (node/source n)]
|
|
||||||
(cond (and src (clip/trace? (clip/symbol clip src))) [[sid id]]
|
|
||||||
src (trace-layers clip src (constantly true)))))))
|
|
||||||
nodes)))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
|
||||||
::trace-selection
|
|
||||||
;; ⇧T: tracing on for what is in the selection only — the selected node, what
|
|
||||||
;; it places, its children — and every other layer off. Again, all of them.
|
|
||||||
(fn [db _]
|
|
||||||
(let [clip (:clip (store/entry (:clip/current db)))
|
|
||||||
[kind sid id] (get-in db [:ui :selection])
|
|
||||||
nodes (:nodes (clip/symbol clip sid))
|
|
||||||
mine (if (and (= :node kind) id)
|
|
||||||
(trace-layers clip sid #(some #{id} (symbol/lineage nodes %)))
|
|
||||||
#{})
|
|
||||||
every (into #{} (mapcat #(trace-layers clip % (constantly true))) (keys (:symbols clip)))
|
|
||||||
solo (assoc (get-in db [:ui :tracing]) :on? true :hidden (reduce disj every mine))]
|
|
||||||
(cond
|
|
||||||
(empty? mine) (assoc-in db [:project :status] "no tracing in the selection")
|
|
||||||
(= solo (get-in db [:ui :tracing])) (assoc-in db [:ui :tracing :hidden] #{})
|
|
||||||
:else (assoc-in db [:ui :tracing] solo)))))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::tracing-on
|
::tracing-on
|
||||||
;; Every tracing layer at once, from the bar above the stage.
|
;; Every tracing layer at once, from the bar above the stage.
|
||||||
|
|
@ -663,6 +557,8 @@
|
||||||
::hover
|
::hover
|
||||||
(fn [db [_ p]] (if p (assoc-in db [:ui :hover] p) (update db :ui dissoc :hover))))
|
(fn [db [_ p]] (if p (assoc-in db [:ui :hover] p) (update db :ui dissoc :hover))))
|
||||||
|
|
||||||
|
(def tool-keys #{"v" "p" "b" "e" "[" "]" "enter" "escape"})
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
::tool-key
|
::tool-key
|
||||||
;; A key from `ui/tools`, decided here against the state it changes, and
|
;; A key from `ui/tools`, decided here against the state it changes, and
|
||||||
|
|
@ -982,13 +878,7 @@
|
||||||
seeded (assoc-in document [:symbols sid] new-symbol)]
|
seeded (assoc-in document [:symbols sid] new-symbol)]
|
||||||
(span/place-symbol seeded st host instance-id sid at
|
(span/place-symbol seeded st host instance-id sid at
|
||||||
{:extent :grow-symbol
|
{:extent :grow-symbol
|
||||||
:remainder-id (random-uuid)
|
:remainder-id (random-uuid)})))]
|
||||||
;; Held like a drawing cel, so
|
|
||||||
;; stretching it shows what is drawn
|
|
||||||
;; in it across the whole cel.
|
|
||||||
:speed (if (and (= :lane destination-kind)
|
|
||||||
(not lane?))
|
|
||||||
0 1)})))]
|
|
||||||
(if-let [why (:refused result)]
|
(if-let [why (:refused result)]
|
||||||
(update db :project merge {:status why})
|
(update db :project merge {:status why})
|
||||||
(let [selection [:node host instance-id (conj (vec down) instance-id)]]
|
(let [selection [:node host instance-id (conj (vec down) instance-id)]]
|
||||||
|
|
@ -1005,27 +895,10 @@
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::new-lane
|
::new-lane
|
||||||
(fn [db [_ where]]
|
(fn [db _]
|
||||||
;; A lane is an explicit persistent row across the effective target symbol.
|
;; A lane is an explicit persistent row across the effective target symbol.
|
||||||
;; The playhead validates that nested target; the row itself begins at zero.
|
;; The playhead validates that nested target; the row itself begins at zero.
|
||||||
(create-container db (or where :inside) true)))
|
(create-container db :inside true)))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
|
||||||
::new
|
|
||||||
;; N and its variants: a new symbol or lane where the selection says, or at
|
|
||||||
;; the top of the tab (`:top`).
|
|
||||||
;;
|
|
||||||
;; A NEW SYMBOL IN A LANE IS A NEW DRAWING, so there it is ⇧K — one meaning
|
|
||||||
;; for "a new empty thing in a lane", rather than two that differ in how
|
|
||||||
;; much of the hold they take. A lane made in a lane is still a lane.
|
|
||||||
(fn [{:keys [db]} [_ where lane?]]
|
|
||||||
(let [{document :clip st :store} (store/entry (:clip/current db))
|
|
||||||
into (creation/target document st (get-in db [:ui :open])
|
|
||||||
(when-not (= :top where) (get-in db [:ui :selection]))
|
|
||||||
(editing-frame db document))]
|
|
||||||
(if (and (not lane?) (= :lane (:kind into)))
|
|
||||||
{:fx [[:dispatch [::drawing-here false into]]]}
|
|
||||||
{:db (create-container db where lane?)}))))
|
|
||||||
|
|
||||||
;; ---------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------
|
||||||
;; a drop in flight
|
;; a drop in flight
|
||||||
|
|
@ -1148,7 +1021,7 @@
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
::new-symbol-at
|
::new-symbol-at
|
||||||
;; ONE GESTURE AND ONE CREATION PATH FOR EVERY LANE. Empty space in a lane
|
;; ONE GESTURE AND ONE CREATION PATH FOR EVERY LANE. Empty space in a lane
|
||||||
;; takes a new one-frame held symbol at the frame double-clicked -- the pointer
|
;; takes a new one-frame symbol at the frame double-clicked -- the pointer
|
||||||
;; names a place in time as well as a lane, which is the whole of the gesture
|
;; names a place in time as well as a lane, which is the whole of the gesture
|
||||||
;; and the reason it is not the playhead's. The DESTINATION decides what is
|
;; and the reason it is not the playhead's. The DESTINATION decides what is
|
||||||
;; created there: a clip of a palette track is a palette symbol whose
|
;; created there: a clip of a palette track is a palette symbol whose
|
||||||
|
|
@ -1169,8 +1042,7 @@
|
||||||
palette? (assoc :type :palette)))
|
palette? (assoc :type :palette)))
|
||||||
result (span/place-symbol seeded st (:sid where) uuid sid (:at where)
|
result (span/place-symbol seeded st (:sid where) uuid sid (:at where)
|
||||||
{:extent :grow-symbol
|
{:extent :grow-symbol
|
||||||
:remainder-id (random-uuid)
|
:remainder-id (random-uuid)})
|
||||||
:speed 0})
|
|
||||||
result (if-let [placed (and palette? (:clip result))]
|
result (if-let [placed (and palette? (:clip result))]
|
||||||
(assoc result :clip
|
(assoc result :clip
|
||||||
(assoc-in placed [:symbols (:sid where) :nodes uuid
|
(assoc-in placed [:symbols (:sid where) :nodes uuid
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@
|
||||||
(let [ops (resolve-frame i)
|
(let [ops (resolve-frame i)
|
||||||
active (clip/active-palette resolve-frame)]
|
active (clip/active-palette resolve-frame)]
|
||||||
(-> ras
|
(-> ras
|
||||||
(raster/clear! pal/bg-slot)
|
(raster/clear! (pal/background-index palette active))
|
||||||
(raster/draw-ops! ops))
|
(raster/draw-ops! ops))
|
||||||
(-> (js/Promise.resolve
|
(-> (js/Promise.resolve
|
||||||
(frame! exporter i
|
(frame! exporter i
|
||||||
|
|
|
||||||
|
|
@ -468,16 +468,8 @@
|
||||||
[:xform :pos] (ch/framed [(- (/ w 2) (* k (:x c)))
|
[:xform :pos] (ch/framed [(- (/ w 2) (* k (:x c)))
|
||||||
(- (* 0.25 h) (* k (:y c)))])}))))
|
(- (* 0.25 h) (* k (:y c)))])}))))
|
||||||
|
|
||||||
;; MOUTH LEAD, in seconds. Roto drawn a frame or two ahead of the sound reads as
|
|
||||||
;; in sync, and roto drawn exactly on it reads late: an animator's standard
|
|
||||||
;; practice, and a 12fps hold already shows each pose up to a frame after it
|
|
||||||
;; happened. 1.5 frames at 12fps. It is stored as the mouth's `:time :offset` in
|
|
||||||
;; the face's own (camera) frames, so the head and the footage under it stay
|
|
||||||
;; where they are and only the mouth anticipates. See docs/animation-model.md.
|
|
||||||
(def mouth-lead 0.125)
|
|
||||||
|
|
||||||
(defn- mouth-part [subject absent? obs
|
(defn- mouth-part [subject absent? obs
|
||||||
{:keys [analysis verts anchor-avg contour-avg aperture-cut fps] :as params}
|
{:keys [analysis verts anchor-avg contour-avg aperture-cut] :as params}
|
||||||
{:keys [outer inner] :as inputs}]
|
{:keys [outer inner] :as inputs}]
|
||||||
(let [own (partial feature/owned subject)
|
(let [own (partial feature/owned subject)
|
||||||
mouth (own :mouth)
|
mouth (own :mouth)
|
||||||
|
|
@ -492,7 +484,6 @@
|
||||||
:verts verts}})]
|
:verts verts}})]
|
||||||
{:nodes {:mouth
|
{:nodes {:mouth
|
||||||
{:id :mouth :name "mouth" :kind :poly :parent :head :z "a1"
|
{:id :mouth :name "mouth" :kind :poly :parent :head :z "a1"
|
||||||
:time {:offset (js/Math.round (* mouth-lead (or fps 0)))}
|
|
||||||
:channels {[:geom :pts] (dense rings 0 (prov :roto/lips-outer))
|
:channels {[:geom :pts] (dense rings 0 (prov :roto/lips-outer))
|
||||||
[:style :color] (ch/framed 2)}}
|
[:style :color] (ch/framed 2)}}
|
||||||
:mouth-in
|
:mouth-in
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
(rf/reg-sub ::rate (fn [db _] (get-in db [:playback :rate])))
|
(rf/reg-sub ::rate (fn [db _] (get-in db [:playback :rate])))
|
||||||
(rf/reg-sub ::loop? (fn [db _] (get-in db [:playback :loop?])))
|
(rf/reg-sub ::loop? (fn [db _] (get-in db [:playback :loop?])))
|
||||||
(rf/reg-sub ::muted? (fn [db _] (get-in db [:playback :muted?])))
|
(rf/reg-sub ::muted? (fn [db _] (get-in db [:playback :muted?])))
|
||||||
(rf/reg-sub ::range (fn [db _] (get-in db [:playback :range (get-in db [:ui :open])])))
|
|
||||||
(rf/reg-sub ::fps (fn [db _] (get-in db [:clip :fps])))
|
(rf/reg-sub ::fps (fn [db _] (get-in db [:clip :fps])))
|
||||||
;; The open symbol can have a local stage size; otherwise it follows the project.
|
;; The open symbol can have a local stage size; otherwise it follows the project.
|
||||||
(rf/reg-sub ::stage-size
|
(rf/reg-sub ::stage-size
|
||||||
|
|
|
||||||
|
|
@ -130,21 +130,28 @@
|
||||||
(fn [clip _] (when clip (pal/compile clip))))
|
(fn [clip _] (when clip (pal/compile clip))))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
::frame-palette
|
::ramp
|
||||||
;; The palette the open tab's stage is in at the frame last painted: an id,
|
:<- [::palette]
|
||||||
;; or `{:from :to :t}` mid-blend. Each tab keeps its own.
|
(fn [compiled _] (:ramp compiled)))
|
||||||
(fn [db _] (get-in db [:ui :frame-palette (get-in db [:ui :open])])))
|
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
::palette-solo?
|
::palettes-shown
|
||||||
;; Show only what is drawn in the chosen colour, and let only it be clicked.
|
:<- [::clip]
|
||||||
(fn [db _] (get-in db [:ui :palette-solo?])))
|
:<- [::open]
|
||||||
|
:<- [::store]
|
||||||
(rf/reg-sub
|
:<- [::open-frame]
|
||||||
::palette-preview
|
:<- [::palette]
|
||||||
;; A palette under the pointer in the chooser: `{:bank id :hexes […]}`, the
|
;; The palettes the stage is drawing in at the playhead: the open symbol's own,
|
||||||
;; bank the stage would draw it into. Viewing only; nothing is edited.
|
;; BOTH ends while its palette lane blends from one to the next, and any an
|
||||||
(fn [db _] (get-in db [:ui :palette-preview])))
|
;; instance in it is set to. The palette strip asks it whether the palette it
|
||||||
|
;; is editing is one of these.
|
||||||
|
(fn [[document sid store frame compiled] _]
|
||||||
|
(when-let [sym (and document (clip/symbol document sid))]
|
||||||
|
(let [at #(clip/palette-at document store (:default compiled) % (or frame 0) nil)
|
||||||
|
ends #(if (map? %) [(:from %) (:to %)] [%])]
|
||||||
|
(into (set (ends (at sym)))
|
||||||
|
(comp (filter :palette) (mapcat (comp ends at)))
|
||||||
|
(vals (:nodes sym)))))))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
::store
|
::store
|
||||||
|
|
|
||||||
|
|
@ -91,4 +91,4 @@
|
||||||
"tracing layer"]
|
"tracing layer"]
|
||||||
[:button.on {:disabled (or loading? (< n 1) (empty? name))
|
[:button.on {:disabled (or loading? (< n 1) (empty? name))
|
||||||
:on-click #(rf/dispatch [::footage/convert])}
|
:on-click #(rf/dispatch [::footage/convert])}
|
||||||
(if loading? "working…" "make roto")]]]]))))
|
(if loading? "working…" "make symbol")]]]]))))
|
||||||
|
|
|
||||||
|
|
@ -50,17 +50,7 @@
|
||||||
;; row out of a dozen says at a glance that its blocks follow one another in
|
;; 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
|
;; time instead of being on screen together. Whole and half coordinates, so
|
||||||
;; the three dividers land on pixels at 11px.
|
;; 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
|
(defn view
|
||||||
"The glyph named `k`, sized by CSS and inked in `currentColor` — so a button's
|
"The glyph named `k`, sized by CSS and inked in `currentColor` — so a button's
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,20 @@
|
||||||
(when (and (nil? t) (not held?)) " · repeats; no single frame above"))
|
(when (and (nil? t) (not held?)) " · repeats; no single frame above"))
|
||||||
:else nil)))
|
: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 []
|
(defn view []
|
||||||
(let [clip @(rf/subscribe [::render/clip])
|
(let [clip @(rf/subscribe [::render/clip])
|
||||||
open @(rf/subscribe [::render/open])
|
open @(rf/subscribe [::render/open])
|
||||||
|
|
@ -120,7 +134,7 @@
|
||||||
n (when (= :node kind) (get-in clip [:symbols sid :nodes id]))
|
n (when (= :node kind) (get-in clip [:symbols sid :nodes id]))
|
||||||
crumbs (trail clip open (if (and n (seq path)) path (when n [id])))
|
crumbs (trail clip open (if (and n (seq path)) path (when n [id])))
|
||||||
last-i (dec (count crumbs))
|
last-i (dec (count crumbs))
|
||||||
shared (some->> n node/source (clip/uses clip))
|
shared (shared-with clip n)
|
||||||
says (whereabouts clip n inside)]
|
says (whereabouts clip n inside)]
|
||||||
[:section.loc
|
[:section.loc
|
||||||
[:nav.crumbs {:aria-label "editing location"}
|
[:nav.crumbs {:aria-label "editing location"}
|
||||||
|
|
|
||||||
|
|
@ -16,62 +16,29 @@
|
||||||
set before you draw, so it is a section of the inspector. See `ui/params`."
|
set before you draw, so it is a section of the inspector. See `ui/params`."
|
||||||
(:require [arthur.domain.channel :as channel]
|
(:require [arthur.domain.channel :as channel]
|
||||||
[arthur.domain.clip :as clip]
|
[arthur.domain.clip :as clip]
|
||||||
[arthur.domain.raster :as raster]
|
|
||||||
[arthur.footage.store :as store]
|
|
||||||
[arthur.domain.node :as node]
|
[arthur.domain.node :as node]
|
||||||
[arthur.domain.palette :as pal]
|
[arthur.domain.palette :as pal]
|
||||||
[arthur.domain.symbol :as symbol]
|
[arthur.domain.symbol :as symbol]
|
||||||
[arthur.subs.playback :as playback]
|
|
||||||
[arthur.events.project :as project]
|
[arthur.events.project :as project]
|
||||||
[arthur.events.ui :as ui]
|
[arthur.events.ui :as ui]
|
||||||
[arthur.subs.render :as render]
|
[arthur.subs.render :as render]
|
||||||
[arthur.subs.ui :as sub]
|
[arthur.subs.ui :as sub]
|
||||||
[arthur.ui.canvas :as canvas]
|
|
||||||
[arthur.ui.menu :as menu]
|
[arthur.ui.menu :as menu]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[re-frame.core :as rf]
|
[re-frame.core :as rf]
|
||||||
[reagent.core :as r]))
|
[reagent.core :as r]))
|
||||||
|
|
||||||
;; WHICH PALETTE THE GRID SHOWS
|
(rf/reg-sub ::chosen (fn [db _] (get-in db [:ui :palette])))
|
||||||
;;
|
|
||||||
;; The one the open tab's stage is in at the playhead — there is only ever one
|
|
||||||
;; — read from where the player decided it, so the grid can never disagree with
|
|
||||||
;; the picture. Another can be picked to look at or retone, and each tab keeps
|
|
||||||
;; its own pick until the active one is picked again.
|
|
||||||
|
|
||||||
(rf/reg-sub ::chosen (fn [db _] (get-in db [:ui :palette (get-in db [:ui :open])])))
|
(rf/reg-event-db ::select (fn [db [_ id]] (assoc-in db [:ui :palette] id)))
|
||||||
|
|
||||||
(rf/reg-sub
|
|
||||||
::followed
|
|
||||||
:<- [::render/frame-palette]
|
|
||||||
:<- [::render/palette]
|
|
||||||
;; Mid-tween, the palette it starts from, held still for the whole tween:
|
|
||||||
;; the only things to do with a tween are change its ends, so the grid shows
|
|
||||||
;; the start's own colours rather than the mix.
|
|
||||||
(fn [[active compiled] _]
|
|
||||||
(let [id (if (map? active) (:from active) active)]
|
|
||||||
(if (contains? (:palettes compiled) id) id (:default compiled)))))
|
|
||||||
|
|
||||||
(rf/reg-event-db ::solo (fn [db _] (update-in db [:ui :palette-solo?] not)))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
|
||||||
::select
|
|
||||||
(fn [db [_ id followed]]
|
|
||||||
(let [open (get-in db [:ui :open])]
|
|
||||||
(if (= id followed)
|
|
||||||
(update-in db [:ui :palette] dissoc open)
|
|
||||||
(project/choose-palette db id)))))
|
|
||||||
|
|
||||||
(rf/reg-event-db ::preview (fn [db [_ p]] (assoc-in db [:ui :palette-preview] p)))
|
|
||||||
|
|
||||||
(defn- shown
|
(defn- shown
|
||||||
"The palette asset the grid shows, and the one the tab draws in."
|
"The palette asset the grid shows: the one chosen, or the project's default."
|
||||||
[]
|
[]
|
||||||
(let [clip @(rf/subscribe [::render/clip])
|
(let [clip @(rf/subscribe [::render/clip])
|
||||||
chosen @(rf/subscribe [::chosen])
|
chosen @(rf/subscribe [::chosen])
|
||||||
followed @(rf/subscribe [::followed])
|
pid (if (contains? (:palettes clip) chosen) chosen (pal/default-palette-id clip))]
|
||||||
pid (if (contains? (:palettes clip) chosen) chosen followed)]
|
[clip pid (get (pal/palettes clip) pid)]))
|
||||||
[clip pid (get (pal/palettes clip) pid) followed]))
|
|
||||||
|
|
||||||
(defn- pick!
|
(defn- pick!
|
||||||
"Make `tone` the colour new shapes get, and recolour what is selected."
|
"Make `tone` the colour new shapes get, and recolour what is selected."
|
||||||
|
|
@ -156,14 +123,14 @@
|
||||||
:title (if (= i from) (str i " — as it is") (str "slot " i))
|
:title (if (= i from) (str i " — as it is") (str "slot " i))
|
||||||
:on-click #(do (map-slot! rm from i) (reset! open nil))}]))])]))))
|
:on-click #(do (map-slot! rm from i) (reset! open nil))}]))])]))))
|
||||||
|
|
||||||
(defn- swatch [pid i {:keys [name hex]} tone placements rm hex-of used?]
|
(defn- swatch [pid i {:keys [name hex]} tone placements rm hex-of]
|
||||||
(let [picker-id (str "palette-picker-" pid "-" i)
|
(let [picker-id (str "palette-picker-" pid "-" i)
|
||||||
to (get (:map rm) i)]
|
to (get (:map rm) i)]
|
||||||
[:div.slot {:key i}
|
[:div.slot {:key i}
|
||||||
[:button {:class (str "cell" (when (= i tone) " on") (when-not used? " unused"))
|
[:button {:class (str "cell" (when (= i tone) " on"))
|
||||||
:style {:background hex}
|
:style {:background hex}
|
||||||
:title (str "slot " i (when name (str " · " (clojure.core/name name)))
|
:title (str "slot " i (when name (str " · " (clojure.core/name name)))
|
||||||
" · " hex (when-not used? " · nothing in the project draws with it")
|
" · " hex
|
||||||
(when to (str " · lit as " to " under the selected remap"))
|
(when to (str " · lit as " to " under the selected remap"))
|
||||||
" — double-click to edit"
|
" — double-click to edit"
|
||||||
(when rm ", drag onto another to remap it under the selected remap"))
|
(when rm ", drag onto another to remap it under the selected remap"))
|
||||||
|
|
@ -186,18 +153,11 @@
|
||||||
(defn grid
|
(defn grid
|
||||||
"The colour chip and the slots, for the tool strip."
|
"The colour chip and the slots, for the tool strip."
|
||||||
[]
|
[]
|
||||||
(let [[clip pid palette followed] (shown)
|
(let [[_ pid palette] (shown)
|
||||||
tone @(rf/subscribe [::sub/tone])
|
tone @(rf/subscribe [::sub/tone])
|
||||||
solo? @(rf/subscribe [::render/palette-solo?])
|
|
||||||
placements @(rf/subscribe [::sub/selected-placements])
|
placements @(rf/subscribe [::sub/selected-placements])
|
||||||
used (conj (pal/slots-used (vals (:symbols clip))) pal/bg-slot)
|
|
||||||
hex (when (number? tone) (:hex (get (:slots palette) tone)))]
|
hex (when (number? tone) (:hex (get (:slots palette) tone)))]
|
||||||
[:div.palette-grid
|
[:div.palette
|
||||||
(when (not= pid followed)
|
|
||||||
[:button.back {:title (str "back to " (:name (get (pal/palettes clip) followed))
|
|
||||||
", the palette the stage is in")
|
|
||||||
:on-click #(rf/dispatch [::select followed followed])}
|
|
||||||
"↩ active"])
|
|
||||||
[:div {:class (str "chip" (cond (= :clear tone) " clear" (symbol/remap? tone) " map"))
|
[:div {:class (str "chip" (cond (= :clear tone) " clear" (symbol/remap? tone) " map"))
|
||||||
:style (when hex {:background hex})
|
:style (when hex {:background hex})
|
||||||
:title (cond (= :clear tone) "clear: what is drawn knocks out what is under it in its symbol"
|
:title (cond (= :clear tone) "clear: what is drawn knocks out what is under it in its symbol"
|
||||||
|
|
@ -206,8 +166,7 @@
|
||||||
[:span (cond (= :clear tone) "×" (symbol/remap? tone) "⇄" :else tone)]]
|
[:span (cond (= :clear tone) "×" (symbol/remap? tone) "⇄" :else tone)]]
|
||||||
[:div.cells
|
[:div.cells
|
||||||
(let [rm (remap) hex-of #(:hex (get (:slots palette) %))]
|
(let [rm (remap) hex-of #(:hex (get (:slots palette) %))]
|
||||||
(doall (map-indexed #(swatch pid %1 %2 tone placements rm hex-of (contains? used %1))
|
(doall (map-indexed #(swatch pid %1 %2 tone placements rm hex-of) (:slots palette))))
|
||||||
(:slots palette))))
|
|
||||||
[:div.slot
|
[:div.slot
|
||||||
[:button {:class (str "cell clear" (when (= :clear tone) " on"))
|
[:button {:class (str "cell clear" (when (= :clear tone) " on"))
|
||||||
:title "clear — draws a knockout: a hole in its symbol"
|
:title "clear — draws a knockout: a hole in its symbol"
|
||||||
|
|
@ -216,22 +175,7 @@
|
||||||
[:button {:class (str "cell map" (when (symbol/remap? tone) " on"))
|
[:button {:class (str "cell map" (when (symbol/remap? tone) " on"))
|
||||||
:title "remap — draws light: what is under it is drawn in other slots of the palette. Set which in the inspector."
|
:title "remap — draws light: what is under it is drawn in other slots of the palette. Set which in the inspector."
|
||||||
:on-click #(pick! [:remap {}] placements)}
|
:on-click #(pick! [:remap {}] placements)}
|
||||||
"⇄"]]]
|
"⇄"]]]]))
|
||||||
[:div.grid-tools
|
|
||||||
[:button {:class (when solo? "on")
|
|
||||||
:disabled (not (number? tone))
|
|
||||||
:title (if solo?
|
|
||||||
"showing only what is drawn in this colour — click one to select it; click again to show everything"
|
|
||||||
"show only what is drawn in the chosen colour, to find and recolour it")
|
|
||||||
:aria-pressed (boolean solo?)
|
|
||||||
:on-click #(rf/dispatch [::solo])}
|
|
||||||
"◎"]
|
|
||||||
[:button {:title (str "empty the colours of " (:name palette)
|
|
||||||
" no shape in the project draws with — they stay as free slots."
|
|
||||||
" The background and the named face tones are kept.")
|
|
||||||
:aria-label "empty unused colours"
|
|
||||||
:on-click #(rf/dispatch [::project/empty-unused-slots pid])}
|
|
||||||
"⌫"]]]))
|
|
||||||
|
|
||||||
(defn strip
|
(defn strip
|
||||||
"Every slot of a palette, side by side: what it looks like at a glance."
|
"Every slot of a palette, side by side: what it looks like at a glance."
|
||||||
|
|
@ -257,168 +201,71 @@
|
||||||
(.blur (.-target e)))
|
(.blur (.-target e)))
|
||||||
nil))}])
|
nil))}])
|
||||||
|
|
||||||
(defn- authored?
|
(defn- chooser
|
||||||
"Not exactly one of the shelf's: a palette someone made or retoned."
|
"Every palette in the project as a row — its strip and its name — so what you
|
||||||
[hexes]
|
would switch to is visible before you switch. The open one carries the edit
|
||||||
(not-any? #(= hexes (pal/hexes-of %)) pal/presets))
|
button that renames it; the ones the stage is drawing in at the playhead carry
|
||||||
|
a dot."
|
||||||
(defonce ^:private thumbs (atom {:key nil :raster nil :urls {}}))
|
[clip pid]
|
||||||
|
(r/with-let [renaming? (r/atom false)]
|
||||||
(defn- frame-raster
|
(let [on-stage @(rf/subscribe [::render/palettes-shown])]
|
||||||
"The open symbol's frame at the playhead, as indices: drawn once, then shown
|
[:div.palette-list {:role "listbox" :aria-label "palettes"}
|
||||||
through each palette's colours, so a list of thumbnails costs one render and a
|
(doall
|
||||||
colour lookup per row."
|
(for [[id p] (sort-by (comp str :name val) (pal/palettes clip))
|
||||||
[clip store compiled open frame]
|
:let [open? (= id pid)]]
|
||||||
(let [k [clip open frame]]
|
^{:key (str id)}
|
||||||
(when-not (= k (:key @thumbs))
|
[:div.palette-row {:class (when open? "on")}
|
||||||
(reset! thumbs
|
(if (and open? @renaming?)
|
||||||
{:key k :urls {}
|
[:div.choose [strip p] [rename id p #(reset! renaming? false)]]
|
||||||
:raster (try
|
[:button.choose {:role "option" :aria-selected open?
|
||||||
(let [resolve (clip/resolver clip open store compiled {})
|
:title (if open? (str "editing " (:name p)) (str "edit " (:name p)))
|
||||||
[w h] (clip/stage clip open)
|
|
||||||
ops (resolve (or frame 0))]
|
|
||||||
(-> (raster/make w h)
|
|
||||||
(raster/clear! pal/bg-slot)
|
|
||||||
(raster/draw-ops! ops)))
|
|
||||||
(catch :default _ nil))}))
|
|
||||||
(:raster @thumbs)))
|
|
||||||
|
|
||||||
(defn- thumb
|
|
||||||
"The playhead's frame in `hexes`."
|
|
||||||
[hexes]
|
|
||||||
(let [k hexes]
|
|
||||||
(or (get-in @thumbs [:urls k])
|
|
||||||
(when-let [r (:raster @thumbs)]
|
|
||||||
(let [url (canvas/->png r (pal/ramp-of hexes))]
|
|
||||||
(swap! thumbs assoc-in [:urls k] url)
|
|
||||||
url)))))
|
|
||||||
|
|
||||||
(defn- hit? [needle & texts]
|
|
||||||
(or (str/blank? needle)
|
|
||||||
(some #(str/includes? (str/lower-case (str %)) needle) texts)))
|
|
||||||
|
|
||||||
(def ^:private via-words {:symbol "set on symbol" :lane "palette lane" :instance "instance"})
|
|
||||||
|
|
||||||
(defn- candidate-row
|
|
||||||
"One palette to switch to: a thumbnail of the playhead's frame in it, its strip,
|
|
||||||
its name and where it is from. Hovering shows it on the stage; clicking opens
|
|
||||||
it in the grid; `use` makes the open symbol draw in it."
|
|
||||||
[{:keys [p note on? thumb-url sid followed]}]
|
|
||||||
(let [hexes (pal/hexes-of p)]
|
|
||||||
[:div.palette-row {:class (when on? "on")
|
|
||||||
:on-mouse-enter #(rf/dispatch [::preview {:hexes hexes}])
|
|
||||||
:on-mouse-leave #(rf/dispatch [::preview nil])}
|
|
||||||
[:button.choose {:role "option" :aria-selected (boolean on?)
|
|
||||||
:title (str "show " (:name p) " in the palette grid")
|
|
||||||
:on-click (fn []
|
:on-click (fn []
|
||||||
(rf/dispatch [::preview nil])
|
(when-not open?
|
||||||
(if (contains? (pal/palettes @(rf/subscribe [::render/clip])) (:id p))
|
(reset! renaming? false)
|
||||||
(rf/dispatch [::select (:id p) followed])
|
(rf/dispatch [::ui/set-tone 0])
|
||||||
(rf/dispatch [::project/add-palette p])))}
|
(rf/dispatch [::select id])))}
|
||||||
(when thumb-url [:img.thumb {:src thumb-url :alt ""}])
|
|
||||||
[:span.text
|
|
||||||
[strip p]
|
[strip p]
|
||||||
[:span.name (:name p)]
|
[:span.name (:name p)]
|
||||||
(when note [:span.note note])]]
|
(when (contains? on-stage id)
|
||||||
[:button.use {:title (str "draw " (clip/symbol-name @(rf/subscribe [::render/clip]) sid)
|
[:span.on-stage {:title "on the stage at the playhead"}])])
|
||||||
" in " (:name p))
|
(when open?
|
||||||
:on-click (fn []
|
[:button.rename {:title (str "rename " (:name p)) :aria-label "rename palette"
|
||||||
(rf/dispatch [::preview nil])
|
:on-click #(swap! renaming? not)}
|
||||||
(rf/dispatch [::project/use-palette sid p]))}
|
"✎"])]))])))
|
||||||
"use"]]))
|
|
||||||
|
|
||||||
(defn- shelf
|
(defn- elsewhere
|
||||||
"The classics, small: a strip each and a name under it, folded away until
|
"An info badge on the palette button when the palette being edited is not one
|
||||||
wanted. Hovering previews; a click brings one into the project."
|
the stage draws in at the playhead — not an error: editing another palette is
|
||||||
[ps followed searching? sid]
|
how one is made ready for a palette lane. Hovering says where to change it.
|
||||||
[:details.palette-shelf {:open searching?}
|
The card is placed in the viewport, as `ui/menu` places its panels, because
|
||||||
[:summary (str "classics · " (count ps))]
|
the tool strip scrolls and clips its overflow."
|
||||||
[:div.shelf
|
[pid palette]
|
||||||
(doall
|
(r/with-let [at (r/atom nil)]
|
||||||
(for [p ps]
|
(let [on-stage @(rf/subscribe [::render/palettes-shown])
|
||||||
^{:key (str (:id p))}
|
clip @(rf/subscribe [::render/clip])
|
||||||
[:button.tile {:title (str (:name p) " — click to open it, double-click to use it")
|
sid @(rf/subscribe [::render/open])]
|
||||||
:on-mouse-enter #(rf/dispatch [::preview {:hexes (pal/hexes-of p)}])
|
(when (and (seq on-stage) (not (contains? on-stage pid)))
|
||||||
:on-mouse-leave #(rf/dispatch [::preview nil])
|
[:span.palette-info
|
||||||
:on-click (fn []
|
{:aria-label "palette not on the stage here"
|
||||||
(rf/dispatch [::preview nil])
|
:on-mouse-enter (fn [^js e]
|
||||||
(if (contains? (pal/palettes @(rf/subscribe [::render/clip])) (:id p))
|
(let [r (.getBoundingClientRect (.-currentTarget e))]
|
||||||
(rf/dispatch [::select (:id p) followed])
|
(reset! at [(+ (.-right r) 8) (- (.-top r) 6)])))
|
||||||
(rf/dispatch [::project/add-palette p])))
|
:on-mouse-leave #(reset! at nil)}
|
||||||
:on-double-click #(rf/dispatch [::project/use-palette sid p])}
|
"i"
|
||||||
[strip p] [:span.name (:name p)]]))]])
|
(when-let [[x y] @at]
|
||||||
|
[:span.info-card {:role "tooltip" :style {:left (str x "px") :top (str y "px")}}
|
||||||
(defn- chooser
|
[:strong (str (:name palette) " isn't on the stage here")]
|
||||||
"Every palette worth switching to, most relevant first: those the open
|
(str (or (clip/symbol-name clip sid) "This symbol")
|
||||||
symbol's tree draws in, saying where; the rest of this project's; those made
|
" draws in " (str/join " and " (map #(:name (get (pal/palettes clip) %)) on-stage))
|
||||||
in other projects, with the project's name; then the classics, folded. One
|
" at this frame. To draw in " (:name palette)
|
||||||
search reaches palette names and project names."
|
", set the authoring palette in the symbol inspector, or blend to it with a palette lane.")])]))))
|
||||||
[clip pid followed]
|
|
||||||
(r/with-let [renaming? (r/atom false) query (r/atom "")]
|
|
||||||
(let [sid @(rf/subscribe [::render/open])
|
|
||||||
compiled @(rf/subscribe [::render/palette])
|
|
||||||
frame @(rf/subscribe [::render/open-frame])
|
|
||||||
clip-id @(rf/subscribe [::render/clip-id])
|
|
||||||
listed (:palettes @(rf/subscribe [::project/assets]))
|
|
||||||
{project-id :id} @(rf/subscribe [::playback/project])
|
|
||||||
needle (str/lower-case (str/trim @query))
|
|
||||||
searching? (not (str/blank? needle))
|
|
||||||
_ (frame-raster clip (:store (store/entry clip-id)) compiled sid frame)
|
|
||||||
own (pal/palettes clip)
|
|
||||||
uses (group-by :palette
|
|
||||||
(cons {:palette (pal/default-palette-id clip) :project? true}
|
|
||||||
(clip/palette-uses clip sid)))
|
|
||||||
note-of (fn [id]
|
|
||||||
(str/join ", " (for [{:keys [sid via project?]} (get uses id)]
|
|
||||||
(if project? "project"
|
|
||||||
(str (clip/symbol-name clip sid) " · " (via-words via))))))
|
|
||||||
row (fn [p note]
|
|
||||||
{:p p :note note :on? (= (:id p) pid) :sid sid :followed followed
|
|
||||||
:thumb-url (thumb (pal/hexes-of p))})
|
|
||||||
here (for [[id p] own :when (contains? uses id)] (row p (note-of id)))
|
|
||||||
project (for [[id p] own
|
|
||||||
:when (and (not (contains? uses id)) (authored? (pal/hexes-of p)))]
|
|
||||||
(row p nil))
|
|
||||||
have (set (map pal/hexes-of (vals own)))
|
|
||||||
elsewhere (->> listed
|
|
||||||
(remove #(= project-id (:project %)))
|
|
||||||
(filter #(and (seq (:hexes %)) (authored? (:hexes %))
|
|
||||||
(not (contains? have (:hexes %)))))
|
|
||||||
(group-by (juxt :name :hexes))
|
|
||||||
(map (fn [[[label hexes] rows]]
|
|
||||||
(let [projects (str/join ", " (distinct (map :project-name rows)))]
|
|
||||||
(assoc (row (pal/from-hexes (random-uuid) label hexes) projects)
|
|
||||||
:key [label hexes] :search projects))))
|
|
||||||
(sort-by (comp str/lower-case :name :p)))
|
|
||||||
keep (fn [rows] (filter #(hit? needle (:name (:p %)) (:note %)) rows))
|
|
||||||
section (fn [title rows]
|
|
||||||
(when (seq rows)
|
|
||||||
[:<>
|
|
||||||
[:div.palette-head title]
|
|
||||||
(doall (for [r rows] ^{:key (str (or (:key r) (:id (:p r))))} [candidate-row r]))]))]
|
|
||||||
[:div.palette-chooser
|
|
||||||
[:input.palette-search {:type "search" :placeholder "search palettes and projects"
|
|
||||||
:aria-label "search palettes"
|
|
||||||
:value @query :on-change #(reset! query (.. % -target -value))}]
|
|
||||||
[:div.palette-list {:role "listbox" :aria-label "palettes"}
|
|
||||||
[section (str "in " (clip/symbol-name clip sid)) (keep here)]
|
|
||||||
[section "this project" (keep project)]
|
|
||||||
[section "your palettes" (keep elsewhere)]]
|
|
||||||
(when-let [open-p (and (not searching?) (get own pid))]
|
|
||||||
[:div.palette-editing
|
|
||||||
(if @renaming?
|
|
||||||
[rename pid open-p #(reset! renaming? false)]
|
|
||||||
[:<> [:span.dim "editing"] [:span.name (:name open-p)]
|
|
||||||
[:button.rename {:title (str "rename " (:name open-p)) :aria-label "rename palette"
|
|
||||||
:on-click #(swap! renaming? not)} "✎"]])])
|
|
||||||
[shelf (filter #(hit? needle (:name %)) pal/presets) followed searching? sid]])))
|
|
||||||
|
|
||||||
(defn assets
|
(defn assets
|
||||||
"The palettes behind a button at the foot of the strip: switch, rename, add.
|
"The palettes behind a button at the foot of the strip: switch, rename, add.
|
||||||
The name is NOT printed in the strip: 44px holds no palette's name, and a name
|
The name is NOT printed in the strip: 44px holds no palette's name, and a name
|
||||||
broken over three lines is worse than one shown when asked for."
|
broken over three lines is worse than one shown when asked for."
|
||||||
[]
|
[]
|
||||||
(let [[clip pid palette followed] (shown)]
|
(let [[clip pid palette] (shown)]
|
||||||
[:div.palette-assets-wrap
|
[:div.palette-assets-wrap
|
||||||
[menu/popover {:class "palette-assets" :title (str "palette: " (:name palette))
|
[menu/popover {:class "palette-assets" :title (str "palette: " (:name palette))
|
||||||
:label [:svg {:view-box "0 0 18 18" :width 18 :height 18}
|
:label [:svg {:view-box "0 0 18 18" :width 18 :height 18}
|
||||||
|
|
@ -428,8 +275,18 @@
|
||||||
[:circle {:cx 12.5 :cy 6.5 :r 1.3}]]}
|
[:circle {:cx 12.5 :cy 6.5 :r 1.3}]]}
|
||||||
(fn [_]
|
(fn [_]
|
||||||
[:div.palette-popout
|
[:div.palette-popout
|
||||||
[chooser clip pid followed]
|
[chooser clip pid]
|
||||||
[:div.row
|
[:div.row
|
||||||
[:button {:title "a new 16-slot palette" :on-click #(rf/dispatch [::project/new-palette])} "new"]
|
[:button {:title "a new 16-slot palette" :on-click #(rf/dispatch [::project/new-palette])} "new"]
|
||||||
[:button {:title (str "a copy of " (:name palette) " you can retone")
|
[:button {:title (str "a copy of " (:name palette) " you can retone")
|
||||||
:on-click #(rf/dispatch [::project/duplicate-palette pid])} "duplicate"]]])]]))
|
:on-click #(rf/dispatch [::project/duplicate-palette pid])} "duplicate"]]
|
||||||
|
(when-let [missing (seq (remove #(contains? (pal/palettes clip) (:id %)) pal/presets))]
|
||||||
|
[:div.palette-list {:aria-label "presets"}
|
||||||
|
(doall
|
||||||
|
(for [p missing]
|
||||||
|
^{:key (str (:id p))}
|
||||||
|
[:div.palette-row
|
||||||
|
[:button.choose {:title (str "add " (:name p) " to this project")
|
||||||
|
:on-click #(rf/dispatch [::project/add-palette p])}
|
||||||
|
[strip p] [:span.name (str "+ " (:name p))]]]))])])]
|
||||||
|
[elsewhere pid palette]]))
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -35,7 +35,6 @@
|
||||||
[arthur.ui.tracing :as tracing]
|
[arthur.ui.tracing :as tracing]
|
||||||
[arthur.ui.layout :as layout]
|
[arthur.ui.layout :as layout]
|
||||||
[re-frame.core :as rf]
|
[re-frame.core :as rf]
|
||||||
[re-frame.db :as rf-db]
|
|
||||||
[reagent.ratom :as ratom]))
|
[reagent.ratom :as ratom]))
|
||||||
|
|
||||||
(defonce ^:private state
|
(defonce ^:private state
|
||||||
|
|
@ -119,8 +118,7 @@
|
||||||
(fn [_ _]
|
(fn [_ _]
|
||||||
{:resolver (rf/subscribe [::render/shown])
|
{:resolver (rf/subscribe [::render/shown])
|
||||||
:palette (rf/subscribe [::render/palette])
|
:palette (rf/subscribe [::render/palette])
|
||||||
:preview (rf/subscribe [::render/palette-preview])
|
:ramp (rf/subscribe [::render/ramp])
|
||||||
:solo? (rf/subscribe [::render/palette-solo?])
|
|
||||||
:fps (rf/subscribe [::sub/fps])
|
:fps (rf/subscribe [::sub/fps])
|
||||||
:frames (rf/subscribe [::render/frames])
|
:frames (rf/subscribe [::render/frames])
|
||||||
:width (rf/subscribe [::sub/width])
|
:width (rf/subscribe [::sub/width])
|
||||||
|
|
@ -129,7 +127,6 @@
|
||||||
:tracing (rf/subscribe [::render/tracing])
|
:tracing (rf/subscribe [::render/tracing])
|
||||||
:frame (rf/subscribe [::sub/frame])
|
:frame (rf/subscribe [::sub/frame])
|
||||||
:playing? (rf/subscribe [::sub/playing?])
|
:playing? (rf/subscribe [::sub/playing?])
|
||||||
:range (rf/subscribe [::sub/range])
|
|
||||||
;; The pen's draft is drawn INTO the picture, filled, so what is on screen
|
;; The pen's draft is drawn INTO the picture, filled, so what is on screen
|
||||||
;; while placing points is the pixels a finished shape will be.
|
;; while placing points is the pixels a finished shape will be.
|
||||||
:draft (rf/subscribe [::ui-sub/draft])
|
:draft (rf/subscribe [::ui-sub/draft])
|
||||||
|
|
@ -163,8 +160,8 @@
|
||||||
;; in the editor's own state, so it changes what the canvases should
|
;; in the editor's own state, so it changes what the canvases should
|
||||||
;; show without touching the frame number OR the resolver.
|
;; show without touching the frame number OR the resolver.
|
||||||
(when-not (and (identical? (:resolver before) (:resolver now))
|
(when-not (and (identical? (:resolver before) (:resolver now))
|
||||||
(= (select-keys before [:tracing :pen :mat :onion :selection :playing? :preview :solo?])
|
(= (select-keys before [:tracing :pen :mat :onion :selection :playing?])
|
||||||
(select-keys now [:tracing :pen :mat :onion :selection :playing? :preview :solo?])))
|
(select-keys now [:tracing :pen :mat :onion :selection :playing?])))
|
||||||
(repaint!))))))
|
(repaint!))))))
|
||||||
|
|
||||||
;; The brush or eraser stroke being painted: its mask, mutated in place as the
|
;; The brush or eraser stroke being painted: its mask, mutated in place as the
|
||||||
|
|
@ -312,6 +309,11 @@
|
||||||
(defn in-rect [rect depth]
|
(defn in-rect [rect depth]
|
||||||
(pick/in-rect (:ops @state) rect depth))
|
(pick/in-rect (:ops @state) rect depth))
|
||||||
|
|
||||||
|
(defn- index-of-slot [palette active slot]
|
||||||
|
(if (and (:palettes palette) (:offsets palette))
|
||||||
|
(pal/render-index palette active slot)
|
||||||
|
slot))
|
||||||
|
|
||||||
(defn- traced
|
(defn- traced
|
||||||
"Stroke `s` as the rings letting go would make of it, `[outer & holes]` per
|
"Stroke `s` as the rings letting go would make of it, `[outer & holes]` per
|
||||||
piece: traced and simplified by the same function the saved shapes are, so
|
piece: traced and simplified by the same function the saved shapes are, so
|
||||||
|
|
@ -344,17 +346,17 @@
|
||||||
(defn- inked
|
(defn- inked
|
||||||
"Op `op` drawn in tone `tone`: a slot's colour, or — for a remap — light on
|
"Op `op` drawn in tone `tone`: a slot's colour, or — for a remap — light on
|
||||||
what is under it, through the same table the saved shape gets."
|
what is under it, through the same table the saved shape gets."
|
||||||
[op tone]
|
[op tone palette active]
|
||||||
(if (symbol/remap? tone)
|
(if (symbol/remap? tone)
|
||||||
(assoc op :lut (symbol/lut pal/slot tone) :color 0)
|
(assoc op :lut (symbol/lut #(index-of-slot palette active %) tone) :color 0)
|
||||||
(assoc op :color (pal/slot tone))))
|
(assoc op :color (index-of-slot palette active tone))))
|
||||||
|
|
||||||
(defn- with-previews
|
(defn- with-previews
|
||||||
"What is being drawn and is not in the document yet, added to `ops` in the
|
"What is being drawn and is not in the document yet, added to `ops` in the
|
||||||
stacking context of the symbol it will land in: the pen's draft as far as the
|
stacking context of the symbol it will land in: the pen's draft as far as the
|
||||||
pointer, a brush stroke as the polygons it will be, and an eraser's cut as
|
pointer, a brush stroke as the polygons it will be, and an eraser's cut as
|
||||||
the shapes it will leave."
|
the shapes it will leave."
|
||||||
[ops]
|
[ops palette active]
|
||||||
(let [{:keys [draft hover tone fit target]} (:pen @snapshot)
|
(let [{:keys [draft hover tone fit target]} (:pen @snapshot)
|
||||||
target (or target [])
|
target (or target [])
|
||||||
pts (cond-> (vec draft) (and (seq draft) hover) (into hover))
|
pts (cond-> (vec draft) (and (seq draft) hover) (into hover))
|
||||||
|
|
@ -362,13 +364,13 @@
|
||||||
rings (when (:mask s) (traced s fit))]
|
rings (when (:mask s) (traced s fit))]
|
||||||
(cond-> ops
|
(cond-> ops
|
||||||
(and (<= 6 (count pts)) (or (number? tone) (symbol/remap? tone)))
|
(and (<= 6 (count pts)) (or (number? tone) (symbol/remap? tone)))
|
||||||
(clip/atop target (inked (poly pts {}) tone))
|
(clip/atop target (inked (poly pts {}) tone palette active))
|
||||||
|
|
||||||
paths
|
paths
|
||||||
(cut-ops paths rings)
|
(cut-ops paths rings)
|
||||||
|
|
||||||
(and rings (not paths) (nil? knock))
|
(and rings (not paths) (nil? knock))
|
||||||
(as-> ops (reduce #(clip/atop %1 target (inked (poly (outline/join %2) {}) slot))
|
(as-> ops (reduce #(clip/atop %1 target (inked (poly (outline/join %2) {}) slot palette active))
|
||||||
ops rings))
|
ops rings))
|
||||||
|
|
||||||
(and rings (not paths) knock)
|
(and rings (not paths) knock)
|
||||||
|
|
@ -381,9 +383,7 @@
|
||||||
rasterised before the next frame is asked for."
|
rasterised before the next frame is asked for."
|
||||||
[f]
|
[f]
|
||||||
(let [{:keys [canvas]} @state
|
(let [{:keys [canvas]} @state
|
||||||
{:keys [resolver palette width height tracing playing? mat preview solo?] :as snap} @snapshot
|
{:keys [resolver palette ramp width height tracing playing? mat]} @snapshot]
|
||||||
tone (get-in snap [:pen :tone])
|
|
||||||
solo (when (and solo? (number? tone)) tone)]
|
|
||||||
(when (and canvas resolver width height)
|
(when (and canvas resolver width height)
|
||||||
;; User Timing, so a profile in the DevTools performance panel has named
|
;; User Timing, so a profile in the DevTools performance panel has named
|
||||||
;; spans in the Timings track instead of a wall of anonymous frames. Three
|
;; spans in the Timings track instead of a wall of anonymous frames. Three
|
||||||
|
|
@ -400,21 +400,12 @@
|
||||||
traces (when (:on? tracing)
|
traces (when (:on? tracing)
|
||||||
(into [] (remove #(contains? (:hidden tracing) (:layer %))) traces))
|
(into [] (remove #(contains? (:hidden tracing) (:layer %))) traces))
|
||||||
active (clip/active-palette resolver)
|
active (clip/active-palette resolver)
|
||||||
bg pal/bg-slot]
|
bg (pal/background-index palette active)]
|
||||||
;; The palette grid shows the frame's palette from here, the one place
|
(swap! state assoc :ops (into (vec picture) traces))
|
||||||
;; it is decided, rather than working it out again.
|
|
||||||
;; Keyed by the resolver too, as a new tab brings a new one.
|
|
||||||
(when (not= [resolver active] (:active @state))
|
|
||||||
(swap! state assoc :active [resolver active])
|
|
||||||
(rf/dispatch [::pb/frame-palette active]))
|
|
||||||
;; Soloed, only what is drawn in the chosen colour can be clicked.
|
|
||||||
(swap! state assoc :ops (if solo
|
|
||||||
(filterv #(or (#{:begin :end} (:kind %)) (= solo (:color %))) picture)
|
|
||||||
(into (vec picture) traces)))
|
|
||||||
;; What is drawn, cut to what is on screen: a frame with nothing off the
|
;; What is drawn, cut to what is on screen: a frame with nothing off the
|
||||||
;; stage costs what the stage does, and a drawing a dozen stages wide
|
;; stage costs what the stage does, and a drawing a dozen stages wide
|
||||||
;; costs no more than the pane it is seen through.
|
;; costs no more than the pane it is seen through.
|
||||||
(let [ops (with-previews picture)
|
(let [ops (with-previews picture palette active)
|
||||||
[ax ay bx by :as all] (reach ops width height)
|
[ax ay bx by :as all] (reach ops width height)
|
||||||
[vx vy wx wy] rect
|
[vx vy wx wy] rect
|
||||||
x0 (max ax vx) y0 (max ay vy) x1 (min bx wx) y1 (min by wy)]
|
x0 (max ax vx) y0 (max ay vy) x1 (min bx wx) y1 (min by wy)]
|
||||||
|
|
@ -424,14 +415,7 @@
|
||||||
(let [off? (or (neg? x0) (neg? y0) (< width x1) (< height y1))
|
(let [off? (or (neg? x0) (neg? y0) (< width x1) (< height y1))
|
||||||
ras (raster-for (- x1 x0) (- y1 y0) [x0 y0] off?)]
|
ras (raster-for (- x1 x0) (- y1 y0) [x0 y0] off?)]
|
||||||
(-> ras (raster/clear! bg) (raster/draw-ops! ops))
|
(-> ras (raster/clear! bg) (raster/draw-ops! ops))
|
||||||
(canvas/blit! canvas ras
|
(canvas/blit! canvas ras (pal/effective-ramp palette active) [width height]))
|
||||||
;; THE frame's colours: the one palette it is in,
|
|
||||||
;; or the one being previewed in its place.
|
|
||||||
(cond-> (if preview
|
|
||||||
(pal/ramp-of (:hexes preview))
|
|
||||||
(pal/effective-ramp palette active))
|
|
||||||
solo (pal/solo-ramp solo))
|
|
||||||
[width height]))
|
|
||||||
(canvas/hide! canvas)))
|
(canvas/hide! canvas)))
|
||||||
(tracing/paint! traces (assoc tracing :rect rect :zoom zoom :stage [width height] :playing? playing?) repaint!))
|
(tracing/paint! traces (assoc tracing :rect rect :zoom zoom :stage [width height] :playing? playing?) repaint!))
|
||||||
(js/performance.measure "arthur/resolve+draw" "arthur/paint:start" "arthur/blit:start")
|
(js/performance.measure "arthur/resolve+draw" "arthur/paint:start" "arthur/blit:start")
|
||||||
|
|
@ -451,23 +435,13 @@
|
||||||
(atom nil))
|
(atom nil))
|
||||||
|
|
||||||
(defn- tick! []
|
(defn- tick! []
|
||||||
(let [{:keys [fps frames frame playing? range]} @snapshot
|
(let [{:keys [fps frames frame playing?]} @snapshot
|
||||||
live? (clock/playing?)
|
live? (clock/playing?)
|
||||||
ready? (some? (:canvas @state))
|
ready? (some? (:canvas @state))
|
||||||
;; DERIVED, never counted. A slow frame drops the frames it missed and
|
;; DERIVED, never counted. A slow frame drops the frames it missed and
|
||||||
;; the next one lands where the audio already is, so the failure mode is
|
;; the next one lands where the audio already is, so the failure mode is
|
||||||
;; a visible stutter rather than an invisible slide out of sync.
|
;; a visible stutter rather than an invisible slide out of sync.
|
||||||
f (if live? (clock/frame fps frames) frame)
|
f (if live? (clock/frame fps frames) frame)]
|
||||||
;; PAST THE OUT MARK, BACK TO THE IN, as Blender's preview range loops.
|
|
||||||
;; Here rather than in either clock, so both backends loop the same
|
|
||||||
;; way, and before the paint, so the frame after the out is never shown.
|
|
||||||
;; CROSSING it, from a frame at or before it: played from past the out
|
|
||||||
;; mark, playback goes on from there.
|
|
||||||
out (or (:out range) (dec frames))
|
|
||||||
wrap? (and live? range (some-> (:played @state) (<= out)) (< out f))
|
|
||||||
f (if wrap? (or (:in range) 0) f)]
|
|
||||||
(swap! state assoc :played (when live? f))
|
|
||||||
(when wrap? (rf/dispatch [::pb/seek f]))
|
|
||||||
;; A paused scrub is an explicit seek, not a playback sample. Clear the
|
;; A paused scrub is an explicit seek, not a playback sample. Clear the
|
||||||
;; meter before the next play so its first frame cannot count the seek as
|
;; meter before the next play so its first frame cannot count the seek as
|
||||||
;; dropped frames or leave a stale low rate in the transport.
|
;; dropped frames or leave a stale low rate in the transport.
|
||||||
|
|
@ -493,14 +467,8 @@
|
||||||
(when live? (rf/dispatch [::pb/tick f])))
|
(when live? (rf/dispatch [::pb/tick f])))
|
||||||
;; The audio ending is the authority on playback having stopped; nothing
|
;; The audio ending is the authority on playback having stopped; nothing
|
||||||
;; counts frames to notice it.
|
;; counts frames to notice it.
|
||||||
;; With marks, running off the end goes round again from the in.
|
(when (and (not live?) playing?)
|
||||||
;;
|
(rf/dispatch [::pb/pause]))))
|
||||||
;; THE DB, NOT THE SNAPSHOT, says whether it is meant to be playing. The
|
|
||||||
;; snapshot catches up a frame late, so straight after a pause it still
|
|
||||||
;; said playing — and with marks that read as running off the end and
|
|
||||||
;; started it again, so pause never stuck while looping.
|
|
||||||
(when (and (not live?) playing? (get-in @rf-db/app-db [:playback :playing?]))
|
|
||||||
(rf/dispatch (if range [::pb/play] [::pb/pause])))))
|
|
||||||
|
|
||||||
(defn- frame-loop []
|
(defn- frame-loop []
|
||||||
;; Scheduled BEFORE the tick, so nothing the tick does can end the loop.
|
;; Scheduled BEFORE the tick, so nothing the tick does can end the loop.
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,6 @@
|
||||||
`events.footage/relabel`. A symbol of ANOTHER project is renameable where it
|
`events.footage/relabel`. A symbol of ANOTHER project is renameable where it
|
||||||
lives and not from here.
|
lives and not from here.
|
||||||
|
|
||||||
ADDING IS AT THE FOOT: a new empty symbol, which goes into the library and is
|
|
||||||
placed nowhere until it is dragged, and an upload, which is the same as a file
|
|
||||||
dropped on the pane.
|
|
||||||
|
|
||||||
THE WHOLE PANE IS THE DROP TARGET for a file. A video dropped anywhere in it
|
THE WHOLE PANE IS THE DROP TARGET for a file. A video dropped anywhere in it
|
||||||
uploads and lands in THIS PROJECT's media, and goes no further: which frames of
|
uploads and lands in THIS PROJECT's media, and goes no further: which frames of
|
||||||
it become a symbol, and what that symbol is called, is asked when it is dropped
|
it become a symbol, and what that symbol is called, is asked when it is dropped
|
||||||
|
|
@ -98,29 +94,29 @@
|
||||||
most phone footage opens on. A symbol's frame 0 is authored: what is on it is
|
most phone footage opens on. A symbol's frame 0 is authored: what is on it is
|
||||||
there because somebody put it there, and the frame a person names a symbol by
|
there because somebody put it there, and the frame a person names a symbol by
|
||||||
is the one it starts on."
|
is the one it starts on."
|
||||||
[document sid store palette]
|
[document sid store palette ramp]
|
||||||
(try
|
(try
|
||||||
(when (clip/symbol document sid)
|
(when (clip/symbol document sid)
|
||||||
(let [resolve (clip/resolver document sid store palette {})
|
(let [resolve (clip/resolver document sid store palette {})
|
||||||
[w h] (clip/stage document sid)]
|
[w h] (clip/stage document sid)]
|
||||||
(let [ops (resolve 0)]
|
(let [ops (resolve 0)]
|
||||||
(-> (raster/make w h)
|
(-> (raster/make w h)
|
||||||
(raster/clear! pal/bg-slot)
|
(raster/clear! (pal/background-index palette (clip/active-palette resolve)))
|
||||||
(raster/draw-ops! ops)
|
(raster/draw-ops! ops)
|
||||||
(canvas/->png (pal/effective-ramp palette (clip/active-palette resolve)))))))
|
(canvas/->png ramp)))))
|
||||||
(catch :default _ nil)))
|
(catch :default _ nil)))
|
||||||
|
|
||||||
(defn- symbol-thumb
|
(defn- symbol-thumb
|
||||||
"`draw-symbol`, once per symbol per version of the document. Rasterising and
|
"`draw-symbol`, once per symbol per version of the document. Rasterising and
|
||||||
PNG-encoding the stage is milliseconds, and the pool redraws on every selection
|
PNG-encoding the stage is milliseconds, and the pool redraws on every selection
|
||||||
click."
|
click."
|
||||||
[document sid store palette]
|
[document sid store palette ramp]
|
||||||
(when-not (identical? document (:clip @thumbs))
|
(when-not (identical? document (:clip @thumbs))
|
||||||
(reset! thumbs {:clip document :urls {}}))
|
(reset! thumbs {:clip document :urls {}}))
|
||||||
(let [urls (:urls @thumbs)]
|
(let [urls (:urls @thumbs)]
|
||||||
(if (contains? urls sid)
|
(if (contains? urls sid)
|
||||||
(get urls sid)
|
(get urls sid)
|
||||||
(let [url (draw-symbol document sid store palette)]
|
(let [url (draw-symbol document sid store palette ramp)]
|
||||||
(swap! thumbs assoc-in [:urls sid] url)
|
(swap! thumbs assoc-in [:urls sid] url)
|
||||||
url))))
|
url))))
|
||||||
|
|
||||||
|
|
@ -256,7 +252,7 @@
|
||||||
;; ---------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------
|
||||||
;; the rows of each kind
|
;; the rows of each kind
|
||||||
|
|
||||||
(defn- symbol-row [document sid {:keys [clip-id store palette selection open main rename]}]
|
(defn- symbol-row [document sid {:keys [clip-id store palette ramp selection open main rename]}]
|
||||||
(let [sym (clip/symbol document sid)
|
(let [sym (clip/symbol document sid)
|
||||||
label (clip/symbol-name document sid)
|
label (clip/symbol-name document sid)
|
||||||
nodes (count (:nodes sym))]
|
nodes (count (:nodes sym))]
|
||||||
|
|
@ -271,7 +267,7 @@
|
||||||
" — double-click to open, drag to place"))
|
" — double-click to open, drag to place"))
|
||||||
:thumb (if (= :trace (:type sym))
|
:thumb (if (= :trace (:type sym))
|
||||||
[tracing-thumb (:media sym)]
|
[tracing-thumb (:media sym)]
|
||||||
[picture (symbol-thumb document sid store palette)])
|
[picture (symbol-thumb document sid store palette ramp)])
|
||||||
:sub2 (str (:frames sym) "f · " nodes (if (= 1 nodes) " node" " nodes"))
|
:sub2 (str (:frames sym) "f · " nodes (if (= 1 nodes) " node" " nodes"))
|
||||||
:on? (= selection [:symbol sid])
|
:on? (= selection [:symbol sid])
|
||||||
:open? (= sid open)
|
:open? (= sid open)
|
||||||
|
|
@ -441,7 +437,7 @@
|
||||||
|
|
||||||
Still not `:main` being special. The document says which symbol that is by its
|
Still not `:main` being special. The document says which symbol that is by its
|
||||||
structure; rename it, place it inside something else, and the pool follows."
|
structure; rename it, place it inside something else, and the pool follows."
|
||||||
[{:keys [document query searching? media sounds images chosen rename main selection] :as ctx}]
|
[{:keys [document query searching? media sounds images chosen rename main palette-choice selection] :as ctx}]
|
||||||
(let [named? #(hit? query (clip/symbol-name document %))
|
(let [named? #(hit? query (clip/symbol-name document %))
|
||||||
top (when (and main (named? main)) main)
|
top (when (and main (named? main)) main)
|
||||||
symbol-ids (sort-by str (keys (:symbols document)))
|
symbol-ids (sort-by str (keys (:symbols document)))
|
||||||
|
|
@ -566,7 +562,9 @@
|
||||||
clip-id @(rf/subscribe [::render/clip-id])
|
clip-id @(rf/subscribe [::render/clip-id])
|
||||||
store @(rf/subscribe [::render/store])
|
store @(rf/subscribe [::render/store])
|
||||||
palette @(rf/subscribe [::render/palette])
|
palette @(rf/subscribe [::render/palette])
|
||||||
|
ramp @(rf/subscribe [::render/ramp])
|
||||||
selection @(rf/subscribe [::sub/selection])
|
selection @(rf/subscribe [::sub/selection])
|
||||||
|
palette-choice @(rf/subscribe [:arthur.ui.palette/chosen])
|
||||||
open @(rf/subscribe [::render/open])
|
open @(rf/subscribe [::render/open])
|
||||||
media @(rf/subscribe [::sub/project-footage])
|
media @(rf/subscribe [::sub/project-footage])
|
||||||
{:keys [symbols palettes]} @(rf/subscribe [::project/assets])
|
{:keys [symbols palettes]} @(rf/subscribe [::project/assets])
|
||||||
|
|
@ -586,11 +584,12 @@
|
||||||
needle (str/lower-case (str/trim @query))
|
needle (str/lower-case (str/trim @query))
|
||||||
searching? (boolean (seq needle))
|
searching? (boolean (seq needle))
|
||||||
ctx {:document document :clip-id clip-id :store store :palette palette
|
ctx {:document document :clip-id clip-id :store store :palette palette
|
||||||
:selection selection :open open
|
:ramp ramp :selection selection :open open
|
||||||
:media media :sounds own-sounds :images own-images :chosen chosen
|
:media media :sounds own-sounds :images own-images :chosen chosen
|
||||||
:available (vec available) :all-sounds (vec sounds)
|
:available (vec available) :all-sounds (vec sounds)
|
||||||
:all-images (vec images)
|
:all-images (vec images)
|
||||||
:symbols symbols :palettes palettes :project-id project-id
|
:symbols symbols :palettes palettes :project-id project-id
|
||||||
|
:palette-choice palette-choice
|
||||||
:query needle :searching? searching?
|
:query needle :searching? searching?
|
||||||
;; `clip/opens-on` and not `:main`: the longest symbol nothing
|
;; `clip/opens-on` and not `:main`: the longest symbol nothing
|
||||||
;; else places is the timeline the work happens in, and it is the
|
;; else places is the timeline the work happens in, and it is the
|
||||||
|
|
@ -611,7 +610,13 @@
|
||||||
(reset! depth 0)
|
(reset! depth 0)
|
||||||
(when-let [file (aget (.. e -dataTransfer -files) 0)]
|
(when-let [file (aget (.. e -dataTransfer -files) 0)]
|
||||||
(rf/dispatch [::footage/upload file])))}
|
(rf/dispatch [::footage/upload file])))}
|
||||||
[:div.pane-head "media pool"]
|
[:div.pane-head
|
||||||
|
"media pool"
|
||||||
|
[:span.spacer]
|
||||||
|
[:button {:title "add a video, a sound or an image"
|
||||||
|
:disabled loading?
|
||||||
|
:on-click #(.click (js/document.getElementById "pool-file"))}
|
||||||
|
"+"]]
|
||||||
[:input {:id "pool-file" :type "file" :accept "video/*,audio/*,image/*"
|
[:input {:id "pool-file" :type "file" :accept "video/*,audio/*,image/*"
|
||||||
:style {:display "none"}
|
:style {:display "none"}
|
||||||
:on-change (fn [^js event]
|
:on-change (fn [^js event]
|
||||||
|
|
@ -641,22 +646,4 @@
|
||||||
[:span.count (get tallies k)])]))]
|
[:span.count (get tallies k)])]))]
|
||||||
[:div.pane-body
|
[:div.pane-body
|
||||||
(if (= :project @scope) [this-project ctx] [all-assets ctx])
|
(if (= :project @scope) [this-project ctx] [all-assets ctx])
|
||||||
(when status [:div.dim status])]
|
(when status [:div.dim status])]])))
|
||||||
;; At the foot, where a list's own "add one" goes, and pinned there so it
|
|
||||||
;; does not scroll away under a long one.
|
|
||||||
[:div.pool-foot
|
|
||||||
[:button {:title "a new empty symbol in this project's library"
|
|
||||||
:on-click (fn [_]
|
|
||||||
(let [sid (clip/fresh-id document)]
|
|
||||||
(rf/dispatch [::project/add-symbol sid])
|
|
||||||
(rf/dispatch [::ui/select [:symbol sid]])
|
|
||||||
;; Show its row and open its name, so what it
|
|
||||||
;; is called is the next thing you type.
|
|
||||||
(reset! scope :project)
|
|
||||||
(reset! query "")
|
|
||||||
(reset! editing [:symbol sid])))}
|
|
||||||
"+ symbol"]
|
|
||||||
[:button {:title "add a video, a sound or an image — or drop one on this pane"
|
|
||||||
:disabled loading?
|
|
||||||
:on-click #(.click (js/document.getElementById "pool-file"))}
|
|
||||||
"upload…"]]])))
|
|
||||||
|
|
|
||||||
|
|
@ -92,9 +92,9 @@
|
||||||
apply! (fn [mode] (close!) (rf/dispatch [::project/set-fps to mode]))
|
apply! (fn [mode] (close!) (rf/dispatch [::project/set-fps to mode]))
|
||||||
changed? (and to (not= to fps))]
|
changed? (and to (not= to fps))]
|
||||||
[:<>
|
[:<>
|
||||||
[:button {:disabled disabled? :title "frame rate · change it"
|
[:label.inspector-field "frame rate"
|
||||||
:on-click #(do (reset! draft fps) (reset! open? true))}
|
[:button {:disabled disabled? :on-click #(do (reset! draft fps) (reset! open? true))}
|
||||||
(str fps " fps")]
|
(str fps " fps")]]
|
||||||
(when @open?
|
(when @open?
|
||||||
[dialog "Frame rate" close!
|
[dialog "Frame rate" close!
|
||||||
[chips (str "from " fps " fps to") rates to #(str % " fps") #(reset! draft %)
|
[chips (str "from " fps " fps to") rates to #(str % " fps") #(reset! draft %)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
[arthur.ui.location :as location]
|
[arthur.ui.location :as location]
|
||||||
[arthur.ui.params :as params]
|
[arthur.ui.params :as params]
|
||||||
[arthur.ui.pool :as pool]
|
[arthur.ui.pool :as pool]
|
||||||
[arthur.ui.shortcuts :as shortcuts]
|
|
||||||
[arthur.ui.stage :as stage]
|
[arthur.ui.stage :as stage]
|
||||||
[arthur.ui.tabs :as tabs]
|
[arthur.ui.tabs :as tabs]
|
||||||
[arthur.ui.timeline :as timeline]
|
[arthur.ui.timeline :as timeline]
|
||||||
|
|
@ -71,7 +70,6 @@
|
||||||
gone? #(contains? shut %)]
|
gone? #(contains? shut %)]
|
||||||
[:div.app {:style (layout/vars state)}
|
[:div.app {:style (layout/vars state)}
|
||||||
[topbar/view]
|
[topbar/view]
|
||||||
[shortcuts/sheet]
|
|
||||||
(when-not (gone? :pool) [pool/view])
|
(when-not (gone? :pool) [pool/view])
|
||||||
(when-not (gone? :pool) [layout/grip :pool pool :col 1])
|
(when-not (gone? :pool) [layout/grip :pool pool :col 1])
|
||||||
[:section.view
|
[:section.view
|
||||||
|
|
|
||||||
|
|
@ -1,209 +0,0 @@
|
||||||
(ns arthur.ui.shortcuts
|
|
||||||
"Every key the window answers to, as one table, and the sheet that lists them.
|
|
||||||
|
|
||||||
A COMMAND IS DATA: what it is called, which keys reach it, and a function of
|
|
||||||
the db that answers the event to send, or nil for nothing to do. One listener
|
|
||||||
reads the table, the `?` sheet prints it, and nothing else in the app listens
|
|
||||||
to the window for keys. What a key does in one element only — nudging the
|
|
||||||
timeline's selected keys, Enter in a rename field — stays on that element,
|
|
||||||
which handles it first and stops it, as Blender's modal operators do.
|
|
||||||
|
|
||||||
NO MODES. A key means one thing everywhere and what it acts on is the
|
|
||||||
selection, so there is no state to remember besides the tool. Space is the one
|
|
||||||
key with two meanings, and they are told apart by the hand rather than by a
|
|
||||||
mode: tapped it plays, held and dragged on the stage it pans, as in Photoshop.
|
|
||||||
|
|
||||||
THE KEYS ARE BLENDER'S, then Resolve's, then Flash's and Harmony's. WASD repeats the arrows
|
|
||||||
for a hand that stays on the left of the keyboard while the other holds the
|
|
||||||
pen. Letters are matched by where they are on the keyboard, not by what they
|
|
||||||
type, so WASD is WASD on any layout.
|
|
||||||
|
|
||||||
SHIFT IS THE ONE MODIFIER, and ⌘ only where the browser's own convention is
|
|
||||||
(undo, the clipboard). Alt types characters on a Mac and is the browser's
|
|
||||||
elsewhere, so nothing here uses it — a key with it passes through untouched."
|
|
||||||
(:require [arthur.events.history :as history]
|
|
||||||
[arthur.events.playback :as pb]
|
|
||||||
[arthur.events.ui :as ui]
|
|
||||||
[arthur.footage.store :as store]
|
|
||||||
[arthur.ui.layout :as layout]
|
|
||||||
[arthur.ui.timeline :as timeline]
|
|
||||||
[clojure.string :as str]
|
|
||||||
[re-frame.core :as rf]
|
|
||||||
[re-frame.db :as db]
|
|
||||||
[reagent.core :as r]))
|
|
||||||
|
|
||||||
(defn stops
|
|
||||||
"The frames ↑ and ↓ stop on: every key and every clip edge the timeline shows,
|
|
||||||
as frames of the open symbol. In a lane that is drawing to drawing, on a tween
|
|
||||||
key to key — one rule, read off the rows the timeline draws, so a jump lands
|
|
||||||
on something you can see."
|
|
||||||
[db]
|
|
||||||
(let [{document :clip} (store/entry (:clip/current db))
|
|
||||||
selection (get-in db [:ui :selection])
|
|
||||||
n (pb/frames db)]
|
|
||||||
(into (sorted-set)
|
|
||||||
(comp (mapcat (fn [{:keys [keys span cels]}]
|
|
||||||
(concat keys span (mapcat (juxt :span :keys) cels))))
|
|
||||||
(mapcat #(if (number? %) [%] %))
|
|
||||||
;; The first whole frame that shows it, forgiving the rounding
|
|
||||||
;; a mapped key picks up on its way through a clock.
|
|
||||||
(map #(js/Math.ceil (- % 1e-6)))
|
|
||||||
(filter #(< -1 % n)))
|
|
||||||
(when document
|
|
||||||
(timeline/rows document (get-in db [:ui :open]) (get-in db [:ui :expanded])
|
|
||||||
(when (= :node (first selection)) (nth selection 3)))))))
|
|
||||||
|
|
||||||
(defn- frame [db] (get-in db [:playback :frame] 0))
|
|
||||||
(defn- seek [f] [::pb/seek f])
|
|
||||||
|
|
||||||
(def commands
|
|
||||||
[["Time"
|
|
||||||
[{:label "Play / pause" :keys ["Space"] :run (constantly [::pb/toggle])
|
|
||||||
:note "hold and drag on the stage to pan"}
|
|
||||||
{:label "Previous frame" :keys ["ArrowLeft" "a"] :run #(seek (dec (frame %)))}
|
|
||||||
{:label "Next frame" :keys ["ArrowRight" "d"] :run #(seek (inc (frame %)))}
|
|
||||||
{:label "Previous key" :keys ["ArrowDown" "s"]
|
|
||||||
:run #(some-> (first (rsubseq (stops %) < (frame %))) seek)}
|
|
||||||
{:label "Next key" :keys ["ArrowUp" "w"]
|
|
||||||
:run #(some-> (first (subseq (stops %) > (frame %))) seek)}
|
|
||||||
{:label "First frame" :keys ["Home" "shift+ArrowLeft" "shift+a"] :run (constantly (seek 0))}
|
|
||||||
{:label "Last frame" :keys ["End" "shift+ArrowRight" "shift+d"] :run #(seek (dec (pb/frames %)))}
|
|
||||||
{:label "Mark in" :keys ["i"] :run (constantly [::pb/mark :in])
|
|
||||||
:note "playback loops between the marks"}
|
|
||||||
{:label "Mark out" :keys ["o"] :run (constantly [::pb/mark :out])}
|
|
||||||
{:label "Clear in" :keys ["shift+i"] :run (constantly [::pb/clear-mark :in])}
|
|
||||||
{:label "Clear out" :keys ["shift+o"] :run (constantly [::pb/clear-mark :out])}
|
|
||||||
{:label "Tracing" :keys ["t"]
|
|
||||||
:run #(vector ::ui/tracing-on (not (get-in % [:ui :tracing :on?])))}
|
|
||||||
{:label "Tracing for the selection only" :keys ["shift+t"]
|
|
||||||
:run (constantly [::ui/trace-selection])}
|
|
||||||
{:label "Onion skin" :keys ["g"] :note "ghosts"
|
|
||||||
:run #(let [on? (get-in % [:ui :onion (:clip/current %) (get-in % [:ui :open]) :on?])]
|
|
||||||
[::layout/onion :on? (not on?)])}]]
|
|
||||||
["Animate"
|
|
||||||
[{:label "Key here" :keys ["k"]
|
|
||||||
:note "in a lane, a copy of the drawing from the playhead on"
|
|
||||||
:run #(if (ui/lane-here %) [::ui/drawing-here true] [::ui/key-selected])}
|
|
||||||
{:label "Blank drawing here" :keys ["shift+k"] :run (constantly [::ui/drawing-here false])}
|
|
||||||
{:label "One frame longer" :keys ["=" "+"] :note "moves the end of the selection's span"
|
|
||||||
:run #(when-let [p (ui/span-path %)] [::ui/slide p 1 :out true])}
|
|
||||||
{:label "One frame shorter" :keys ["-"]
|
|
||||||
:run #(when-let [p (ui/span-path %)] [::ui/slide p -1 :out true])}]]
|
|
||||||
["Make"
|
|
||||||
[{:label "New symbol" :keys ["n"] :run (constantly [::ui/new :inside false])
|
|
||||||
:note "in the selected symbol; in a lane, a blank drawing"}
|
|
||||||
{:label "New lane" :keys ["shift+n"] :run (constantly [::ui/new :inside true])}
|
|
||||||
{:label "New symbol at the top of the tab" :keys ["m"] :run (constantly [::ui/new :top false])}
|
|
||||||
{:label "New lane at the top of the tab" :keys ["shift+m"] :run (constantly [::ui/new :top true])}]]
|
|
||||||
["Draw"
|
|
||||||
[{:label "Select" :keys ["v"] :run (constantly [::ui/tool-key "v"])}
|
|
||||||
{:label "Pen" :keys ["p"] :run (constantly [::ui/tool-key "p"])}
|
|
||||||
{:label "Brush" :keys ["b"] :run (constantly [::ui/tool-key "b"])}
|
|
||||||
{:label "Eraser" :keys ["e"] :run (constantly [::ui/tool-key "e"])}
|
|
||||||
{:label "Smaller brush" :keys ["["] :run (constantly [::ui/tool-key "["])}
|
|
||||||
{:label "Bigger brush" :keys ["]"] :run (constantly [::ui/tool-key "]"])}
|
|
||||||
{:label "Close the pen's shape" :keys ["Enter"] :run (constantly [::ui/tool-key "enter"])}
|
|
||||||
{:label "Leave the pen" :keys ["Escape"] :run (constantly [::ui/tool-key "escape"])}]]
|
|
||||||
["Edit"
|
|
||||||
[{:label "Undo" :keys ["mod+z"] :run (constantly [::history/undo])}
|
|
||||||
{:label "Redo" :keys ["mod+shift+z" "mod+y"] :run (constantly [::history/redo])}
|
|
||||||
{:label "Copy" :keys ["mod+c"] :run (constantly [::ui/copy])}
|
|
||||||
{:label "Cut" :keys ["mod+x"] :run (constantly [::ui/cut])}
|
|
||||||
{:label "Paste" :keys ["mod+v"] :run (constantly [::ui/paste])}
|
|
||||||
{:label "Duplicate" :keys ["mod+d"] :run (constantly [::ui/duplicate])}
|
|
||||||
{:label "Duplicate as new symbol" :keys ["mod+shift+d"] :run (constantly [::ui/duplicate-unique])}
|
|
||||||
{:label "Delete" :keys ["Delete" "Backspace"] :run (constantly [::ui/delete-selected])}]]
|
|
||||||
["Help"
|
|
||||||
[{:label "These shortcuts" :keys ["?"]}]]])
|
|
||||||
|
|
||||||
(def ^:private by-chord
|
|
||||||
(into {} (for [[_ cs] commands c cs k (:keys c)] [k c])))
|
|
||||||
|
|
||||||
(defn- chord
|
|
||||||
"The key as the table spells it: `mod+` for ⌘ or Ctrl, then `alt+`, then
|
|
||||||
`shift+` — except on a character that shift itself typed, like `?`."
|
|
||||||
[^js e]
|
|
||||||
(let [code (.-code e)
|
|
||||||
letter (when (str/starts-with? code "Key") (str/lower-case (subs code 3)))
|
|
||||||
k (cond letter letter (= "Space" code) "Space" :else (.-key e))]
|
|
||||||
(str (when (or (.-metaKey e) (.-ctrlKey e)) "mod+")
|
|
||||||
(when (.-altKey e) "alt+")
|
|
||||||
(when (and (.-shiftKey e) (or letter (< 1 (count k)))) "shift+")
|
|
||||||
k)))
|
|
||||||
|
|
||||||
(defn- typing?
|
|
||||||
"Is a key going into a field? A slider or a checkbox has focus without taking
|
|
||||||
letters, so the window's keys still work there, as a tool's key does in
|
|
||||||
Photoshop."
|
|
||||||
[^js target]
|
|
||||||
(or (#{"TEXTAREA" "SELECT"} (.-tagName target))
|
|
||||||
(and (= "INPUT" (.-tagName target))
|
|
||||||
(not (#{"range" "checkbox" "radio" "button" "color"} (.-type target))))
|
|
||||||
(.-isContentEditable target)))
|
|
||||||
|
|
||||||
(defn- press!
|
|
||||||
"Send what key `k` answers now, against the db as it is.
|
|
||||||
|
|
||||||
SYNCHRONOUSLY, so a held arrow counts every repeat. Dispatched instead, two
|
|
||||||
presses in quick succession both read the frame before either had moved it,
|
|
||||||
and D D went one frame."
|
|
||||||
[k]
|
|
||||||
(when-let [ev (some-> (get-in by-chord [k :run]) (#(% @db/app-db)))]
|
|
||||||
(rf/dispatch-sync ev)))
|
|
||||||
|
|
||||||
;; Nil, :held, or :panned once a drag on the stage has used the hold — see
|
|
||||||
;; `ui/stage`. A tap is a hold that was never used.
|
|
||||||
(defonce space (atom nil))
|
|
||||||
(defonce ^:private open? (r/atom false))
|
|
||||||
|
|
||||||
(defn- on-key-down [^js e]
|
|
||||||
(when-not (typing? (.-target e))
|
|
||||||
(let [k (chord e)]
|
|
||||||
(cond
|
|
||||||
(and @open? (#{"Escape" "?"} k)) (do (.preventDefault e) (reset! open? false))
|
|
||||||
(= "?" k) (do (.preventDefault e) (reset! open? true))
|
|
||||||
;; Played on the way UP, because only then is it known to be a tap.
|
|
||||||
;; Default prevented both ways, or a focused button clicks as well.
|
|
||||||
(= "Space" k) (do (.preventDefault e)
|
|
||||||
(when-not (.-repeat e) (reset! space :held)))
|
|
||||||
(by-chord k) (do (.preventDefault e) (press! k))))))
|
|
||||||
|
|
||||||
(defn- on-key-up [^js e]
|
|
||||||
(when (= "Space" (.-code e))
|
|
||||||
(when (= :held @space)
|
|
||||||
(.preventDefault e)
|
|
||||||
(press! "Space"))
|
|
||||||
(reset! space nil)))
|
|
||||||
|
|
||||||
(defn install! []
|
|
||||||
(.addEventListener js/window "keydown" on-key-down)
|
|
||||||
(.addEventListener js/window "keyup" on-key-up)
|
|
||||||
(.addEventListener js/window "blur" #(reset! space nil)))
|
|
||||||
|
|
||||||
(def ^:private glyphs
|
|
||||||
{"mod" "⌘" "shift" "⇧" "ArrowLeft" "←" "ArrowRight" "→"
|
|
||||||
"ArrowUp" "↑" "ArrowDown" "↓" "Backspace" "⌫" "Escape" "Esc"})
|
|
||||||
|
|
||||||
(defn- spell [k]
|
|
||||||
(apply str (map #(or (glyphs %) (str/upper-case %)) (str/split k #"\+"))))
|
|
||||||
|
|
||||||
(defn sheet
|
|
||||||
"The `?` sheet. Shut by Esc, by `?` again, or by a click anywhere off it."
|
|
||||||
[]
|
|
||||||
(when @open?
|
|
||||||
[:<>
|
|
||||||
[:div.keys-scrim {:on-click #(reset! open? false)}]
|
|
||||||
[:section.keys-sheet {:role "dialog" :aria-modal true :aria-label "Keyboard shortcuts"}
|
|
||||||
(for [[title cs] commands]
|
|
||||||
^{:key title}
|
|
||||||
[:div.keys-group
|
|
||||||
[:h3 title]
|
|
||||||
(for [{:keys [label note] ks :keys} cs]
|
|
||||||
^{:key label}
|
|
||||||
[:div.keys-row
|
|
||||||
[:span label (when note [:small note])]
|
|
||||||
[:span.keys (for [k ks] ^{:key k} [:kbd (spell k)])]])])]]))
|
|
||||||
|
|
||||||
(defn button []
|
|
||||||
[:button {:title "keyboard shortcuts (?)" :aria-label "keyboard shortcuts"
|
|
||||||
:on-click #(reset! open? true)} "?"])
|
|
||||||
|
|
@ -28,7 +28,6 @@
|
||||||
[arthur.ui.layout :as layout]
|
[arthur.ui.layout :as layout]
|
||||||
[arthur.ui.player :as player]
|
[arthur.ui.player :as player]
|
||||||
[arthur.ui.tracing :as tracing]
|
[arthur.ui.tracing :as tracing]
|
||||||
[arthur.ui.shortcuts :as shortcuts]
|
|
||||||
[arthur.ui.tools :as tools]
|
[arthur.ui.tools :as tools]
|
||||||
[arthur.ui.timeline :as timeline]
|
[arthur.ui.timeline :as timeline]
|
||||||
[re-frame.core :as rf]
|
[re-frame.core :as rf]
|
||||||
|
|
@ -759,10 +758,24 @@
|
||||||
(when pen? [draft-lines draft hover])
|
(when pen? [draft-lines draft hover])
|
||||||
(when paints? [cursor tool])]))
|
(when paints? [cursor tool])]))
|
||||||
|
|
||||||
|
(defonce space-held? (atom false))
|
||||||
(defonce pan (atom nil))
|
(defonce pan (atom nil))
|
||||||
(defonce navigation-blur
|
(defn- stage-key-target? [target]
|
||||||
|
(and (.closest target ".stage-area")
|
||||||
|
(not (.closest target "input, textarea, select, button, a, summary, [role='button']"))
|
||||||
|
(not (.-isContentEditable target))))
|
||||||
|
|
||||||
|
(defonce navigation-keys
|
||||||
(when (exists? js/window)
|
(when (exists? js/window)
|
||||||
(.addEventListener js/window "blur" #(reset! pan nil))))
|
(.addEventListener js/window "keydown"
|
||||||
|
(fn [e]
|
||||||
|
(when (and (= "Space" (.-code e))
|
||||||
|
(not (or (.-ctrlKey e) (.-metaKey e) (.-altKey e)))
|
||||||
|
(stage-key-target? (.-target e)))
|
||||||
|
(.preventDefault e)
|
||||||
|
(reset! space-held? true))))
|
||||||
|
(.addEventListener js/window "keyup" #(when (= "Space" (.-code %)) (reset! space-held? false)))
|
||||||
|
(.addEventListener js/window "blur" #(do (reset! space-held? false) (reset! pan nil)))))
|
||||||
|
|
||||||
(defonce pinch-start-zoom (atom nil))
|
(defonce pinch-start-zoom (atom nil))
|
||||||
|
|
||||||
|
|
@ -804,10 +817,8 @@
|
||||||
(fn [e] (.preventDefault e) (reset! pinch-start-zoom nil))))
|
(fn [e] (.preventDefault e) (reset! pinch-start-zoom nil))))
|
||||||
nil)
|
nil)
|
||||||
:on-pointer-down-capture
|
:on-pointer-down-capture
|
||||||
(fn [e] (when (or (= 1 (.-button e)) (and (= 0 (.-button e)) @shortcuts/space))
|
(fn [e] (when (or (= 1 (.-button e)) (and (= 0 (.-button e)) @space-held?))
|
||||||
(.preventDefault e) (.stopPropagation e)
|
(.preventDefault e) (.stopPropagation e)
|
||||||
;; Space held and used to pan, so letting go does not also play.
|
|
||||||
(when @shortcuts/space (reset! shortcuts/space :panned))
|
|
||||||
(let [el (.-currentTarget e)]
|
(let [el (.-currentTarget e)]
|
||||||
(reset! pan [(.-clientX e) (.-clientY e) (.-scrollLeft el) (.-scrollTop el)])
|
(reset! pan [(.-clientX e) (.-clientY e) (.-scrollLeft el) (.-scrollTop el)])
|
||||||
(.setPointerCapture el (.-pointerId e)))))
|
(.setPointerCapture el (.-pointerId e)))))
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
first pass is drawn. An expanded loop therefore shows keys where they first
|
first pass is drawn. An expanded loop therefore shows keys where they first
|
||||||
happen and not where they happen again."
|
happen and not where they happen again."
|
||||||
(:require [clojure.string :as str]
|
(:require [clojure.string :as str]
|
||||||
[arthur.domain.channel :as channel]
|
|
||||||
[arthur.domain.node :as node]
|
[arthur.domain.node :as node]
|
||||||
[arthur.domain.keyframes :as keyframes]
|
[arthur.domain.keyframes :as keyframes]
|
||||||
[arthur.domain.clipboard :as clipboard]
|
[arthur.domain.clipboard :as clipboard]
|
||||||
|
|
@ -30,7 +29,6 @@
|
||||||
[arthur.domain.span :as span]
|
[arthur.domain.span :as span]
|
||||||
[arthur.domain.symbol :as symbol]
|
[arthur.domain.symbol :as symbol]
|
||||||
[arthur.events.playback :as pb]
|
[arthur.events.playback :as pb]
|
||||||
[arthur.events.project :as project]
|
|
||||||
[arthur.events.ui :as ui]
|
[arthur.events.ui :as ui]
|
||||||
[arthur.footage.store :as store]
|
[arthur.footage.store :as store]
|
||||||
[arthur.ui.icon :as icon]
|
[arthur.ui.icon :as icon]
|
||||||
|
|
@ -91,19 +89,6 @@
|
||||||
{:sid sid :id (:id n) :channel channel :frame f
|
{:sid sid :id (:id n) :channel channel :frame f
|
||||||
:at (->open f) :scale (- (->open 1) (->open 0))})))
|
: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]
|
(defn- channel-rows [n sid path depth ->open span]
|
||||||
(let [keyed (filter (comp seq :keys val)
|
(let [keyed (filter (comp seq :keys val)
|
||||||
(sort-by (comp str key) (node/channels n)))]
|
(sort-by (comp str key) (node/channels n)))]
|
||||||
|
|
@ -111,13 +96,12 @@
|
||||||
(for [[cpath ch] keyed]
|
(for [[cpath ch] keyed]
|
||||||
{:path (conj path cpath)
|
{:path (conj path cpath)
|
||||||
:depth depth
|
:depth depth
|
||||||
:label (node/channel-name cpath)
|
:label (str/join " " (map name cpath))
|
||||||
:kind :channel
|
:kind :channel
|
||||||
:select nil
|
:select nil
|
||||||
:span span
|
:span span
|
||||||
:keys (mapv ->open (keyed-frames ch))
|
:keys (mapv ->open (keyed-frames ch))
|
||||||
:key-items (filterv #(= cpath (:channel %)) (key-items n sid ->open))
|
:key-items (filterv #(= cpath (:channel %)) (key-items n sid ->open))
|
||||||
:gaps (gaps n sid cpath ch ->open)
|
|
||||||
:dense? (boolean (:dense ch))})
|
:dense? (boolean (:dense ch))})
|
||||||
[{:path (conj path ::automation-hint)
|
[{:path (conj path ::automation-hint)
|
||||||
:depth depth
|
:depth depth
|
||||||
|
|
@ -187,7 +171,6 @@
|
||||||
:kind :node
|
:kind :node
|
||||||
:node-kind (:kind child)
|
:node-kind (:kind child)
|
||||||
:of (node/source child)
|
:of (node/source child)
|
||||||
:uses (some->> (node/source child) (clip/uses clip))
|
|
||||||
:portal? true
|
:portal? true
|
||||||
:select [:node sid (:id child) cpath]
|
:select [:node sid (:id child) cpath]
|
||||||
:expandable? true
|
:expandable? true
|
||||||
|
|
@ -300,7 +283,6 @@
|
||||||
:node-kind (:kind n)
|
:node-kind (:kind n)
|
||||||
:lane? lane?
|
:lane? lane?
|
||||||
:of (node/source n)
|
:of (node/source n)
|
||||||
:uses (some->> (node/source n) (clip/uses clip))
|
|
||||||
:select [:node sid id rpath]
|
:select [:node sid id rpath]
|
||||||
:expandable? true
|
:expandable? true
|
||||||
:expanded? open?
|
:expanded? open?
|
||||||
|
|
@ -365,39 +347,26 @@
|
||||||
(walk sid [] 0 identity)
|
(walk sid [] 0 identity)
|
||||||
[])))))
|
[])))))
|
||||||
|
|
||||||
(defn palette-track-rows
|
(defn palette-track-row
|
||||||
"`sid`'s palette rows. Its row: ONE LANE ROW WHETHER OR NOT THE LANE EXISTS YET, because
|
"`sid`'s palette row: ONE LANE ROW WHETHER OR NOT THE LANE EXISTS YET, because
|
||||||
a person putting a palette transition somewhere is doing the same thing in
|
a person putting a palette transition somewhere is doing the same thing in
|
||||||
either case. Empty, it names the symbol whose palette it would be; filled, it
|
either case. Empty, it names the symbol whose palette it would be; filled, it
|
||||||
is the lane symbol's own row under this pane's name for it, and opens as any
|
is the lane symbol's own row under this pane's name for it."
|
||||||
lane does: onto the selected transition, its keys and channels."
|
|
||||||
[clip sid frames expanded chosen]
|
[clip sid frames expanded chosen]
|
||||||
(let [track-id (get-in clip [:symbols sid :palette-track])
|
(let [track-id (get-in clip [:symbols sid :palette-track])
|
||||||
track (get-in clip [:symbols track-id])]
|
track (get-in clip [:symbols track-id])]
|
||||||
(if (= :palette-track (:type track))
|
(if (= :palette-track (:type track))
|
||||||
;; A MATERIALIZED TRACK IS AN ORDINARY LANE ROW, selection, portal and
|
;; A MATERIALIZED TRACK IS AN ORDINARY LANE ROW, selection and all: it is
|
||||||
;; all: it is what `rows` already draws for a lane symbol, wearing this
|
;; the row `rows` already draws for a lane symbol, wearing this pane's
|
||||||
;; pane's name for it. Only the row of a track that does not exist yet has
|
;; name for it. Only the row of a track that does not exist yet has to say
|
||||||
;; to say whose palette it would be, which is what creating in it needs.
|
;; whose palette it would be, which is what creating in it needs.
|
||||||
;;
|
(-> (first (rows clip track-id expanded chosen))
|
||||||
;; `rows` calls a lane's own row `[::lane]`, which is also the open
|
(assoc :path [::palette-track] :owner track-id
|
||||||
;; symbol's when that is a lane, so this row goes by `[::palette-track]`
|
:label "palette" :kind :palette
|
||||||
;; and is translated on the way in. The portal's rows keep their authored
|
:expandable? false :expanded? false))
|
||||||
;; paths -- the clip ids are the track's own -- and carry the track as
|
{:path [::palette-track] :depth 0 :label "palette" :kind :palette
|
||||||
;; their `:owner`, so dragging them slides the clip in the track.
|
|
||||||
(let [expanded (cond-> (disj (set expanded) [::lane])
|
|
||||||
(contains? (set expanded) [::palette-track]) (conj [::lane]))
|
|
||||||
[lane & more] (rows clip track-id expanded chosen)]
|
|
||||||
(into [(assoc lane :path [::palette-track] :owner track-id
|
|
||||||
:label "palette" :kind :palette)]
|
|
||||||
(comp (take-while #(pos? (:depth %)))
|
|
||||||
(map #(cond-> (assoc % :owner track-id)
|
|
||||||
(= ::lane (first (:path %)))
|
|
||||||
(assoc :path (into [::palette-track] (rest (:path %)))))))
|
|
||||||
more))
|
|
||||||
[{:path [::palette-track] :depth 0 :label "palette" :kind :palette
|
|
||||||
:lane? true :owner nil :select [::palette-track sid]
|
:lane? true :owner nil :select [::palette-track sid]
|
||||||
:span [0 frames] :keys [] :cels []}])))
|
:span [0 frames] :keys [] :cels []})))
|
||||||
|
|
||||||
(defn sound-rows
|
(defn sound-rows
|
||||||
"Audio rows use the same flattened intervals as the mixer, including source
|
"Audio rows use the same flattened intervals as the mixer, including source
|
||||||
|
|
@ -542,15 +511,15 @@
|
||||||
;; Where the playhead is and how it moves. Nothing here depends on a
|
;; Where the playhead is and how it moves. Nothing here depends on a
|
||||||
;; selection, which is why it is the one group that is never greyed.
|
;; selection, which is why it is the one group that is never greyed.
|
||||||
[:div.group
|
[:div.group
|
||||||
[:button.ico {:aria-label "go to start" :title "go to the first frame (Home)"
|
[:button.ico {:aria-label "go to start" :title "go to the first frame"
|
||||||
:on-click (act [::pb/seek 0])} [icon/view :start]]
|
:on-click (act [::pb/seek 0])} [icon/view :start]]
|
||||||
[:button {:aria-label "−1" :title "step back one frame (← or A)"
|
[:button {:aria-label "−1" :title "step back one frame"
|
||||||
:on-click (act [::pb/step -1])} "−1"]
|
:on-click (act [::pb/step -1])} "−1"]
|
||||||
[:button.ico.ico-play {:aria-label (if playing? "pause" "play")
|
[:button.ico.ico-play {:aria-label (if playing? "pause" "play")
|
||||||
:title (if playing? "pause (Space)" "play (Space)")
|
:title (if playing? "pause" "play")
|
||||||
:on-click (act [::pb/toggle])}
|
:on-click (act [::pb/toggle])}
|
||||||
[icon/view (if playing? :pause :play)]]
|
[icon/view (if playing? :pause :play)]]
|
||||||
[:button {:aria-label "+1" :title "step forward one frame (→ or D)"
|
[:button {:aria-label "+1" :title "step forward one frame"
|
||||||
:on-click (act [::pb/step 1])} "+1"]]
|
:on-click (act [::pb/step 1])} "+1"]]
|
||||||
[:div.group
|
[:div.group
|
||||||
[:button.ico {:class (when loop? "on") :aria-label "loop"
|
[:button.ico {:class (when loop? "on") :aria-label "loop"
|
||||||
|
|
@ -654,12 +623,9 @@
|
||||||
on every render after, which would fight a person scrolling away."
|
on every render after, which would fight a person scrolling away."
|
||||||
(memoize (fn [_selection] (fn [el] (some-> el (.scrollIntoView #js {:block "nearest"}))))))
|
(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 uses]}
|
(defn- label-cell [{:keys [path depth label kind node-kind lane? span select expandable? expanded? of via]}
|
||||||
selection selections target-path over solo tracing renaming draft choose-row!]
|
selection selections target-path over solo tracing renaming draft choose-row!]
|
||||||
(let [node? (= :node kind)
|
(let [node? (= :node kind)
|
||||||
;; The palette row is the symbol's one palette lane: "palette" says all
|
|
||||||
;; there is to say, and it has no name of its own to change.
|
|
||||||
named-lane? (and lane? (not= :palette kind))
|
|
||||||
selected? (contains? selections select)
|
selected? (contains? selections select)
|
||||||
editing? (and lane? (= select @renaming))
|
editing? (and lane? (= select @renaming))
|
||||||
begin-rename! (fn [] (reset! draft label) (reset! renaming select))
|
begin-rename! (fn [] (reset! draft label) (reset! renaming select))
|
||||||
|
|
@ -673,7 +639,6 @@
|
||||||
(when (and select (= select selection)) " primary")
|
(when (and select (= select selection)) " primary")
|
||||||
(when (= path target-path) " target")
|
(when (= path target-path) " target")
|
||||||
(when lane? " lane")
|
(when lane? " lane")
|
||||||
(when (= :palette kind) " palette")
|
|
||||||
(when (= :ghost kind) " ghost")
|
(when (= :ghost kind) " ghost")
|
||||||
(when (= path over-path)
|
(when (= path over-path)
|
||||||
(case where
|
(case where
|
||||||
|
|
@ -761,15 +726,10 @@
|
||||||
"Escape" (do (.preventDefault e) (reset! renaming nil))
|
"Escape" (do (.preventDefault e) (reset! renaming nil))
|
||||||
nil))}]
|
nil))}]
|
||||||
[:span.name label])
|
[: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
|
(cond
|
||||||
named-lane? [:span.kind "·lane"]
|
lane? [:span.kind "·lane"]
|
||||||
node? [:span.kind (if via (str "· in " via) (str "·" (name node-kind)))])
|
node? [:span.kind (if via (str "· in " via) (str "·" (name node-kind)))])
|
||||||
(when named-lane?
|
(when lane?
|
||||||
[:button.tl-rename
|
[:button.tl-rename
|
||||||
{:title "rename lane"
|
{:title "rename lane"
|
||||||
:on-click (fn [^js e] (.stopPropagation e) (begin-rename!))}
|
:on-click (fn [^js e] (.stopPropagation e) (begin-rename!))}
|
||||||
|
|
@ -915,7 +875,7 @@
|
||||||
`: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 keys key-items gaps dense? kind node-kind select slides cels lane? of unmapped? owner]}
|
[{:keys [path span keys key-items 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)
|
||||||
|
|
@ -1264,21 +1224,6 @@
|
||||||
(when select
|
(when select
|
||||||
[: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! % (nth select 3) :out select nil nil)}])]))
|
: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
|
;; 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.
|
;; 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
|
;; The lane's own keys, and those of the clips on it drawn after the
|
||||||
|
|
@ -1316,37 +1261,7 @@
|
||||||
to move two elements' `left`. That cost more than painting the frame did and
|
to move two elements' `left`. That cost more than painting the frame did and
|
||||||
starved the rAF loop painting it, which ran at 16fps against a 60fps ceiling."
|
starved the rAF loop painting it, which ran at 16fps against a 60fps ceiling."
|
||||||
[tag frames]
|
[tag frames]
|
||||||
(let [f @(rf/subscribe [::render/open-frame])
|
[tag {:style {:left (at% @(rf/subscribe [::render/open-frame]) frames)}}])
|
||||||
head? (= tag :div.tl-knob)]
|
|
||||||
;; The head is as wide as its number needs and never narrower than the frame.
|
|
||||||
[tag {:style {:left (edge% f frames) (if head? :min-width :width) (edge% 1 frames)}}
|
|
||||||
(when head? f)]))
|
|
||||||
|
|
||||||
(defn- outside-marks
|
|
||||||
"The frames playback leaves out, shaded, and the span it plays, banded on the
|
|
||||||
ruler. Its own component, deref'ing the marks itself, as `playhead` does."
|
|
||||||
[frames ruler?]
|
|
||||||
(when-let [{:keys [in out]} @(rf/subscribe [::playback/range])]
|
|
||||||
(let [lo (or in 0) hi (inc (min (dec frames) (or out (dec frames))))]
|
|
||||||
(if ruler?
|
|
||||||
[:<>
|
|
||||||
[:div.tl-range {:style {:left (edge% lo frames) :width (edge% (- hi lo) frames)}}]
|
|
||||||
(for [[which f at] [[:in in lo] [:out out hi]] :when f]
|
|
||||||
^{:key which}
|
|
||||||
[:div.tl-mark
|
|
||||||
{:class (name which) :style {:left (edge% at frames)}
|
|
||||||
:title (str (name which) " mark · drag to move")
|
|
||||||
:on-pointer-down (fn [^js e]
|
|
||||||
(.stopPropagation e)
|
|
||||||
(try (.setPointerCapture (.-currentTarget e) (.-pointerId e))
|
|
||||||
(catch :default _ nil)))
|
|
||||||
:on-pointer-move (fn [^js e]
|
|
||||||
(when (.hasPointerCapture (.-currentTarget e) (.-pointerId e))
|
|
||||||
(rf/dispatch [::pb/drag-mark which
|
|
||||||
(frame-under e frames (.closest (.-currentTarget e) ".tl-ruler"))])))}])]
|
|
||||||
[:<>
|
|
||||||
(when (pos? lo) [:div.tl-outside {:style {:left 0 :width (edge% lo frames)}}])
|
|
||||||
(when (< hi frames) [:div.tl-outside {:style {:left (edge% hi frames) :right 0}}])]))))
|
|
||||||
|
|
||||||
(defn- key-marquee [marquee]
|
(defn- key-marquee [marquee]
|
||||||
(when-let [{:keys [x y x2 y2]} @marquee]
|
(when-let [{:keys [x y x2 y2]} @marquee]
|
||||||
|
|
@ -1356,22 +1271,8 @@
|
||||||
:width (str (abs (- x2 x)) "px") :height (str (abs (- y2 y)) "px")
|
:width (str (abs (- x2 x)) "px") :height (str (abs (- y2 y)) "px")
|
||||||
:border "1px solid var(--pick)" :background "color-mix(in srgb, var(--pick) 15%, transparent)"}}])))
|
:border "1px solid var(--pick)" :background "color-mix(in srgb, var(--pick) 15%, transparent)"}}])))
|
||||||
|
|
||||||
(defn- frame-step
|
|
||||||
"How many frames apart the grid's fine lines are: every frame where a frame
|
|
||||||
is wide enough to see, else the fewest that divide a second evenly and are —
|
|
||||||
so a line still falls on every second — or nil when not even that fits under
|
|
||||||
the second lines."
|
|
||||||
[frame-px fps]
|
|
||||||
(first (filter #(and (zero? (mod fps %)) (<= 6 (* % frame-px)) (< % fps))
|
|
||||||
(range 1 fps))))
|
|
||||||
|
|
||||||
(defn- timeline-view []
|
(defn- timeline-view []
|
||||||
(r/with-let [scrubbing (r/atom false)
|
(r/with-let [scrubbing (r/atom false)
|
||||||
;; How wide the tracks are drawn, for how many pixels a frame
|
|
||||||
;; gets: the grid and the playhead change with it.
|
|
||||||
tracks-px (r/atom nil)
|
|
||||||
sizer (js/ResizeObserver.
|
|
||||||
(fn [entries] (reset! tracks-px (.. (aget entries 0) -contentRect -width))))
|
|
||||||
;; The row a carried row is over and which part of it, for the
|
;; The row a carried row is over and which part of it, for the
|
||||||
;; highlight.
|
;; highlight.
|
||||||
over (r/atom nil)
|
over (r/atom nil)
|
||||||
|
|
@ -1452,7 +1353,7 @@
|
||||||
{:id ::drop :label (str "+ " (:label drop)) :ghost? true
|
{:id ::drop :label (str "+ " (:label drop)) :ghost? true
|
||||||
:span drop-span})
|
:span drop-span})
|
||||||
chosen (when (= :node (first selection)) (nth selection 3))
|
chosen (when (= :node (first selection)) (nth selection 3))
|
||||||
picture (cond-> (cond->> (into (palette-track-rows clip open frames expanded chosen)
|
picture (cond-> (cond->> (into [(palette-track-row clip open frames expanded chosen)]
|
||||||
(rows clip open expanded chosen))
|
(rows clip open expanded chosen))
|
||||||
lane-ghost
|
lane-ghost
|
||||||
(mapv (fn [row]
|
(mapv (fn [row]
|
||||||
|
|
@ -1479,8 +1380,6 @@
|
||||||
;; FPS-blind 20/40/60 ruler.
|
;; FPS-blind 20/40/60 ruler.
|
||||||
fps (max 1 (or (:fps clip) 1))
|
fps (max 1 (or (:fps clip) 1))
|
||||||
step (* fps (max 1 (js/Math.ceil (/ frames (* fps 10)))))
|
step (* fps (max 1 (js/Math.ceil (/ frames (* fps 10)))))
|
||||||
frame-px (/ (or @tracks-px 0) frames)
|
|
||||||
fine (frame-step frame-px fps)
|
|
||||||
choose-row! (fn [e target]
|
choose-row! (fn [e target]
|
||||||
(let [xs (vec (keep :select visible))
|
(let [xs (vec (keep :select visible))
|
||||||
anchor (or @row-anchor selection target)
|
anchor (or @row-anchor selection target)
|
||||||
|
|
@ -1615,10 +1514,7 @@
|
||||||
;; The rows and ruler share this exact major interval. Keeping a
|
;; The rows and ruler share this exact major interval. Keeping a
|
||||||
;; second, hard-coded five-frame grid here made its lines disagree
|
;; second, hard-coded five-frame grid here made its lines disagree
|
||||||
;; with the numbered marks whenever the project's FPS changed.
|
;; with the numbered marks whenever the project's FPS changed.
|
||||||
:ref #(when % (.observe sizer %))
|
:style {"--tick" (str (* 100 (/ step frames)) "%")}}
|
||||||
:class (when (< frame-px 4) "narrow")
|
|
||||||
:style {"--tick" (str (* 100 (/ step frames)) "%")
|
|
||||||
"--fine" (if fine (str (* 100 (/ fine frames)) "%") "none")}}
|
|
||||||
[:div.tl-ruler
|
[:div.tl-ruler
|
||||||
{:on-pointer-down (fn [^js e]
|
{:on-pointer-down (fn [^js e]
|
||||||
(rf/dispatch [::pb/seek (frame-at e frames)])
|
(rf/dispatch [::pb/seek (frame-at e frames)])
|
||||||
|
|
@ -1643,7 +1539,6 @@
|
||||||
(doall
|
(doall
|
||||||
(for [f (range 0 frames step)]
|
(for [f (range 0 frames step)]
|
||||||
^{:key f} [:div.tick {:style {:left (edge% f frames)}} f]))
|
^{:key f} [:div.tick {:style {:left (edge% f frames)}} f]))
|
||||||
[outside-marks frames true]
|
|
||||||
[playhead :div.tl-knob frames]]
|
[playhead :div.tl-knob frames]]
|
||||||
(if (seq visible)
|
(if (seq visible)
|
||||||
(doall (for [row visible]
|
(doall (for [row visible]
|
||||||
|
|
@ -1656,14 +1551,9 @@
|
||||||
:key-anchor key-anchor :key-state key-state :key-elements key-elements :choose-row! choose-row!}])
|
:key-anchor key-anchor :key-state key-state :key-elements key-elements :choose-row! choose-row!}])
|
||||||
{:key (str (:path row))})))
|
{:key (str (:path row))})))
|
||||||
[:div.tl-empty "nothing in this symbol"])
|
[:div.tl-empty "nothing in this symbol"])
|
||||||
;; Over the rows, through the cels, as Flash draws its frames: a frame
|
|
||||||
;; is a cell you can see wherever there is time.
|
|
||||||
[:div.tl-grid {:class (when-not fine "coarse")}]
|
|
||||||
[outside-marks frames false]
|
|
||||||
[playhead :div.tl-playhead frames]
|
[playhead :div.tl-playhead frames]
|
||||||
[key-marquee marquee]]]
|
[key-marquee marquee]]]
|
||||||
[cursor-hint hint]])
|
[cursor-hint hint]])))
|
||||||
(finally (.disconnect sizer))))
|
|
||||||
|
|
||||||
(defn view []
|
(defn view []
|
||||||
[timeline-view])
|
[timeline-view])
|
||||||
|
|
|
||||||
|
|
@ -109,3 +109,24 @@
|
||||||
(when (and (= :brush kind) (< 1 (count ids))) [:span.dim (str (count ids) " pieces")])
|
(when (and (= :brush kind) (< 1 (count ids))) [:span.dim (str (count ids) " pieces")])
|
||||||
[fit-control fit ::ui/adjust-last]]))
|
[fit-control fit ::ui/adjust-last]]))
|
||||||
|
|
||||||
|
(defn- typing?
|
||||||
|
"Is a key going into a field? A slider or a checkbox has focus without
|
||||||
|
taking letters, and a tool's key still picks the tool there, as in Photoshop."
|
||||||
|
[^js target]
|
||||||
|
(or (#{"TEXTAREA" "SELECT"} (.-tagName target))
|
||||||
|
(and (= "INPUT" (.-tagName target))
|
||||||
|
(not (#{"range" "checkbox" "radio" "button" "color"} (.-type target))))
|
||||||
|
(.-isContentEditable target)))
|
||||||
|
|
||||||
|
(defn install-keys!
|
||||||
|
"V, P, B and E pick a tool. Enter closes the pen's polygon, or takes the pen
|
||||||
|
to the selected shape's points; Esc closes it too, and then leaves the pen.
|
||||||
|
[ and ] size the brush. Delete and undo are `events/history`'s."
|
||||||
|
[]
|
||||||
|
(.addEventListener
|
||||||
|
js/window "keydown"
|
||||||
|
(fn [^js e]
|
||||||
|
(when-not (or (typing? (.-target e)) (.-metaKey e) (.-ctrlKey e) (.-altKey e))
|
||||||
|
(when (contains? ui/tool-keys (.toLowerCase (.-key e)))
|
||||||
|
(.preventDefault e)
|
||||||
|
(rf/dispatch [::ui/tool-key (.toLowerCase (.-key e))]))))))
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
[arthur.ui.openmenu :as openmenu]
|
[arthur.ui.openmenu :as openmenu]
|
||||||
[arthur.ui.settings :as settings]
|
[arthur.ui.settings :as settings]
|
||||||
[arthur.ui.share :as share]
|
[arthur.ui.share :as share]
|
||||||
[arthur.ui.shortcuts :as shortcuts]
|
|
||||||
[arthur.ui.snapshots :as snapshots]
|
[arthur.ui.snapshots :as snapshots]
|
||||||
[arthur.ui.undo :as undo]
|
[arthur.ui.undo :as undo]
|
||||||
[re-frame.core :as rf]
|
[re-frame.core :as rf]
|
||||||
|
|
@ -116,5 +115,4 @@
|
||||||
title (when project-seq (str " r" project-seq))])
|
title (when project-seq (str " r" project-seq))])
|
||||||
[:span.status (or export-status status footage-status)]
|
[:span.status (or export-status status footage-status)]
|
||||||
[exporter export-open?]
|
[exporter export-open?]
|
||||||
[share/view]
|
[share/view]])))
|
||||||
[shortcuts/button]])))
|
|
||||||
|
|
|
||||||
|
|
@ -281,10 +281,9 @@
|
||||||
(testing "an unnamed symbol falls back to its id, not to the node's uuid"
|
(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)
|
(is (= "inner" (clip/node-label (update-in c [:symbols :inner] dissoc :name)
|
||||||
id n))))
|
id n))))
|
||||||
(testing "and a name left on the instance is not read: it has none of its own"
|
(testing "but a name somebody typed on the instance still wins"
|
||||||
(is (= "mouth" (clip/node-label c id (assoc n :name "left eye")))))
|
;; Two instances of one symbol are told apart only by this.
|
||||||
(testing "every placement of a symbol is counted"
|
(is (= "left eye" (clip/node-label c id (assoc n :name "left eye")))))
|
||||||
(is (= 1 (clip/uses c :inner))))
|
|
||||||
(testing "and a node that places nothing is labelled by its own name or id"
|
(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 :name "lid"})))
|
||||||
(is (= "lid" (clip/node-label c :lid {:id :lid :kind :rect}))))))
|
(is (= "lid" (clip/node-label c :lid {:id :lid :kind :rect}))))))
|
||||||
|
|
@ -423,95 +422,79 @@
|
||||||
(is (= [55 35] (gesture/pivot (gesture/values (get-in out [:symbols :main :nodes :cel]) 0 nil) nil))
|
(is (= [55 35] (gesture/pivot (gesture/values (get-in out [:symbols :main :nodes :cel]) 0 nil) nil))
|
||||||
"and from then on it is the node's own, whatever the symbol does next"))))))
|
"and from then on it is the node's own, whatever the symbol does next"))))))
|
||||||
|
|
||||||
(def ^:private one-palette-doc
|
(deftest palette-context-is-inherited-keyed-and-overridable
|
||||||
(let [palette (fn [id color] {:id id :name (name id) :slots [{:hex "#000000"} {:hex color}]})
|
(let [palette (fn [id name a b]
|
||||||
|
{:id id :name name :slots [{:hex a} {:hex b}]})
|
||||||
mark {:id :mark :kind :rect :z "a1"
|
mark {:id :mark :kind :rect :z "a1"
|
||||||
:channels {[:geom :size] (ch/framed 2)
|
:channels {[:geom :size] (ch/framed 2)
|
||||||
[:style :color] (ch/framed 1)}}]
|
[:style :color] (ch/framed 1)}}
|
||||||
{:fps 30 :width 20 :height 20
|
instance (fn [id child z]
|
||||||
:palettes {:day (palette :day "#112233") :night (palette :night "#aabbcc")
|
{:id id :kind :instance :z z :source {:symbol child}})
|
||||||
:ink (palette :ink "#101010") :dusk (palette :dusk "#664422")}
|
document {:fps 30 :width 20 :height 20
|
||||||
|
:palettes {:day (palette :day "Day" "#000000" "#112233")
|
||||||
|
:flash (palette :flash "Flash" "#ffffff" "#aabbcc")}
|
||||||
:default-palette :day
|
:default-palette :day
|
||||||
:symbols
|
:symbols
|
||||||
{:main {:id :main :frames 6
|
{:main {:id :main :frames 4
|
||||||
:nodes {:plain {:id :plain :kind :instance :z "a1" :source {:symbol :plain}}
|
:palette (ch/keyed {0 :day 2 :flash} :hold)
|
||||||
:face {:id :face :kind :instance :z "a2" :source {:symbol :face}
|
:nodes {:inherited (instance :inherited :drawing "a1")
|
||||||
:span [0 3] :time {:at 0}}}}
|
:fixed (assoc (instance :fixed :fixed "a2")
|
||||||
:plain {:id :plain :frames 6 :nodes {:mark mark}}
|
:palette (ch/framed :day))}}
|
||||||
:face {:id :face :frames 6 :palette :night :nodes {:mark mark}}
|
:drawing {:id :drawing :frames 4 :nodes {:mark mark}}
|
||||||
:lane {:id :lane :type :palette-track :display :lane :frames 6
|
:fixed {:id :fixed :frames 4 :palette (ch/framed :flash)
|
||||||
:nodes {:n {:id :n :kind :instance :z "a1" :source {:symbol :ink-palette}
|
:nodes {:mark mark}}}}
|
||||||
|
context (pal/compile document)
|
||||||
|
resolve (clip/resolver document :main nil context nil)
|
||||||
|
colors #(mapv :color (resolve %))]
|
||||||
|
(is (= [1 1] (colors 0)) "both children start in the day bank")
|
||||||
|
(is (= [3 1] (colors 2))
|
||||||
|
"the inheriting child follows the lightning cut; an instance override wins")
|
||||||
|
(is (= [17 34 51] (nth (:ramp context) 1)))
|
||||||
|
(is (= [170 187 204] (nth (:ramp context) 3)))))
|
||||||
|
|
||||||
|
(deftest symbol-authoring-palettes-seed-only-the-view-root
|
||||||
|
(let [palette (fn [id name color]
|
||||||
|
{:id id :name name :slots [{:hex color} {:hex color}]})
|
||||||
|
mark {:id :mark :kind :rect :z "a1"
|
||||||
|
:channels {[:geom :size] (ch/framed 2)
|
||||||
|
[:style :color] (ch/framed 1)}}
|
||||||
|
document {:fps 30 :width 20 :height 20
|
||||||
|
:palettes {:day (palette :day "Day" "#112233")
|
||||||
|
:night (palette :night "Night" "#aabbcc")}
|
||||||
|
:default-palette :day
|
||||||
|
:symbols
|
||||||
|
{:main {:id :main :frames 4 :palette :day :palette-track :palette-lane
|
||||||
|
:nodes {:child {:id :child :kind :instance :z "a1"
|
||||||
|
:source {:symbol :drawing}}}}
|
||||||
|
:palette-lane {:id :palette-lane :name "palette"
|
||||||
|
:type :palette-track :display :lane :frames 4
|
||||||
|
:nodes {:night {:id :night :kind :instance :z "a1"
|
||||||
|
:source {:symbol :night-palette}
|
||||||
:span [0 1] :time {:at 1}}}}
|
:span [0 1] :time {:at 1}}}}
|
||||||
:ink-palette {:id :ink-palette :type :palette :palette-ref :ink :frames 1 :nodes {}}}}))
|
:night-palette {:id :night-palette :name "Night"
|
||||||
|
:type :palette :palette-ref :night
|
||||||
(defn- frame-of
|
:frames 1 :nodes {}}
|
||||||
"What frame `f` of symbol `sid` draws, and the one palette it is in."
|
:drawing {:id :drawing :frames 4 :palette :night
|
||||||
[document sid f]
|
:nodes {:mark mark}}}}
|
||||||
(let [context (pal/compile document)
|
context (pal/compile document)
|
||||||
r (clip/resolver document sid nil context nil)
|
main (clip/resolver document :main nil context nil)
|
||||||
ops (vec (r f))]
|
drawing (clip/resolver document :drawing nil context nil)
|
||||||
{:colors (mapv :color (remove #(#{:begin :end} (:kind %)) ops))
|
color #(-> (%1 %2) first :color)]
|
||||||
:active (clip/active-palette r)
|
(is (= (pal/render-index context :day 1) (color main 0))
|
||||||
:ramp (pal/effective-ramp context (clip/active-palette r))}))
|
"a nested symbol's authoring palette does not override the viewed root")
|
||||||
|
(is (= (pal/render-index context :night 1) (color main 1))
|
||||||
(deftest a-frame-is-in-one-palette-and-the-shallowest-choice-wins
|
"a covered palette-track interval overrides the root fallback")
|
||||||
(let [doc one-palette-doc]
|
(is (= (pal/render-index context :day 1) (color main 2))
|
||||||
(is (= {:colors [1 1] :active :night}
|
"a nil track interval is a real gap and restores the authoring palette")
|
||||||
(select-keys (frame-of doc :main 0) [:colors :active]))
|
(is (= (pal/render-index context :night 1) (color drawing 0))
|
||||||
"a face set to night turns ALL of main night while it is drawn; shapes keep their slot")
|
"the same nested symbol uses its authoring palette when viewed directly")
|
||||||
(is (= :day (:active (frame-of doc :main 4)))
|
;; The renderer clears with this exact resolver state before rasterising the
|
||||||
"once the face is gone main is back in the project's palette")
|
;; returned ops, so a palette cut changes the stage background as well as
|
||||||
(is (= :day (:active (frame-of (assoc-in doc [:symbols :main :palette] :day) :main 0)))
|
;; authored shapes.
|
||||||
"a palette set on the open symbol beats anything inside it")
|
(main 1)
|
||||||
(is (= :ink (:active (frame-of (assoc-in doc [:symbols :main :palette-track] :lane) :main 1)))
|
(is (= :night (clip/active-palette main)))
|
||||||
"and so does the open symbol's palette lane")
|
(is (= (pal/render-index context :night 0)
|
||||||
(is (= :dusk (:active (frame-of (assoc-in doc [:symbols :main :nodes :face :palette] :dusk) :main 0)))
|
(pal/background-index context (clip/active-palette main))))))
|
||||||
"an instance set to a palette stands in for the symbol's own")
|
|
||||||
(is (= :ink (:active (frame-of (assoc-in doc [:symbols :face :palette-track] :lane) :main 1)))
|
|
||||||
"a child's palette lane turns the whole frame, not just the child")
|
|
||||||
(is (= :night (:active (frame-of doc :face 0)))
|
|
||||||
"the face's own tab is in its palette")
|
|
||||||
(is (= [[0 0 0] [170 187 204]] (:ramp (frame-of doc :main 0)))
|
|
||||||
"the frame's colours are that one palette's and nothing else's")))
|
|
||||||
|
|
||||||
(deftest between-two-choices-at-one-depth-the-one-on-top-wins
|
|
||||||
(let [doc (-> one-palette-doc
|
|
||||||
(assoc-in [:symbols :plain :palette] :dusk))]
|
|
||||||
(is (= :night (:active (frame-of doc :main 0))) "face is drawn over plain")
|
|
||||||
(is (= :dusk (:active (frame-of doc :main 4))) "and without the face, plain's")))
|
|
||||||
|
|
||||||
(deftest an-inherit-end-of-a-blend-is-what-the-frame-is-in-without-it
|
|
||||||
(let [choice (assoc (ch/keyed {0 pal/inherit 2 :ink} :linear) :semantic :palette)
|
|
||||||
doc (-> one-palette-doc
|
|
||||||
(assoc-in [:symbols :main :palette-track] :lane)
|
|
||||||
(assoc-in [:symbols :lane :nodes :n]
|
|
||||||
{:id :n :kind :instance :z "a1" :source {:symbol :ink-palette}
|
|
||||||
:span [0 3] :time {:at 0} :channels {[:palette] choice}}))]
|
|
||||||
(is (= {:from :night :to :ink :t 0.5} (:active (frame-of doc :main 1)))
|
|
||||||
"main's lane blends from what the face makes the frame, to ink")))
|
|
||||||
|
|
||||||
(deftest the-palettes-a-tree-uses
|
|
||||||
(let [doc (-> one-palette-doc
|
|
||||||
(assoc-in [:symbols :main :nodes :plain :palette] :ink))]
|
|
||||||
(is (= [{:palette :ink :sid :main :via :instance}
|
|
||||||
{:palette :night :sid :face :via :symbol}]
|
|
||||||
(clip/palette-uses doc :main)))))
|
|
||||||
|
|
||||||
(deftest unused-slots-are-emptied-in-place
|
|
||||||
(let [p {:id :a :name "a"
|
|
||||||
:slots [{:name :bg :hex "#000000"} {:hex "#111111"} {:name :teeth :hex "#222222"}
|
|
||||||
{:hex "#333333"} {:hex "#444444"} {:hex "#000000"}]}
|
|
||||||
mark (fn [id c] {:id id :kind :rect :z "a1" :channels {[:style :color] c}})
|
|
||||||
nodes {:x (mark :x (ch/keyed {0 3 1 1} :hold))
|
|
||||||
:y (mark :y (ch/framed [:remap {4 1}]))}
|
|
||||||
used (pal/slots-used [{:nodes nodes}])]
|
|
||||||
(is (= #{1 3 4} used) "every key counts, and both sides of a remap")
|
|
||||||
(is (= [] (pal/emptyable p used))
|
|
||||||
"the background, a named face tone and an already empty slot are left alone")
|
|
||||||
(is (= [3] (pal/emptyable p #{1 4})))
|
|
||||||
(is (= ["#000000" "#111111" "#222222" "#000000" "#444444" "#000000"]
|
|
||||||
(mapv :hex (:slots (pal/empty-slots p [3]))))
|
|
||||||
"emptied where it is, so no slot number moves")))
|
|
||||||
|
|
||||||
(deftest a-palette-lane-can-blend-between-keyed-palettes
|
(deftest a-palette-lane-can-blend-between-keyed-palettes
|
||||||
(let [palette (fn [id color]
|
(let [palette (fn [id color]
|
||||||
|
|
@ -547,7 +530,8 @@
|
||||||
(clip/palette-at document nil :day (clip/symbol document :main) 2 nil))
|
(clip/palette-at document nil :day (clip/symbol document :main) 2 nil))
|
||||||
"the palette strip asks the same question the resolver answers: both ends of a blend")
|
"the palette strip asks the same question the resolver answers: both ends of a blend")
|
||||||
(is (= [128 128 128]
|
(is (= [128 128 128]
|
||||||
(nth (pal/effective-ramp context (clip/active-palette resolve)) 1)))
|
(nth (pal/effective-ramp context (clip/active-palette resolve))
|
||||||
|
(pal/render-index context :day 1))))
|
||||||
(is (nil? (:refused slid)) (:refused slid))
|
(is (nil? (:refused slid)) (:refused slid))
|
||||||
(is (= [1 6] (node/placed-span
|
(is (= [1 6] (node/placed-span
|
||||||
(get-in slid [:clip :symbols :palettes :nodes :change]))))
|
(get-in slid [:clip :symbols :palettes :nodes :change]))))
|
||||||
|
|
@ -584,7 +568,8 @@
|
||||||
(resolve 2)
|
(resolve 2)
|
||||||
(is (= {:from day :to night :t 0.5} (clip/active-palette resolve)))
|
(is (= {:from day :to night :t 0.5} (clip/active-palette resolve)))
|
||||||
(is (= [128 128 128]
|
(is (= [128 128 128]
|
||||||
(nth (pal/effective-ramp context (clip/active-palette resolve)) 1)))))
|
(nth (pal/effective-ramp context (clip/active-palette resolve))
|
||||||
|
(pal/render-index context day 1))))))
|
||||||
(deftest a-knockout-makes-a-hole-in-its-own-symbol-only
|
(deftest a-knockout-makes-a-hole-in-its-own-symbol-only
|
||||||
(let [sq (fn [x0 y0 x1 y1] [x0 y0 x1 y0 x1 y1 x0 y1])
|
(let [sq (fn [x0 y0 x1 y1] [x0 y0 x1 y0 x1 y1 x0 y1])
|
||||||
document
|
document
|
||||||
|
|
@ -648,7 +633,7 @@
|
||||||
ops (vec ((clip/resolver document :main nil context nil) 0))
|
ops (vec ((clip/resolver document :main nil context nil) 0))
|
||||||
ras (raster/draw-ops! (raster/clear! (raster/make 320 200) 0) ops)
|
ras (raster/draw-ops! (raster/clear! (raster/make 320 200) 0) ops)
|
||||||
at (fn [x y] (aget (:buf ras) (+ x (* y 320))))
|
at (fn [x y] (aget (:buf ras) (+ x (* y 320))))
|
||||||
slot identity]
|
slot #(pal/render-index context (pal/default-palette-id document) %)]
|
||||||
(is (= (slot 5) (at 7 10)) "the wall under the beam is lit")
|
(is (= (slot 5) (at 7 10)) "the wall under the beam is lit")
|
||||||
(is (= (slot 3) (at 12 10)) "the door under it is a slot the map leaves alone")
|
(is (= (slot 3) (at 12 10)) "the door under it is a slot the map leaves alone")
|
||||||
(is (= (slot 2) (at 30 10)) "and the wall outside it is as it was")
|
(is (= (slot 2) (at 30 10)) "and the wall outside it is as it was")
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
(let [ls (leaf/leaves :c1 @take/clip)
|
(let [ls (leaf/leaves :c1 @take/clip)
|
||||||
n (get ls "clip/c1/symbol/face-1/node/mouth")]
|
n (get ls "clip/c1/symbol/face-1/node/mouth")]
|
||||||
(is (= {:id :mouth :name "mouth" :kind :poly :parent :head
|
(is (= {:id :mouth :name "mouth" :kind :poly :parent :head
|
||||||
:z "a1" :time {:offset 4} :pose-group :mouth} n))
|
:z "a1" :pose-group :mouth} n))
|
||||||
(is (nil? (:channels n)))
|
(is (nil? (:channels n)))
|
||||||
(is (:animated? (get ls "clip/c1/symbol/face-1/channel/mouth/geom.pts")))))
|
(is (:animated? (get ls "clip/c1/symbol/face-1/channel/mouth/geom.pts")))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -331,17 +331,3 @@
|
||||||
"editing repairs an older tweened colour channel")
|
"editing repairs an older tweened colour channel")
|
||||||
(is (= :hold (get-in (node/toggle-key n [:style :color] 3 nil)
|
(is (= :hold (get-in (node/toggle-key n [:style :color] 3 nil)
|
||||||
[:channels [:style :color] :interp])))))
|
[:channels [:style :color] :interp])))))
|
||||||
|
|
||||||
(deftest keying-here-keys-what-is-animated-or-else-the-transform
|
|
||||||
(let [n {:id :x :kind :group}
|
|
||||||
fresh (node/key-at n 4 nil)
|
|
||||||
keyed-at #(set (keep (fn [[path c]] (when (contains? (:keys c) %2) path)) (node/channels %1)))]
|
|
||||||
(is (= #{[:xform :pos] [:xform :rot] [:xform :scale]} (keyed-at fresh 4))
|
|
||||||
"nothing animated: position, turn and scale, as Blender's I")
|
|
||||||
(let [turning (node/set-keyed-channel n [:xform :rot] 0 0.0)
|
|
||||||
turning (node/set-keyed-channel turning [:xform :rot] 10 2.0)
|
|
||||||
keyed (node/key-at turning 5 nil)]
|
|
||||||
(is (= #{[:xform :rot]} (keyed-at keyed 5)) "only what is already animated")
|
|
||||||
(is (= 1.0 (ch/value-at (get (node/channels keyed) [:xform :rot]) 5 nil))
|
|
||||||
"with the value it had there, so nothing moves"))
|
|
||||||
(is (= fresh (node/key-at fresh 4 nil)) "a key already there is kept, not toggled off")))
|
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,7 @@
|
||||||
(is (= [15 60 640 360 :arthur/pico-8]
|
(is (= [15 60 640 360 :arthur/pico-8]
|
||||||
[(:fps doc) (clip/frames doc :main) (:width doc) (:height doc) (:default-palette doc)]))
|
[(:fps doc) (clip/frames doc :main) (:width doc) (:height doc) (:default-palette doc)]))
|
||||||
(is (every? pal/valid-palette? (vals (:palettes doc))))
|
(is (every? pal/valid-palette? (vals (:palettes doc))))
|
||||||
(is (= [:arthur/pico-8] (keys (:palettes doc)))
|
(is (= (count pal/presets) (count (:palettes doc))))))
|
||||||
"a project carries the palette it draws with, not the whole shelf")))
|
|
||||||
(testing "a drawing made in a nested lane is one project frame long"
|
(testing "a drawing made in a nested lane is one project frame long"
|
||||||
;; The bug that started this: a lane made at 30 in a project then set to
|
;; The bug that started this: a lane made at 30 in a project then set to
|
||||||
;; 12 got drawings a thirtieth of a second long, which the output either
|
;; 12 got drawings a thirtieth of a second long, which the output either
|
||||||
|
|
|
||||||
|
|
@ -879,58 +879,3 @@
|
||||||
(is (= 10 (get-in result [:clip :symbols :main :nodes :insert :time :at])))
|
(is (= 10 (get-in result [:clip :symbols :main :nodes :insert :time :at])))
|
||||||
(is (= (get-in doc [:symbols :wave :nodes])
|
(is (= (get-in doc [:symbols :wave :nodes])
|
||||||
(get-in result [:clip :symbols :wave :nodes])))))
|
(get-in result [:clip :symbols :wave :nodes])))))
|
||||||
|
|
||||||
(deftest a-held-placement-shows-its-first-frame-for-as-long-as-it-lasts
|
|
||||||
(let [lane (-> (document)
|
|
||||||
(assoc-in [:symbols :main] {:id :main :frames 40 :display :lane :nodes {}})
|
|
||||||
(assoc-in [:symbols :blank] {:id :blank :frames 1 :nodes {}}))
|
|
||||||
placed (:clip (span/place-symbol lane nil :main :cel :blank 0
|
|
||||||
{:extent :grow-symbol :remainder-id :r :speed 0}))
|
|
||||||
stretched (:clip (span/resize-out placed :main :cel 6 {:extent :grow-symbol}))
|
|
||||||
n (get-in stretched [:symbols :main :nodes :cel])]
|
|
||||||
(is (= [0 1] (node/placed-span (get-in placed [:symbols :main :nodes :cel])))
|
|
||||||
"a held cel starts one frame long rather than its symbol's length over zero")
|
|
||||||
(is (= [0 6] (node/placed-span n)))
|
|
||||||
(is (every? #(= {:symbol :blank :frame 0} (node/placed-frame n % 1)) (range 6))
|
|
||||||
"stretched, every frame of it shows the one drawing")))
|
|
||||||
|
|
||||||
(defn- cel-spans [result sid]
|
|
||||||
(into {} (map (juxt :id node/placed-span))
|
|
||||||
(symbol/children (get-in result [:clip :symbols sid :nodes]))))
|
|
||||||
|
|
||||||
(deftest a-new-drawing-takes-over-from-the-playhead
|
|
||||||
(let [doc (document)]
|
|
||||||
(testing "inside a hold: the hold ends there and the copy has the rest of it"
|
|
||||||
(let [r (span/drawing-at doc :main 2 :new :copy {:copy? true})]
|
|
||||||
(is (= {:a [0 2] :new [2 4] :b [4 8] :insert [8 12]} (cel-spans r :main)))
|
|
||||||
(is (= 2 (:frame r)))
|
|
||||||
(is (= (get-in doc [:symbols :drawing-a :nodes])
|
|
||||||
(get-in r [:clip :symbols :copy :nodes])))))
|
|
||||||
(testing "on a drawing's first frame it goes on the frame after, as F6 does again and again"
|
|
||||||
(let [r (span/drawing-at doc :main 4 :new :copy {:copy? true})]
|
|
||||||
(is (= {:a [0 4] :b [4 5] :new [5 8] :insert [8 12]} (cel-spans r :main)))
|
|
||||||
(is (= (get-in doc [:symbols :drawing-b :nodes])
|
|
||||||
(get-in r [:clip :symbols :copy :nodes])))))
|
|
||||||
(testing "past the last cel: one frame, of the drawing before it, or empty"
|
|
||||||
(let [r (span/drawing-at doc :main 12 :new :blank {:extent :grow-symbol})]
|
|
||||||
(is (= [12 13] (get (cel-spans r :main) :new)))
|
|
||||||
(is (= {} (get-in r [:clip :symbols :blank :nodes])))
|
|
||||||
(is (= 13 (get-in r [:clip :symbols :main :frames]))))
|
|
||||||
(is (:required-frames (span/drawing-at doc :main 12 :new :blank {}))
|
|
||||||
"growing the shot is the caller's say"))))
|
|
||||||
|
|
||||||
(deftest a-new-drawing-in-a-gap-or-before-a-cel
|
|
||||||
(let [lane (fn [& cels]
|
|
||||||
(-> (document)
|
|
||||||
(assoc-in [:symbols :main] {:id :main :frames 12 :display :lane
|
|
||||||
:nodes (into {} (map (juxt :id identity)) cels)})))]
|
|
||||||
(is (= {:x [0 2] :new [3 5] :y [5 6]}
|
|
||||||
(cel-spans (span/drawing-at (lane (cel :x :drawing-a 0 2 0) (cel :y :drawing-b 5 1 0))
|
|
||||||
:main 3 :new :copy {:copy? true}) :main))
|
|
||||||
"in a gap it runs to the next cel, copying the one before")
|
|
||||||
(is (= {:x [0 1] :new [1 2] :y [2 4]}
|
|
||||||
(cel-spans (span/drawing-at (lane (cel :x :drawing-a 0 1 0) (cel :y :drawing-b 1 2 0))
|
|
||||||
:main 0 :new :copy {:copy? true}) :main))
|
|
||||||
"on a one-frame drawing with the next right after, room is made")
|
|
||||||
(is (:refused (span/drawing-at (lane) :main 0 :new :copy {:copy? true}))
|
|
||||||
"an empty lane has nothing to copy")))
|
|
||||||
|
|
|
||||||
|
|
@ -61,26 +61,26 @@
|
||||||
#uuid "22222222-2222-4222-8222-222222222222"
|
#uuid "22222222-2222-4222-8222-222222222222"
|
||||||
{:id #uuid "22222222-2222-4222-8222-222222222222"
|
{:id #uuid "22222222-2222-4222-8222-222222222222"
|
||||||
:kind :instance :parent :root :z "a2"
|
:kind :instance :parent :root :z "a2"
|
||||||
|
:name "8625 right"
|
||||||
:source {:symbol :sym/face}}
|
:source {:symbol :sym/face}}
|
||||||
#uuid "11111111-1111-4111-8111-111111111111"
|
#uuid "11111111-1111-4111-8111-111111111111"
|
||||||
{:id #uuid "11111111-1111-4111-8111-111111111111"
|
{:id #uuid "11111111-1111-4111-8111-111111111111"
|
||||||
:kind :instance :parent :root :z "a1"
|
:kind :instance :parent :root :z "a1"
|
||||||
|
:name "8625 left"
|
||||||
:source {:symbol :sym/face}}
|
:source {:symbol :sym/face}}
|
||||||
:a-rect {:id :a-rect :kind :rect :parent :root :z "a3"}}}
|
:a-rect {:id :a-rect :kind :rect :parent :root :z "a3"}}}
|
||||||
:sym/face {:frames 40 :nodes {:root {:id :root :kind :group :z "a1"}}}}})
|
: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
|
(deftest the-picker-offers-every-symbol-then-every-instance-in-the-open-one
|
||||||
(let [ts (export/targets clip :main)]
|
(let [ts (export/targets clip :main)]
|
||||||
(is (= ["main" "face" "face 1" "face 2"] (mapv :label ts))
|
(is (= ["main" "face" "8625 left" "8625 right"] (mapv :label ts))
|
||||||
"every symbol, then the instances in the open one")
|
"every symbol, then the instances in the open one")
|
||||||
(testing "the instances isolate a node in the open symbol and the symbols do not"
|
(testing "the instances isolate a node in the open symbol and the symbols do not"
|
||||||
(is (= [nil nil] (mapv :isolate (take 2 ts))))
|
(is (= [nil nil] (mapv :isolate (take 2 ts))))
|
||||||
(is (every? uuid? (mapv :isolate (drop 2 ts))))
|
(is (every? uuid? (mapv :isolate (drop 2 ts))))
|
||||||
(is (every? #(= :main (:symbol %)) (drop 2 ts))))
|
(is (every? #(= :main (:symbol %)) (drop 2 ts))))
|
||||||
(testing "one symbol placed twice is numbered in stacking order, because a uuid sorts at random"
|
(testing "ordered by label, because a uuid sorts at random"
|
||||||
(is (= [#uuid "11111111-1111-4111-8111-111111111111"
|
(is (= ["8625 left" "8625 right"] (mapv :label (drop 2 ts)))))
|
||||||
#uuid "22222222-2222-4222-8222-222222222222"]
|
|
||||||
(mapv :isolate (drop 2 ts)))))
|
|
||||||
(testing "and a node that is not an instance is not offered"
|
(testing "and a node that is not an instance is not offered"
|
||||||
(is (not-any? #{"a-rect"} (map :label ts))))))
|
(is (not-any? #{"a-rect"} (map :label ts))))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,42 +98,19 @@
|
||||||
"creating in a lane does not move the playhead"))))
|
"creating in a lane does not move the playhead"))))
|
||||||
|
|
||||||
(deftest the-palette-row-is-a-lane-row-whether-or-not-its-track-exists
|
(deftest the-palette-row-is-a-lane-row-whether-or-not-its-track-exists
|
||||||
(let [empty-row (first (timeline/palette-track-rows (clip/blank) :main 120 #{} nil))
|
(let [empty-row (timeline/palette-track-row (clip/blank) :main 120 #{} nil)
|
||||||
filled (-> (clip/blank)
|
filled (-> (clip/blank)
|
||||||
(assoc-in [:symbols :main :palette-track] :track)
|
(assoc-in [:symbols :main :palette-track] :track)
|
||||||
(assoc-in [:symbols :track]
|
(assoc-in [:symbols :track]
|
||||||
{:id :track :type :palette-track :display :lane
|
{:id :track :type :palette-track :display :lane
|
||||||
:frames 120 :nodes {}}))
|
:frames 120 :nodes {}}))
|
||||||
filled-row (first (timeline/palette-track-rows filled :main 120 #{} nil))]
|
filled-row (timeline/palette-track-row filled :main 120 #{} nil)]
|
||||||
;; The double-click that creates in a lane asks nothing else of a row.
|
;; The double-click that creates in a lane asks nothing else of a row.
|
||||||
(is (:lane? empty-row))
|
(is (:lane? empty-row))
|
||||||
(is (:lane? filled-row))
|
(is (:lane? filled-row))
|
||||||
(is (= [:node :track nil []] (:select filled-row))
|
(is (= [:node :track nil []] (:select filled-row))
|
||||||
"a track that exists is addressed as the lane it is")))
|
"a track that exists is addressed as the lane it is")))
|
||||||
|
|
||||||
(deftest the-palette-row-opens-onto-the-selected-transition-like-any-lane
|
|
||||||
(let [doc (-> (clip/blank)
|
|
||||||
(assoc-in [:symbols :main :palette-track] :track)
|
|
||||||
(assoc-in [:symbols :night] {:id :night :type :palette :frames 1 :nodes {}})
|
|
||||||
(assoc-in [:symbols :track]
|
|
||||||
{:id :track :type :palette-track :display :lane :frames 120
|
|
||||||
:nodes {:p {:id :p :kind :instance :source :night :span [10 40]
|
|
||||||
:time {:mode :map :at 10 :rate 1}
|
|
||||||
:channels {[:pos] {:keys {0 [0 0] 12 [5 0]}}}}}}))
|
|
||||||
closed (timeline/palette-track-rows doc :main 120 #{} [:p])
|
|
||||||
[lane portal & channels] (timeline/palette-track-rows
|
|
||||||
doc :main 120 #{[:arthur.ui.timeline/palette-track] [:p]} [:p])]
|
|
||||||
(is (= 1 (count closed)))
|
|
||||||
(is (:expandable? (first closed)) "the palette lane has a disclosure like any lane")
|
|
||||||
(is (:expanded? lane))
|
|
||||||
(is (= [:p] (:path portal)) "the portal is the selected transition, by its own path")
|
|
||||||
(is (= [:node :track :p [:p]] (:select portal)))
|
|
||||||
(is (= :track (:owner portal)) "dragging its bar slides it in the track")
|
|
||||||
(is (= [10 22] (:keys portal)) "its keys are on this ruler")
|
|
||||||
(is (= [:p [:pos]] (:path (first channels))) "and it opens onto its channels")
|
|
||||||
(is (not (contains? #{[:arthur.ui.timeline/lane]} (:path lane)))
|
|
||||||
"the palette lane never shares the open lane's expansion")))
|
|
||||||
|
|
||||||
(deftest the-same-double-click-command-creates-a-palette-symbol-on-the-palette-row
|
(deftest the-same-double-click-command-creates-a-palette-symbol-on-the-palette-row
|
||||||
(let [doc (clip/blank)
|
(let [doc (clip/blank)
|
||||||
id (store/install! {:clip doc :store {}} "double-click-palette-symbol")]
|
id (store/install! {:clip doc :store {}} "double-click-palette-symbol")]
|
||||||
|
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
(ns arthur.events.tracing-test
|
|
||||||
(:require [cljs.test :refer [deftest is]]
|
|
||||||
[arthur.events.ui :as ui]
|
|
||||||
[arthur.footage.store :as store]
|
|
||||||
[re-frame.core :as rf]
|
|
||||||
[re-frame.db :as rf-db]))
|
|
||||||
|
|
||||||
(defn- placed [id src] {:id id :kind :instance :z (name id) :source {:symbol src}})
|
|
||||||
|
|
||||||
(def document
|
|
||||||
;; Two references side by side, and a face traced from footage of its own.
|
|
||||||
{:fps 12 :width 320 :height 200
|
|
||||||
:symbols {:main {:id :main :frames 12
|
|
||||||
:nodes {:a (placed :a :ref) :c (placed :c :ref) :b (placed :b :face)}}
|
|
||||||
:ref {:id :ref :frames 12 :type :trace :nodes {}}
|
|
||||||
:face {:id :face :frames 12
|
|
||||||
:nodes {:plate {:id :plate :kind :rect :z "a"}
|
|
||||||
:mouth {:id :mouth :kind :rect :z "b"}}}}})
|
|
||||||
|
|
||||||
(defn- shift-t [selection tracing]
|
|
||||||
(let [id (store/install! {:clip document :store {}} "trace-selection")]
|
|
||||||
(reset! rf-db/app-db {:clip/current id :ui {:open :main :selection selection :tracing tracing}})
|
|
||||||
(rf/dispatch-sync [::ui/trace-selection])
|
|
||||||
(get-in @rf-db/app-db [:ui :tracing])))
|
|
||||||
|
|
||||||
(deftest shift-t-traces-the-selection-only
|
|
||||||
(is (= {:on? true :opacity 0.5 :hidden #{[:main :c] [:face :plate]}}
|
|
||||||
(shift-t [:node :main :a [:a]] {:on? false :opacity 0.5 :hidden #{}}))
|
|
||||||
"one reference: the other and the face's footage go")
|
|
||||||
(is (= #{[:main :a] [:main :c]}
|
|
||||||
(:hidden (shift-t [:node :main :b [:b]] {:on? false :opacity 0.5 :hidden #{}})))
|
|
||||||
"the face: its own footage, wherever it is placed")
|
|
||||||
(is (= #{} (:hidden (shift-t [:node :main :a [:a]]
|
|
||||||
{:on? true :opacity 0.5 :hidden #{[:main :c] [:face :plate]}})))
|
|
||||||
"again, and every layer is back")
|
|
||||||
(is (= {:on? false :opacity 0.5 :hidden #{}}
|
|
||||||
(shift-t nil {:on? false :opacity 0.5 :hidden #{}}))
|
|
||||||
"nothing selected changes nothing"))
|
|
||||||
|
|
@ -98,9 +98,7 @@
|
||||||
(is (= [:mouth :head :place] (symbol/lineage (:nodes @sym*) :mouth)))
|
(is (= [:mouth :head :place] (symbol/lineage (:nodes @sym*) :mouth)))
|
||||||
(is (= [:mouth-in :mouth :head :place] (symbol/lineage (:nodes @sym*) :mouth-in)))
|
(is (= [:mouth-in :mouth :head :place] (symbol/lineage (:nodes @sym*) :mouth-in)))
|
||||||
(is (= {:mode :map :expose 2} (:time (node :root))))
|
(is (= {:mode :map :expose 2} (:time (node :root))))
|
||||||
;; The mouth leads, 125ms at the take's 30fps; its interior inherits that.
|
(is (every? #(nil? (:time (node %))) [:place :head :mouth :mouth-in])))
|
||||||
(is (= {:offset 4} (:time (node :mouth))))
|
|
||||||
(is (every? #(nil? (:time (node %))) [:place :head :mouth-in])))
|
|
||||||
|
|
||||||
(deftest geometry-is-flat-and-dense-and-the-interior-shares-the-outline-s-block
|
(deftest geometry-is-flat-and-dense-and-the-interior-shares-the-outline-s-block
|
||||||
(doseq [id [:mouth :mouth-in]]
|
(doseq [id [:mouth :mouth-in]]
|
||||||
|
|
@ -206,9 +204,7 @@
|
||||||
res (clip/resolver c :main @store pal/index-of nil)
|
res (clip/resolver c :main @store pal/index-of nil)
|
||||||
k (first (:value (chan :place [:xform :scale])))
|
k (first (:value (chan :place [:xform :scale])))
|
||||||
pos (:value (chan :place [:xform :pos]))
|
pos (:value (chan :place [:xform :pos]))
|
||||||
tfs (:transforms @take/measured)
|
tfs (:transforms @take/measured)]
|
||||||
lead (get-in c [:symbols :face-1 :nodes :mouth :time :offset] 0)]
|
|
||||||
(is (pos? lead) "a frozen mouth leads by default")
|
|
||||||
(doseq [f (range 0 take/frames 13)]
|
(doseq [f (range 0 take/frames 13)]
|
||||||
(let [ops (res f)
|
(let [ops (res f)
|
||||||
op (first (filter #(= [:face-1 :mouth] (:node %)) ops))
|
op (first (filter #(= [:face-1 :mouth] (:node %)) ops))
|
||||||
|
|
@ -220,9 +216,7 @@
|
||||||
ef (node/expose f 2)
|
ef (node/expose f 2)
|
||||||
;; The frozen, quantised vertex — so the fixed point is not part of
|
;; The frozen, quantised vertex — so the fixed point is not part of
|
||||||
;; what is being asserted here; it has its own test.
|
;; what is being asserted here; it has its own test.
|
||||||
;; The mouth LEADS: its pose is read `lead` frames ahead of the
|
flat (pts-at :mouth ef)
|
||||||
;; head it hangs off, held at the last frame. See `freeze/mouth-lead`.
|
|
||||||
flat (pts-at :mouth (min (dec take/frames) (+ ef lead)))
|
|
||||||
g {:x (nth flat 0) :y (nth flat 1)}
|
g {:x (nth flat 0) :y (nth flat 1)}
|
||||||
;; Where the anchor fit says that head-local point was in the image:
|
;; Where the anchor fit says that head-local point was in the image:
|
||||||
;; the fit removed the head's motion, so putting it back is the fit's
|
;; the fit removed the head's motion, so putting it back is the fit's
|
||||||
|
|
|
||||||
|
|
@ -101,9 +101,7 @@
|
||||||
cut (pose/put-cut clip :main :face-2 :mouth 0 20)
|
cut (pose/put-cut clip :main :face-2 :mouth 0 20)
|
||||||
original (by-node clip store 4)
|
original (by-node clip store 4)
|
||||||
held (by-node cut store 4)
|
held (by-node cut store 4)
|
||||||
;; Uncut, frame f shows pose f + lead, so pose 20 is on frame 20 − lead.
|
source (by-node clip store 20)]
|
||||||
lead (get-in clip [:symbols :face-2 :nodes :mouth :time :offset] 0)
|
|
||||||
source (by-node clip store (- 20 lead))]
|
|
||||||
(is (empty? (clip/problems cut)))
|
(is (empty? (clip/problems cut)))
|
||||||
(is (= (get held [:face-2 :mouth]) (get source [:face-2 :mouth])))
|
(is (= (get held [:face-2 :mouth]) (get source [:face-2 :mouth])))
|
||||||
(is (not= (get held [:face-2 :mouth]) (get original [:face-2 :mouth])))
|
(is (not= (get held [:face-2 :mouth]) (get original [:face-2 :mouth])))
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
(ns arthur.ui.shortcuts-test
|
|
||||||
(:require [cljs.test :refer [deftest is]]
|
|
||||||
[arthur.domain.sequence-test :as fixture]
|
|
||||||
[arthur.footage.store :as store]
|
|
||||||
[arthur.ui.shortcuts :as shortcuts]))
|
|
||||||
|
|
||||||
(deftest the-key-jumps-stop-on-every-cel-edge-and-key-the-timeline-shows
|
|
||||||
;; Cels at 0, 4 and 8; `:b` keyed on its own frames 0 and 1, which it shows
|
|
||||||
;; at 4 and 5; the plate keyed at 0 and 11. The lane's end, 12, is past the
|
|
||||||
;; last frame and is not somewhere to stand.
|
|
||||||
(let [id (store/install! {:clip (fixture/document) :store {}} "shortcut-stops")]
|
|
||||||
(is (= [0 4 5 8 11]
|
|
||||||
(vec (shortcuts/stops {:clip/current id :ui {:open :main}}))))))
|
|
||||||
|
|
@ -78,9 +78,7 @@ try {
|
||||||
|
|
||||||
await evaluate(`(() => {
|
await evaluate(`(() => {
|
||||||
const k = cljs.core.keyword, v = cljs.core.vector, m = cljs.core.hash_map;
|
const k = cljs.core.keyword, v = cljs.core.vector, m = cljs.core.hash_map;
|
||||||
// The drags below measure frames as fractions of a 120-frame ruler, so the
|
let c = arthur.domain.clip.blank();
|
||||||
// ruler is pinned rather than left to the blank document's length.
|
|
||||||
let c = cljs.core.assoc_in(arthur.domain.clip.blank(), v(k('symbols'), k('main'), k('frames')), 120);
|
|
||||||
const rect = (id, at, keys) => m(k('id'), k(id), k('kind'), k('rect'), k('z'), id,
|
const rect = (id, at, keys) => m(k('id'), k(id), k('kind'), k('rect'), k('z'), id,
|
||||||
k('time'), m(k('at'), at, k('rate'), 1), k('span'), v(0, 20),
|
k('time'), m(k('at'), at, k('rate'), 1), k('span'), v(0, 20),
|
||||||
k('channels'), keys ? m(v(k('xform'), k('pos')), arthur.domain.channel.keyed(m(2, v(2,0), 4, v(4,0)), k('linear'))) : m());
|
k('channels'), keys ? m(v(k('xform'), k('pos')), arthur.domain.channel.keyed(m(2, v(2,0), 4, v(4,0)), k('linear'))) : m());
|
||||||
|
|
|
||||||
|
|
@ -58,11 +58,7 @@ try {
|
||||||
|
|
||||||
await send('Runtime.enable');
|
await send('Runtime.enable');
|
||||||
for (let i = 0; i < 100; i++) {
|
for (let i = 0; i < 100; i++) {
|
||||||
try {
|
|
||||||
if (await evaluate('typeof arthur !== "undefined" && !!document.querySelector("canvas.stage")')) break;
|
if (await evaluate('typeof arthur !== "undefined" && !!document.querySelector("canvas.stage")')) break;
|
||||||
} catch (error) {
|
|
||||||
if (!error.message.includes("Cannot find default execution context")) throw error;
|
|
||||||
}
|
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
}
|
}
|
||||||
await evaluate(`(() => {
|
await evaluate(`(() => {
|
||||||
|
|
@ -82,16 +78,21 @@ try {
|
||||||
await evaluate(`(() => { document.querySelectorAll('.menu-scrim').forEach(x => x.click()); return true })()`);
|
await evaluate(`(() => { document.querySelectorAll('.menu-scrim').forEach(x => x.click()); return true })()`);
|
||||||
await sleep(80);
|
await sleep(80);
|
||||||
};
|
};
|
||||||
// Creation is two buttons in the timeline's toolbar: a symbol, or a lane.
|
|
||||||
const clickNew = async label => {
|
const clickNew = async label => {
|
||||||
await closeMenus();
|
await closeMenus();
|
||||||
assert(await evaluate(`(() => {
|
assert(await evaluate(`(() => {
|
||||||
const button = [...document.querySelectorAll('.creation-controls button')]
|
const menu = document.querySelector('.loc .menu-wrap > button');
|
||||||
.find(b => b.textContent.trim() === ${JSON.stringify(label)});
|
if (!menu) return false;
|
||||||
if (!button || button.disabled) return false;
|
menu.click(); return true;
|
||||||
button.click(); return true;
|
})()`), 'new menu exists');
|
||||||
|
await sleep(100);
|
||||||
|
assert(await evaluate(`(() => {
|
||||||
|
const item = [...document.querySelectorAll('.menu-item')].find(${named(label)});
|
||||||
|
if (!item || item.disabled) return false;
|
||||||
|
item.click(); return true;
|
||||||
})()`), `enabled creation command: ${label}`);
|
})()`), `enabled creation command: ${label}`);
|
||||||
await sleep(220);
|
await sleep(220);
|
||||||
|
await closeMenus();
|
||||||
};
|
};
|
||||||
const shot = async () => JSON.parse(JSON.stringify(await evaluate('laneSnapshot()'),
|
const shot = async () => JSON.parse(JSON.stringify(await evaluate('laneSnapshot()'),
|
||||||
(_key, value) => value?.uuid ?? value));
|
(_key, value) => value?.uuid ?? value));
|
||||||
|
|
@ -110,7 +111,7 @@ try {
|
||||||
assert.equal((await shot()).clip.symbols.main.display, undefined,
|
assert.equal((await shot()).clip.symbols.main.display, undefined,
|
||||||
'a blank document starts as an ordinary symbol');
|
'a blank document starts as an ordinary symbol');
|
||||||
|
|
||||||
await clickNew('symbol');
|
await clickNew('inside');
|
||||||
let s = await shot();
|
let s = await shot();
|
||||||
let placed = mainInstances(s);
|
let placed = mainInstances(s);
|
||||||
assert.equal(placed.length, 1, 'new symbol places one instance');
|
assert.equal(placed.length, 1, 'new symbol places one instance');
|
||||||
|
|
@ -129,12 +130,12 @@ try {
|
||||||
placed = mainInstances(s);
|
placed = mainInstances(s);
|
||||||
assert.equal(placed.length, 2, 'explicit lane places a second symbol');
|
assert.equal(placed.length, 2, 'explicit lane places a second symbol');
|
||||||
assert.equal(laneSymbols(s).length, 1, 'only the lane command marks a symbol as a lane');
|
assert.equal(laneSymbols(s).length, 1, 'only the lane command marks a symbol as a lane');
|
||||||
assert.equal(await evaluate('[...document.querySelectorAll(".tl-track:not(.palette)")].filter(t => t.arthurLane).length'), 1,
|
assert.equal(await evaluate('[...document.querySelectorAll(".tl-track")].filter(t => t.arthurLane).length'), 1,
|
||||||
'the explicit lane is drawn as one linear track');
|
'the explicit lane is drawn as one linear track');
|
||||||
|
|
||||||
assert.equal(await evaluate('document.querySelectorAll(".tl-label:not(.palette) .tl-rename").length'), 1,
|
assert.equal(await evaluate('document.querySelectorAll(".tl-rename").length'), 1,
|
||||||
'the lane exposes its rename control');
|
'the lane exposes its rename control');
|
||||||
await evaluate('document.querySelector(".tl-label:not(.palette) .tl-rename").click()');
|
await evaluate('document.querySelector(".tl-rename").click()');
|
||||||
await sleep(80);
|
await sleep(80);
|
||||||
assert(await evaluate(`(() => {
|
assert(await evaluate(`(() => {
|
||||||
const input = document.querySelector('.tl-name-input');
|
const input = document.querySelector('.tl-name-input');
|
||||||
|
|
@ -146,16 +147,13 @@ try {
|
||||||
})()`), 'lane rename editor opens');
|
})()`), 'lane rename editor opens');
|
||||||
await sleep(180);
|
await sleep(180);
|
||||||
s = await shot();
|
s = await shot();
|
||||||
// A lane is an instance, and an instance is called what it places: the
|
assert(mainInstances(s).some(n => n.name === 'Foreground'), 'lane name persists');
|
||||||
// rename lands on the lane's symbol, not on the placement.
|
|
||||||
assert(laneSymbols(s).some(sym => sym.name === 'Foreground'), 'lane name persists on its symbol');
|
|
||||||
assert(!mainInstances(s).some(n => n.name), 'and the placement carries no name of its own');
|
|
||||||
|
|
||||||
// Drag a library symbol into the explicit lane. The row itself is the target;
|
// Drag a library symbol into the explicit lane. The row itself is the target;
|
||||||
// no temporary lane is previewed or created.
|
// no temporary lane is previewed or created.
|
||||||
const drop = await evaluate(`(() => {
|
const drop = await evaluate(`(() => {
|
||||||
const source = document.querySelector('.pool-row:not(.main) .pool-item[draggable="true"]');
|
const source = document.querySelector('.pool-row:not(.main) .pool-item[draggable="true"]');
|
||||||
const track = [...document.querySelectorAll('.tl-track:not(.palette)')].find(t => t.arthurLane);
|
const track = [...document.querySelectorAll('.tl-track')].find(t => t.arthurLane);
|
||||||
if (!source || !track) return null;
|
if (!source || !track) return null;
|
||||||
source.scrollIntoView({block: 'center'});
|
source.scrollIntoView({block: 'center'});
|
||||||
const a = source.getBoundingClientRect(), b = track.getBoundingClientRect();
|
const a = source.getBoundingClientRect(), b = track.getBoundingClientRect();
|
||||||
|
|
@ -194,7 +192,7 @@ try {
|
||||||
s = await shot();
|
s = await shot();
|
||||||
assert.equal(laneSymbols(s).length, 2, 'a second explicit command creates a second lane');
|
assert.equal(laneSymbols(s).length, 2, 'a second explicit command creates a second lane');
|
||||||
const move = await evaluate(`(() => {
|
const move = await evaluate(`(() => {
|
||||||
const tracks = [...document.querySelectorAll('.tl-track:not(.palette)')].filter(t => t.arthurLane);
|
const tracks = [...document.querySelectorAll('.tl-track')].filter(t => t.arthurLane);
|
||||||
const from = tracks.find(t => t.querySelector('.tl-cel'));
|
const from = tracks.find(t => t.querySelector('.tl-cel'));
|
||||||
const to = tracks.find(t => t !== from);
|
const to = tracks.find(t => t !== from);
|
||||||
const cel = from?.querySelector('.tl-cel');
|
const cel = from?.querySelector('.tl-cel');
|
||||||
|
|
@ -220,7 +218,7 @@ try {
|
||||||
await evaluate(`re_frame.core.dispatch_sync(cljs.core.vector(
|
await evaluate(`re_frame.core.dispatch_sync(cljs.core.vector(
|
||||||
cljs.core.keyword('arthur.events.project/new'))) `);
|
cljs.core.keyword('arthur.events.project/new'))) `);
|
||||||
await sleep(250);
|
await sleep(250);
|
||||||
await clickNew('symbol');
|
await clickNew('inside');
|
||||||
const clipboardBaseline = (await shot()).clip;
|
const clipboardBaseline = (await shot()).clip;
|
||||||
await shortcut('d', 'KeyD');
|
await shortcut('d', 'KeyD');
|
||||||
assert.equal(mainInstances(await shot()).length, 2, 'duplicate copies the selected instance');
|
assert.equal(mainInstances(await shot()).length, 2, 'duplicate copies the selected instance');
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,7 @@ try {
|
||||||
await send('Runtime.enable');
|
await send('Runtime.enable');
|
||||||
await send('Page.enable');
|
await send('Page.enable');
|
||||||
for (let i = 0; i < 160; i++) {
|
for (let i = 0; i < 160; i++) {
|
||||||
// The page can reload under the first probes, which then have no context
|
if (await evalJS('return !!(window.cljs && window.re_frame && window.arthur)')) break;
|
||||||
// to run in; that is not the page being broken, so wait it out.
|
|
||||||
try { if (await evalJS('return !!(window.cljs && window.re_frame && window.arthur)')) break; } catch {}
|
|
||||||
await sleep(250);
|
await sleep(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -562,26 +562,31 @@ async function main() {
|
||||||
await page.eval(SEEK(f));
|
await page.eval(SEEK(f));
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
check(await page.eval(`(() => {
|
check(await page.eval(`(() => {
|
||||||
const button = document.querySelector('.params .chan[data-channel="geom pts"] button.key');
|
const button = [...document.querySelectorAll('.params button')]
|
||||||
if (!button || button.disabled || button.classList.contains('on')) return false;
|
.find(b => b.textContent === 'drawing key here');
|
||||||
|
if (!button || button.disabled) return false;
|
||||||
button.click();
|
button.click();
|
||||||
return true;
|
return true;
|
||||||
})()`), `a drawing key can be added at frame ${f}`);
|
})()`), `a drawing key can be added at frame ${f}`);
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
}
|
}
|
||||||
// Standing on key 16, the gap switch is about the gap arriving at it, 8 → 16.
|
await page.eval(SEEK(8));
|
||||||
const GAP = `document.querySelector('.params .chan[data-channel="geom pts"] button.gap')`;
|
|
||||||
await page.eval(SEEK(16));
|
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
const tweenSelected = await page.eval(`(() => {
|
const tweenSelected = await page.eval(`(() => {
|
||||||
const gap = ${GAP};
|
const label = [...document.querySelectorAll('.params label')]
|
||||||
if (!gap || gap.getAttribute('aria-label') !== 'hold') return false;
|
.find(el => el.textContent.startsWith('key 8 → 16'));
|
||||||
gap.click();
|
const select = label?.querySelector('select');
|
||||||
|
if (!select) return false;
|
||||||
|
select.value = 'linear';
|
||||||
|
select.dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
return true;
|
return true;
|
||||||
})()`);
|
})()`);
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
check(tweenSelected && await page.eval(`${GAP}?.getAttribute('aria-label') === 'tween'`),
|
check(tweenSelected && await page.eval(`(() => {
|
||||||
'the second drawing gap can be set to tween');
|
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((await statusMatching(/saved r\d+/)) !== null,
|
check((await statusMatching(/saved r\d+/)) !== null,
|
||||||
'the painted shape saves by itself', await page.eval(STATUS));
|
'the painted shape saves by itself', await page.eval(STATUS));
|
||||||
check(await fromMenu(MENU_PICK_NEWEST), 'the painted document can be reopened');
|
check(await fromMenu(MENU_PICK_NEWEST), 'the painted document can be reopened');
|
||||||
|
|
@ -605,10 +610,13 @@ async function main() {
|
||||||
re_frame.core.dispatch_sync(c.vector(k('arthur.events.ui/select'),
|
re_frame.core.dispatch_sync(c.vector(k('arthur.events.ui/select'),
|
||||||
c.vector(k('node'), k('main'), id, c.vector(id))));
|
c.vector(k('node'), k('main'), id, c.vector(id))));
|
||||||
})()`);
|
})()`);
|
||||||
await page.eval(SEEK(16));
|
await page.eval(SEEK(8));
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
check(await page.eval(`${GAP}?.getAttribute('aria-label') === 'tween'`),
|
check(await page.eval(`(() => {
|
||||||
'the per-gap tween setting survives the project round trip');
|
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');
|
||||||
|
|
||||||
// The local 8625 study is optional in a fresh test database. When present,
|
// The local 8625 study is optional in a fresh test database. When present,
|
||||||
// tune its shared symbol while its stage is playing.
|
// tune its shared symbol while its stage is playing.
|
||||||
|
|
@ -619,7 +627,7 @@ async function main() {
|
||||||
const stageLoaded = await statusMatching(/loaded 8625 stage study/, 160);
|
const stageLoaded = await statusMatching(/loaded 8625 stage study/, 160);
|
||||||
check(stageLoaded !== null, 'the 8625 stage is ready', stageLoaded ?? (await page.eval(STATUS)));
|
check(stageLoaded !== null, 'the 8625 stage is ready', stageLoaded ?? (await page.eval(STATUS)));
|
||||||
const eyeSelected = await page.eval(`(() => {
|
const eyeSelected = await page.eval(`(() => {
|
||||||
const select = [...document.querySelectorAll('.params .section')].find(s => s.querySelector('h2')?.textContent === 'tracking')?.querySelector('select');
|
const select = document.querySelector('.params .section:last-child select');
|
||||||
// Settings belong to tracked features shared by the stage placements.
|
// Settings belong to tracked features shared by the stage placements.
|
||||||
const option = [...select.options]
|
const option = [...select.options]
|
||||||
.find(o => o.textContent.trim().endsWith('feature · face-1/eye-r'));
|
.find(o => o.textContent.trim().endsWith('feature · face-1/eye-r'));
|
||||||
|
|
@ -663,7 +671,7 @@ async function main() {
|
||||||
await page.eval(CLICK('pause'));
|
await page.eval(CLICK('pause'));
|
||||||
}
|
}
|
||||||
const subjectSelected = await page.eval(`(() => {
|
const subjectSelected = await page.eval(`(() => {
|
||||||
const select = [...document.querySelectorAll('.params .section')].find(s => s.querySelector('h2')?.textContent === 'tracking')?.querySelector('select');
|
const select = document.querySelector('.params .section:last-child select');
|
||||||
const option = [...select.options]
|
const option = [...select.options]
|
||||||
.find(o => o.textContent.includes('subject · face-1'));
|
.find(o => o.textContent.includes('subject · face-1'));
|
||||||
if (!option) return false;
|
if (!option) return false;
|
||||||
|
|
@ -712,7 +720,7 @@ async function main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const teethSelected = await page.eval(`(() => {
|
const teethSelected = await page.eval(`(() => {
|
||||||
const select = [...document.querySelectorAll('.params .section')].find(s => s.querySelector('h2')?.textContent === 'tracking')?.querySelector('select');
|
const select = document.querySelector('.params .section:last-child select');
|
||||||
const option = [...select.options]
|
const option = [...select.options]
|
||||||
.find(o => o.textContent.trim().endsWith('feature · face-1/teeth'));
|
.find(o => o.textContent.trim().endsWith('feature · face-1/teeth'));
|
||||||
if (!option) return false;
|
if (!option) return false;
|
||||||
|
|
|
||||||
|
|
@ -525,22 +525,6 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
|
||||||
}
|
}
|
||||||
.pool-clear:hover { background: var(--hair); color: var(--fg); }
|
.pool-clear:hover { background: var(--hair); color: var(--fg); }
|
||||||
|
|
||||||
/* The pool's add buttons. Pushed to the bottom by the auto margin and sticky
|
|
||||||
there, so they sit at the foot of a short list and stay in view under a long
|
|
||||||
one. */
|
|
||||||
.pool-foot {
|
|
||||||
position: sticky;
|
|
||||||
bottom: 0;
|
|
||||||
z-index: 2;
|
|
||||||
margin-top: auto;
|
|
||||||
display: flex;
|
|
||||||
gap: 4px;
|
|
||||||
padding: 3px 5px;
|
|
||||||
background: var(--chrome);
|
|
||||||
border-top: 1px solid var(--line);
|
|
||||||
}
|
|
||||||
.pool-foot > button { flex: 1; }
|
|
||||||
|
|
||||||
/* The scope tabs, in the vocabulary `ui/tabs` already established for symbols —
|
/* The scope tabs, in the vocabulary `ui/tabs` already established for symbols —
|
||||||
the same object, so two rows of tabs on one screen read as one idea. */
|
the same object, so two rows of tabs on one screen read as one idea. */
|
||||||
.pool > .tabs { top: 45px; position: sticky; z-index: 2; }
|
.pool > .tabs { top: 45px; position: sticky; z-index: 2; }
|
||||||
|
|
@ -942,6 +926,7 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
|
||||||
letter-spacing: .07em;
|
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 { display: grid; gap: 2px; color: var(--dim); }
|
||||||
.inspector-field input { width: 100%; color: var(--fg); }
|
.inspector-field input { width: 100%; color: var(--fg); }
|
||||||
|
|
||||||
|
|
@ -951,6 +936,11 @@ 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 { display: flex; align-items: center; gap: 4px; min-width: 0; }
|
||||||
.correction-item > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
.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 { display: grid; gap: 1px; margin-bottom: 6px; }
|
||||||
.knob .top-line { display: flex; justify-content: space-between; gap: 8px; }
|
.knob .top-line { display: flex; justify-content: space-between; gap: 8px; }
|
||||||
.knob .top-line .name { color: var(--dim); }
|
.knob .top-line .name { color: var(--dim); }
|
||||||
|
|
@ -1066,21 +1056,12 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
|
||||||
min-width: max(340px, calc((100% - var(--label)) * var(--tl-zoom, 1)));
|
min-width: max(340px, calc((100% - var(--label)) * var(--tl-zoom, 1)));
|
||||||
position: relative;
|
position: relative;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
/* The major frame grid, using the same whole-second interval as the numbered
|
||||||
|
ruler. It is a background rather than an element per mark; `--tick` is set
|
||||||
/* THE FRAME GRID, over the rows so it shows through the cels as Flash's does:
|
by the component because only it knows the open symbol's length and FPS. */
|
||||||
a hairline at every frame (or every few, when a frame is too narrow to see —
|
|
||||||
`--fine` is set by the component, which knows how wide a frame is drawn) and
|
|
||||||
a stronger line at every whole second, the interval the ruler numbers. */
|
|
||||||
.tl-grid {
|
|
||||||
position: absolute; inset: 0; z-index: 1; pointer-events: none;
|
|
||||||
background-image:
|
background-image:
|
||||||
repeating-linear-gradient(90deg, var(--grid-5) 0 1px, transparent 1px var(--tick, 10%)),
|
repeating-linear-gradient(90deg,
|
||||||
repeating-linear-gradient(90deg, rgba(0, 0, 0, .07) 0 1px, transparent 1px var(--fine));
|
var(--grid-5) 0 1px, transparent 1px var(--tick, 10%));
|
||||||
}
|
|
||||||
.tl-grid.coarse {
|
|
||||||
background-image:
|
|
||||||
repeating-linear-gradient(90deg, var(--grid-5) 0 1px, transparent 1px var(--tick, 10%));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tl-label,
|
.tl-label,
|
||||||
|
|
@ -1189,12 +1170,6 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
|
||||||
.tl-ruler {
|
.tl-ruler {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
/* The fine grid's ticks along its foot, so the frames under the numbers can
|
|
||||||
be counted too. */
|
|
||||||
background-image: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px var(--fine));
|
|
||||||
background-size: 100% 4px;
|
|
||||||
background-position: bottom;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tl-ruler .tick {
|
.tl-ruler .tick {
|
||||||
|
|
@ -1330,39 +1305,27 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* THE PLAYHEAD IS THE FRAME, a cell wide: tinted over the tracks, with its line
|
|
||||||
on the frame's left edge, where its time begins and where the ruler's number
|
|
||||||
sits. A frame too narrow to tint is the line alone. */
|
|
||||||
.tl-playhead {
|
.tl-playhead {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
min-width: 1px;
|
width: 1px;
|
||||||
box-sizing: border-box;
|
background: var(--playhead);
|
||||||
border-left: 1px solid var(--playhead);
|
|
||||||
background: color-mix(in srgb, var(--playhead) 13%, transparent);
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
.tl-tracks.narrow .tl-playhead { background: none; }
|
|
||||||
|
|
||||||
/* Its head, on the same cell in the ruler and carrying the frame number, so
|
/* The playhead's head, in the ruler rather than on the line, so it stays at the
|
||||||
where you are is read where you are looking. In the ruler rather than on the
|
top with the ruler while the rows scroll. */
|
||||||
line, so it stays at the top while the rows scroll. */
|
|
||||||
.tl-knob {
|
.tl-knob {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
z-index: 1;
|
|
||||||
box-sizing: border-box;
|
|
||||||
padding: 0 3px;
|
|
||||||
white-space: nowrap;
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
margin-left: -4px;
|
||||||
|
top: 1px;
|
||||||
|
width: 9px;
|
||||||
|
height: 9px;
|
||||||
|
border-radius: 50%;
|
||||||
background: var(--playhead);
|
background: var(--playhead);
|
||||||
color: #fff;
|
|
||||||
font-size: 10px;
|
|
||||||
line-height: var(--ruler);
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tl-empty { padding: 9px; color: var(--dim); }
|
.tl-empty { padding: 9px; color: var(--dim); }
|
||||||
|
|
@ -1439,70 +1402,28 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
|
||||||
border-top: 1px solid var(--hair);
|
border-top: 1px solid var(--hair);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The inspector. One column of names, 46px, and controls after it: the
|
/* A transform or visibility channel: its key button, then a field per component. */
|
||||||
header, then a row per channel, then labelled rows. */
|
.facts dd.channel { display: flex; gap: 3px; align-items: center; overflow: visible; }
|
||||||
.inspect-head {
|
.facts dd.channel input[type=number] { width: 0; flex: 1; min-width: 0; }
|
||||||
display: flex; align-items: center; gap: 5px;
|
.facts dd.channel .key { padding: 0 3px; color: var(--dim); }
|
||||||
padding: 6px; border-bottom: 1px solid var(--hair);
|
.facts dd.channel .key.keyed { color: var(--fg); }
|
||||||
position: sticky; top: 0; z-index: 1; background: var(--pane);
|
.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;
|
||||||
}
|
}
|
||||||
.inspect-kind { color: var(--dim); flex: 0 0 auto; }
|
.facts dd.channel .channel-swatches .swatch { flex: 0 0 15px; }
|
||||||
.inspect-name { flex: 1; min-width: 0; font-weight: 600; }
|
.facts dd.channel.live {
|
||||||
.uses, .tl-label .uses { color: var(--dim); flex: 0 0 auto; }
|
margin: -2px;
|
||||||
|
padding: 2px;
|
||||||
.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;
|
border-radius: 3px;
|
||||||
background: var(--live-bg);
|
background: var(--live-bg);
|
||||||
box-shadow: 0 0 0 1px rgba(35, 148, 71, .45);
|
box-shadow: 0 0 0 1px rgba(35, 148, 71, .45), 0 0 6px rgba(35, 148, 71, .28);
|
||||||
}
|
}
|
||||||
.chan.live input { border-color: var(--live); }
|
.facts dd.channel.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; font-size: 15px; line-height: 1; }
|
|
||||||
.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). */
|
/* 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; }
|
.paint-overlay .handles .box { fill: none; stroke: #e6ca8b; stroke-width: 0.5; stroke-dasharray: 2 1; pointer-events: none; }
|
||||||
|
|
@ -1702,38 +1623,38 @@ button.tl-gap:hover { background: rgba(47, 111, 192, .28); }
|
||||||
.tool svg .cut { fill: none; stroke: var(--chrome); stroke-width: 1.2; }
|
.tool svg .cut { fill: none; stroke: var(--chrome); stroke-width: 1.2; }
|
||||||
.tool.on svg .cut { stroke: var(--sel-bg); }
|
.tool.on svg .cut { stroke: var(--sel-bg); }
|
||||||
|
|
||||||
.palette-grid { display: grid; gap: 7px; justify-items: center; padding-top: 9px; border-top: 1px solid var(--hair); }
|
.palette { display: grid; gap: 7px; justify-items: center; padding-top: 9px; border-top: 1px solid var(--hair); }
|
||||||
|
|
||||||
/* The colour a new shape gets: Photoshop's foreground chip. */
|
/* The colour a new shape gets: Photoshop's foreground chip. */
|
||||||
.palette-grid .chip {
|
.palette .chip {
|
||||||
width: 36px; height: 36px;
|
width: 36px; height: 36px;
|
||||||
display: grid; place-items: end start;
|
display: grid; place-items: end start;
|
||||||
border: 1px solid var(--fg);
|
border: 1px solid var(--fg);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
box-shadow: inset 0 0 0 2px var(--pane);
|
box-shadow: inset 0 0 0 2px var(--pane);
|
||||||
}
|
}
|
||||||
.palette-grid .chip span {
|
.palette .chip span {
|
||||||
margin: 0 0 2px 3px; padding: 0 3px;
|
margin: 0 0 2px 3px; padding: 0 3px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
background: rgba(255, 255, 255, .85);
|
background: rgba(255, 255, 255, .85);
|
||||||
color: var(--fg); font-size: 9px; line-height: 12px;
|
color: var(--fg); font-size: 9px; line-height: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.palette-grid .cells { display: grid; grid-template-columns: repeat(2, 17px); gap: 2px; }
|
.palette .cells { display: grid; grid-template-columns: repeat(2, 17px); gap: 2px; }
|
||||||
.palette-grid .slot { display: contents; }
|
.palette .slot { display: contents; }
|
||||||
.palette-grid .cell {
|
.palette .cell {
|
||||||
width: 17px; height: 17px;
|
width: 17px; height: 17px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: 1px solid rgba(0, 0, 0, .35);
|
border: 1px solid rgba(0, 0, 0, .35);
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.palette-grid .cell:hover { border-color: var(--fg); transform: scale(1.12); }
|
.palette .cell:hover { border-color: var(--fg); transform: scale(1.12); }
|
||||||
.palette-grid .cell.on { border-color: var(--fg); box-shadow: 0 0 0 1px var(--pane), 0 0 0 2px var(--sel); position: relative; z-index: 1; }
|
.palette .cell.on { border-color: var(--fg); box-shadow: 0 0 0 1px var(--pane), 0 0 0 2px var(--sel); position: relative; z-index: 1; }
|
||||||
|
|
||||||
/* Clear is no colour: a knockout. Checkered, as transparency is everywhere. */
|
/* Clear is no colour: a knockout. Checkered, as transparency is everywhere. */
|
||||||
.palette-grid .clear,
|
.palette .clear,
|
||||||
.palette-grid .chip.clear {
|
.palette .chip.clear {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
background-image:
|
background-image:
|
||||||
linear-gradient(45deg, #c9c9c5 25%, transparent 25%, transparent 75%, #c9c9c5 75%),
|
linear-gradient(45deg, #c9c9c5 25%, transparent 25%, transparent 75%, #c9c9c5 75%),
|
||||||
|
|
@ -1783,13 +1704,13 @@ button.tl-gap:hover { background: rgba(47, 111, 192, .28); }
|
||||||
/* Remap: the map swatch, and the inspector's grid for a remap shape. A slot is
|
/* Remap: the map swatch, and the inspector's grid for a remap shape. A slot is
|
||||||
shown as what is under the shape will be drawn in; the original is the chip
|
shown as what is under the shape will be drawn in; the original is the chip
|
||||||
in its corner. */
|
in its corner. */
|
||||||
.palette-grid .cell.map,
|
.palette .cell.map,
|
||||||
.palette-grid .chip.map {
|
.palette .chip.map {
|
||||||
background: linear-gradient(135deg, #3a3f52 0 50%, #e8d9a8 50% 100%);
|
background: linear-gradient(135deg, #3a3f52 0 50%, #e8d9a8 50% 100%);
|
||||||
color: #fff; font-size: 11px; line-height: 1; text-shadow: 0 1px 1px rgba(0, 0, 0, .6);
|
color: #fff; font-size: 11px; line-height: 1; text-shadow: 0 1px 1px rgba(0, 0, 0, .6);
|
||||||
}
|
}
|
||||||
.palette-grid .cell { position: relative; }
|
.palette .cell { position: relative; }
|
||||||
.palette-grid .cell .badge {
|
.palette .cell .badge {
|
||||||
position: absolute; right: -2px; bottom: -2px;
|
position: absolute; right: -2px; bottom: -2px;
|
||||||
width: 7px; height: 7px;
|
width: 7px; height: 7px;
|
||||||
border: 1px solid var(--pane); border-radius: 50%;
|
border: 1px solid var(--pane); border-radius: 50%;
|
||||||
|
|
@ -1856,81 +1777,35 @@ button.tl-gap:hover { background: rgba(47, 111, 192, .28); }
|
||||||
.palette-row .rename { align-self: stretch; padding: 0 7px; border-color: transparent; background: none; }
|
.palette-row .rename { align-self: stretch; padding: 0 7px; border-color: transparent; background: none; }
|
||||||
.palette-row .rename:hover:not(:disabled) { border-color: var(--sel); background: #fff; }
|
.palette-row .rename:hover:not(:disabled) { border-color: var(--sel); background: #fff; }
|
||||||
|
|
||||||
/* The chooser: search, then sections most relevant first, then the classics
|
|
||||||
folded small at the foot. Each row is the playhead's frame in that palette,
|
|
||||||
its strip, its name and where it is from; `use` sits beside it. */
|
|
||||||
/* The list scrolls and nothing else does, so search sits at the top and the
|
|
||||||
shelf at the foot however many palettes there are between them. */
|
|
||||||
.menu.popout:has(.palette-chooser) { width: 300px; display: flex; flex-direction: column; overflow: hidden; }
|
|
||||||
.palette-popout:has(.palette-chooser) { display: flex; flex-direction: column; min-height: 0; flex: 1; }
|
|
||||||
.palette-chooser { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; flex: 1; }
|
|
||||||
.palette-chooser .palette-list { flex: 1 1 auto; min-height: 80px; max-height: none; }
|
|
||||||
.palette-search { width: 100%; }
|
|
||||||
.palette-head {
|
|
||||||
padding: 6px 2px 2px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
|
|
||||||
color: var(--dim);
|
|
||||||
}
|
|
||||||
.palette-head:first-child { padding-top: 0; }
|
|
||||||
.palette-row .choose { grid-template-columns: auto 1fr; }
|
|
||||||
.palette-row .choose .text { display: grid; gap: 2px; min-width: 0; }
|
|
||||||
.palette-row .choose .strip { height: 9px; }
|
|
||||||
.palette-row .thumb {
|
|
||||||
width: 48px; height: 36px; object-fit: contain; border-radius: 2px;
|
|
||||||
background: #000; box-shadow: 0 0 0 1px rgba(0, 0, 0, .3);
|
|
||||||
}
|
|
||||||
.palette-row .note {
|
|
||||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
||||||
font-size: 10px; color: var(--dim);
|
|
||||||
}
|
|
||||||
.palette-row .use {
|
|
||||||
align-self: stretch; padding: 0 7px; font-size: 10px;
|
|
||||||
border-color: transparent; background: none; opacity: 0;
|
|
||||||
}
|
|
||||||
.palette-row:hover .use, .palette-row .use:focus { opacity: 1; }
|
|
||||||
.palette-row .use:hover:not(:disabled) { border-color: var(--sel); background: #fff; }
|
|
||||||
.palette-editing { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
|
||||||
.palette-editing .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
|
|
||||||
.palette-editing .rename { padding: 0 7px; border-color: transparent; background: none; }
|
|
||||||
.palette-editing .palette-name { flex: 1; min-width: 0; }
|
|
||||||
|
|
||||||
.palette-shelf > summary {
|
|
||||||
cursor: pointer; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
|
|
||||||
color: var(--dim); padding: 2px;
|
|
||||||
}
|
|
||||||
.palette-shelf .shelf {
|
|
||||||
display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px;
|
|
||||||
padding-top: 4px; max-height: 30vh; overflow: auto;
|
|
||||||
}
|
|
||||||
.palette-shelf .tile {
|
|
||||||
display: grid; gap: 2px; min-width: 0; padding: 3px;
|
|
||||||
border: 1px solid transparent; border-radius: 3px; background: none; text-align: left;
|
|
||||||
}
|
|
||||||
.palette-shelf .tile:hover { background: var(--sunk); border-color: var(--hair); }
|
|
||||||
.palette-shelf .tile .strip { height: 8px; }
|
|
||||||
.palette-shelf .tile .name {
|
|
||||||
font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.strip { display: flex; height: 14px; border: 1px solid rgba(0, 0, 0, .35); border-radius: 2px; overflow: hidden; }
|
.strip { display: flex; height: 14px; border: 1px solid rgba(0, 0, 0, .35); border-radius: 2px; overflow: hidden; }
|
||||||
.strip i { flex: 1; }
|
.strip i { flex: 1; }
|
||||||
|
|
||||||
/* On the stage at the playhead. */
|
/* On the stage at the playhead. */
|
||||||
.on-stage { width: 7px; height: 7px; border-radius: 50%; background: var(--live); }
|
.on-stage { width: 7px; height: 7px; border-radius: 50%; background: var(--live); }
|
||||||
|
|
||||||
|
/* A palette being edited that the stage is not drawing in here. Information,
|
||||||
|
not alarm: the accent of a selection, not of a warning. */
|
||||||
.palette-assets-wrap { position: relative; }
|
.palette-assets-wrap { position: relative; }
|
||||||
|
.palette-info {
|
||||||
/* Back to the palette the stage is in, when another is open in the grid. */
|
position: absolute; top: -3px; right: -5px;
|
||||||
.palette-grid .back { padding: 1px 4px; font-size: 10px; white-space: nowrap; }
|
width: 13px; height: 13px; border-radius: 50%;
|
||||||
/* A slot nothing in the open symbol draws with. */
|
display: grid; place-items: center;
|
||||||
.palette-grid .cell.unused { opacity: .5; }
|
background: var(--sel); color: #fff;
|
||||||
.palette-grid .cell.unused::after {
|
font: italic 600 9px/1 Georgia, serif;
|
||||||
content: ""; position: absolute; inset: 0; pointer-events: none;
|
cursor: help;
|
||||||
background: linear-gradient(135deg, transparent 45%, rgba(255, 255, 255, .8) 45% 55%, transparent 55%);
|
box-shadow: 0 0 0 1.5px var(--chrome);
|
||||||
}
|
}
|
||||||
.palette-grid .grid-tools { display: flex; gap: 2px; }
|
.info-card {
|
||||||
.palette-grid .grid-tools button { padding: 0 4px; min-width: 17px; font-size: 11px; }
|
position: fixed; z-index: 60;
|
||||||
.palette-grid .grid-tools button.on { background: var(--sel-bg); border-color: var(--sel); }
|
width: 240px; padding: 8px 10px;
|
||||||
|
display: grid; gap: 3px;
|
||||||
|
background: var(--pane); color: var(--fg);
|
||||||
|
font: 11px/1.45 "Lucida Grande", "Segoe UI", system-ui, sans-serif;
|
||||||
|
border: 1px solid var(--sel); border-left-width: 3px; border-radius: 3px;
|
||||||
|
box-shadow: 0 3px 10px rgba(0, 0, 0, .25);
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
.info-card strong { color: #14395f; }
|
||||||
.view-popout label { display: block; margin-bottom: 8px; }
|
.view-popout label { display: block; margin-bottom: 8px; }
|
||||||
.view-popout label:last-child { margin-bottom: 0; }
|
.view-popout label:last-child { margin-bottom: 0; }
|
||||||
.view-popout input, .view-popout select { width: 100%; }
|
.view-popout input, .view-popout select { width: 100%; }
|
||||||
|
|
@ -1959,40 +1834,3 @@ button.tl-key.selected { background: var(--pick); box-shadow: 0 0 0 2px var(--pi
|
||||||
.choice { display: grid; gap: 6px; margin: 12px 0; }
|
.choice { display: grid; gap: 6px; margin: 12px 0; }
|
||||||
.choice button { display: grid; gap: 2px; text-align: left; padding: 8px; white-space: normal; height: auto; }
|
.choice button { display: grid; gap: 2px; text-align: left; padding: 8px; white-space: normal; height: auto; }
|
||||||
.choice button .dim { font-size: 11px; }
|
.choice button .dim { font-size: 11px; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------
|
|
||||||
the keyboard sheet, `?` */
|
|
||||||
|
|
||||||
.keys-scrim { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45); }
|
|
||||||
.keys-sheet {
|
|
||||||
position: fixed; z-index: 51; top: 50%; left: 50%; transform: translate(-50%, -50%);
|
|
||||||
width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
|
|
||||||
padding: 16px 20px; columns: 2 300px; column-gap: 32px;
|
|
||||||
background: var(--pane); border: 1px solid var(--line); border-radius: 3px;
|
|
||||||
box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
|
|
||||||
}
|
|
||||||
.keys-group { break-inside: avoid; margin-bottom: 14px; }
|
|
||||||
.keys-group h3 { margin: 0 0 6px; font: inherit; font-weight: 600; color: var(--dim); }
|
|
||||||
.keys-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 2px 0; }
|
|
||||||
.keys-row small { display: block; color: var(--dim); }
|
|
||||||
.keys-row .keys { display: flex; gap: 4px; flex-shrink: 0; }
|
|
||||||
.keys-row kbd {
|
|
||||||
min-width: 1.6em; padding: 0 5px; text-align: center; font: inherit; font-size: .92em;
|
|
||||||
background: var(--chrome); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* What the in and out marks leave out of playback: dimmed over the tracks, and
|
|
||||||
the span that plays banded along the foot of the ruler. */
|
|
||||||
.tl-outside {
|
|
||||||
position: absolute; top: 0; bottom: 0; z-index: 2; pointer-events: none;
|
|
||||||
background: rgba(0, 0, 0, .16);
|
|
||||||
}
|
|
||||||
.tl-range {
|
|
||||||
position: absolute; bottom: 0; height: 3px; pointer-events: none;
|
|
||||||
background: var(--sel);
|
|
||||||
}
|
|
||||||
.tl-mark {
|
|
||||||
position: absolute; top: 0; bottom: 0; z-index: 1; width: 9px; margin-left: -4px;
|
|
||||||
cursor: ew-resize; touch-action: none;
|
|
||||||
background: linear-gradient(var(--sel), var(--sel)) center / 2px 100% no-repeat;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue