Compare commits

...

16 commits

Author SHA1 Message Date
Olive Vaughn
4fe620f50a Shift-T traces the selection only
Tracing on for the tracing layers in the selection — the selected node,
what it places at any depth, its children, a face's own footage — and every
other layer off. Again, and every layer shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:52:15 -04:00
Olive Vaughn
ea2becf4c7 Plain letters, shift for a companion, never alt
T switches tracing and G onion skin (ghosts); shift-I and shift-O clear
the in and out marks; M and shift-M make a symbol or a lane at the top of
the tab. Alt types characters on a Mac and belongs to the browser
elsewhere, so no key uses it now, and shift only ever pairs with the plain
key it modifies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:43:41 -04:00
Olive Vaughn
af0df98a15 N makes a symbol, shift-N a lane, alt for the top of the tab; alt-T traces
N and shift-N make a symbol or a lane where the selection says, as the
timeline's buttons do; with alt, at the top of the tab whatever is
selected. A new symbol in a lane is a new drawing, so there N is shift-K:
one meaning for a new empty thing in a lane. Alt-T switches tracing, beside
alt-O for onion skin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:38:41 -04:00
Olive Vaughn
285a195fee The playhead's head is as wide as its number
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:38:41 -04:00
Olive Vaughn
e72d63214c Frames are cells: a grid through the rows, and a playhead a frame wide
As in Flash, a hairline at every frame over the rows and through the cels,
stronger at every second; too narrow to see, it steps by the fewest frames
that divide a second, and goes when even that is too dense. The playhead is
the frame it is on: a tinted cell with its line on the frame's left edge,
where the ruler's number is, and a head carrying the frame number. Too
narrow to tint, it is the line alone, as in Resolve.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:36:51 -04:00
Olive Vaughn
b45f7307a3 Pause sticks while looping, play past the out mark, drag the marks
Pause during a loop restarted at once: the player's snapshot still said
playing for a frame after the clock stopped, and with marks that read as
running off the end. It now asks the db. Playback loops only on crossing
the out mark, so playing from past it plays on, as playing from before the
in already did. The marks have handles on the ruler. = and - move the end
of the selection's span, any symbol's, or the cel a selection in a lane is
in, rippling what follows in a lane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:31:20 -04:00
Olive Vaughn
1c6c45e465 I and O mark where playback loops, and the timeline dims the rest
Resolve's in and out marks, per tab. Play starts from the in mark when the
playhead is outside them and goes round from the out mark back to the in,
as Blender's preview range does; the loop is in the player's frame loop, so
both clocks do it the same way. Alt-X clears them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:20:33 -04:00
Olive Vaughn
246b6d6468 K keys or draws on, shift-K draws blank, = and - change a hold
In a lane, K is Flash's F6: a copy of the drawing showing, taking over
from the playhead, or on the next frame when the playhead is on a
drawing's first one, so pressing it again and again draws on. Shift-K is
F7, the same with an empty drawing. Elsewhere K is Blender's I: what is
animated, or else position, turn and scale, keyed at the playhead.
= and - lengthen and shorten the selected hold by a frame, as in Harmony.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:17:30 -04:00
Olive Vaughn
e96464459d One table of keyboard shortcuts, and ? to see it
Space plays and pauses, and still pans when held and dragged on the stage.
Arrows and WASD step frames and jump between keys and cel edges; Home/End
and shift go to the first and last frame; alt-O toggles onion skin. The
tool, undo and clipboard keys move into the same table, which the ? sheet
prints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:08:26 -04:00
Olive Vaughn
fcf2e20f78 Play from the last frame starts over, rather than playing one frame
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:02:42 -04:00
Olive Vaughn
c359ac650f Open the palette lane onto its selected transition, like any lane
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 19:52:34 -04:00
Olive Vaughn
1a6d6564c5 One palette per frame, chosen by the shallowest override in the open tab
A frame is drawn in exactly one palette, or one blend of two while a palette
lane tweens. Shapes store slots and the raster index is the slot, so the
palette is only the ramp a frame is expanded through: there is no way for two
palettes' colours to share a frame. The per-palette index banks are gone.

Every symbol drawn says which palette it chooses — its lane, its instance's
palette, its own — and the shallowest wins, so a palette set on the open
symbol beats anything inside it, and a child set to one turns the whole frame
while it is drawn. Nothing chosen is the project's palette.

The palette grid follows the palette the stage is in, per tab, read from the
player rather than worked out again; mid-tween it holds the start palette.
Another can be opened per tab, with a button back to the active one.

The chooser puts the palettes the open symbol uses first, saying where, then
the project's, then palettes made in other projects (with their project, and
searchable by either name), each with the playhead's frame drawn in it;
hovering previews on the stage, `use` sets the symbol to it. The classics are
a folded shelf, now with VGA, Commodore 64, CGA and Workbench 1.3, and a new
project carries only the palette it was made with.

Unused slots are marked; solo shows and lets you click only what is drawn in
the chosen colour; ⌫ empties the open palette's unused slots in place.
The project palette can be changed in the inspector. The palette lane's
label no longer collides with the sidebar grid's styles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 19:47:44 -04:00
Olive Vaughn
641f1fa18c Hold a new cel in a lane, so stretching it shows what is drawn in it
A double-clicked or newly created cel in a lane was a one-frame symbol
playing at speed 1 and stopping at its end, so dragging its edge out left
every frame past the first empty. It is now held at speed 0, as a drawing
cel already is: the two are the same lane-creation operation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 19:45:38 -04:00
Olive Vaughn
cd02eb0477 Add symbols and uploads from the foot of the media pool
A "+ symbol" and an "upload…" button pinned to the bottom of the pool, where
a list's own "add one" goes. A new symbol goes into the library only, one
empty frame placed nowhere, as Flash's New Symbol, and its name opens for
editing. The pane head loses its "+". Converting footage reads "make roto".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 18:29:42 -04:00
Olive Vaughn
b2b6af8f26 Bring the browser tests up to date
- automation: pin the fixture to 120 frames; a blank document is 48 now,
  and the drags measure frames as fractions of a 120-frame ruler.
- lane: create from the timeline's symbol/lane buttons, skip the palette
  lane when looking for lanes and rename buttons, and expect a lane's
  rename on its symbol.
- lane, peg: wait out the page reloading under the first probes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 18:28:03 -04:00
Olive Vaughn
4b780f9e91 Inspector: one row per channel, names from symbols, tweens you can see
The inspector shows what can be changed and nothing else. Ids, spans and the
facts the fields below them already said are gone; explanations are hover
text. Performance only appears for a face.

Every animatable thing is one row: ◀ ◆ ▶, its name, its value, its gap. The
arrows jump to the key before and after on every channel. A drawing's keys
are an ordinary `shape` row, as are a palette placement's and a tracing
layer's holds. The gap switch is about the gap the playhead is in, and on a
key the one arriving at it, so keying B asks about A→B.

The timeline draws every gap on a channel row, tween or hold, and a click
switches it.

An instance has no name of its own: it is called what it places, a rename
renames the symbol, and `(n)` says how many places show it. Export numbers
two placements of one symbol. Instance names in old documents are ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 18:28:03 -04:00
46 changed files with 2388 additions and 1145 deletions

View file

@ -436,8 +436,8 @@ class DocumentTests(TestCase):
self.assertEqual(200, self.save(leaves).status_code)
rows = self.client.get("/api/symbols").json()["palettes"]
self.assertEqual(
[("Moonlit", "night", "c1")],
[(r["name"], r["palette"], r["cid"]) for r in rows],
[("Moonlit", "night", "c1", ["#001122"])],
[(r["name"], r["palette"], r["cid"], r["hexes"]) for r in rows],
)
def test_a_document_comes_back_exactly(self):

View file

@ -413,6 +413,26 @@ def footage_list(request):
_SYMBOL_LEAF = re.compile(r"^clip/([^/]+)/symbol/([^/]+)$")
_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):
@ -459,6 +479,9 @@ def symbols(request):
"cid": m.group(1),
"palette": m.group(2),
"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"]))
return JsonResponse({"symbols": rows, "palettes": palettes})

View file

@ -17,7 +17,7 @@
[arthur.ui.index :as index]
[arthur.ui.player :as player]
[arthur.ui.shell :as shell]
[arthur.ui.tools :as tools]
[arthur.ui.shortcuts :as shortcuts]
[re-frame.core :as rf]
[reagent.dom.client :as rdc]))
@ -46,8 +46,7 @@
;; 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.
(collab/start!)
(history/install-keys!)
(tools/install-keys!)
(shortcuts/install!)
(reset! root (rdc/create-root (js/document.getElementById "app")))
(mount)
(player/start!))

View file

@ -74,28 +74,28 @@
(defn node-label
"What to call node `n` on screen.
A NAME A PERSON TYPED WINS, and for an instance that is the ONLY thing `:name`
now means: `place-symbol` deliberately does not copy the symbol's name onto the
node it makes. Two instances of one symbol are told apart by what somebody
called them — `8625 left` and `8625 right` of one `face` — and reading through
in front of that would collapse them to the same word.
AN INSTANCE IS CALLED WHAT IT PLACES, read through on every render, and has
no name of its own. A name on the placement meant the same drawing could show
under two names, and that a rename in one place reached nowhere else; renaming
an instance renames its symbol (`::ui/rename-node`), so every placement of it
follows. How many places share it is `uses`.
OTHERWISE AN INSTANCE IS LABELLED BY WHAT IT PLACES, read through on every
render. A name copied at creation goes stale the moment the symbol is renamed,
and then the document shows one thing under two names: the symbol reads `bg` in
its tab while an instance of it still reads `symbol-18`, which is how a person
comes to paste a symbol into itself without being able to see that is what they
are doing. `problems` refuses that cycle; this is why it stops looking like a
reasonable thing to try.
An id is a uuid for a placement and a keyword for an authored node, and neither
reads as a name, so the last resort is a legible stand-in rather than `(str
id)` — `:face-1` keeps its colon and a uuid pushes a column open."
Anything else is called by its own `:name`. An id is a uuid for a placement
and a keyword for an authored node, and neither reads as a name, so the last
resort is a legible stand-in — `:face-1` loses its colon and a uuid is cut."
[clip id n]
(or (:name n)
(some->> (node/source n) (symbol-name clip))
(or (some->> (node/source n) (symbol-name clip))
(:name n)
(if (keyword? id) (subs (str id) 1) (subs (str id) 0 8))))
(defn uses
"How many nodes in the document place symbol `sid`."
[clip sid]
(count (for [[_ sym] (:symbols clip)
[_ n] (:nodes sym)
:when (= sid (node/source n))]
n)))
(defn frames
"A symbol's length. Read off the symbol, never copied beside it."
[clip sid]
@ -188,17 +188,18 @@
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.
`settings` overrides any of `blank-settings`. It starts with every one of
`palette/presets`, and `:palette` is the id of the one it draws with."
`settings` overrides any of `blank-settings`. `:palette` names the preset it
draws with, and that one is the project's only palette until more are added."
([] (blank {}))
([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)
:fps fps
:width width :height height
:palettes presets
:default-palette (if (contains? presets palette) palette pal/default-id)
:palettes (select-keys presets [palette])
:default-palette palette
:root :main
:symbols {:main {:id :main :frames (max 1 (js/Math.round (* seconds fps))) :nodes {}}}})))
@ -306,80 +307,115 @@
(ch/value-at selection frame store)
:else selection))
(defn palette-at
"The palette symbol `owner` draws in at `frame`, as the stage's root does: a
palette id, or `{:from :to :t}` while its palette lane blends from one to the
next. `inherited` is what an unset palette falls back to, then `default`."
[clip store default owner frame inherited]
;; A palette track has meaningful uncovered time. Ordinary held
;; channels clamp to their first key before it, but doing that
;; here would erase the gap before the first palette segment.
(let [channel-value (partial channel-value store)
fallback (or (channel-value (:palette owner) frame)
inherited default)
materialize (fn [choice]
(cond
(= pal/inherit choice) fallback
(map? choice) (-> choice
(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
(defn- own-palette
"The palette symbol `owner` itself chooses at `frame`, or nil when it chooses
none and takes what it is in: its palette lane where a segment covers the
frame, else its own `:palette` (which an instance's palette stands in for).
A lane's `inherit` end means the symbol's own palette when it has one, and
stays `inherit` — whatever the frame is in without this lane — when not.
A palette lane has meaningful uncovered time: ordinary held channels clamp to
their first key before it, which here would erase the gap before the first
segment."
[clip store owner frame]
(let [own (channel-value store (:palette owner) frame)
fill #(if (and own (= pal/inherit %)) own %)
settle (fn [choice] (if (map? choice) (-> choice (update :from fill) (update :to fill)) (fill choice)))
track (:palette-channel owner)]
(or (when-let [track-symbol (some->> (:palette-track owner) (symbol clip))]
(let [palette-clip (first
(filter (fn [n]
(let [[a b] (node/placed-span n)]
(and a (<= a frame) (< frame b))))
(symbol/children (:nodes track-symbol))))
palette-symbol (some-> palette-clip node/source
(#(symbol clip %)))
fallback (when (= :palette (:type palette-symbol))
(:palette-ref palette-symbol))
palette-symbol (some-> palette-clip node/source (#(symbol clip %)))
choice (get-in palette-clip [:channels [:palette]])
start (some-> palette-clip node/placed-span first)]
(or (when (and choice start)
(materialize (channel-value choice (- frame start))))
fallback)))
track-value
fallback)))
(settle (channel-value store choice (- frame start))))
(when (= :palette (:type palette-symbol))
(:palette-ref palette-symbol)))))
(if-let [ks (:keys track)]
(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
"Resolve an output frame, selecting native content at each symbol boundary.
Every instance owns its cursors and buffers. The IResolver queries return
native node frames and world matrices for the last rendered output frame."
[clip sid store palette opts]
(let [context? (and (map? palette) (:palettes palette) (:offsets palette))
active-palette-state (atom (:default palette))]
(letfn [(root-selection-at [owner frame inherited]
(palette-at clip store (:default palette) owner frame inherited))
(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?]
(let [context? (and (map? palette) (contains? palette :palettes))
active-palette-state (atom (:default palette))
;; What each symbol drawn this frame chooses, as `[depth choice]`.
chosen (volatile! [])]
(letfn [(build [sid chain pose-tracks root?]
(when (some #{sid} chain)
(throw (ex-info "symbol cycle" {:chain (conj chain sid)})))
(let [sym (or (symbol clip sid)
(throw (ex-info "an instance names a missing symbol" {:symbol sid})))
active (volatile! (when context? (:default palette)))
depth (count chain)
nodes (:nodes sym)
rank (symbol/draw-rank nodes (symbol/order nodes))
ids (sort-by rank (keys nodes))
own (symbol/resolver sym store (if context?
#(pal/render-index palette @active %)
palette)
own (symbol/resolver sym store (if context? pal/slot palette)
(assoc opts :pose-tracks pose-tracks))
;; Each cel owns its source resolver and mutable buffers. A
;; tracing symbol has nothing to resolve: it is one op.
@ -399,16 +435,18 @@
;; A symbol that knocks out is drawn into a layer of its own,
;; so what it clears is only ever its own.
layered? (symbol/knocks? nodes)
step (fn [f pre inherited forced]
;; Each symbol drawn says which palette it chooses, if any;
;; 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?
(vreset! active (or forced
(if root?
(root-selection-at sym (js/Math.floor f) inherited)
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))
(when-let [c (own-palette clip store
(cond-> sym override (assoc :palette override))
(js/Math.floor f))]
(vswap! chosen conj [depth c])))
(vreset! entered {})
(let [by-id (into {} (map (juxt :node identity))
(own (js/Math.floor f) (js/Math.floor pre)))]
@ -450,17 +488,15 @@
(or (:frame (when (number? prior)
(placed-frame clip n prior)))
(dec frame))
@active
(when (and context? (:palette n))
(selection-at n frame nil)))))))
(:palette n))))))
(when-let [op (get by-id id)] [op]))))
ids))
layered? (conj {:kind :end :node []}))))]
(reify
IFn
(-invoke [_ f] (step f (dec f) nil nil))
(-invoke [_ f pre] (step f pre nil nil))
(-invoke [_ f pre inherited forced] (step f pre inherited forced))
(-invoke [_ f] (step f (dec f) nil))
(-invoke [_ f pre] (step f pre nil))
(-invoke [_ f pre override] (step f pre override))
symbol/IResolver
(world-of [_ [id & more]]
(if more
@ -484,7 +520,11 @@
IFn
;; `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.
(-invoke [_ f] (r f (dec f) (when context? (:default palette)) nil))
(-invoke [_ f]
(let [ops (r f (dec f))]
(when context?
(reset! active-palette-state (frame-palette (:default palette) @chosen)))
ops))
symbol/IResolver
(world-of [_ path] (symbol/world-of r path))
(frame-of [_ path] (symbol/frame-of r path))
@ -555,7 +595,9 @@
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,
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.
`speed` is 1 unless the symbol's frames are footage's at another rate, and 0
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
cannot be placed inside itself or inside anything it places."
@ -575,7 +617,7 @@
;; Lexicographic draw order, as `domain/paint` does it: an instance made
;; later sits above one made earlier, and neither has to renumber.
:z (str "z" (js/Date.now) "-" (name sid))
:span [0 (js/Math.ceil (/ (:frames target) speed))]
:span [0 (if (pos? speed) (js/Math.ceil (/ (:frames target) speed)) 1)]
:time {:mode :map :at frame :rate 1}
:source {:symbol sid}
:playback {:in 0 :speed speed :end :stop}

View file

@ -15,7 +15,8 @@
interpolating matrix entries is meaningless: a rotation tweened through its
matrix shears on the way. Flat Float64Array for evaluation because at 30fps
per-frame allocation is the only thing that will make this stutter."
(:require [arthur.domain.channel :as ch]))
(:require [arthur.domain.channel :as ch]
[clojure.string :as str]))
(def kinds
"`:bitmap` is in the vocabulary and not implemented; it is
@ -108,6 +109,17 @@
[:audio :pan] (ch/framed 0.0)
[:audio :rate] (ch/framed 1.0)})
(def ^:private channel-names
{[:xform :pos] "pos" [:xform :rot] "rot°" [:xform :scale] "scale"
[:xform :skew] "skew" [:xform :pivot] "pivot" [:geom :pts] "shape"
[:style :color] "color" [:vis] "vis" [:palette] "palette"})
(defn channel-name
"What to call channel `path` on screen: the same short word in the inspector
and the timeline."
[path]
(or (channel-names path) (str/join " " (map name path))))
(defn defaults-of [n]
(if (= :audio (:kind n)) audio-defaults defaults))
@ -198,6 +210,19 @@
(:segments c) (update :segments dissoc f))
: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
"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 —

View file

@ -64,10 +64,30 @@
free)})
(def presets
"Palettes a new project starts with, borrowed from worlds that already work
in sixteen colours or fewer. Only the one a project draws with costs it
anything; the rest are there to switch to."
"Palettes borrowed from worlds that already work in sixteen colours or fewer:
a shelf to start a project from or add to one, kept out of the project until
then. A sixteen-colour machine's palette is all sixteen of its colours, each
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
;; 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.
(preset :arthur/pico-8 "PICO-8"
["#1d2b53" "#ffccaa" "#ab5236" "#7e2553" "#fff1e8" "#c2c3c7" "#29adff" "#000000" "#5f574f"]
@ -99,89 +119,133 @@
(when (contains? ps default-id) default-id)
(first (sort-by str (keys ps))))))
(defn- slot-index [p value]
(cond
(and (integer? value) (<= 0 value) (< value (count (:slots p)))) value
;; Compatibility for existing documents. New drawing data is numeric.
(keyword? value) (first (keep-indexed #(when (= value (:name %2)) %1) (:slots p)))
:else nil))
;; ONE PALETTE PER FRAME
;;
;; 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`.
(defn compile
"Compile the project's palette assets into the one ramp used by the raster.
Index 255 remains the conspicuous bad-data sentinel."
[clip]
(let [selection-values (fn [x]
(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
(and (integer? value) (<= 0 value) (< value 255)) value
;; Compatibility for existing documents. New drawing data is numeric.
(keyword? value) (get index-of value 255)
:else 255))
(defn choices
"The palette ids a palette setting can name: the one it holds, or each its
keys do. `inherit` is not one."
[x]
(remove #(= inherit %)
(cond
(nil? x) []
(and (map? x) (:keys x)) (vals (:keys x))
(and (map? x) (contains? x :value)) [(:value 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)}))
:else [x])))
(defn render-index
"A local slot (or a legacy tone keyword) in palette `id` -> raster index."
[{:keys [palettes offsets]} id value]
(let [id (if (map? id) (:from id) id)
p (get palettes id)
i (and p (slot-index p value))]
(if (some? i) (+ (get offsets id 0) i) 255)))
(defn compile
"The project's palettes and the one a frame falls back to, for a renderer."
[clip]
{:palettes (palettes clip)
:default (default-palette-id clip)})
(defn background-index
"The raster index of slot zero in the resolver's active palette.
`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 ramp-of
"A strip of hex colours as the ramp a raster is expanded through."
[hexes]
(mapv hex->rgb hexes))
(defn effective-ramp
"The compiled ramp with the active palette blend applied. A hold returns the
original vector; a linear palette segment rewrites only the left palette's
bank, which is the bank the indexed raster was drawn into."
[{:keys [palettes offsets ramp]} active]
"The ramp of the active palette: an id, or `{:from :to :t}` while a palette
lane blends, which is one pseudopalette mixed slot by slot. A slot only one
end has keeps its colour."
[{:keys [palettes default]} active]
(let [ramp #(ramp-of (map :hex (:slots (get palettes %))))]
(if-let [{:keys [from to t]} (when (map? active) active)]
(let [a (get palettes from)
b (get palettes to)
at (get offsets from)
n (min (count (:slots a)) (count (:slots b)))]
(if (and a b (number? at) (number? t))
(reduce (fn [out i]
(let [x (hex->rgb (get-in a [:slots i :hex]))
y (hex->rgb (get-in b [:slots i :hex]))]
(assoc out (+ at i)
(mapv #(js/Math.round (+ %1 (* t (- %2 %1)))) x y))))
ramp (range n))
ramp))
ramp))
(let [a (ramp from) b (ramp to)]
(if (number? t)
(into (mapv (fn [x y] (mapv #(js/Math.round (+ %1 (* t (- %2 %1)))) x y)) a b)
(drop (count b) a))
a))
(ramp (if (contains? palettes active) active default)))))
(defn solo-ramp
"`ramp` with every slot but `shown` faded most of the way to the background,
so what is drawn in `shown` is all that stands out."
[ramp shown]
(let [bg (get ramp bg-slot [0 0 0])
fade (fn [c] (mapv (fn [x b] (js/Math.round (+ b (* 0.2 (- x b))))) c bg))]
(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]}]
(and id (string? name) (seq name) (vector? slots) (pos? (count slots))

View file

@ -778,6 +778,51 @@
nodes (assoc nodes id (held id drawing-id at))]
(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
"Point clip `id` at a private copy of its content, leaving every other
clip of that drawing sharing the original.

View file

@ -78,18 +78,22 @@
the other instances removed, which is why seven instances of one symbol are
seven different exports rather than seven copies of one.
Instances are ordered and labelled by `clip/node-label`, never by id: a uuid
sorts at random and means nothing to read."
Instances are labelled by `clip/node-label` — the symbol they place — and
numbered in stacking order where one symbol is placed more than once, never
by id: a uuid sorts at random and means nothing to read."
[clip open]
(let [label #(clip/node-label clip %1 %2)
instances (->> (get-in clip [:symbols open :nodes])
(filter (comp #{:instance} :kind val))
(sort-by (fn [[id n]] [(label id n) (str id)])))]
(sort-by (fn [[id n]] [(label id n) (or (:z n) "") (str id)])))
numbered (mapcat (fn [same]
(if (< 1 (count same))
(map-indexed (fn [i [id n]] [id (str (label id n) " " (inc i))]) same)
(map (fn [[id n]] [id (label id n)]) same)))
(partition-by (fn [[id n]] (label id n)) instances))]
(into (mapv (fn [sid] {:symbol sid :label (name sid)})
(sort-by str (keys (:symbols clip))))
(mapv (fn [[id n]]
{:symbol open :isolate id :label (label id n)})
instances))))
(mapv (fn [[id l]] {:symbol open :isolate id :label l}) numbered))))
(defn target
"What the export is pointed at. A nil symbol is whichever one is open, so a
@ -155,7 +159,7 @@
;; through. Read here rather than in the fx so that the effect
;; takes data and nothing else.
:palette (pal/compile (:clip entry))
:ramp (:ramp (pal/compile (:clip entry)))
:ramp (let [p (pal/compile (:clip entry))] (pal/effective-ramp p (:default p)))
:zoom zoom
:audio-url (:audio entry)
:name (stem (:label entry)

View file

@ -71,28 +71,3 @@
(:paint/revision 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])))))))

View file

@ -63,11 +63,28 @@
(get-in db [:ui :gesture :auto-key?])
(assoc :dispatch [:arthur.events.ui/record-gesture f])))))
(rf/reg-event-fx
::play
(fn [{:keys [db]} _]
{:db (assoc-in db [:playback :playing?] true)
::play-from! [(fps db) (frames db) (get-in db [:playback :frame] 0)]}))
(defn bounds
"The frames playback runs between, both included: the open tab's in and out
marks, or the whole symbol where one is not set."
[db]
(let [n (frames db)
{:keys [in out]} (get-in db [:playback :range (get-in db [:ui :open])])]
[(or in 0) (min (dec n) (or out (dec n)))]))
(defn- start
"Play from the playhead, 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
::pause
@ -80,8 +97,7 @@
(fn [{:keys [db]} _]
(if (get-in db [:playback :playing?])
{:db (assoc-in db [:playback :playing?] false) ::pause! nil}
{:db (assoc-in db [:playback :playing?] true)
::play-from! [(fps db) (frames db) (get-in db [:playback :frame] 0)]})))
(start db))))
(rf/reg-event-fx
::seek
@ -95,6 +111,37 @@
(fn [{:keys [db]} [_ delta]]
{:fx [[:dispatch [::seek (+ (get-in db [:playback :frame]) delta)]]]}))
(rf/reg-event-db
::mark
;; Resolve's I and O, on the open tab. A mark the other one has passed goes,
;; rather than leaving a range that ends before it starts.
(fn [db [_ which]]
(let [f (get-in db [:playback :frame] 0)]
(update-in db [:playback :range (get-in db [:ui :open])]
(fn [{:keys [in out] :as marks}]
(case which
:in (cond-> (assoc marks :in f) (and out (< out f)) (dissoc :out))
:out (cond-> (assoc marks :out f) (and in (< f in)) (dissoc :in))))))))
(rf/reg-event-db
::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
::set-rate
(fn [{:keys [db]} [_ r]]
@ -252,3 +299,8 @@
:else (let [i (.indexOf tabs sid)]
{:db (assoc-in db [:ui :tabs] 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)))

View file

@ -162,6 +162,12 @@
:host (get-in db [:ui :open]) :frame frame :point point
: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
::import-palette
(fn [{:keys [db]} [_ {:keys [project cid palette name]}]]
@ -187,7 +193,7 @@
(let [id (random-uuid)]
(-> (edit/edit db #(assoc-in % [:palettes id]
(assoc palette :id id :name (str (:name palette) " copy"))))
(assoc-in [:ui :palette] id)
(choose-palette id)
(assoc-in [:project :status] (str "imported " (:name palette)))))))
(rf/reg-event-fx
@ -341,7 +347,8 @@
(array-seq (.-symbols listed)))
(mapv (fn [^js 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)))])))
(.catch (fn [error]
(rf/dispatch [::failed (or (ex-message error) (str error))]))))))
@ -697,6 +704,17 @@
(assoc-in % [:symbols sid :name] value)
(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
::symbol-setting
(fn [db [_ sid key value]]
@ -716,14 +734,41 @@
p {:id id :name "Untitled palette"
:slots (mapv #(select-keys % [:name :hex]) (:slots pal/default-palette))}]
(-> (edit/edit db #(assoc-in % [:palettes id] p))
(assoc-in [:ui :palette] id)))))
(choose-palette id)))))
(rf/reg-event-db
::add-palette
;; One of `palette/presets` into a project that does not have it yet.
(fn [db [_ p]]
(-> (edit/edit db #(assoc-in % [:palettes (:id p)] p))
(assoc-in [:ui :palette] (:id p)))))
(choose-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
::duplicate-palette
@ -741,7 +786,7 @@
(-> (edit/edit db #(assoc-in % [:palettes new-id]
(assoc p :id new-id
:name (str (:name p) " copy"))))
(assoc-in [:ui :palette] new-id)))))))
(choose-palette new-id)))))))
(rf/reg-event-db
::palette-name
@ -870,6 +915,16 @@
(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
::set-segment-interp
(fn [db [_ sid id path left interp]]

View file

@ -30,6 +30,7 @@
[arthur.domain.palette :as pal]
[arthur.domain.pick :as pick]
[arthur.domain.span :as span]
[arthur.domain.symbol :as symbol]
[arthur.events.edit :as edit]
[arthur.domain.paint :as paint]
[arthur.events.playback :as playback]
@ -45,14 +46,19 @@
(rf/reg-event-db
::rename-node
;; An instance has no name of its own — see `clip/node-label` — so renaming one
;; renames the symbol it places, everywhere it is placed. Blank removes the
;; name, which falls back to the id.
(fn [db [_ sid id value]]
(let [document (:clip (store/entry (:clip/current db)))
n (get-in document [:symbols sid :nodes id])
path (if-let [of (node/source n)] [:symbols of] [:symbols sid :nodes id])
value (not-empty (str/trim (str value)))]
(if-not (get-in document [:symbols sid :nodes id])
(if (or (nil? n) (nil? (get-in document path)))
db
(edit/transaction db #(if value
(assoc-in % [:symbols sid :nodes id :name] value)
(update-in % [:symbols sid :nodes id] dissoc :name)))))))
(assoc-in % (conj path :name) value)
(update-in % path dissoc :name)))))))
(defn selected
"`db` with `selection` as its primary active row.
@ -357,6 +363,73 @@
result (span/extend-hold clip sid id delta {:extent (or extent :keep)})]
(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
::retry
(fn [{:keys [db]} _]
@ -404,6 +477,39 @@
#(cond-> (update % :hidden (fnil (if on? disj conj) #{}) layer)
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
::tracing-on
;; Every tracing layer at once, from the bar above the stage.
@ -557,8 +663,6 @@
::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
::tool-key
;; A key from `ui/tools`, decided here against the state it changes, and
@ -878,7 +982,13 @@
seeded (assoc-in document [:symbols sid] new-symbol)]
(span/place-symbol seeded st host instance-id sid at
{: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)]
(update db :project merge {:status why})
(let [selection [:node host instance-id (conj (vec down) instance-id)]]
@ -895,10 +1005,27 @@
(rf/reg-event-db
::new-lane
(fn [db _]
(fn [db [_ where]]
;; A lane is an explicit persistent row across the effective target symbol.
;; The playhead validates that nested target; the row itself begins at zero.
(create-container db :inside true)))
(create-container db (or where :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
@ -1021,7 +1148,7 @@
(rf/reg-event-db
::new-symbol-at
;; ONE GESTURE AND ONE CREATION PATH FOR EVERY LANE. Empty space in a lane
;; takes a new one-frame symbol at the frame double-clicked -- the pointer
;; takes a new one-frame held 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
;; 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
@ -1042,7 +1169,8 @@
palette? (assoc :type :palette)))
result (span/place-symbol seeded st (:sid where) uuid sid (:at where)
{:extent :grow-symbol
:remainder-id (random-uuid)})
:remainder-id (random-uuid)
:speed 0})
result (if-let [placed (and palette? (:clip result))]
(assoc result :clip
(assoc-in placed [:symbols (:sid where) :nodes uuid

View file

@ -213,7 +213,7 @@
(let [ops (resolve-frame i)
active (clip/active-palette resolve-frame)]
(-> ras
(raster/clear! (pal/background-index palette active))
(raster/clear! pal/bg-slot)
(raster/draw-ops! ops))
(-> (js/Promise.resolve
(frame! exporter i

View file

@ -468,8 +468,16 @@
[:xform :pos] (ch/framed [(- (/ w 2) (* k (:x 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
{:keys [analysis verts anchor-avg contour-avg aperture-cut] :as params}
{:keys [analysis verts anchor-avg contour-avg aperture-cut fps] :as params}
{:keys [outer inner] :as inputs}]
(let [own (partial feature/owned subject)
mouth (own :mouth)
@ -484,6 +492,7 @@
:verts verts}})]
{:nodes {:mouth
{: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))
[:style :color] (ch/framed 2)}}
:mouth-in

View file

@ -11,6 +11,7 @@
(rf/reg-sub ::rate (fn [db _] (get-in db [:playback :rate])))
(rf/reg-sub ::loop? (fn [db _] (get-in db [:playback :loop?])))
(rf/reg-sub ::muted? (fn [db _] (get-in db [:playback :muted?])))
(rf/reg-sub ::range (fn [db _] (get-in db [:playback :range (get-in db [:ui :open])])))
(rf/reg-sub ::fps (fn [db _] (get-in db [:clip :fps])))
;; The open symbol can have a local stage size; otherwise it follows the project.
(rf/reg-sub ::stage-size

View file

@ -130,28 +130,21 @@
(fn [clip _] (when clip (pal/compile clip))))
(rf/reg-sub
::ramp
:<- [::palette]
(fn [compiled _] (:ramp compiled)))
::frame-palette
;; The palette the open tab's stage is in at the frame last painted: an id,
;; or `{:from :to :t}` mid-blend. Each tab keeps its own.
(fn [db _] (get-in db [:ui :frame-palette (get-in db [:ui :open])])))
(rf/reg-sub
::palettes-shown
:<- [::clip]
:<- [::open]
:<- [::store]
:<- [::open-frame]
:<- [::palette]
;; The palettes the stage is drawing in at the playhead: the open symbol's own,
;; BOTH ends while its palette lane blends from one to the next, and any an
;; 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)))))))
::palette-solo?
;; Show only what is drawn in the chosen colour, and let only it be clicked.
(fn [db _] (get-in db [:ui :palette-solo?])))
(rf/reg-sub
::palette-preview
;; A palette under the pointer in the chooser: `{:bank id :hexes […]}`, the
;; bank the stage would draw it into. Viewing only; nothing is edited.
(fn [db _] (get-in db [:ui :palette-preview])))
(rf/reg-sub
::store

View file

@ -91,4 +91,4 @@
"tracing layer"]
[:button.on {:disabled (or loading? (< n 1) (empty? name))
:on-click #(rf/dispatch [::footage/convert])}
(if loading? "working…" "make symbol")]]]]))))
(if loading? "working…" "make roto")]]]]))))

View file

@ -50,7 +50,17 @@
;; row out of a dozen says at a glance that its blocks follow one another in
;; time instead of being on screen together. Whole and half coordinates, so
;; the three dividers land on pixels at 11px.
:lane {:stroke ["M1.5 3.5h9v5h-9z" "M4.5 3.5v5" "M7.5 3.5v5"]}})
:lane {:stroke ["M1.5 3.5h9v5h-9z" "M4.5 3.5v5" "M7.5 3.5v5"]}
;; To the key before and after: the transport's step, without its bar.
:prev {:fill ["M8.5 3v6L4 6z"]}
:next {:fill ["M3.5 3v6L8 6z"]}
;; The gap between two keys as a value graph draws it: a ramp from one to
;; the other, or a step that holds and then jumps.
:tween {:fill ["M1.5 8h2v2h-2z" "M8.5 2h2v2h-2z"] :stroke ["M3 8.5 9 3.5"]}
:hold {:fill ["M1.5 8h2v2h-2z" "M8.5 2h2v2h-2z"] :stroke ["M3.5 9H9.5V4"]}
;; How an instance plays: through once into a stop, round, or one frame.
:once {:fill ["M2.4 2.6 7.6 6 2.4 9.4z" "M8.4 2.6h1.4v6.8H8.4z"]}
:still {:stroke ["M3.5 2.5h5v7h-5z"] :fill ["M5 4.5h2v3H5z"]}})
(defn view
"The glyph named `k`, sized by CSS and inked in `currentColor` — so a button's

View file

@ -111,20 +111,6 @@
(when (and (nil? t) (not held?)) " · repeats; no single frame above"))
:else nil)))
(defn- shared-with
"How many places in the document use the same drawing as `n`, or nil where it
places none. Counted rather than flagged, because \"used in 4 places\" is the
fact somebody needs before deciding to decouple one — and counted over every
node that places it, not only over cels, because a drawing reused as a plain
instance somewhere else is just as shared and `make unique` is just as much
the answer."
[clip n]
(when-let [of (and n (node/source n))]
(count (for [[_ sym] (:symbols clip)
[_ other] (:nodes sym)
:when (= of (node/source other))]
other))))
(defn view []
(let [clip @(rf/subscribe [::render/clip])
open @(rf/subscribe [::render/open])
@ -134,7 +120,7 @@
n (when (= :node kind) (get-in clip [:symbols sid :nodes id]))
crumbs (trail clip open (if (and n (seq path)) path (when n [id])))
last-i (dec (count crumbs))
shared (shared-with clip n)
shared (some->> n node/source (clip/uses clip))
says (whereabouts clip n inside)]
[:section.loc
[:nav.crumbs {:aria-label "editing location"}

View file

@ -16,29 +16,62 @@
set before you draw, so it is a section of the inspector. See `ui/params`."
(:require [arthur.domain.channel :as channel]
[arthur.domain.clip :as clip]
[arthur.domain.raster :as raster]
[arthur.footage.store :as store]
[arthur.domain.node :as node]
[arthur.domain.palette :as pal]
[arthur.domain.symbol :as symbol]
[arthur.subs.playback :as playback]
[arthur.events.project :as project]
[arthur.events.ui :as ui]
[arthur.subs.render :as render]
[arthur.subs.ui :as sub]
[arthur.ui.canvas :as canvas]
[arthur.ui.menu :as menu]
[clojure.string :as str]
[re-frame.core :as rf]
[reagent.core :as r]))
(rf/reg-sub ::chosen (fn [db _] (get-in db [:ui :palette])))
;; WHICH PALETTE THE GRID SHOWS
;;
;; 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-event-db ::select (fn [db [_ id]] (assoc-in db [:ui :palette] id)))
(rf/reg-sub ::chosen (fn [db _] (get-in db [:ui :palette (get-in db [:ui :open])])))
(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
"The palette asset the grid shows: the one chosen, or the project's default."
"The palette asset the grid shows, and the one the tab draws in."
[]
(let [clip @(rf/subscribe [::render/clip])
chosen @(rf/subscribe [::chosen])
pid (if (contains? (:palettes clip) chosen) chosen (pal/default-palette-id clip))]
[clip pid (get (pal/palettes clip) pid)]))
followed @(rf/subscribe [::followed])
pid (if (contains? (:palettes clip) chosen) chosen followed)]
[clip pid (get (pal/palettes clip) pid) followed]))
(defn- pick!
"Make `tone` the colour new shapes get, and recolour what is selected."
@ -123,14 +156,14 @@
:title (if (= i from) (str i " — as it is") (str "slot " i))
:on-click #(do (map-slot! rm from i) (reset! open nil))}]))])]))))
(defn- swatch [pid i {:keys [name hex]} tone placements rm hex-of]
(defn- swatch [pid i {:keys [name hex]} tone placements rm hex-of used?]
(let [picker-id (str "palette-picker-" pid "-" i)
to (get (:map rm) i)]
[:div.slot {:key i}
[:button {:class (str "cell" (when (= i tone) " on"))
[:button {:class (str "cell" (when (= i tone) " on") (when-not used? " unused"))
:style {:background hex}
:title (str "slot " i (when name (str " · " (clojure.core/name name)))
" · " hex
" · " hex (when-not used? " · nothing in the project draws with it")
(when to (str " · lit as " to " under the selected remap"))
" — double-click to edit"
(when rm ", drag onto another to remap it under the selected remap"))
@ -153,11 +186,18 @@
(defn grid
"The colour chip and the slots, for the tool strip."
[]
(let [[_ pid palette] (shown)
(let [[clip pid palette followed] (shown)
tone @(rf/subscribe [::sub/tone])
solo? @(rf/subscribe [::render/palette-solo?])
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)))]
[:div.palette
[:div.palette-grid
(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"))
:style (when hex {:background hex})
:title (cond (= :clear tone) "clear: what is drawn knocks out what is under it in its symbol"
@ -166,7 +206,8 @@
[:span (cond (= :clear tone) "×" (symbol/remap? tone) "⇄" :else tone)]]
[:div.cells
(let [rm (remap) hex-of #(:hex (get (:slots palette) %))]
(doall (map-indexed #(swatch pid %1 %2 tone placements rm hex-of) (:slots palette))))
(doall (map-indexed #(swatch pid %1 %2 tone placements rm hex-of (contains? used %1))
(:slots palette))))
[:div.slot
[:button {:class (str "cell clear" (when (= :clear tone) " on"))
:title "clear — draws a knockout: a hole in its symbol"
@ -175,7 +216,22 @@
[: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."
: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
"Every slot of a palette, side by side: what it looks like at a glance."
@ -201,71 +257,168 @@
(.blur (.-target e)))
nil))}])
(defn- chooser
"Every palette in the project as a row — its strip and its name — so what you
would switch to is visible before you switch. The open one carries the edit
button that renames it; the ones the stage is drawing in at the playhead carry
a dot."
[clip pid]
(r/with-let [renaming? (r/atom false)]
(let [on-stage @(rf/subscribe [::render/palettes-shown])]
[:div.palette-list {:role "listbox" :aria-label "palettes"}
(doall
(for [[id p] (sort-by (comp str :name val) (pal/palettes clip))
:let [open? (= id pid)]]
^{:key (str id)}
[:div.palette-row {:class (when open? "on")}
(if (and open? @renaming?)
[:div.choose [strip p] [rename id p #(reset! renaming? false)]]
[:button.choose {:role "option" :aria-selected open?
:title (if open? (str "editing " (:name p)) (str "edit " (:name p)))
(defn- authored?
"Not exactly one of the shelf's: a palette someone made or retoned."
[hexes]
(not-any? #(= hexes (pal/hexes-of %)) pal/presets))
(defonce ^:private thumbs (atom {:key nil :raster nil :urls {}}))
(defn- frame-raster
"The open symbol's frame at the playhead, as indices: drawn once, then shown
through each palette's colours, so a list of thumbnails costs one render and a
colour lookup per row."
[clip store compiled open frame]
(let [k [clip open frame]]
(when-not (= k (:key @thumbs))
(reset! thumbs
{:key k :urls {}
:raster (try
(let [resolve (clip/resolver clip open store compiled {})
[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 []
(when-not open?
(reset! renaming? false)
(rf/dispatch [::ui/set-tone 0])
(rf/dispatch [::select id])))}
(rf/dispatch [::preview nil])
(if (contains? (pal/palettes @(rf/subscribe [::render/clip])) (:id p))
(rf/dispatch [::select (:id p) followed])
(rf/dispatch [::project/add-palette p])))}
(when thumb-url [:img.thumb {:src thumb-url :alt ""}])
[:span.text
[strip p]
[:span.name (:name p)]
(when (contains? on-stage id)
[:span.on-stage {:title "on the stage at the playhead"}])])
(when open?
[:button.rename {:title (str "rename " (:name p)) :aria-label "rename palette"
:on-click #(swap! renaming? not)}
"✎"])]))])))
(when note [:span.note note])]]
[:button.use {:title (str "draw " (clip/symbol-name @(rf/subscribe [::render/clip]) sid)
" in " (:name p))
:on-click (fn []
(rf/dispatch [::preview nil])
(rf/dispatch [::project/use-palette sid p]))}
"use"]]))
(defn- elsewhere
"An info badge on the palette button when the palette being edited is not one
the stage draws in at the playhead — not an error: editing another palette is
how one is made ready for a palette lane. Hovering says where to change it.
The card is placed in the viewport, as `ui/menu` places its panels, because
the tool strip scrolls and clips its overflow."
[pid palette]
(r/with-let [at (r/atom nil)]
(let [on-stage @(rf/subscribe [::render/palettes-shown])
clip @(rf/subscribe [::render/clip])
sid @(rf/subscribe [::render/open])]
(when (and (seq on-stage) (not (contains? on-stage pid)))
[:span.palette-info
{:aria-label "palette not on the stage here"
:on-mouse-enter (fn [^js e]
(let [r (.getBoundingClientRect (.-currentTarget e))]
(reset! at [(+ (.-right r) 8) (- (.-top r) 6)])))
:on-mouse-leave #(reset! at nil)}
"i"
(when-let [[x y] @at]
[:span.info-card {:role "tooltip" :style {:left (str x "px") :top (str y "px")}}
[:strong (str (:name palette) " isn't on the stage here")]
(str (or (clip/symbol-name clip sid) "This symbol")
" draws in " (str/join " and " (map #(:name (get (pal/palettes clip) %)) on-stage))
" at this frame. To draw in " (:name palette)
", set the authoring palette in the symbol inspector, or blend to it with a palette lane.")])]))))
(defn- shelf
"The classics, small: a strip each and a name under it, folded away until
wanted. Hovering previews; a click brings one into the project."
[ps followed searching? sid]
[:details.palette-shelf {:open searching?}
[:summary (str "classics · " (count ps))]
[:div.shelf
(doall
(for [p ps]
^{:key (str (:id p))}
[:button.tile {:title (str (:name p) " — click to open it, double-click to use it")
:on-mouse-enter #(rf/dispatch [::preview {:hexes (pal/hexes-of p)}])
:on-mouse-leave #(rf/dispatch [::preview nil])
:on-click (fn []
(rf/dispatch [::preview nil])
(if (contains? (pal/palettes @(rf/subscribe [::render/clip])) (:id p))
(rf/dispatch [::select (:id p) followed])
(rf/dispatch [::project/add-palette p])))
:on-double-click #(rf/dispatch [::project/use-palette sid p])}
[strip p] [:span.name (:name p)]]))]])
(defn- chooser
"Every palette worth switching to, most relevant first: those the open
symbol's tree draws in, saying where; the rest of this project's; those made
in other projects, with the project's name; then the classics, folded. One
search reaches palette names and project names."
[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
"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
broken over three lines is worse than one shown when asked for."
[]
(let [[clip pid palette] (shown)]
(let [[clip pid palette followed] (shown)]
[:div.palette-assets-wrap
[menu/popover {:class "palette-assets" :title (str "palette: " (:name palette))
:label [:svg {:view-box "0 0 18 18" :width 18 :height 18}
@ -275,18 +428,8 @@
[:circle {:cx 12.5 :cy 6.5 :r 1.3}]]}
(fn [_]
[:div.palette-popout
[chooser clip pid]
[chooser clip pid followed]
[:div.row
[: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")
: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]]))
:on-click #(rf/dispatch [::project/duplicate-palette pid])} "duplicate"]]])]]))

File diff suppressed because it is too large Load diff

View file

@ -35,6 +35,7 @@
[arthur.ui.tracing :as tracing]
[arthur.ui.layout :as layout]
[re-frame.core :as rf]
[re-frame.db :as rf-db]
[reagent.ratom :as ratom]))
(defonce ^:private state
@ -118,7 +119,8 @@
(fn [_ _]
{:resolver (rf/subscribe [::render/shown])
:palette (rf/subscribe [::render/palette])
:ramp (rf/subscribe [::render/ramp])
:preview (rf/subscribe [::render/palette-preview])
:solo? (rf/subscribe [::render/palette-solo?])
:fps (rf/subscribe [::sub/fps])
:frames (rf/subscribe [::render/frames])
:width (rf/subscribe [::sub/width])
@ -127,6 +129,7 @@
:tracing (rf/subscribe [::render/tracing])
:frame (rf/subscribe [::sub/frame])
:playing? (rf/subscribe [::sub/playing?])
:range (rf/subscribe [::sub/range])
;; The pen's draft is drawn INTO the picture, filled, so what is on screen
;; while placing points is the pixels a finished shape will be.
:draft (rf/subscribe [::ui-sub/draft])
@ -160,8 +163,8 @@
;; in the editor's own state, so it changes what the canvases should
;; show without touching the frame number OR the resolver.
(when-not (and (identical? (:resolver before) (:resolver now))
(= (select-keys before [:tracing :pen :mat :onion :selection :playing?])
(select-keys now [:tracing :pen :mat :onion :selection :playing?])))
(= (select-keys before [:tracing :pen :mat :onion :selection :playing? :preview :solo?])
(select-keys now [:tracing :pen :mat :onion :selection :playing? :preview :solo?])))
(repaint!))))))
;; The brush or eraser stroke being painted: its mask, mutated in place as the
@ -309,11 +312,6 @@
(defn in-rect [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
"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
@ -346,17 +344,17 @@
(defn- inked
"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."
[op tone palette active]
[op tone]
(if (symbol/remap? tone)
(assoc op :lut (symbol/lut #(index-of-slot palette active %) tone) :color 0)
(assoc op :color (index-of-slot palette active tone))))
(assoc op :lut (symbol/lut pal/slot tone) :color 0)
(assoc op :color (pal/slot tone))))
(defn- with-previews
"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
pointer, a brush stroke as the polygons it will be, and an eraser's cut as
the shapes it will leave."
[ops palette active]
[ops]
(let [{:keys [draft hover tone fit target]} (:pen @snapshot)
target (or target [])
pts (cond-> (vec draft) (and (seq draft) hover) (into hover))
@ -364,13 +362,13 @@
rings (when (:mask s) (traced s fit))]
(cond-> ops
(and (<= 6 (count pts)) (or (number? tone) (symbol/remap? tone)))
(clip/atop target (inked (poly pts {}) tone palette active))
(clip/atop target (inked (poly pts {}) tone))
paths
(cut-ops paths rings)
(and rings (not paths) (nil? knock))
(as-> ops (reduce #(clip/atop %1 target (inked (poly (outline/join %2) {}) slot palette active))
(as-> ops (reduce #(clip/atop %1 target (inked (poly (outline/join %2) {}) slot))
ops rings))
(and rings (not paths) knock)
@ -383,7 +381,9 @@
rasterised before the next frame is asked for."
[f]
(let [{:keys [canvas]} @state
{:keys [resolver palette ramp width height tracing playing? mat]} @snapshot]
{:keys [resolver palette width height tracing playing? mat preview solo?] :as snap} @snapshot
tone (get-in snap [:pen :tone])
solo (when (and solo? (number? tone)) tone)]
(when (and canvas resolver width height)
;; 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
@ -400,12 +400,21 @@
traces (when (:on? tracing)
(into [] (remove #(contains? (:hidden tracing) (:layer %))) traces))
active (clip/active-palette resolver)
bg (pal/background-index palette active)]
(swap! state assoc :ops (into (vec picture) traces))
bg pal/bg-slot]
;; The palette grid shows the frame's palette from here, the one place
;; 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
;; stage costs what the stage does, and a drawing a dozen stages wide
;; costs no more than the pane it is seen through.
(let [ops (with-previews picture palette active)
(let [ops (with-previews picture)
[ax ay bx by :as all] (reach ops width height)
[vx vy wx wy] rect
x0 (max ax vx) y0 (max ay vy) x1 (min bx wx) y1 (min by wy)]
@ -415,7 +424,14 @@
(let [off? (or (neg? x0) (neg? y0) (< width x1) (< height y1))
ras (raster-for (- x1 x0) (- y1 y0) [x0 y0] off?)]
(-> ras (raster/clear! bg) (raster/draw-ops! ops))
(canvas/blit! canvas ras (pal/effective-ramp palette active) [width height]))
(canvas/blit! canvas ras
;; 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)))
(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")
@ -435,13 +451,23 @@
(atom nil))
(defn- tick! []
(let [{:keys [fps frames frame playing?]} @snapshot
(let [{:keys [fps frames frame playing? range]} @snapshot
live? (clock/playing?)
ready? (some? (:canvas @state))
;; DERIVED, never counted. A slow frame drops the frames it missed and
;; the next one lands where the audio already is, so the failure mode is
;; a visible stutter rather than an invisible slide out of sync.
f (if live? (clock/frame fps frames) frame)]
f (if live? (clock/frame fps frames) frame)
;; PAST THE OUT MARK, BACK TO THE IN, as Blender's preview range loops.
;; Here rather than in either clock, so both backends loop the same
;; way, and before the paint, so the frame after the out is never shown.
;; 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
;; 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.
@ -467,8 +493,14 @@
(when live? (rf/dispatch [::pb/tick f])))
;; The audio ending is the authority on playback having stopped; nothing
;; counts frames to notice it.
(when (and (not live?) playing?)
(rf/dispatch [::pb/pause]))))
;; With marks, running off the end goes round again from the in.
;;
;; 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 []
;; Scheduled BEFORE the tick, so nothing the tick does can end the loop.

View file

@ -38,6 +38,10 @@
`events.footage/relabel`. A symbol of ANOTHER project is renameable where it
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
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
@ -94,29 +98,29 @@
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
is the one it starts on."
[document sid store palette ramp]
[document sid store palette]
(try
(when (clip/symbol document sid)
(let [resolve (clip/resolver document sid store palette {})
[w h] (clip/stage document sid)]
(let [ops (resolve 0)]
(-> (raster/make w h)
(raster/clear! (pal/background-index palette (clip/active-palette resolve)))
(raster/clear! pal/bg-slot)
(raster/draw-ops! ops)
(canvas/->png ramp)))))
(canvas/->png (pal/effective-ramp palette (clip/active-palette resolve)))))))
(catch :default _ nil)))
(defn- symbol-thumb
"`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
click."
[document sid store palette ramp]
[document sid store palette]
(when-not (identical? document (:clip @thumbs))
(reset! thumbs {:clip document :urls {}}))
(let [urls (:urls @thumbs)]
(if (contains? urls sid)
(get urls sid)
(let [url (draw-symbol document sid store palette ramp)]
(let [url (draw-symbol document sid store palette)]
(swap! thumbs assoc-in [:urls sid] url)
url))))
@ -252,7 +256,7 @@
;; ---------------------------------------------------------------------------
;; the rows of each kind
(defn- symbol-row [document sid {:keys [clip-id store palette ramp selection open main rename]}]
(defn- symbol-row [document sid {:keys [clip-id store palette selection open main rename]}]
(let [sym (clip/symbol document sid)
label (clip/symbol-name document sid)
nodes (count (:nodes sym))]
@ -267,7 +271,7 @@
" — double-click to open, drag to place"))
:thumb (if (= :trace (:type sym))
[tracing-thumb (:media sym)]
[picture (symbol-thumb document sid store palette ramp)])
[picture (symbol-thumb document sid store palette)])
:sub2 (str (:frames sym) "f · " nodes (if (= 1 nodes) " node" " nodes"))
:on? (= selection [:symbol sid])
:open? (= sid open)
@ -437,7 +441,7 @@
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."
[{:keys [document query searching? media sounds images chosen rename main palette-choice selection] :as ctx}]
[{:keys [document query searching? media sounds images chosen rename main selection] :as ctx}]
(let [named? #(hit? query (clip/symbol-name document %))
top (when (and main (named? main)) main)
symbol-ids (sort-by str (keys (:symbols document)))
@ -562,9 +566,7 @@
clip-id @(rf/subscribe [::render/clip-id])
store @(rf/subscribe [::render/store])
palette @(rf/subscribe [::render/palette])
ramp @(rf/subscribe [::render/ramp])
selection @(rf/subscribe [::sub/selection])
palette-choice @(rf/subscribe [:arthur.ui.palette/chosen])
open @(rf/subscribe [::render/open])
media @(rf/subscribe [::sub/project-footage])
{:keys [symbols palettes]} @(rf/subscribe [::project/assets])
@ -584,12 +586,11 @@
needle (str/lower-case (str/trim @query))
searching? (boolean (seq needle))
ctx {:document document :clip-id clip-id :store store :palette palette
:ramp ramp :selection selection :open open
:selection selection :open open
:media media :sounds own-sounds :images own-images :chosen chosen
:available (vec available) :all-sounds (vec sounds)
:all-images (vec images)
:symbols symbols :palettes palettes :project-id project-id
:palette-choice palette-choice
:query needle :searching? searching?
;; `clip/opens-on` and not `:main`: the longest symbol nothing
;; else places is the timeline the work happens in, and it is the
@ -610,13 +611,7 @@
(reset! depth 0)
(when-let [file (aget (.. e -dataTransfer -files) 0)]
(rf/dispatch [::footage/upload file])))}
[: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"))}
"+"]]
[:div.pane-head "media pool"]
[:input {:id "pool-file" :type "file" :accept "video/*,audio/*,image/*"
:style {:display "none"}
:on-change (fn [^js event]
@ -646,4 +641,22 @@
[:span.count (get tallies k)])]))]
[:div.pane-body
(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…"]]])))

View file

@ -92,9 +92,9 @@
apply! (fn [mode] (close!) (rf/dispatch [::project/set-fps to mode]))
changed? (and to (not= to fps))]
[:<>
[:label.inspector-field "frame rate"
[:button {:disabled disabled? :on-click #(do (reset! draft fps) (reset! open? true))}
(str fps " fps")]]
[:button {:disabled disabled? :title "frame rate · change it"
:on-click #(do (reset! draft fps) (reset! open? true))}
(str fps " fps")]
(when @open?
[dialog "Frame rate" close!
[chips (str "from " fps " fps to") rates to #(str % " fps") #(reset! draft %)

View file

@ -16,6 +16,7 @@
[arthur.ui.location :as location]
[arthur.ui.params :as params]
[arthur.ui.pool :as pool]
[arthur.ui.shortcuts :as shortcuts]
[arthur.ui.stage :as stage]
[arthur.ui.tabs :as tabs]
[arthur.ui.timeline :as timeline]
@ -70,6 +71,7 @@
gone? #(contains? shut %)]
[:div.app {:style (layout/vars state)}
[topbar/view]
[shortcuts/sheet]
(when-not (gone? :pool) [pool/view])
(when-not (gone? :pool) [layout/grip :pool pool :col 1])
[:section.view

View file

@ -0,0 +1,209 @@
(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)} "?"])

View file

@ -28,6 +28,7 @@
[arthur.ui.layout :as layout]
[arthur.ui.player :as player]
[arthur.ui.tracing :as tracing]
[arthur.ui.shortcuts :as shortcuts]
[arthur.ui.tools :as tools]
[arthur.ui.timeline :as timeline]
[re-frame.core :as rf]
@ -758,24 +759,10 @@
(when pen? [draft-lines draft hover])
(when paints? [cursor tool])]))
(defonce space-held? (atom false))
(defonce pan (atom nil))
(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
(defonce navigation-blur
(when (exists? js/window)
(.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)))))
(.addEventListener js/window "blur" #(reset! pan nil))))
(defonce pinch-start-zoom (atom nil))
@ -817,8 +804,10 @@
(fn [e] (.preventDefault e) (reset! pinch-start-zoom nil))))
nil)
:on-pointer-down-capture
(fn [e] (when (or (= 1 (.-button e)) (and (= 0 (.-button e)) @space-held?))
(fn [e] (when (or (= 1 (.-button e)) (and (= 0 (.-button e)) @shortcuts/space))
(.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)]
(reset! pan [(.-clientX e) (.-clientY e) (.-scrollLeft el) (.-scrollTop el)])
(.setPointerCapture el (.-pointerId e)))))

View file

@ -21,6 +21,7 @@
first pass is drawn. An expanded loop therefore shows keys where they first
happen and not where they happen again."
(:require [clojure.string :as str]
[arthur.domain.channel :as channel]
[arthur.domain.node :as node]
[arthur.domain.keyframes :as keyframes]
[arthur.domain.clipboard :as clipboard]
@ -29,6 +30,7 @@
[arthur.domain.span :as span]
[arthur.domain.symbol :as symbol]
[arthur.events.playback :as pb]
[arthur.events.project :as project]
[arthur.events.ui :as ui]
[arthur.footage.store :as store]
[arthur.ui.icon :as icon]
@ -89,6 +91,19 @@
{:sid sid :id (:id n) :channel channel :frame f
:at (->open f) :scale (- (->open 1) (->open 0))})))
(defn- gaps
"The stretches between one key of a channel and the next, each holding or
tweening, as Flash draws a classic tween between two keyframes. Nil for a
channel whose values are choices — a colour, a switch — which only ever hold."
[n sid path ch ->open]
(let [fs (keyed-frames ch)]
(when-not (node/hold-only? path (val (first (:keys ch))))
(mapv (fn [[a b]]
{:sid sid :id (:id n) :channel path :left a
:from (->open a) :to (->open b)
:tween? (= :linear (channel/segment-interp ch a))})
(partition 2 1 fs)))))
(defn- channel-rows [n sid path depth ->open span]
(let [keyed (filter (comp seq :keys val)
(sort-by (comp str key) (node/channels n)))]
@ -96,12 +111,13 @@
(for [[cpath ch] keyed]
{:path (conj path cpath)
:depth depth
:label (str/join " " (map name cpath))
:label (node/channel-name cpath)
:kind :channel
:select nil
:span span
:keys (mapv ->open (keyed-frames ch))
:key-items (filterv #(= cpath (:channel %)) (key-items n sid ->open))
:gaps (gaps n sid cpath ch ->open)
:dense? (boolean (:dense ch))})
[{:path (conj path ::automation-hint)
:depth depth
@ -171,6 +187,7 @@
:kind :node
:node-kind (:kind child)
:of (node/source child)
:uses (some->> (node/source child) (clip/uses clip))
:portal? true
:select [:node sid (:id child) cpath]
:expandable? true
@ -283,6 +300,7 @@
:node-kind (:kind n)
:lane? lane?
:of (node/source n)
:uses (some->> (node/source n) (clip/uses clip))
:select [:node sid id rpath]
:expandable? true
:expanded? open?
@ -347,26 +365,39 @@
(walk sid [] 0 identity)
[])))))
(defn palette-track-row
"`sid`'s palette row: ONE LANE ROW WHETHER OR NOT THE LANE EXISTS YET, because
(defn palette-track-rows
"`sid`'s palette rows. Its 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
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."
is the lane symbol's own row under this pane's name for it, and opens as any
lane does: onto the selected transition, its keys and channels."
[clip sid frames expanded chosen]
(let [track-id (get-in clip [:symbols sid :palette-track])
track (get-in clip [:symbols track-id])]
(if (= :palette-track (:type track))
;; A MATERIALIZED TRACK IS AN ORDINARY LANE ROW, selection and all: it is
;; the row `rows` already draws for a lane symbol, wearing this pane's
;; name for it. Only the row of a track that does not exist yet has to say
;; whose palette it would be, which is what creating in it needs.
(-> (first (rows clip track-id expanded chosen))
(assoc :path [::palette-track] :owner track-id
:label "palette" :kind :palette
:expandable? false :expanded? false))
{:path [::palette-track] :depth 0 :label "palette" :kind :palette
;; A MATERIALIZED TRACK IS AN ORDINARY LANE ROW, selection, portal and
;; all: it is what `rows` already draws for a lane symbol, wearing this
;; pane's name for it. Only the row of a track that does not exist yet has
;; to say whose palette it would be, which is what creating in it needs.
;;
;; `rows` calls a lane's own row `[::lane]`, which is also the open
;; symbol's when that is a lane, so this row goes by `[::palette-track]`
;; and is translated on the way in. The portal's rows keep their authored
;; paths -- the clip ids are the track's own -- and carry the track as
;; 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]
:span [0 frames] :keys [] :cels []})))
:span [0 frames] :keys [] :cels []}])))
(defn sound-rows
"Audio rows use the same flattened intervals as the mixer, including source
@ -511,15 +542,15 @@
;; 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.
[:div.group
[:button.ico {:aria-label "go to start" :title "go to the first frame"
[:button.ico {:aria-label "go to start" :title "go to the first frame (Home)"
:on-click (act [::pb/seek 0])} [icon/view :start]]
[:button {:aria-label "−1" :title "step back one frame"
[:button {:aria-label "−1" :title "step back one frame (← or A)"
:on-click (act [::pb/step -1])} "−1"]
[:button.ico.ico-play {:aria-label (if playing? "pause" "play")
:title (if playing? "pause" "play")
:title (if playing? "pause (Space)" "play (Space)")
:on-click (act [::pb/toggle])}
[icon/view (if playing? :pause :play)]]
[:button {:aria-label "+1" :title "step forward one frame"
[:button {:aria-label "+1" :title "step forward one frame (→ or D)"
:on-click (act [::pb/step 1])} "+1"]]
[:div.group
[:button.ico {:class (when loop? "on") :aria-label "loop"
@ -623,9 +654,12 @@
on every render after, which would fight a person scrolling away."
(memoize (fn [_selection] (fn [el] (some-> el (.scrollIntoView #js {:block "nearest"}))))))
(defn- label-cell [{:keys [path depth label kind node-kind lane? span select expandable? expanded? of via]}
(defn- label-cell [{:keys [path depth label kind node-kind lane? span select expandable? expanded? of via uses]}
selection selections target-path over solo tracing renaming draft choose-row!]
(let [node? (= :node kind)
;; 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)
editing? (and lane? (= select @renaming))
begin-rename! (fn [] (reset! draft label) (reset! renaming select))
@ -639,6 +673,7 @@
(when (and select (= select selection)) " primary")
(when (= path target-path) " target")
(when lane? " lane")
(when (= :palette kind) " palette")
(when (= :ghost kind) " ghost")
(when (= path over-path)
(case where
@ -726,10 +761,15 @@
"Escape" (do (.preventDefault e) (reset! renaming nil))
nil))}]
[:span.name label])
;; How many places show this same drawing: rename it here and every one
;; of them changes, and `make unique` is how to stop that.
(when (and uses (< 1 uses) (not editing?))
[:span.uses {:title (str "placed " uses " times · a rename reaches every one")}
(str "(" uses ")")])
(cond
lane? [:span.kind "·lane"]
named-lane? [:span.kind "·lane"]
node? [:span.kind (if via (str "· in " via) (str "·" (name node-kind)))])
(when lane?
(when named-lane?
[:button.tl-rename
{:title "rename lane"
:on-click (fn [^js e] (.stopPropagation e) (begin-rename!))}
@ -875,7 +915,7 @@
`:from` is the frame the press was on and `:df` how many frames the pointer has
moved since. What it looks like mid-drag is `[:ui :sliding]`, which the clip
every row and the stage are drawn from already has in it."
[{:keys [path span keys key-items dense? kind node-kind select slides cels lane? of unmapped? owner]}
[{:keys [path span keys key-items gaps dense? kind node-kind select slides cels lane? of unmapped? owner]}
frames sliding hint {:keys [clip store open selection selections target-path key-selection key-preview key-anchor key-state key-elements choose-row!]}]
(let [selected-set (set selections)
active-row (:row @sliding)
@ -1224,6 +1264,21 @@
(when select
[:span.tl-edge.out {:title "Drag endpoint · Shift-drag ripples later clips"
:on-pointer-down #(begin! % (nth select 3) :out select nil nil)}])]))
;; Click a gap between two keys to switch it between holding and tweening.
(doall
(for [{:keys [sid id channel left from to tween?]} gaps
:when (and (< from frames) (< 0 to))]
^{:key left}
[:button.tl-gap
{:type "button" :class (when tween? "tween")
:title (if tween? "tween · click to hold" "hold · click to tween")
:style {:left (at% from frames)
:width (str (* 100 (/ (- to from) (max 1 frames))) "%")}
:on-pointer-down #(.stopPropagation %)
:on-click (fn [^js e]
(.stopPropagation e)
(rf/dispatch [::project/set-segment-interp sid id channel left
(if tween? :hold :linear)]))}]))
;; A dense channel has a value on every frame, so ticking each one is a solid
;; block that says less than the bar behind it already does.
;; The lane's own keys, and those of the clips on it drawn after the
@ -1261,7 +1316,37 @@
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."
[tag frames]
[tag {:style {:left (at% @(rf/subscribe [::render/open-frame]) frames)}}])
(let [f @(rf/subscribe [::render/open-frame])
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]
(when-let [{:keys [x y x2 y2]} @marquee]
@ -1271,8 +1356,22 @@
: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)"}}])))
(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 []
(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
;; highlight.
over (r/atom nil)
@ -1353,7 +1452,7 @@
{:id ::drop :label (str "+ " (:label drop)) :ghost? true
:span drop-span})
chosen (when (= :node (first selection)) (nth selection 3))
picture (cond-> (cond->> (into [(palette-track-row clip open frames expanded chosen)]
picture (cond-> (cond->> (into (palette-track-rows clip open frames expanded chosen)
(rows clip open expanded chosen))
lane-ghost
(mapv (fn [row]
@ -1380,6 +1479,8 @@
;; FPS-blind 20/40/60 ruler.
fps (max 1 (or (:fps clip) 1))
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]
(let [xs (vec (keep :select visible))
anchor (or @row-anchor selection target)
@ -1514,7 +1615,10 @@
;; The rows and ruler share this exact major interval. Keeping a
;; second, hard-coded five-frame grid here made its lines disagree
;; with the numbered marks whenever the project's FPS changed.
:style {"--tick" (str (* 100 (/ step frames)) "%")}}
:ref #(when % (.observe sizer %))
:class (when (< frame-px 4) "narrow")
:style {"--tick" (str (* 100 (/ step frames)) "%")
"--fine" (if fine (str (* 100 (/ fine frames)) "%") "none")}}
[:div.tl-ruler
{:on-pointer-down (fn [^js e]
(rf/dispatch [::pb/seek (frame-at e frames)])
@ -1539,6 +1643,7 @@
(doall
(for [f (range 0 frames step)]
^{:key f} [:div.tick {:style {:left (edge% f frames)}} f]))
[outside-marks frames true]
[playhead :div.tl-knob frames]]
(if (seq visible)
(doall (for [row visible]
@ -1551,9 +1656,14 @@
:key-anchor key-anchor :key-state key-state :key-elements key-elements :choose-row! choose-row!}])
{:key (str (:path row))})))
[:div.tl-empty "nothing in this symbol"])
;; 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]
[key-marquee marquee]]]
[cursor-hint hint]])))
[cursor-hint hint]])
(finally (.disconnect sizer))))
(defn view []
[timeline-view])

View file

@ -109,24 +109,3 @@
(when (and (= :brush kind) (< 1 (count ids))) [:span.dim (str (count ids) " pieces")])
[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))]))))))

View file

@ -16,6 +16,7 @@
[arthur.ui.openmenu :as openmenu]
[arthur.ui.settings :as settings]
[arthur.ui.share :as share]
[arthur.ui.shortcuts :as shortcuts]
[arthur.ui.snapshots :as snapshots]
[arthur.ui.undo :as undo]
[re-frame.core :as rf]
@ -115,4 +116,5 @@
title (when project-seq (str " r" project-seq))])
[:span.status (or export-status status footage-status)]
[exporter export-open?]
[share/view]])))
[share/view]
[shortcuts/button]])))

View file

@ -281,9 +281,10 @@
(testing "an unnamed symbol falls back to its id, not to the node's uuid"
(is (= "inner" (clip/node-label (update-in c [:symbols :inner] dissoc :name)
id n))))
(testing "but a name somebody typed on the instance still wins"
;; Two instances of one symbol are told apart only by this.
(is (= "left eye" (clip/node-label c id (assoc n :name "left eye")))))
(testing "and a name left on the instance is not read: it has none of its own"
(is (= "mouth" (clip/node-label c id (assoc n :name "left eye")))))
(testing "every placement of a symbol is counted"
(is (= 1 (clip/uses c :inner))))
(testing "and a node that places nothing is labelled by its own name or id"
(is (= "lid" (clip/node-label c :lid {:id :lid :kind :rect :name "lid"})))
(is (= "lid" (clip/node-label c :lid {:id :lid :kind :rect}))))))
@ -422,79 +423,95 @@
(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"))))))
(deftest palette-context-is-inherited-keyed-and-overridable
(let [palette (fn [id name a b]
{:id id :name name :slots [{:hex a} {:hex b}]})
(def ^:private one-palette-doc
(let [palette (fn [id color] {:id id :name (name id) :slots [{:hex "#000000"} {:hex color}]})
mark {:id :mark :kind :rect :z "a1"
:channels {[:geom :size] (ch/framed 2)
[:style :color] (ch/framed 1)}}
instance (fn [id child z]
{:id id :kind :instance :z z :source {:symbol child}})
document {:fps 30 :width 20 :height 20
:palettes {:day (palette :day "Day" "#000000" "#112233")
:flash (palette :flash "Flash" "#ffffff" "#aabbcc")}
[:style :color] (ch/framed 1)}}]
{:fps 30 :width 20 :height 20
:palettes {:day (palette :day "#112233") :night (palette :night "#aabbcc")
:ink (palette :ink "#101010") :dusk (palette :dusk "#664422")}
:default-palette :day
:symbols
{:main {:id :main :frames 4
:palette (ch/keyed {0 :day 2 :flash} :hold)
:nodes {:inherited (instance :inherited :drawing "a1")
:fixed (assoc (instance :fixed :fixed "a2")
:palette (ch/framed :day))}}
:drawing {:id :drawing :frames 4 :nodes {:mark mark}}
:fixed {:id :fixed :frames 4 :palette (ch/framed :flash)
: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}
{:main {:id :main :frames 6
:nodes {:plain {:id :plain :kind :instance :z "a1" :source {:symbol :plain}}
:face {:id :face :kind :instance :z "a2" :source {:symbol :face}
:span [0 3] :time {:at 0}}}}
:plain {:id :plain :frames 6 :nodes {:mark mark}}
:face {:id :face :frames 6 :palette :night :nodes {:mark mark}}
:lane {:id :lane :type :palette-track :display :lane :frames 6
:nodes {:n {:id :n :kind :instance :z "a1" :source {:symbol :ink-palette}
:span [0 1] :time {:at 1}}}}
:night-palette {:id :night-palette :name "Night"
:type :palette :palette-ref :night
:frames 1 :nodes {}}
:drawing {:id :drawing :frames 4 :palette :night
:nodes {:mark mark}}}}
context (pal/compile document)
main (clip/resolver document :main nil context nil)
drawing (clip/resolver document :drawing nil context nil)
color #(-> (%1 %2) first :color)]
(is (= (pal/render-index context :day 1) (color main 0))
"a nested symbol's authoring palette does not override the viewed root")
(is (= (pal/render-index context :night 1) (color main 1))
"a covered palette-track interval overrides the root fallback")
(is (= (pal/render-index context :day 1) (color main 2))
"a nil track interval is a real gap and restores the authoring palette")
(is (= (pal/render-index context :night 1) (color drawing 0))
"the same nested symbol uses its authoring palette when viewed directly")
;; The renderer clears with this exact resolver state before rasterising the
;; returned ops, so a palette cut changes the stage background as well as
;; authored shapes.
(main 1)
(is (= :night (clip/active-palette main)))
(is (= (pal/render-index context :night 0)
(pal/background-index context (clip/active-palette main))))))
:ink-palette {:id :ink-palette :type :palette :palette-ref :ink :frames 1 :nodes {}}}}))
(defn- frame-of
"What frame `f` of symbol `sid` draws, and the one palette it is in."
[document sid f]
(let [context (pal/compile document)
r (clip/resolver document sid nil context nil)
ops (vec (r f))]
{:colors (mapv :color (remove #(#{:begin :end} (:kind %)) ops))
:active (clip/active-palette r)
:ramp (pal/effective-ramp context (clip/active-palette r))}))
(deftest a-frame-is-in-one-palette-and-the-shallowest-choice-wins
(let [doc one-palette-doc]
(is (= {:colors [1 1] :active :night}
(select-keys (frame-of doc :main 0) [:colors :active]))
"a face set to night turns ALL of main night while it is drawn; shapes keep their slot")
(is (= :day (:active (frame-of doc :main 4)))
"once the face is gone main is back in the project's palette")
(is (= :day (:active (frame-of (assoc-in doc [:symbols :main :palette] :day) :main 0)))
"a palette set on the open symbol beats anything inside it")
(is (= :ink (:active (frame-of (assoc-in doc [:symbols :main :palette-track] :lane) :main 1)))
"and so does the open symbol's palette lane")
(is (= :dusk (:active (frame-of (assoc-in doc [:symbols :main :nodes :face :palette] :dusk) :main 0)))
"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
(let [palette (fn [id color]
@ -530,8 +547,7 @@
(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")
(is (= [128 128 128]
(nth (pal/effective-ramp context (clip/active-palette resolve))
(pal/render-index context :day 1))))
(nth (pal/effective-ramp context (clip/active-palette resolve)) 1)))
(is (nil? (:refused slid)) (:refused slid))
(is (= [1 6] (node/placed-span
(get-in slid [:clip :symbols :palettes :nodes :change]))))
@ -568,8 +584,7 @@
(resolve 2)
(is (= {:from day :to night :t 0.5} (clip/active-palette resolve)))
(is (= [128 128 128]
(nth (pal/effective-ramp context (clip/active-palette resolve))
(pal/render-index context day 1))))))
(nth (pal/effective-ramp context (clip/active-palette resolve)) 1)))))
(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])
document
@ -633,7 +648,7 @@
ops (vec ((clip/resolver document :main nil context nil) 0))
ras (raster/draw-ops! (raster/clear! (raster/make 320 200) 0) ops)
at (fn [x y] (aget (:buf ras) (+ x (* y 320))))
slot #(pal/render-index context (pal/default-palette-id document) %)]
slot identity]
(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 2) (at 30 10)) "and the wall outside it is as it was")

View file

@ -73,7 +73,7 @@
(let [ls (leaf/leaves :c1 @take/clip)
n (get ls "clip/c1/symbol/face-1/node/mouth")]
(is (= {:id :mouth :name "mouth" :kind :poly :parent :head
:z "a1" :pose-group :mouth} n))
:z "a1" :time {:offset 4} :pose-group :mouth} n))
(is (nil? (:channels n)))
(is (:animated? (get ls "clip/c1/symbol/face-1/channel/mouth/geom.pts")))))

View file

@ -331,3 +331,17 @@
"editing repairs an older tweened colour channel")
(is (= :hold (get-in (node/toggle-key n [:style :color] 3 nil)
[: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")))

View file

@ -50,7 +50,8 @@
(is (= [15 60 640 360 :arthur/pico-8]
[(:fps doc) (clip/frames doc :main) (:width doc) (:height doc) (:default-palette doc)]))
(is (every? pal/valid-palette? (vals (:palettes doc))))
(is (= (count pal/presets) (count (:palettes doc))))))
(is (= [:arthur/pico-8] (keys (: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"
;; 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

View file

@ -879,3 +879,58 @@
(is (= 10 (get-in result [:clip :symbols :main :nodes :insert :time :at])))
(is (= (get-in doc [: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")))

View file

@ -61,26 +61,26 @@
#uuid "22222222-2222-4222-8222-222222222222"
{:id #uuid "22222222-2222-4222-8222-222222222222"
:kind :instance :parent :root :z "a2"
:name "8625 right"
:source {:symbol :sym/face}}
#uuid "11111111-1111-4111-8111-111111111111"
{:id #uuid "11111111-1111-4111-8111-111111111111"
:kind :instance :parent :root :z "a1"
:name "8625 left"
:source {:symbol :sym/face}}
:a-rect {:id :a-rect :kind :rect :parent :root :z "a3"}}}
:sym/face {:frames 40 :nodes {:root {:id :root :kind :group :z "a1"}}}}})
(deftest the-picker-offers-every-symbol-then-every-instance-in-the-open-one
(let [ts (export/targets clip :main)]
(is (= ["main" "face" "8625 left" "8625 right"] (mapv :label ts))
(is (= ["main" "face" "face 1" "face 2"] (mapv :label ts))
"every symbol, then the instances in the open one")
(testing "the instances isolate a node in the open symbol and the symbols do not"
(is (= [nil nil] (mapv :isolate (take 2 ts))))
(is (every? uuid? (mapv :isolate (drop 2 ts))))
(is (every? #(= :main (:symbol %)) (drop 2 ts))))
(testing "ordered by label, because a uuid sorts at random"
(is (= ["8625 left" "8625 right"] (mapv :label (drop 2 ts)))))
(testing "one symbol placed twice is numbered in stacking order, because a uuid sorts at random"
(is (= [#uuid "11111111-1111-4111-8111-111111111111"
#uuid "22222222-2222-4222-8222-222222222222"]
(mapv :isolate (drop 2 ts)))))
(testing "and a node that is not an instance is not offered"
(is (not-any? #{"a-rect"} (map :label ts))))))

View file

@ -98,19 +98,42 @@
"creating in a lane does not move the playhead"))))
(deftest the-palette-row-is-a-lane-row-whether-or-not-its-track-exists
(let [empty-row (timeline/palette-track-row (clip/blank) :main 120 #{} nil)
(let [empty-row (first (timeline/palette-track-rows (clip/blank) :main 120 #{} nil))
filled (-> (clip/blank)
(assoc-in [:symbols :main :palette-track] :track)
(assoc-in [:symbols :track]
{:id :track :type :palette-track :display :lane
:frames 120 :nodes {}}))
filled-row (timeline/palette-track-row filled :main 120 #{} nil)]
filled-row (first (timeline/palette-track-rows filled :main 120 #{} nil))]
;; The double-click that creates in a lane asks nothing else of a row.
(is (:lane? empty-row))
(is (:lane? filled-row))
(is (= [:node :track nil []] (:select filled-row))
"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
(let [doc (clip/blank)
id (store/install! {:clip doc :store {}} "double-click-palette-symbol")]

View file

@ -0,0 +1,38 @@
(ns arthur.events.tracing-test
(:require [cljs.test :refer [deftest is]]
[arthur.events.ui :as ui]
[arthur.footage.store :as store]
[re-frame.core :as rf]
[re-frame.db :as rf-db]))
(defn- placed [id src] {:id id :kind :instance :z (name id) :source {:symbol src}})
(def document
;; Two references side by side, and a face traced from footage of its own.
{:fps 12 :width 320 :height 200
:symbols {:main {:id :main :frames 12
:nodes {:a (placed :a :ref) :c (placed :c :ref) :b (placed :b :face)}}
:ref {:id :ref :frames 12 :type :trace :nodes {}}
:face {:id :face :frames 12
:nodes {:plate {:id :plate :kind :rect :z "a"}
:mouth {:id :mouth :kind :rect :z "b"}}}}})
(defn- shift-t [selection tracing]
(let [id (store/install! {:clip document :store {}} "trace-selection")]
(reset! rf-db/app-db {:clip/current id :ui {:open :main :selection selection :tracing tracing}})
(rf/dispatch-sync [::ui/trace-selection])
(get-in @rf-db/app-db [:ui :tracing])))
(deftest shift-t-traces-the-selection-only
(is (= {:on? true :opacity 0.5 :hidden #{[:main :c] [:face :plate]}}
(shift-t [:node :main :a [:a]] {:on? false :opacity 0.5 :hidden #{}}))
"one reference: the other and the face's footage go")
(is (= #{[:main :a] [:main :c]}
(:hidden (shift-t [:node :main :b [:b]] {:on? false :opacity 0.5 :hidden #{}})))
"the face: its own footage, wherever it is placed")
(is (= #{} (:hidden (shift-t [:node :main :a [:a]]
{:on? true :opacity 0.5 :hidden #{[:main :c] [:face :plate]}})))
"again, and every layer is back")
(is (= {:on? false :opacity 0.5 :hidden #{}}
(shift-t nil {:on? false :opacity 0.5 :hidden #{}}))
"nothing selected changes nothing"))

View file

@ -98,7 +98,9 @@
(is (= [:mouth :head :place] (symbol/lineage (:nodes @sym*) :mouth)))
(is (= [:mouth-in :mouth :head :place] (symbol/lineage (:nodes @sym*) :mouth-in)))
(is (= {:mode :map :expose 2} (:time (node :root))))
(is (every? #(nil? (:time (node %))) [:place :head :mouth :mouth-in])))
;; The mouth leads, 125ms at the take's 30fps; its interior inherits that.
(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
(doseq [id [:mouth :mouth-in]]
@ -204,7 +206,9 @@
res (clip/resolver c :main @store pal/index-of nil)
k (first (:value (chan :place [:xform :scale])))
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)]
(let [ops (res f)
op (first (filter #(= [:face-1 :mouth] (:node %)) ops))
@ -216,7 +220,9 @@
ef (node/expose f 2)
;; The frozen, quantised vertex — so the fixed point is not part of
;; what is being asserted here; it has its own test.
flat (pts-at :mouth ef)
;; The mouth LEADS: its pose is read `lead` frames ahead of the
;; 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)}
;; 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

View file

@ -101,7 +101,9 @@
cut (pose/put-cut clip :main :face-2 :mouth 0 20)
original (by-node clip store 4)
held (by-node cut store 4)
source (by-node clip store 20)]
;; Uncut, frame f shows pose f + lead, so pose 20 is on frame 20 − lead.
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 (= (get held [:face-2 :mouth]) (get source [:face-2 :mouth])))
(is (not= (get held [:face-2 :mouth]) (get original [:face-2 :mouth])))

View file

@ -0,0 +1,13 @@
(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}}))))))

View file

@ -78,7 +78,9 @@ try {
await evaluate(`(() => {
const k = cljs.core.keyword, v = cljs.core.vector, m = cljs.core.hash_map;
let c = arthur.domain.clip.blank();
// The drags below measure frames as fractions of a 120-frame ruler, so the
// 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,
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());

View file

@ -58,7 +58,11 @@ try {
await send('Runtime.enable');
for (let i = 0; i < 100; i++) {
try {
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 evaluate(`(() => {
@ -78,21 +82,16 @@ try {
await evaluate(`(() => { document.querySelectorAll('.menu-scrim').forEach(x => x.click()); return true })()`);
await sleep(80);
};
// Creation is two buttons in the timeline's toolbar: a symbol, or a lane.
const clickNew = async label => {
await closeMenus();
assert(await evaluate(`(() => {
const menu = document.querySelector('.loc .menu-wrap > button');
if (!menu) return false;
menu.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;
const button = [...document.querySelectorAll('.creation-controls button')]
.find(b => b.textContent.trim() === ${JSON.stringify(label)});
if (!button || button.disabled) return false;
button.click(); return true;
})()`), `enabled creation command: ${label}`);
await sleep(220);
await closeMenus();
};
const shot = async () => JSON.parse(JSON.stringify(await evaluate('laneSnapshot()'),
(_key, value) => value?.uuid ?? value));
@ -111,7 +110,7 @@ try {
assert.equal((await shot()).clip.symbols.main.display, undefined,
'a blank document starts as an ordinary symbol');
await clickNew('inside');
await clickNew('symbol');
let s = await shot();
let placed = mainInstances(s);
assert.equal(placed.length, 1, 'new symbol places one instance');
@ -130,12 +129,12 @@ try {
placed = mainInstances(s);
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(await evaluate('[...document.querySelectorAll(".tl-track")].filter(t => t.arthurLane).length'), 1,
assert.equal(await evaluate('[...document.querySelectorAll(".tl-track:not(.palette)")].filter(t => t.arthurLane).length'), 1,
'the explicit lane is drawn as one linear track');
assert.equal(await evaluate('document.querySelectorAll(".tl-rename").length'), 1,
assert.equal(await evaluate('document.querySelectorAll(".tl-label:not(.palette) .tl-rename").length'), 1,
'the lane exposes its rename control');
await evaluate('document.querySelector(".tl-rename").click()');
await evaluate('document.querySelector(".tl-label:not(.palette) .tl-rename").click()');
await sleep(80);
assert(await evaluate(`(() => {
const input = document.querySelector('.tl-name-input');
@ -147,13 +146,16 @@ try {
})()`), 'lane rename editor opens');
await sleep(180);
s = await shot();
assert(mainInstances(s).some(n => n.name === 'Foreground'), 'lane name persists');
// A lane is an instance, and an instance is called what it places: the
// 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;
// no temporary lane is previewed or created.
const drop = await evaluate(`(() => {
const source = document.querySelector('.pool-row:not(.main) .pool-item[draggable="true"]');
const track = [...document.querySelectorAll('.tl-track')].find(t => t.arthurLane);
const track = [...document.querySelectorAll('.tl-track:not(.palette)')].find(t => t.arthurLane);
if (!source || !track) return null;
source.scrollIntoView({block: 'center'});
const a = source.getBoundingClientRect(), b = track.getBoundingClientRect();
@ -192,7 +194,7 @@ try {
s = await shot();
assert.equal(laneSymbols(s).length, 2, 'a second explicit command creates a second lane');
const move = await evaluate(`(() => {
const tracks = [...document.querySelectorAll('.tl-track')].filter(t => t.arthurLane);
const tracks = [...document.querySelectorAll('.tl-track:not(.palette)')].filter(t => t.arthurLane);
const from = tracks.find(t => t.querySelector('.tl-cel'));
const to = tracks.find(t => t !== from);
const cel = from?.querySelector('.tl-cel');
@ -218,7 +220,7 @@ try {
await evaluate(`re_frame.core.dispatch_sync(cljs.core.vector(
cljs.core.keyword('arthur.events.project/new'))) `);
await sleep(250);
await clickNew('inside');
await clickNew('symbol');
const clipboardBaseline = (await shot()).clip;
await shortcut('d', 'KeyD');
assert.equal(mainInstances(await shot()).length, 2, 'duplicate copies the selected instance');

View file

@ -62,7 +62,9 @@ try {
await send('Runtime.enable');
await send('Page.enable');
for (let i = 0; i < 160; i++) {
if (await evalJS('return !!(window.cljs && window.re_frame && window.arthur)')) break;
// The page can reload under the first probes, which then have no context
// 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);
}

View file

@ -562,31 +562,26 @@ async function main() {
await page.eval(SEEK(f));
await sleep(100);
check(await page.eval(`(() => {
const button = [...document.querySelectorAll('.params button')]
.find(b => b.textContent === 'drawing key here');
if (!button || button.disabled) return false;
const button = document.querySelector('.params .chan[data-channel="geom pts"] button.key');
if (!button || button.disabled || button.classList.contains('on')) return false;
button.click();
return true;
})()`), `a drawing key can be added at frame ${f}`);
await sleep(100);
}
await page.eval(SEEK(8));
// Standing on key 16, the gap switch is about the gap arriving at it, 8 → 16.
const GAP = `document.querySelector('.params .chan[data-channel="geom pts"] button.gap')`;
await page.eval(SEEK(16));
await sleep(100);
const tweenSelected = await page.eval(`(() => {
const label = [...document.querySelectorAll('.params label')]
.find(el => el.textContent.startsWith('key 8 → 16'));
const select = label?.querySelector('select');
if (!select) return false;
select.value = 'linear';
select.dispatchEvent(new Event('change', { bubbles: true }));
const gap = ${GAP};
if (!gap || gap.getAttribute('aria-label') !== 'hold') return false;
gap.click();
return true;
})()`);
await sleep(100);
check(tweenSelected && await page.eval(`(() => {
const label = [...document.querySelectorAll('.params label')]
.find(el => el.textContent.startsWith('key 8 → 16'));
return label?.querySelector('select')?.value === 'linear';
})()`), 'the second drawing gap can be set to tween');
check(tweenSelected && await page.eval(`${GAP}?.getAttribute('aria-label') === 'tween'`),
'the second drawing gap can be set to tween');
check((await statusMatching(/saved r\d+/)) !== null,
'the painted shape saves by itself', await page.eval(STATUS));
check(await fromMenu(MENU_PICK_NEWEST), 'the painted document can be reopened');
@ -610,13 +605,10 @@ async function main() {
re_frame.core.dispatch_sync(c.vector(k('arthur.events.ui/select'),
c.vector(k('node'), k('main'), id, c.vector(id))));
})()`);
await page.eval(SEEK(8));
await page.eval(SEEK(16));
await sleep(100);
check(await page.eval(`(() => {
const label = [...document.querySelectorAll('.params label')]
.find(el => el.textContent.startsWith('key 8 → 16'));
return label?.querySelector('select')?.value === 'linear';
})()`), 'the per-gap tween setting survives the project round trip');
check(await page.eval(`${GAP}?.getAttribute('aria-label') === 'tween'`),
'the per-gap tween setting survives the project round trip');
// The local 8625 study is optional in a fresh test database. When present,
// tune its shared symbol while its stage is playing.
@ -627,7 +619,7 @@ async function main() {
const stageLoaded = await statusMatching(/loaded 8625 stage study/, 160);
check(stageLoaded !== null, 'the 8625 stage is ready', stageLoaded ?? (await page.eval(STATUS)));
const eyeSelected = await page.eval(`(() => {
const select = document.querySelector('.params .section:last-child select');
const select = [...document.querySelectorAll('.params .section')].find(s => s.querySelector('h2')?.textContent === 'tracking')?.querySelector('select');
// Settings belong to tracked features shared by the stage placements.
const option = [...select.options]
.find(o => o.textContent.trim().endsWith('feature · face-1/eye-r'));
@ -671,7 +663,7 @@ async function main() {
await page.eval(CLICK('pause'));
}
const subjectSelected = await page.eval(`(() => {
const select = document.querySelector('.params .section:last-child select');
const select = [...document.querySelectorAll('.params .section')].find(s => s.querySelector('h2')?.textContent === 'tracking')?.querySelector('select');
const option = [...select.options]
.find(o => o.textContent.includes('subject · face-1'));
if (!option) return false;
@ -720,7 +712,7 @@ async function main() {
}
}
const teethSelected = await page.eval(`(() => {
const select = document.querySelector('.params .section:last-child select');
const select = [...document.querySelectorAll('.params .section')].find(s => s.querySelector('h2')?.textContent === 'tracking')?.querySelector('select');
const option = [...select.options]
.find(o => o.textContent.trim().endsWith('feature · face-1/teeth'));
if (!option) return false;

View file

@ -525,6 +525,22 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
}
.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 same object, so two rows of tabs on one screen read as one idea. */
.pool > .tabs { top: 45px; position: sticky; z-index: 2; }
@ -926,7 +942,6 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
letter-spacing: .07em;
}
.inspector-form { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 7px; }
.inspector-field { display: grid; gap: 2px; color: var(--dim); }
.inspector-field input { width: 100%; color: var(--fg); }
@ -936,11 +951,6 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
.correction-item { display: flex; align-items: center; gap: 4px; min-width: 0; }
.correction-item > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Label / value, once, for every read-only fact in the pane. */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 0; }
.facts dt { color: var(--dim); }
.facts dd { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.knob { display: grid; gap: 1px; margin-bottom: 6px; }
.knob .top-line { display: flex; justify-content: space-between; gap: 8px; }
.knob .top-line .name { color: var(--dim); }
@ -1056,12 +1066,21 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
min-width: max(340px, calc((100% - var(--label)) * var(--tl-zoom, 1)));
position: relative;
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
by the component because only it knows the open symbol's length and FPS. */
}
/* THE FRAME GRID, over the rows so it shows through the cels as Flash's does:
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:
repeating-linear-gradient(90deg,
var(--grid-5) 0 1px, transparent 1px var(--tick, 10%));
repeating-linear-gradient(90deg, var(--grid-5) 0 1px, transparent 1px var(--tick, 10%)),
repeating-linear-gradient(90deg, rgba(0, 0, 0, .07) 0 1px, transparent 1px var(--fine));
}
.tl-grid.coarse {
background-image:
repeating-linear-gradient(90deg, var(--grid-5) 0 1px, transparent 1px var(--tick, 10%));
}
.tl-label,
@ -1170,6 +1189,12 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
.tl-ruler {
cursor: pointer;
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 {
@ -1305,27 +1330,39 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
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 {
position: absolute;
top: 0;
bottom: 0;
width: 1px;
background: var(--playhead);
min-width: 1px;
box-sizing: border-box;
border-left: 1px solid var(--playhead);
background: color-mix(in srgb, var(--playhead) 13%, transparent);
pointer-events: none;
z-index: 3;
}
.tl-tracks.narrow .tl-playhead { background: none; }
/* The playhead's head, in the ruler rather than on the line, so it stays at the
top with the ruler while the rows scroll. */
/* Its head, on the same cell in the ruler and carrying the frame number, so
where you are is read where you are looking. In the ruler rather than on the
line, so it stays at the top while the rows scroll. */
.tl-knob {
position: absolute;
top: 0;
bottom: 0;
z-index: 1;
box-sizing: border-box;
padding: 0 3px;
white-space: nowrap;
pointer-events: none;
margin-left: -4px;
top: 1px;
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--playhead);
color: #fff;
font-size: 10px;
line-height: var(--ruler);
font-variant-numeric: tabular-nums;
}
.tl-empty { padding: 9px; color: var(--dim); }
@ -1402,28 +1439,70 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
border-top: 1px solid var(--hair);
}
/* A transform or visibility channel: its key button, then a field per component. */
.facts dd.channel { display: flex; gap: 3px; align-items: center; overflow: visible; }
.facts dd.channel input[type=number] { width: 0; flex: 1; min-width: 0; }
.facts dd.channel .key { padding: 0 3px; color: var(--dim); }
.facts dd.channel .key.keyed { color: var(--fg); }
.facts dd.channel .key.on { color: var(--sel); }
.facts dd.channel .channel-swatches {
display: flex;
flex: 1;
flex-wrap: wrap;
gap: 3px;
min-width: 0;
/* The inspector. One column of names, 46px, and controls after it: the
header, then a row per channel, then labelled rows. */
.inspect-head {
display: flex; align-items: center; gap: 5px;
padding: 6px; border-bottom: 1px solid var(--hair);
position: sticky; top: 0; z-index: 1; background: var(--pane);
}
.facts dd.channel .channel-swatches .swatch { flex: 0 0 15px; }
.facts dd.channel.live {
margin: -2px;
padding: 2px;
.inspect-kind { color: var(--dim); flex: 0 0 auto; }
.inspect-name { flex: 1; min-width: 0; font-weight: 600; }
.uses, .tl-label .uses { color: var(--dim); flex: 0 0 auto; }
.chans, .props { padding: 4px 6px; display: grid; gap: 3px; border-bottom: 1px solid var(--hair); }
/* ◀ ◆ ▶ · name · value · gap */
.chan { display: grid; grid-template-columns: auto 38px 1fr 16px; gap: 4px; align-items: center; min-height: 20px; }
.chan-name, .prop-name { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan-value { display: flex; gap: 3px; align-items: center; min-width: 0; }
.chan-value input[type=number], .prop input[type=number] { width: 0; flex: 1; min-width: 0; }
.chan-value select, .prop select { flex: 1; min-width: 0; }
.chan.live {
margin: -1px -3px; padding: 1px 3px;
border-radius: 3px;
background: var(--live-bg);
box-shadow: 0 0 0 1px rgba(35, 148, 71, .45), 0 0 6px rgba(35, 148, 71, .28);
box-shadow: 0 0 0 1px rgba(35, 148, 71, .45);
}
.facts dd.channel.live input { border-color: var(--live); }
.chan.live input { border-color: var(--live); }
.key-nav { display: flex; align-items: center; }
.key-nav button, .chan .gap, .prop .icon, .chan-value .icon {
padding: 0; border: 0; background: none; width: 14px; height: 18px;
display: inline-flex; align-items: center; justify-content: center;
color: var(--dim);
}
.key-nav button:disabled { opacity: .3; }
.key-nav .key { width: 16px; 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). */
.paint-overlay .handles .box { fill: none; stroke: #e6ca8b; stroke-width: 0.5; stroke-dasharray: 2 1; pointer-events: none; }
@ -1623,38 +1702,38 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
.tool svg .cut { fill: none; stroke: var(--chrome); stroke-width: 1.2; }
.tool.on svg .cut { stroke: var(--sel-bg); }
.palette { display: grid; gap: 7px; justify-items: center; padding-top: 9px; border-top: 1px solid var(--hair); }
.palette-grid { 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. */
.palette .chip {
.palette-grid .chip {
width: 36px; height: 36px;
display: grid; place-items: end start;
border: 1px solid var(--fg);
border-radius: 3px;
box-shadow: inset 0 0 0 2px var(--pane);
}
.palette .chip span {
.palette-grid .chip span {
margin: 0 0 2px 3px; padding: 0 3px;
border-radius: 2px;
background: rgba(255, 255, 255, .85);
color: var(--fg); font-size: 9px; line-height: 12px;
}
.palette .cells { display: grid; grid-template-columns: repeat(2, 17px); gap: 2px; }
.palette .slot { display: contents; }
.palette .cell {
.palette-grid .cells { display: grid; grid-template-columns: repeat(2, 17px); gap: 2px; }
.palette-grid .slot { display: contents; }
.palette-grid .cell {
width: 17px; height: 17px;
padding: 0;
border: 1px solid rgba(0, 0, 0, .35);
border-radius: 2px;
cursor: pointer;
}
.palette .cell:hover { border-color: var(--fg); transform: scale(1.12); }
.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; }
.palette-grid .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; }
/* Clear is no colour: a knockout. Checkered, as transparency is everywhere. */
.palette .clear,
.palette .chip.clear {
.palette-grid .clear,
.palette-grid .chip.clear {
background-color: #fff;
background-image:
linear-gradient(45deg, #c9c9c5 25%, transparent 25%, transparent 75%, #c9c9c5 75%),
@ -1704,13 +1783,13 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
/* 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
in its corner. */
.palette .cell.map,
.palette .chip.map {
.palette-grid .cell.map,
.palette-grid .chip.map {
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);
}
.palette .cell { position: relative; }
.palette .cell .badge {
.palette-grid .cell { position: relative; }
.palette-grid .cell .badge {
position: absolute; right: -2px; bottom: -2px;
width: 7px; height: 7px;
border: 1px solid var(--pane); border-radius: 50%;
@ -1777,35 +1856,81 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
.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; }
/* 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 i { flex: 1; }
/* On the stage at the playhead. */
.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-info {
position: absolute; top: -3px; right: -5px;
width: 13px; height: 13px; border-radius: 50%;
display: grid; place-items: center;
background: var(--sel); color: #fff;
font: italic 600 9px/1 Georgia, serif;
cursor: help;
box-shadow: 0 0 0 1.5px var(--chrome);
/* Back to the palette the stage is in, when another is open in the grid. */
.palette-grid .back { padding: 1px 4px; font-size: 10px; white-space: nowrap; }
/* A slot nothing in the open symbol draws with. */
.palette-grid .cell.unused { opacity: .5; }
.palette-grid .cell.unused::after {
content: ""; position: absolute; inset: 0; pointer-events: none;
background: linear-gradient(135deg, transparent 45%, rgba(255, 255, 255, .8) 45% 55%, transparent 55%);
}
.info-card {
position: fixed; z-index: 60;
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; }
.palette-grid .grid-tools { display: flex; gap: 2px; }
.palette-grid .grid-tools button { padding: 0 4px; min-width: 17px; font-size: 11px; }
.palette-grid .grid-tools button.on { background: var(--sel-bg); border-color: var(--sel); }
.view-popout label { display: block; margin-bottom: 8px; }
.view-popout label:last-child { margin-bottom: 0; }
.view-popout input, .view-popout select { width: 100%; }
@ -1834,3 +1959,40 @@ button.tl-key.selected { background: var(--pick); box-shadow: 0 0 0 2px var(--pi
.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 .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;
}