fixed creating in
This commit is contained in:
parent
2697401aad
commit
a90e0cfb61
5 changed files with 99 additions and 17 deletions
|
|
@ -6,20 +6,39 @@
|
|||
is actually available. See `docs/creating-in.md`."
|
||||
(:require [arthur.domain.clip :as clip]
|
||||
[arthur.domain.nest :as nest]
|
||||
[arthur.domain.node :as node]
|
||||
[arthur.domain.symbol :as symbol]))
|
||||
|
||||
(defn- path-node
|
||||
"The node at the end of an occurrence `path`, walked from `open`.
|
||||
|
||||
Selection also carries an owner sid and node id for commands that edit the
|
||||
node directly. Those are deliberately not used here: the path is the address
|
||||
of the row as seen from the open symbol, and is the only part that describes
|
||||
every enclosing occurrence at arbitrary depth."
|
||||
[document open path]
|
||||
(loop [sid open [id & more] (seq path) found nil]
|
||||
(if-not id
|
||||
found
|
||||
(when-let [n (get-in document [:symbols sid :nodes id])]
|
||||
(if (seq more)
|
||||
(when-let [inner (and (= :instance (:kind n)) (node/source n))]
|
||||
(recur inner more n))
|
||||
n)))))
|
||||
|
||||
(defn preferred-path
|
||||
"The container path structurally implied by `selection`.
|
||||
|
||||
Selecting an instance means inside it. Selecting any other node means its
|
||||
containing symbol. An empty or non-node selection means the open symbol."
|
||||
[document selection]
|
||||
(let [[kind sid id selected-path] selection
|
||||
[document open selection]
|
||||
(let [[kind _sid id selected-path] selection
|
||||
path (when (= :node kind)
|
||||
(vec (or (seq selected-path) (when id [id]))))]
|
||||
(vec (or (seq selected-path) (when id [id]))))
|
||||
selected (path-node document open path)]
|
||||
(cond
|
||||
(empty? path) []
|
||||
(= :instance (get-in document [:symbols sid :nodes id :kind])) path
|
||||
(= :instance (:kind selected)) path
|
||||
:else (vec (butlast path)))))
|
||||
|
||||
(defn target
|
||||
|
|
@ -33,7 +52,7 @@
|
|||
|
||||
Returns `{:kind :lane|:symbol :sid :path :frame :matrix :time}`."
|
||||
[document store open selection frame]
|
||||
(let [preferred (preferred-path document selection)]
|
||||
(let [preferred (preferred-path document open selection)]
|
||||
(some (fn [path]
|
||||
(when-let [inside (nest/inside document store open path frame)]
|
||||
(when-let [sid (:sid inside)]
|
||||
|
|
|
|||
|
|
@ -345,9 +345,16 @@
|
|||
|
||||
|
||||
(rf/reg-event-db
|
||||
::toggle-row
|
||||
(fn [db [_ path]]
|
||||
(update-in db [:ui :expanded] #(if (contains? % path) (disj % path) (conj % path)))))
|
||||
::set-row-expanded
|
||||
(fn [db [_ path expanded?]]
|
||||
;; The disclosure control says what the next state is instead of asking us
|
||||
;; to invert whatever happens to be in app-db by the time its event runs.
|
||||
;; A structural drop may reveal this path between pointer-down and click;
|
||||
;; blindly toggling then immediately closed the row whose triangle was still
|
||||
;; painted as closed.
|
||||
(update-in db [:ui :expanded]
|
||||
(fn [paths]
|
||||
((if expanded? conj disj) (set paths) path)))))
|
||||
|
||||
(rf/reg-event-db
|
||||
::solo
|
||||
|
|
@ -800,8 +807,11 @@
|
|||
;; One gesture and one creation path for every lane. The destination decides
|
||||
;; the kind: an ordinary lane gets a blank symbol; the synthetic palette row
|
||||
;; gets a blank palette symbol whose placement starts by inheriting.
|
||||
(fn [db [_ frame target]]
|
||||
(fn [db [_ _pointer-frame target]]
|
||||
(let [{document :clip st :store} (store/entry (:clip/current db))
|
||||
;; Creation always happens at the playhead. The double-click only
|
||||
;; names the lane; it is not a second, pointer-based time cursor.
|
||||
frame (editing-frame db document)
|
||||
palette? (= :arthur.ui.timeline/palette-track (first target))
|
||||
root-sid (second target)
|
||||
root (when palette? (clip/symbol document root-sid))
|
||||
|
|
|
|||
|
|
@ -656,11 +656,14 @@
|
|||
:else [::ui/group [from path]])))))}))
|
||||
[:button.tl-twist
|
||||
{:disabled (not expandable?)
|
||||
;; This button lives inside a draggable row label. Do not let a tiny
|
||||
;; pointer movement turn disclosure into a native row drag (whose click
|
||||
;; is then suppressed by the browser).
|
||||
:draggable false
|
||||
:on-pointer-down (fn [^js e] (.stopPropagation e))
|
||||
:on-click (fn [^js e]
|
||||
(println "heyyy")
|
||||
(.stopPropagation e)
|
||||
(rf/dispatch [::ui/toggle-row path]))
|
||||
:class (println expandable?)}
|
||||
(rf/dispatch [::ui/set-row-expanded path (not expanded?)]))}
|
||||
(when expandable? (if expanded? "▾" "▸"))]
|
||||
;; A LANE IS NOT AN INSTANCE WEARING A DIFFERENT HAT, to read. Its one row
|
||||
;; holds blocks that follow one another in time, where every other row
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue