diff --git a/frontend/src/arthur/domain/clip.cljs b/frontend/src/arthur/domain/clip.cljs index 9bb0257..4c46bcb 100644 --- a/frontend/src/arthur/domain/clip.cljs +++ b/frontend/src/arthur/domain/clip.cljs @@ -66,10 +66,56 @@ [sym] (= :trace (:type sym))) -(defn symbol-name - "What to call a symbol: its `:name`, or its id when it has none." +(defonce ^:private placed-cache (atom nil)) + +(defn placements + "Where every symbol is placed: `{sid [[owner frame] ...]}`, earliest first, + where `owner` is the symbol whose node places it and `frame` is where in the + owner that node starts. + + Cached by IDENTITY of the document, as `raster` caches a palette: a document + is a value, so the same object means the same answer, and names and the pool + ask this once per symbol per render." + [clip] + (let [cached @placed-cache] + (if (identical? clip (:clip cached)) + (:index cached) + (let [index (-> (reduce (fn [m [owner sym]] + (reduce (fn [m [_ n]] + (if-let [sid (node/source n)] + (update m sid (fnil conj []) + [owner (:at (node/time-of n))]) + m)) + m (:nodes sym))) + {} (:symbols clip)) + (update-vals #(vec (sort-by second %))))] + (reset! placed-cache {:clip clip :index index}) + index)))) + +(defn owners + "The symbols that place `sid`, each once." [clip sid] - (or (:name (symbol clip sid)) (name sid))) + (into [] (comp (map first) (distinct)) (get (placements clip) sid))) + +(defn symbol-name + "What to call a symbol: its `:name`, or where it is when it has none. + + A DRAWING IS NAMED BY WHERE IT IS DRAWN. One placed by exactly one symbol + reads as that symbol's name and the frame it starts on — `body 12` — worked + out on every read, so renaming the lane renames its drawings and moving one + renames it. A symbol placed nowhere, or in two places, has no one place to be + named by and reads as its id. A `:name` that is just the id is no name: older + documents stored one on every drawing." + ([clip sid] (symbol-name clip sid #{})) + ([clip sid seen] + (let [given (:name (symbol clip sid)) + [owner :as os] (owners clip sid)] + (cond + (and given (not= given (name sid))) given + (and (= 1 (count os)) (not (seen owner))) + (str (symbol-name clip owner (conj seen sid)) " " + (js/Math.floor (second (first (get (placements clip) sid))))) + :else (name sid))))) (defn node-label "What to call node `n` on screen. diff --git a/frontend/src/arthur/domain/nest.cljs b/frontend/src/arthur/domain/nest.cljs index cccfdcd..c6f084c 100644 --- a/frontend/src/arthur/domain/nest.cljs +++ b/frontend/src/arthur/domain/nest.cljs @@ -253,6 +253,23 @@ [clip sid id] (clip/update-symbol clip sid update :nodes #(apply dissoc % (subtree % id)))) +(defn delete-symbol + "Symbol `sid` gone from the library, with every node that places it — as + deleting a library item in Flash takes its instances with it. What it placed + stays, placed nowhere now, for whoever deletes it next. `{:clip}`, or + `{:refused why}` for the root, which is what the document opens on." + [clip sid] + (cond + (not (clip/symbol clip sid)) {:refused "there is no such symbol"} + (= sid (clip/opens-on clip)) {:refused "the project opens on this symbol; it cannot be deleted"} + :else + {:clip (reduce (fn [c [owner _]] + (reduce (fn [c [id n]] + (if (= sid (node/source n)) (delete-node c owner id) c)) + c (:nodes (clip/symbol c owner)))) + (update clip :symbols dissoc sid) + (:symbols clip))})) + (defn- transplant "Move node `id` from symbol `host`, where frame `frame` is showing, into symbol `target`, keeping where it is on screen and when. `carry` is the matrix from diff --git a/frontend/src/arthur/domain/span.cljs b/frontend/src/arthur/domain/span.cljs index 26d56f2..2863b6d 100644 --- a/frontend/src/arthur/domain/span.cljs +++ b/frontend/src/arthur/domain/span.cljs @@ -701,7 +701,7 @@ (when (clip/symbol clip drawing-id) "the new drawing ID is already used"))] {:refused why} (place (assoc-in clip [:symbols drawing-id] - {:id drawing-id :name (name drawing-id) :frames 1 :nodes {}}) + {:id drawing-id :frames 1 :nodes {}}) sid id drawing-id at extent true))) (defn reuse-drawing @@ -774,7 +774,7 @@ (clip/symbol clip drawing-id) "the new drawing ID is already used")] {:refused why} (let [c (assoc-in clip [:symbols drawing-id] - {:id drawing-id :name (name drawing-id) :frames 1 :nodes {}}) + {:id drawing-id :frames 1 :nodes {}}) nodes (assoc nodes id (held id drawing-id at))] (claim c sid nodes id extent remainder-id))))) @@ -810,10 +810,10 @@ :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 {}}))] + ;; No name: it is a new drawing, named by where it + ;; is drawn, and two of one name is a question nobody asked. + (-> (clip/symbol clip from) (assoc :id drawing-id) (dissoc :name)) + {:id 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) diff --git a/frontend/src/arthur/events/project.cljs b/frontend/src/arthur/events/project.cljs index b9121ba..860fcc7 100644 --- a/frontend/src/arthur/events/project.cljs +++ b/frontend/src/arthur/events/project.cljs @@ -694,9 +694,9 @@ ;; a rename coalesce with whatever edit happened next. ;; ;; BLANK REMOVES THE NAME rather than storing an empty one. `clip/symbol-name` - ;; falls back to the id, so a symbol cleared of its name reads as `main` - ;; again instead of as a row with nothing on it — and the document carries no - ;; field it did not need. + ;; falls back to where the symbol is drawn, or its id, so a symbol cleared of + ;; its name reads as `body 12` or `main` again instead of as a row with + ;; nothing on it — and the document carries no field it did not need. (let [value (not-empty (str/trim (str value)))] (if-not (clip/symbol (:clip (store/entry (:clip/current db))) sid) db diff --git a/frontend/src/arthur/events/ui.cljs b/frontend/src/arthur/events/ui.cljs index 9815690..f109dab 100644 --- a/frontend/src/arthur/events/ui.cljs +++ b/frontend/src/arthur/events/ui.cljs @@ -1163,10 +1163,8 @@ (if (:refused where) (update db :project merge {:status (:refused where)}) (let [seeded (assoc-in document [:symbols sid] - (cond-> {:id sid - :name (if palette? "palette transition" (name sid)) - :frames 1 :nodes {}} - palette? (assoc :type :palette))) + (cond-> {:id sid :frames 1 :nodes {}} + palette? (assoc :type :palette :name "palette transition"))) result (span/place-symbol seeded st (:sid where) uuid sid (:at where) {:extent :grow-symbol :remainder-id (random-uuid) @@ -1441,30 +1439,73 @@ (boolean (get-in db [:ui :auto-key?])) st)) % edits)))))) -(rf/reg-event-db +(rf/reg-fx + ::confirm + (fn [{:keys [message then]}] + (when (js/confirm message) (rf/dispatch then)))) + +(rf/reg-event-fx + ::delete-symbol + ;; Out of the library, with its placements; see `nest/delete-symbol`. Its tab + ;; closes, and if it was on screen the root takes its place. + ;; + ;; ASKED FIRST WHEN IT IS PLACED, because then the delete reaches past the row + ;; you pointed at, into every symbol that uses it. One placed nowhere goes + ;; without a question; undo is there either way. + (fn [{:keys [db]} [_ sid sure?]] + (let [clip (:clip (store/entry (:clip/current db))) + {gone :clip why :refused} (nest/delete-symbol clip sid) + uses (clip/uses clip sid)] + (cond + why + {:db (refused db why)} + + (and (pos? uses) (not sure?)) + {::confirm {:message (str "Delete " (clip/symbol-name clip sid) "? It is used " + (if (= 1 uses) "once" (str uses " times")) ", in " + (str/join ", " (map #(clip/symbol-name clip %) + (clip/owners clip sid))) + ", and every use of it goes too.") + :then [::delete-symbol sid true]}} + + :else + (cond-> {:db (-> db + (edit/transaction (constantly gone)) + (update-in [:ui :tabs] #(vec (remove #{sid} %))) + (update :ui (fn [ui] + (cond-> ui + (= [:symbol sid] (:selection ui)) + (assoc :selection nil :selections [])))))} + (= sid (get-in db [:ui :open])) + (assoc :dispatch [::playback/open-symbol (clip/opens-on gone)])))))) + +(rf/reg-event-fx ::delete-selected ;; Backspace while drawing takes the last point back, as in Illustrator; on - ;; the pen, with a point of the selected shape picked, it takes that point. - (fn [db _] + ;; the pen, with a point of the selected shape picked, it takes that point. A + ;; symbol picked in the pool is deleted from the library. + (fn [{:keys [db]} _] (let [[vsid vid i] (get-in db [:ui :vertex]) primary (get-in db [:ui :selection])] (cond (seq (get-in db [:ui :draft])) - (update-in db [:ui :draft] #(subvec % 0 (- (count %) 2))) + {:db (update-in db [:ui :draft] #(subvec % 0 (- (count %) 2)))} (and i (= :pen (get-in db [:ui :tool])) (= [:node vsid vid] (take 3 primary))) - (deleting-vertex db vsid vid i) + {:db (deleting-vertex db vsid vid i)} + + (= :symbol (first primary)) + {:dispatch [::delete-symbol (second primary)]} :else (let [many (vec (get-in db [:ui :selections])) selections (if (some #{primary} many) many (if primary [primary] [])) nodes (distinct (keep (fn [[kind sid id]] (when (= :node kind) [sid id])) selections))] - (if (seq nodes) - (-> db - (edit/transaction #(reduce (fn [c [sid id]] (nest/delete-node c sid id)) % nodes)) - (assoc-in [:ui :selection] nil) - (assoc-in [:ui :selections] [])) - db)))))) + (when (seq nodes) + {:db (-> db + (edit/transaction #(reduce (fn [c [sid id]] (nest/delete-node c sid id)) % nodes)) + (assoc-in [:ui :selection] nil) + (assoc-in [:ui :selections] []))})))))) (rf/reg-event-db ::restack diff --git a/frontend/src/arthur/ui/pool.cljs b/frontend/src/arthur/ui/pool.cljs index e574bbc..65f32c5 100644 --- a/frontend/src/arthur/ui/pool.cljs +++ b/frontend/src/arthur/ui/pool.cljs @@ -15,13 +15,12 @@ looking at and puts the number on its tab. THE MAIN TIMELINE LEADS, and it is `clip/opens-on`'s answer rather than a - name: the longest symbol nothing else places is the one the project plays and - the one the work happens in, so it gets the top of the pane and a row drawn at - a size you can read a pose off. Every other symbol is the list under it. That - is one list and not two — every symbol here IS a timeline, and heading a - section TIMELINES and the next one SYMBOLS would name the same thing twice. - None of it is `:main` being special either: rename it, place it inside - something else, and the pool follows the document. + name: the symbol the project plays and the one the work happens in, so it gets + the top of the pane and a row drawn at a size you can read a pose off. Every + other symbol is the tree under it: what nothing places beside it at the top, + and the rest under whatever places it — see `this-project`. None of it is + `:main` being special either: rename it, place it inside something else, and + the pool follows the document. Every row is a drag source, and what it carries says what it is: `symbol:` for a symbol of this document, `import:||` for @@ -199,13 +198,27 @@ its own under the name — `sub2` — rather than one of them out at the edge. `rename` is `{:key :value :begin! :commit!}` and is what makes a row - renameable at all: a row without one has no pencil and does not answer F2." - [{:keys [label sub sub2 title thumb on? open? main? disabled? rename] :as opts}] + renameable at all: a row without one has no pencil and does not answer F2. + + `depth` puts a row in a tree: indented that far, with a twisty ahead of it. + `inside` is `{:count :open? :flip!}` for a row with rows under it; a row with + none keeps the twisty's room, so names line up down a level. + + `delete!` puts a cross beside the pencil, on hover as the pencil is." + [{:keys [label sub sub2 title thumb on? open? main? disabled? rename depth inside delete!] + :as opts}] (let [{:keys [key value begin! commit!]} rename editing? (boolean (and key (= key (:editing rename))))] [:div.pool-row {:class (str (when main? "main ") (when on? "on ") (when open? "open ") (when disabled? "disabled ") - (when editing? "editing"))} + (when editing? "editing")) + :style (when depth {:padding-left (+ 4 (* 10 depth))})} + (when depth + (if-let [{:keys [count open? flip!]} inside] + [:span.pool-twisty {:title (str count " inside") + :on-click (fn [^js e] (.stopPropagation e) (flip!))} + (if open? "\u25BE" "\u25B8")] + [:span.pool-twisty])) (if editing? ;; The input REPLACES the row rather than floating over it, so the list ;; does not change height while you type in it. @@ -235,7 +248,7 @@ (.preventDefault e) (begin! key))))} (dissoc opts :label :sub :sub2 :title :on? :open? :main? - :disabled? :thumb :rename)) + :disabled? :thumb :rename :depth :inside :delete!)) thumb [:span.text ;; The label is `.text`'s first child and stays that way: it is how @@ -250,13 +263,19 @@ ;; being avoided, and F2 already reaches it from the keyboard. :on-click (fn [^js e] (.stopPropagation e) (begin! key))} "\u270E"]) + (when delete! + [:span.pool-rename.pool-delete + {:title (str "delete " label " (Delete)") + :on-click (fn [^js e] (.stopPropagation e) (delete!))} + "\u00D7"]) ;; The main row says both its facts under the name instead. (when (and sub (not main?)) [:span.sub sub])]])])) ;; --------------------------------------------------------------------------- ;; the rows of each kind -(defn- symbol-row [document sid {:keys [clip-id store palette selection open main rename]}] +(defn- symbol-row [document sid {:keys [clip-id store palette selection open main rename + depth inside]}] (let [sym (clip/symbol document sid) label (clip/symbol-name document sid) nodes (count (:nodes sym))] @@ -276,6 +295,9 @@ :on? (= selection [:symbol sid]) :open? (= sid open) :main? (= sid main) + :depth depth + :inside inside + :delete! (when-not (= sid main) #(rf/dispatch [::ui/delete-symbol sid])) :rename (assoc rename :key [:symbol sid] :value label @@ -427,23 +449,62 @@ [:div.pool-empty "no match in this scope"] (into [:<>] (map section) children))) +(def ^:private own-section? + "Symbols with a section of their own, kept out of the tree." + #{:palette :palette-track :trace}) + +(defn- listed? [document sid] + (not (own-section? (:type (clip/symbol document sid))))) + +(defn- placed-in + "What each symbol places, as `{owner [sid ...]}`: each once, in the order they + first start in it." + [document] + (reduce-kv (fn [m sid at] + (if (listed? document sid) + (reduce-kv (fn [m owner [[_ f]]] (update m owner (fnil conj []) [f sid])) + m (group-by first at)) + m)) + {} (clip/placements document))) + +(defn- tree + "`sid`'s row and, while it is open, the rows of what it places under it. A + symbol placed in two symbols is under both. `path` is what this row is under, + which keys the row and stops a cycle." + [{:keys [document placed expanded flip! main] :as ctx} sid depth path] + (let [kids (->> (get placed sid) (sort-by (juxt first (comp str second))) + (map second) (remove (set (conj path sid)))) + root? (and (= main sid) (empty? path)) + open? (and (seq kids) (or root? (contains? expanded [path sid])))] + (into [(with-meta (symbol-row document sid + (assoc ctx :depth depth + :inside (when (and (seq kids) (not root?)) + {:count (count kids) :open? open? + :flip! #(flip! [path sid])}))) + {:key (str (conj path sid))})] + (when open? + (mapcat #(tree ctx % (inc depth) (conj path sid)) kids))))) + (defn- this-project - "The open document's own, with the main timeline at the top and every other - symbol under it. + "The open document's own: its symbols as the tree of what places what, then + each kind with a section of its own. - NOT \"TIMELINES AND SYMBOLS\". Every symbol in this model IS a timeline — it - has frames and nodes and you open it and work in it — so a pair of headings - naming those two things names one thing twice, and invites a reader to go - looking for the difference. There is one list of symbols. What is true is that - exactly one of them is where the work happens: `clip/opens-on`'s answer, the - longest symbol nothing else places. That gets the top of the pane and a row - drawn like the thing it is, and the rest of the library is the list below it. + WHAT NOTHING PLACES IS AT THE TOP, and everything else is under what places + it. Drawing makes a symbol per drawing, and a flat list of every one buries the + few that matter; a drawing is under its lane, its lane under its scene. What + is left at the top is the root the project opens on, drawn big and first with + what it places always showing under it, and + whatever is placed nowhere — a scene, something made to be placed later, or + something left behind — which is what wants looking at: keep it, place it, or + delete it. Nothing is ever cleared away for you. - 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." + One rule for every symbol, worked out from the document on each render and + stored nowhere: place it, unplace it, and the pool follows. + + A SEARCH IS FLAT: you asked for it by name, and a hit inside a closed twisty is + a hit you cannot see." [{: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))) transition-ids (into #{} (mapcat (fn [sym] (when (= :palette-track (:type sym)) @@ -454,22 +515,24 @@ 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 :trace} - (:type (clip/symbol document %))))) - symbol-ids) + listed (filterv #(listed? document %) symbol-ids) + symbols (if searching? + (mapv #(symbol-row document % ctx) (filterv named? listed)) + (let [ctx (assoc ctx :placed (placed-in document)) + top (cond->> (filterv #(and (not= main %) + (empty? (clip/owners document %))) + listed) + (contains? (:symbols document) main) (into [main]))] + (into [] (mapcat #(tree ctx % 0 [])) top))) 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) (count tracing) + (+ (count symbols) (count transitions) (count tracing) (count media) (count sounds) (count images)) - [{:title "project" :searching? searching? + [{:title "symbols" :searching? searching? :blank "nothing to open yet" - :rows (when top [(symbol-row document top ctx)])} - {:title "symbols" :searching? searching? - :blank "nothing else in the library" - :rows (mapv #(symbol-row document % ctx) rest)} + :rows symbols} {:title "tracing layers" :searching? searching? :blank "no tracing layers yet" :rows (mapv #(symbol-row document % ctx) tracing)} @@ -559,7 +622,10 @@ ;; Which row is being renamed, as `[kind id]`. One atom rather ;; than a flag per row: exactly one name is ever being edited, and ;; opening a second input has to close the first. - editing (r/atom nil)] + editing (r/atom nil) + ;; Which tree rows are open, as `[path sid]`. Everything under + ;; the root's own children starts shut — see `tree`. + expanded (r/atom #{})] (let [{:keys [loading? status available sounds images uploaded chosen]} @(rf/subscribe [::playback/footage]) document @(rf/subscribe [::sub/settled-clip]) @@ -596,7 +662,9 @@ ;; else places is the timeline the work happens in, and it is the ;; one row in this pane drawn big enough to read a pose off. :main (clip/opens-on document) - :rename {:editing @editing :begin! #(reset! editing %)}} + :rename {:editing @editing :begin! #(reset! editing %)} + :expanded @expanded + :flip! #(swap! expanded (fn [open] (if (open %) (disj open %) (conj open %))))} tallies (counts ctx) files? (fn [^js e] (some #{"Files"} (array-seq (.. e -dataTransfer -types))))] [:section.pane.pool diff --git a/frontend/test/arthur/domain/instance_test.cljs b/frontend/test/arthur/domain/instance_test.cljs index f4585e9..ceb43d5 100644 --- a/frontend/test/arthur/domain/instance_test.cljs +++ b/frontend/test/arthur/domain/instance_test.cljs @@ -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" diff --git a/frontend/test/arthur/domain/nest_test.cljs b/frontend/test/arthur/domain/nest_test.cljs index 2d3473b..13f29ec 100644 --- a/frontend/test/arthur/domain/nest_test.cljs +++ b/frontend/test/arthur/domain/nest_test.cljs @@ -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"))) diff --git a/frontend/test/arthur/events/export_test.cljs b/frontend/test/arthur/events/export_test.cljs index a92c334..75e933f 100644 --- a/frontend/test/arthur/events/export_test.cljs +++ b/frontend/test/arthur/events/export_test.cljs @@ -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)))) diff --git a/static/arthur/app.css b/static/arthur/app.css index d3363bb..e16348d 100644 --- a/static/arthur/app.css +++ b/static/arthur/app.css @@ -600,6 +600,19 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); } } .pool-row:hover:not(.disabled) { background: #fff; } + +/* A tree row's disclosure: what this symbol places, shut until asked. A row + with nothing under it keeps the width, so names line up down a level. */ +.pool-twisty { + flex: none; + width: 10px; + color: var(--dim); + cursor: pointer; + text-align: center; + user-select: none; +} +.pool-twisty:empty { cursor: default; } +.pool-twisty:hover:not(:empty) { color: var(--fg); } .pool-row.on { background: var(--sel-bg); border-color: var(--sel); } /* WHICH ONE IS OPEN, as a mark and not as the word "open" — a list this narrow