Drawing in a lane draws into the drawing it shows

With the lane as the target, the brush and the pen made a new cel at the
playhead and cut the one showing there short. What is on screen is what
you are drawing on, so the shape goes into it, as if that cel were
selected; only where the lane shows nothing is a new cel made.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011FLuCjp9kNH6ovwJVXSbq9
This commit is contained in:
Olive Vaughn 2026-10-11 00:07:13 -04:00
parent 86f2d96762
commit 1a92a103cc
2 changed files with 40 additions and 17 deletions

View file

@ -705,12 +705,8 @@
(fn [db [_ size]] (assoc-in db [:ui :brush] (-> size js/Math.round (max 1) (min 64))))) (fn [db [_ size]] (assoc-in db [:ui :brush] (-> size js/Math.round (max 1) (min 64)))))
(defn new-lane-drawing (defn new-lane-drawing
"Create the one-frame drawing cel implied by drawing with a lane row active. "Create the one-frame drawing cel implied by drawing with a lane row active,
where the lane shows nothing at the playhead — see `polygon-landing`.
A lane is an insertion surface, so this always makes a new cel at the
playhead. Existing content at that frame is claimed and trimmed by
`overwrite-drawing`. Selecting an existing cel resolves to that cel's ordinary
source symbol before this function is reached, and therefore draws inside it.
`overwrite-drawing` rather than `append-drawing`, because a gap already has `overwrite-drawing` rather than `append-drawing`, because a gap already has
the room. Appending RIPPLES everything after it later by the new clip's the room. Appending RIPPLES everything after it later by the new clip's
@ -729,17 +725,31 @@
made made
{:clip (:clip made) :sid sid :path (conj (vec path) cel-id)})))) {:clip (:clip made) :sid sid :path (conj (vec path) cel-id)}))))
(defn- showing
"The id of the clip of lane `sid` that is on screen at the lane's frame `f`,
or nil where the lane shows nothing."
[clip sid f]
(some (fn [[id n]]
(when-let [[lo hi] (node/placed-span n)]
(when (and (node/source n) (<= lo f) (< f hi)) id)))
(get-in clip [:symbols sid :nodes])))
(defn polygon-landing (defn polygon-landing
"Choose the document and row path a finished polygon is drawn into. "Choose the document and row path a finished polygon is drawn into.
A resolved lane always gets a new drawing cel. A selected cel resolves to its DRAWING IN A LANE DRAWS INTO WHAT IT SHOWS. With the lane as the target, the
source symbol instead, so drawing there adds a child to that existing cel." drawing on screen at the playhead is what you are drawing on, so the shape
goes into it — exactly as if that cel were selected. Only where the lane shows
nothing is a new cel made; a new drawing over an old one is K's job, and ⇧K's,
not a side effect of the brush."
[clip st db] [clip st db]
(let [into (creation/target clip st (get-in db [:ui :open]) (let [into (creation/target clip st (get-in db [:ui :open])
(get-in db [:ui :selection]) (editing-frame db clip))] (get-in db [:ui :selection]) (editing-frame db clip))
(if (= :lane (:kind into)) cel (when (= :lane (:kind into)) (showing clip (:sid into) (:frame into)))]
(assoc (new-lane-drawing clip into) :lane? true) (cond
{:clip clip :sid (:sid into) :path (:path into) :lane? false}))) cel {:clip clip :path (conj (vec (:path into)) cel) :lane? false}
(= :lane (:kind into)) (assoc (new-lane-drawing clip into) :lane? true)
:else {:clip clip :sid (:sid into) :path (:path into) :lane? false})))
(defn beginning-polygon (defn beginning-polygon
"Enter polygon mode, first materializing a new drawing at the playhead when "Enter polygon mode, first materializing a new drawing at the playhead when

View file

@ -370,10 +370,14 @@
(deftest polygon-landing-obeys-the-destination-symbol-mode (deftest polygon-landing-obeys-the-destination-symbol-mode
(let [lane (fixture/document) (let [lane (fixture/document)
gap (update-in lane [:symbols :main :nodes] dissoc :b)
ordinary (update-in lane [:symbols :main] dissoc :display) ordinary (update-in lane [:symbols :main] dissoc :display)
db {:ui {:open :main :selection [:node :main :plate [:plate]]} db {:ui {:open :main :selection [:node :main :plate [:plate]]}
:playback {:frame 5}}] :playback {:frame 5}}]
(is (true? (:lane? (ui/polygon-landing lane {} db)))) (is (= {:lane? false :path [:b]} (select-keys (ui/polygon-landing lane {} db) [:lane? :path]))
"a lane draws into the cel it shows at the playhead")
(is (true? (:lane? (ui/polygon-landing gap {} db)))
"and makes a new one only where it shows nothing")
(is (false? (:lane? (ui/polygon-landing ordinary {} db)))))) (is (false? (:lane? (ui/polygon-landing ordinary {} db))))))
(deftest beginning-a-polygon-does-not-invent-a-lane (deftest beginning-a-polygon-does-not-invent-a-lane
@ -389,18 +393,27 @@
(is (nil? (get-in saved [:symbols :main :display]))) (is (nil? (get-in saved [:symbols :main :display])))
(is (nil? (get-in (store/entry (:clip/current after)) [:history :done]))))) (is (nil? (get-in (store/entry (:clip/current after)) [:history :done])))))
(deftest drawing-with-the-lane-row-active-creates-a-new-cel (deftest drawing-with-the-lane-row-active-draws-into-what-it-shows
(let [doc (fixture/document) (let [doc (fixture/document)
id (store/install! {:clip doc :store {}} "draw-new-lane-cel") id (store/install! {:clip doc :store {}} "draw-into-lane-cel")
db {:clip/current id :paint/revision 0 db {:clip/current id :paint/revision 0
:ui {:open :main :selection [:node :main nil []]} :ui {:open :main :selection [:node :main nil []]}
:playback {:frame 1}} :playback {:frame 1}}
after (ui/beginning-polygon db)]
(is (= doc (:clip (store/entry id))) "no cel is made over the one showing")
(is (= [] (get-in after [:ui :draft])))))
(deftest drawing-with-the-lane-row-active-in-a-gap-creates-a-new-cel
(let [doc (update-in (fixture/document) [:symbols :main :nodes] dissoc :b)
id (store/install! {:clip doc :store {}} "draw-new-lane-cel")
db {:clip/current id :paint/revision 0
:ui {:open :main :selection [:node :main nil []]}
:playback {:frame 5}}
after (ui/beginning-polygon db) after (ui/beginning-polygon db)
[_ sid cel-id] (get-in after [:ui :selection]) [_ sid cel-id] (get-in after [:ui :selection])
saved (:clip (store/entry id))] saved (:clip (store/entry id))]
(is (= :main sid)) (is (= :main sid))
(is (not= :a cel-id) "the occupied cel is not reused") (is (= [5 6] (node/placed-span (get-in saved [:symbols sid :nodes cel-id]))))
(is (= [1 2] (node/placed-span (get-in saved [:symbols sid :nodes cel-id]))))
(is (= 1 (clip/frames saved (node/source (get-in saved [:symbols sid :nodes cel-id]))))) (is (= 1 (clip/frames saved (node/source (get-in saved [:symbols sid :nodes cel-id])))))
(is (= [] (get-in after [:ui :draft]))))) (is (= [] (get-in after [:ui :draft])))))