The pool is a tree of what places what, and deletes
A drawing is named by where it is drawn, `body 12`, until it is given a name of its own. The pool lists each symbol under what places it, with the root's lanes always showing and anything placed nowhere at the top, where it wants looking at. Delete or the cross removes a symbol and its placements, asking first when it is used anywhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4fe620f50a
commit
fbcbcd0321
10 changed files with 285 additions and 68 deletions
|
|
@ -267,6 +267,25 @@
|
|||
(is (= (get-in c [:symbols :outer :nodes])
|
||||
(get-in (leaf/clip "c" (leaf/leaves "c" c)) [:symbols :outer :nodes]))))))
|
||||
|
||||
(deftest a-drawing-is-named-by-where-it-is-drawn
|
||||
(let [c (assoc-in (nested) [:symbols :outer :name] "body")]
|
||||
(testing "placed by one symbol: that symbol's name and the frame it starts on"
|
||||
(is (= [:outer] (clip/owners c :inner)))
|
||||
(is (= "body 5" (clip/symbol-name c :inner)))
|
||||
(is (= "lane 5" (clip/symbol-name (assoc-in c [:symbols :outer :name] "lane") :inner))
|
||||
"renaming the lane renames its drawings"))
|
||||
(testing "a name of its own wins, and one that is only the id is no name"
|
||||
(is (= "hand" (clip/symbol-name (assoc-in c [:symbols :inner :name] "hand") :inner)))
|
||||
(is (= "body 5" (clip/symbol-name (assoc-in c [:symbols :inner :name] "inner") :inner))))
|
||||
(testing "placed nowhere, or in two symbols, it is its id"
|
||||
(is (= "loose" (clip/symbol-name c :loose)))
|
||||
(is (= "inner" (clip/symbol-name (clip/place-symbol c nil :loose :inner 0 (random-uuid) nil)
|
||||
:inner))))
|
||||
(testing "a cycle of unnamed symbols ends rather than recurring"
|
||||
(let [loop (clip/place-symbol (update-in c [:symbols :outer] dissoc :name)
|
||||
nil :inner :outer 0 (random-uuid) nil)]
|
||||
(is (string? (clip/symbol-name loop :inner)))))))
|
||||
|
||||
(deftest an-instance-is-labelled-by-what-it-places
|
||||
(let [c (-> (nested)
|
||||
(assoc-in [:symbols :inner :name] "mouth"))
|
||||
|
|
@ -278,9 +297,9 @@
|
|||
(is (= "mouth" (clip/node-label c id n)))
|
||||
(is (= "jaw" (clip/node-label (assoc-in c [:symbols :inner :name] "jaw") id n))
|
||||
"renaming the symbol renames every row that shows an instance of it"))
|
||||
(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 "an unnamed symbol is named by where it is drawn, not by the node's uuid"
|
||||
(is (= "outer 5" (clip/node-label (update-in c [:symbols :inner] dissoc :name)
|
||||
id n))))
|
||||
(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"
|
||||
|
|
|
|||
|
|
@ -560,3 +560,16 @@
|
|||
(is (near? [10 90] (piv c)))
|
||||
(is (near? [10 90] (piv grown))
|
||||
"the pivot moved because something else was drawn, which is the bug")))
|
||||
|
||||
(deftest deleting-a-symbol-takes-its-placements-and-leaves-what-it-placed
|
||||
(let [c (-> (clip/blank)
|
||||
(assoc-in [:symbols :lane] {:id :lane :frames 10 :nodes {}})
|
||||
(assoc-in [:symbols :cel] {:id :cel :frames 1 :nodes {}})
|
||||
(clip/place-symbol nil :main :lane 0 (random-uuid) nil)
|
||||
(clip/place-symbol nil :lane :cel 3 (random-uuid) nil))
|
||||
{gone :clip} (nest/delete-symbol c :lane)]
|
||||
(is (nil? (clip/symbol gone :lane)))
|
||||
(is (empty? (:nodes (clip/symbol gone :main))) "its instance in the root went with it")
|
||||
(is (clip/symbol gone :cel) "what it placed stays")
|
||||
(is (empty? (clip/owners gone :cel)) "placed nowhere now")
|
||||
(is (:refused (nest/delete-symbol c :main)) "the root cannot be deleted")))
|
||||
|
|
|
|||
|
|
@ -67,11 +67,11 @@
|
|||
:kind :instance :parent :root :z "a1"
|
||||
: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"}}}}})
|
||||
:sym/face {:name "head" :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" "face 1" "face 2"] (mapv :label ts))
|
||||
(is (= ["main" "face" "head 1" "head 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))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue