The timeline's bar shows what the selection can take

Blender's transport: the ends, the keys either side, a frame, play. Speed
is one button that steps. In and out set the loop marks, as I and O do.
Between them and making things, only what the selection can have done to
it: key and blank in a lane, - and = on anything with a span, split where
the playhead cuts it, and peg on one node, which leaves the edit menu with
nothing a key does not already do, so it goes. A button and its key send
the same thing, from one function.

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-10 23:21:49 -04:00
parent 2f6fde26fb
commit 0291d7c628
6 changed files with 142 additions and 93 deletions

View file

@ -30,6 +30,7 @@
(def ^:private glyphs (def ^:private glyphs
{:start {:fill ["M2 2.5h1.3v7H2z" ; the bar it stops against {:start {:fill ["M2 2.5h1.3v7H2z" ; the bar it stops against
"M10 2.5v7L4.2 6z"]} ; and the triangle into it "M10 2.5v7L4.2 6z"]} ; and the triangle into it
:end {:fill ["M8.7 2.5H10v7H8.7z" "M2 2.5v7L7.8 6z"]}
:play {:fill ["M3.4 2.3L10 6 3.4 9.7z"]} :play {:fill ["M3.4 2.3L10 6 3.4 9.7z"]}
:pause {:fill ["M3.3 2.4h1.9v7.2H3.3z" :pause {:fill ["M3.3 2.4h1.9v7.2H3.3z"
"M6.8 2.4h1.9v7.2H6.8z"]} "M6.8 2.4h1.9v7.2H6.8z"]}

View file

@ -24,7 +24,6 @@
(:require [arthur.events.history :as history] (:require [arthur.events.history :as history]
[arthur.events.playback :as pb] [arthur.events.playback :as pb]
[arthur.events.ui :as ui] [arthur.events.ui :as ui]
[arthur.footage.store :as store]
[arthur.ui.layout :as layout] [arthur.ui.layout :as layout]
[arthur.ui.timeline :as timeline] [arthur.ui.timeline :as timeline]
[clojure.string :as str] [clojure.string :as str]
@ -32,27 +31,6 @@
[re-frame.db :as db] [re-frame.db :as db]
[reagent.core :as r])) [reagent.core :as r]))
(defn stops
"The frames ↑ and ↓ stop on: every key and every clip edge the timeline shows,
as frames of the open symbol. In a lane that is drawing to drawing, on a tween
key to key — one rule, read off the rows the timeline draws, so a jump lands
on something you can see."
[db]
(let [{document :clip} (store/entry (:clip/current db))
selection (get-in db [:ui :selection])
n (pb/frames db)]
(into (sorted-set)
(comp (mapcat (fn [{:keys [keys span cels]}]
(concat keys span (mapcat (juxt :span :keys) cels))))
(mapcat #(if (number? %) [%] %))
;; The first whole frame that shows it, forgiving the rounding
;; a mapped key picks up on its way through a clock.
(map #(js/Math.ceil (- % 1e-6)))
(filter #(< -1 % n)))
(when document
(timeline/rows document (get-in db [:ui :open]) (get-in db [:ui :expanded])
(when (= :node (first selection)) (nth selection 3)))))))
(defn- frame [db] (get-in db [:playback :frame] 0)) (defn- frame [db] (get-in db [:playback :frame] 0))
(defn- seek [f] [::pb/seek f]) (defn- seek [f] [::pb/seek f])
@ -62,12 +40,10 @@
:note "hold and drag on the stage to pan"} :note "hold and drag on the stage to pan"}
{:label "Previous frame" :keys ["ArrowLeft" "a"] :run #(seek (dec (frame %)))} {:label "Previous frame" :keys ["ArrowLeft" "a"] :run #(seek (dec (frame %)))}
{:label "Next frame" :keys ["ArrowRight" "d"] :run #(seek (inc (frame %)))} {:label "Next frame" :keys ["ArrowRight" "d"] :run #(seek (inc (frame %)))}
{:label "Previous key" :keys ["ArrowDown" "s"] {:label "Previous key" :keys ["ArrowDown" "s"] :run timeline/prev-key}
:run #(some-> (first (rsubseq (stops %) < (frame %))) seek)} {:label "Next key" :keys ["ArrowUp" "w"] :run timeline/next-key}
{:label "Next key" :keys ["ArrowUp" "w"]
:run #(some-> (first (subseq (stops %) > (frame %))) seek)}
{:label "First frame" :keys ["Home" "shift+ArrowLeft" "shift+a"] :run (constantly (seek 0))} {:label "First frame" :keys ["Home" "shift+ArrowLeft" "shift+a"] :run (constantly (seek 0))}
{:label "Last frame" :keys ["End" "shift+ArrowRight" "shift+d"] :run #(seek (dec (pb/frames %)))} {:label "Last frame" :keys ["End" "shift+ArrowRight" "shift+d"] :run timeline/last-frame}
{:label "Mark in" :keys ["i"] :run (constantly [::pb/mark :in]) {:label "Mark in" :keys ["i"] :run (constantly [::pb/mark :in])
:note "playback loops between the marks"} :note "playback loops between the marks"}
{:label "Mark out" :keys ["o"] :run (constantly [::pb/mark :out])} {:label "Mark out" :keys ["o"] :run (constantly [::pb/mark :out])}
@ -83,12 +59,12 @@
["Animate" ["Animate"
[{:label "Key here" :keys ["k"] [{:label "Key here" :keys ["k"]
:note "in a lane, a copy of the drawing from the playhead on" :note "in a lane, a copy of the drawing from the playhead on"
:run #(if (ui/lane-here %) [::ui/drawing-here true] [::ui/key-selected])} :run timeline/key-here}
{:label "Blank drawing here" :keys ["shift+k"] :run (constantly [::ui/drawing-here false])} {:label "Blank drawing here" :keys ["shift+k"] :run (constantly [::ui/drawing-here false])}
{:label "One frame longer" :keys ["=" "+"] :note "moves the end of the selection's span" {:label "One frame longer" :keys ["=" "+"] :note "moves the end of the selection's span"
:run #(when-let [p (ui/span-path %)] [::ui/slide p 1 :out true])} :run (timeline/hold 1)}
{:label "One frame shorter" :keys ["-"] {:label "One frame shorter" :keys ["-"]
:run #(when-let [p (ui/span-path %)] [::ui/slide p -1 :out true])}]] :run (timeline/hold -1)}]]
["Make" ["Make"
[{:label "New symbol" :keys ["n"] :run (constantly [::ui/new :inside false]) [{:label "New symbol" :keys ["n"] :run (constantly [::ui/new :inside false])
:note "in the selected symbol; in a lane, a blank drawing"} :note "in the selected symbol; in a lane, a blank drawing"}

View file

@ -41,6 +41,7 @@
[arthur.ui.layout :as layout] [arthur.ui.layout :as layout]
[arthur.ui.player :as player] [arthur.ui.player :as player]
[re-frame.core :as rf] [re-frame.core :as rf]
[re-frame.db :as rf-db]
[reagent.core :as r])) [reagent.core :as r]))
;; --------------------------------------------------------------------------- ;; ---------------------------------------------------------------------------
@ -497,9 +498,60 @@
(aget cel "arthurCel"))) (aget cel "arthurCel")))
(array-seq (.elementsFromPoint js/document (.-clientX event) (.-clientY event))))) (array-seq (.elementsFromPoint js/document (.-clientX event) (.-clientY event)))))
(defn stops
"The frames ↑ and ↓ stop on: every key and every clip edge the timeline shows,
as frames of the open symbol. In a lane that is drawing to drawing, on a tween
key to key — one rule, read off the rows the timeline draws, so a jump lands
on something you can see."
[db]
(let [{document :clip} (store/entry (:clip/current db))
selection (get-in db [:ui :selection])
n (pb/frames db)]
(into (sorted-set)
(comp (mapcat (fn [{:keys [keys span cels]}]
(concat keys span (mapcat (juxt :span :keys) cels))))
(mapcat #(if (number? %) [%] %))
;; The first whole frame that shows it, forgiving the rounding
;; a mapped key picks up on its way through a clock.
(map #(js/Math.ceil (- % 1e-6)))
(filter #(< -1 % n)))
(when document
(rows document (get-in db [:ui :open]) (get-in db [:ui :expanded])
(when (= :node (first selection)) (nth selection 3)))))))
(defn- at [db] (get-in db [:playback :frame] 0))
;; WHAT A KEY AND ITS BUTTON BOTH SEND, as functions of the db answering the
;; event, or nil for nothing to do. `ui/shortcuts` puts them on keys and the
;; toolbar on buttons, so the two cannot come to mean different things.
(defn prev-key [db] (some->> (first (rsubseq (stops db) < (at db))) (vector ::pb/seek)))
(defn next-key [db] (some->> (first (subseq (stops db) > (at db))) (vector ::pb/seek)))
(defn last-frame [db] [::pb/seek (dec (pb/frames db))])
(defn key-here
"K: in a lane, a new drawing from the playhead on, copying the one there; on
anything else, a key of what is selected."
[db]
(if (ui/lane-here db) [::ui/drawing-here true] [::ui/key-selected]))
(defn hold
"= and −: the end of the selection's span, `delta` frames later."
[delta]
(fn [db] (when-let [p (ui/span-path db)] [::ui/slide p delta :out true])))
(rf/reg-sub
::here
;; Which of the toolbar's commands mean something for the selection right now.
(fn [db _]
{:lane? (some? (ui/lane-here db))
:span? (some? (ui/span-path db))}))
;; --------------------------------------------------------------------------- ;; ---------------------------------------------------------------------------
;; the panes ;; the panes
(def ^:private speeds [[0.25 "¼×"] [0.5 "½×"] [1 "1×"] [2 "2×"] [4 "4×"]])
(defn- transport [] (defn- transport []
(let [playing? @(rf/subscribe [::playback/playing?]) (let [playing? @(rf/subscribe [::playback/playing?])
rate @(rf/subscribe [::playback/rate]) rate @(rf/subscribe [::playback/rate])
@ -536,14 +588,27 @@
host (when (number? owner-frame) (span/host-frame clip sid id owner-frame)) host (when (number? owner-frame) (span/host-frame clip sid id owner-frame))
cuttable? (and span? (integer? host) cuttable? (and span? (integer? host)
(let [[lo hi] (node/placed-span n)] (< lo host hi))) (let [[lo hi] (node/placed-span n)] (< lo host hi)))
act (fn [event] #(rf/dispatch event))] act (fn [event] #(rf/dispatch event))
;; A command that reads the db when it is pressed, as a key does.
run (fn [f] #(some-> (f @rf-db/app-db) rf/dispatch))
here @(rf/subscribe [::here])
marks @(rf/subscribe [::playback/range])
selections @(rf/subscribe [::sub/selections])
;; A peg goes over ONE node: it takes that node's place in the
;; hierarchy, and there is no one place a pair of them would go.
one-node (when (= 1 (count selections))
(let [[kind _ _ path] (first selections)]
(when (and (= :node kind) (seq path)) path)))]
[:div.pane-head [:div.pane-head
;; ----------------------------------------------------------------- time ;; ----------------------------------------------------------------- time
;; Where the playhead is and how it moves. Nothing here depends on a ;; Where the playhead is and how it moves. Nothing here depends on a
;; selection, which is why it is the one group that is never greyed. ;; selection, which is why it is the one group that is never greyed.
;; Blender's timeline header: the ends, the keys, a frame, play.
[:div.group [:div.group
[:button.ico {:aria-label "go to start" :title "go to the first frame (Home)" [:button.ico {:aria-label "go to start" :title "go to the first frame (Home)"
:on-click (act [::pb/seek 0])} [icon/view :start]] :on-click (act [::pb/seek 0])} [icon/view :start]]
[:button.ico {:aria-label "previous key" :title "back to the key or drawing before (↓ or S)"
:on-click (run prev-key)} [icon/view :prev]]
[:button {:aria-label "−1" :title "step back one frame (← or A)" [:button {:aria-label "−1" :title "step back one frame (← or A)"
:on-click (act [::pb/step -1])} "−1"] :on-click (act [::pb/step -1])} "−1"]
[:button.ico.ico-play {:aria-label (if playing? "pause" "play") [:button.ico.ico-play {:aria-label (if playing? "pause" "play")
@ -551,7 +616,11 @@
:on-click (act [::pb/toggle])} :on-click (act [::pb/toggle])}
[icon/view (if playing? :pause :play)]] [icon/view (if playing? :pause :play)]]
[:button {:aria-label "+1" :title "step forward one frame (→ or D)" [:button {:aria-label "+1" :title "step forward one frame (→ or D)"
:on-click (act [::pb/step 1])} "+1"]] :on-click (act [::pb/step 1])} "+1"]
[:button.ico {:aria-label "next key" :title "on to the key or drawing after (↑ or W)"
:on-click (run next-key)} [icon/view :next]]
[:button.ico {:aria-label "go to end" :title "go to the last frame (End)"
:on-click (run last-frame)} [icon/view :end]]]
[:div.group [:div.group
[:button.ico {:class (when loop? "on") :aria-label "loop" [:button.ico {:class (when loop? "on") :aria-label "loop"
:title "loop playback" :on-click (act [::pb/toggle-loop])} :title "loop playback" :on-click (act [::pb/toggle-loop])}
@ -563,36 +632,68 @@
;; read WHILE scrubbing, and tabular figures keep it from twitching as it ;; read WHILE scrubbing, and tabular figures keep it from twitching as it
;; counts. ;; counts.
[:span.readout.at-frame (str frame " / " frames)] [:span.readout.at-frame (str frame " / " frames)]
;; Five buttons for one mutually exclusive choice that is 1× almost always. ;; ONE BUTTON THAT SAYS THE SPEED AND STEPS IT, rather than a menu: it is
;; A select says "pick one of these" in the width of the answer. ;; 1× almost always, and a click is all the other four are away. Shift goes
;; playbackRate on the audio element and nothing else: the sound slows, ;; back. playbackRate on the audio element and nothing else: the sound
;; currentTime advances proportionally, and the derived frame follows. Slow ;; slows, currentTime advances proportionally, and the derived frame
;; motion cannot desync by construction. ;; follows. Slow motion cannot desync by construction.
[:span.pick (let [i (or (first (keep-indexed #(when (= rate (first %2)) %1) speeds)) 2)]
[:select {:value rate :aria-label "playback speed" :title "playback speed" [:button.speed {:class (when (not= 1 rate) "on") :aria-label "playback speed"
:on-change #(rf/dispatch [::pb/set-rate :title "playback speed · click for faster, shift-click for slower"
(js/parseFloat (.. % -target -value))])} :on-click (fn [^js e]
(doall (for [[r label] [[0.25 "¼×"] [0.5 "½×"] [1.0 "1×"] [2.0 "2×"] [4.0 "4×"]]] (let [j (mod (+ i (if (.-shiftKey e) -1 1)) (count speeds))]
^{:key r} [:option {:value r} label]))]] (rf/dispatch [::pb/set-rate (first (nth speeds j))])))}
[:span.sep] (second (nth speeds i))])
;; The same direct timing operations apply to any selected symbol clip, ;; Resolve's I and O: where playback loops in the open tab. Lit while set,
;; whether it is placed freely or lives in a lane. ;; and shift takes one away, as on the keys.
[:div.group.timing-controls {:aria-label "timing"} [:div.group {:aria-label "loop marks"}
[:button {:disabled (not cuttable?) :aria-label "split" (doall
:title "split the selected clip at the playhead" (for [[which word k] [[:in "in" "I"] [:out "out" "O"]]]
:on-click (act [::ui/split])} "split"] ^{:key which}
[:button {:disabled (not cuttable?) :aria-label "trim in" [:button {:class (when (get marks which) "on")
:title "move the selected clip's start to the playhead" :title (str "mark " word " at the playhead (" k ")"
:on-click (act [::ui/trim :in])} "in"] " · shift-click clears it (⇧" k ")")
[:button {:disabled (not cuttable?) :aria-label "trim out" :on-click (fn [^js e]
:title "move the selected clip's end to the playhead" (rf/dispatch (if (.-shiftKey e)
:on-click (act [::ui/trim :out])} "out"]] [::pb/clear-mark which]
[::pb/mark which])))}
word]))]
[:span.sep] [:span.sep]
;; WHAT THE SELECTION CAN HAVE DONE TO IT, and nothing else. A drawing in
;; a lane takes a new drawing and a longer hold; a symbol placed anywhere
;; takes a cut and a longer span; a node takes a key and a peg. Shown, not
;; greyed, so the strip says what is possible here, and each says its key.
(let [{:keys [lane?] hold? :span?} here]
[:div.group.context-controls {:aria-label "selection"}
(when (or lane? one-node)
[:button {:title (if lane?
"a new drawing from the playhead on, copying the one there (K)"
"key the selection at the playhead (K)")
:on-click (run key-here)} "◆ key"])
(when lane?
[:button {:title "a blank drawing from the playhead on (⇧K)"
:on-click (act [::ui/drawing-here false])} "□ blank"])
(when hold?
[:<>
[:button {:aria-label "one frame shorter" :title "one frame shorter (−)"
:on-click (run (hold -1))} "−"]
[:button {:aria-label "one frame longer" :title "one frame longer (=)"
:on-click (run (hold 1))} "="]])
(when cuttable?
[:button {:title "split the selected clip at the playhead"
:on-click (act [::ui/split])} "split"])
(when (and one-node (not lane?))
;; The only way to keep a pivot, and the only way to transform a
;; measured part by hand — which is what `gesture/refusal` tells you
;; to do, so it has to be reachable from somewhere.
[:button {:title "a transform node over the selection · ⌃/⌘-drag its cross to place the pivot"
:on-click (act [::ui/peg one-node])} "peg"])])
[:span.spacer]
[:div.group.creation-controls {:aria-label "create"} [:div.group.creation-controls {:aria-label "create"}
[:button {:title "create a symbol in the selected location" [:button {:title "create a symbol in the selected location (N)"
:on-click (act [::ui/new-symbol :inside])} :on-click (act [::ui/new-symbol :inside])}
[icon/view :symbol] " symbol"] [icon/view :symbol] " symbol"]
[:button {:title "create a lane in the selected location" [:button {:title "create a lane in the selected location (⇧N)"
:on-click (act [::ui/new-lane])} :on-click (act [::ui/new-lane])}
[icon/view :lane] " lane"]] [icon/view :lane] " lane"]]
[:button.auto-key {:class (when auto? "on") [:button.auto-key {:class (when auto? "on")
@ -602,7 +703,7 @@
"auto-key edited parameters at this frame") "auto-key edited parameters at this frame")
:on-click (act [::ui/toggle-auto-key])} :on-click (act [::ui/toggle-auto-key])}
"◆ auto key"] "◆ auto key"]
[:span.spacer] [:span.sep]
;; How many pixels a frame is. The tracks are positioned in percentages of ;; How many pixels a frame is. The tracks are positioned in percentages of
;; their own width, so this is one custom property on the grid and no ;; their own width, so this is one custom property on the grid and no
;; arithmetic here — see `ui/layout`. ;; arithmetic here — see `ui/layout`.

View file

@ -8,11 +8,8 @@
(:require [arthur.events.collab :as collab] (:require [arthur.events.collab :as collab]
[arthur.events.export :as export] [arthur.events.export :as export]
[arthur.events.project :as project] [arthur.events.project :as project]
[arthur.events.ui :as ui]
[arthur.subs.playback :as playback] [arthur.subs.playback :as playback]
[arthur.subs.ui :as sub]
[arthur.ui.layout :as layout] [arthur.ui.layout :as layout]
[arthur.ui.menu :as menu]
[arthur.ui.openmenu :as openmenu] [arthur.ui.openmenu :as openmenu]
[arthur.ui.settings :as settings] [arthur.ui.settings :as settings]
[arthur.ui.share :as share] [arthur.ui.share :as share]
@ -57,14 +54,6 @@
(let [{project-name :name project-seq :seq :keys [busy? status]} @(rf/subscribe [::playback/project]) (let [{project-name :name project-seq :seq :keys [busy? status]} @(rf/subscribe [::playback/project])
{footage-status :status} @(rf/subscribe [::playback/footage]) {footage-status :status} @(rf/subscribe [::playback/footage])
{export-status :status} @(rf/subscribe [::export/state]) {export-status :status} @(rf/subscribe [::export/state])
selections @(rf/subscribe [::sub/selections])
clipboard @(rf/subscribe [::sub/clipboard])
selected? (boolean (seq selections))
;; A peg goes over ONE node: it takes that node's place in the
;; hierarchy, and there is no one place a pair of them would go.
one-node (when (= 1 (count selections))
(let [[kind _ _ path] (first selections)]
(when (and (= :node kind) (seq path)) path)))
title (or project-name "untitled") title (or project-name "untitled")
commit! (fn [] commit! (fn []
(rf/dispatch [::project/rename @draft]) (rf/dispatch [::project/rename @draft])
@ -79,27 +68,6 @@
[settings/new-project "new"] [settings/new-project "new"]
[openmenu/view] [openmenu/view]
[undo/view] [undo/view]
[menu/view
{:label "edit" :title "selection and clipboard"
:items [{:label "copy" :sub "Copy selection · ⌘/Ctrl C"
:disabled? (not selected?) :on-click #(rf/dispatch [::ui/copy])}
{:label "cut" :sub "Cut selection · ⌘/Ctrl X"
:disabled? (not selected?) :on-click #(rf/dispatch [::ui/cut])}
{:label "paste" :sub "Paste at playhead into the active row · ⌘/Ctrl V"
:disabled? (nil? clipboard) :on-click #(rf/dispatch [::ui/paste])}
{:label "duplicate" :sub "Duplicate beside selection; lanes repeat forward · ⌘/Ctrl D"
:disabled? (not selected?) :on-click #(rf/dispatch [::ui/duplicate])}
{:label "duplicate unique"
:sub "Duplicate with a private nested symbol graph · ⇧⌘/Ctrl D"
:disabled? (not selected?)
:on-click #(rf/dispatch [::ui/duplicate-unique])}
;; The only way to keep a pivot, and the only way to transform a
;; measured part by hand — which is what `gesture/refusal` tells
;; you to do, so it has to be reachable from somewhere.
{:label "add peg"
:sub "A transform node over the selection · ⌃/⌘-drag its cross to place the pivot"
:disabled? (nil? one-node)
:on-click #(rf/dispatch [::ui/peg one-node])}]}]
[snapshots/view] [snapshots/view]
(if @renaming? (if @renaming?
[:input.project-name {:auto-focus true :value @draft [:input.project-name {:auto-focus true :value @draft

View file

@ -2,7 +2,7 @@
(:require [cljs.test :refer [deftest is]] (:require [cljs.test :refer [deftest is]]
[arthur.domain.sequence-test :as fixture] [arthur.domain.sequence-test :as fixture]
[arthur.footage.store :as store] [arthur.footage.store :as store]
[arthur.ui.shortcuts :as shortcuts])) [arthur.ui.timeline :as timeline]))
(deftest the-key-jumps-stop-on-every-cel-edge-and-key-the-timeline-shows (deftest the-key-jumps-stop-on-every-cel-edge-and-key-the-timeline-shows
;; Cels at 0, 4 and 8; `:b` keyed on its own frames 0 and 1, which it shows ;; Cels at 0, 4 and 8; `:b` keyed on its own frames 0 and 1, which it shows
@ -10,4 +10,4 @@
;; last frame and is not somewhere to stand. ;; last frame and is not somewhere to stand.
(let [id (store/install! {:clip (fixture/document) :store {}} "shortcut-stops")] (let [id (store/install! {:clip (fixture/document) :store {}} "shortcut-stops")]
(is (= [0 4 5 8 11] (is (= [0 4 5 8 11]
(vec (shortcuts/stops {:clip/current id :ui {:open :main}})))))) (vec (timeline/stops {:clip/current id :ui {:open :main}}))))))

View file

@ -1024,6 +1024,9 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
.loc-shared { flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 5px; } .loc-shared { flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 5px; }
.loc .spacer { flex: 1; } .loc .spacer { flex: 1; }
.creation-controls button { display: inline-flex; align-items: center; gap: 4px; } .creation-controls button { display: inline-flex; align-items: center; gap: 4px; }
/* Wide enough for the widest speed it steps through, so the strip does not
shift as it changes. */
.pane-head button.speed { min-width: 3.2em; font-variant-numeric: tabular-nums; }
.creation-controls svg { width: 11px; height: 11px; } .creation-controls svg { width: 11px; height: 11px; }
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------