Group tracing layers in the pool and fit new drops to the stage

This commit is contained in:
Olive Vaughn 2026-10-04 00:16:03 -04:00
parent f4dd047642
commit 1ae49a4015
3 changed files with 58 additions and 25 deletions

View file

@ -1013,6 +1013,24 @@
result)]
(landed db where uuid result))))))
(defn- fitted
"Tracing placement `uuid` in symbol `sid` of `document`, sized so its picture
fits within `sid`'s stage, and — dropped on the timeline, with no point to
land on — middled on that stage rather than wherever the picture's own middle
happens to fall. A 1920px still is otherwise six stages tall.
A DEFAULT, set once, as the anchor is: nothing keeps it fitted afterwards."
[document sid uuid {:keys [width height]} point?]
(let [[w h] (clip/stage document sid)
k (min (/ w width) (/ h height))]
(update-in document [:symbols sid :nodes uuid :channels]
(fn [chs]
(cond-> (assoc chs [:xform :scale] (ch/framed [k k]))
(not point?)
(assoc [:xform :pos]
(ch/framed (mapv - [(/ w 2) (/ h 2)]
(:value (get chs [:xform :anchor]))))))))))
(rf/reg-event-db
::drop-symbol
;; A symbol dropped on a row becomes a naturally playing clip in the symbol that
@ -1028,29 +1046,15 @@
uuid (random-uuid)]
(if (:refused where)
(-> db (update :ui dissoc :drop) (update :project merge {:status (:refused where)}))
(landed db where uuid
(span/place-symbol (:clip where) st (:sid where)
uuid source-id (:at where)
{:extent :grow-symbol :point point
:remainder-id (random-uuid)}))))))
(defn- fitted
"Tracing placement `uuid` in symbol `sid` of `document`, sized so its picture
is as tall as `sid`'s stage, and — dropped on the timeline, with no point to
land on — middled on that stage rather than wherever the picture's own middle
happens to fall. A 1920px still is otherwise six stages tall.
A DEFAULT, set once, as the anchor is: nothing keeps it fitted afterwards."
[document sid uuid {:keys [height]} point?]
(let [[w h] (clip/stage document sid)
k (/ h height)]
(update-in document [:symbols sid :nodes uuid :channels]
(fn [chs]
(cond-> (assoc chs [:xform :scale] (ch/framed [k k]))
(not point?)
(assoc [:xform :pos]
(ch/framed (mapv - [(/ w 2) (/ h 2)]
(:value (get chs [:xform :anchor]))))))))))
(let [sym (clip/symbol document source-id)
result (span/place-symbol (:clip where) st (:sid where)
uuid source-id (:at where)
{:extent :grow-symbol :point point
:remainder-id (random-uuid)})]
(landed db where uuid
(cond-> result
(and (:clip result) (clip/trace? sym))
(update :clip fitted (:sid where) uuid sym (some? point)))))))))
(rf/reg-event-db
::drop-tracing

View file

@ -448,15 +448,17 @@
transition? #(or (= :palette (:type (clip/symbol document %)))
(contains? transition-ids %))
transitions (filterv #(and (named? %) (transition? %)) symbol-ids)
tracing (filterv #(and (named? %) (clip/trace? (clip/symbol document %)))
symbol-ids)
rest (filterv #(and (named? %) (not= main %)
(not (#{:palette :palette-track}
(not (#{:palette :palette-track :trace}
(:type (clip/symbol document %)))))
symbol-ids)
media (filterv #(hit? query (:label %)) media)
sounds (filterv #(hit? query (:label %)) sounds)
images (filterv #(hit? query (:label %)) images)]
[sections searching?
(+ (if top 1 0) (count rest) (count transitions)
(+ (if top 1 0) (count rest) (count transitions) (count tracing)
(count media) (count sounds) (count images))
[{:title "project" :searching? searching?
:blank "nothing to open yet"
@ -464,6 +466,9 @@
{:title "symbols" :searching? searching?
:blank "nothing else in the library"
:rows (mapv #(symbol-row document % ctx) rest)}
{:title "tracing layers" :searching? searching?
:blank "no tracing layers yet"
:rows (mapv #(symbol-row document % ctx) tracing)}
{:title "palette transitions" :searching? searching?
:blank "no palette transitions"
:rows (mapv #(palette-transition-row document % selection rename) transitions)}