forge
Explore
Log in

Don't you dare go Hollow

🔥 remove(ui): the legacy tree — darkroom is the only room

Browse files at this commit

5dcc6c244030c27d97ac5790b20a677c1c0ecb6cAhmet Kaan GümüşParent: 6da98cd
Delete the whole legacy UI (timeline.rs, toolbar.rs, inspector.rs, legacy
render body, OLD_GUI gate — the env read is gone, not a switch) and every
helper only it reached: ~6,900 LOC out. Darkroom stance is the only room.

Real gaps the removal flushed out, fixed here:
- typed bitrate in the export card was completely dead — NumberEdit
  digits/backspace/enter/esc now wired in param_card_key
- ActionId::CancelExport was a no-op while the progress card promised the
  chord — now calls cancel_export (ctrl+esc, oracle-enabled during export)
- actions card had no pointer entry — "?" ghost is clickable, scrim
  click closes, inner list swallows
- snap toggle got a button beside zoom-fit in the VIEW group

Dead-by-construction machinery deleted with its tests: key rebinding
(rebinding/rebind_action/capture never set live), keys_search (no search
box exists), cancels_export/format_key/next_audio_kbps, 17 layout.rs
consts/fns, and the rest of the 32 no-—tests dead-code warnings; both
`cargo build -p edith` and `--tests` are warning-free, 245 tests green.

38 changed files +709 -7365

DESIGN.mdmodified+2 -1
@@ -178,7 +178,8 @@ capability is genuinely absent — otherwise it is a bug, not a message. A verb
178 verbs; source dot: ink acts). Plate styling, chords on every row, destructive verbs below a178 verbs; source dot: ink acts). Plate styling, chords on every row, destructive verbs below a
179 rule line. Never a junk drawer.179 rule line. Never a junk drawer.
180 - **`?` held** dims the room one fill step and surfaces chords *in place* beside their controls;180 - **`?` held** dims the room one fill step and surfaces chords *in place* beside their controls;
181- release restores. No modal cheat-sheet; learning stays geographic. The film keeps playing.181+ release restores, and a click on the scrim also dismisses it. Hold-to-peek, not a latch;
182+ learning stays geographic. The film keeps playing.
182 183
183 **Amendment (2026-08-20), explicit per this section's own rule:** the geographic reading above184 **Amendment (2026-08-20), explicit per this section's own rule:** the geographic reading above
184 is only partly built and edith currently ships the fallback instead — named here rather than185 is only partly built and edith currently ships the fallback instead — named here rather than
crates/app/src/export_ui.rsmodified+0 -32
@@ -262,19 +262,6 @@ pub(crate) const FORMATS: [(&[Format], &str, &str, &str); 8] = [
262 (&[], "", "VP9", "AV1 above replaces it"),262 (&[], "", "VP9", "AV1 above replaces it"),
263 ];263 ];
264 264
265-/// The codec row a key picks, landed in the container already chosen: pressing
266-/// `a` after an mp4 gives AV1 *in mp4*, because a box decided once is not a
267-/// question again. A letter of the row's own name, spelled out in the table
268-/// rather than taken from the initial (`MP4` and `MP3` share one). Never a
269-/// digit -- those are the bitrate field's. `None` for every other stroke, the rows
270-/// that cannot be picked included.
271-pub(crate) fn format_key(key: &str, current: Format) -> Option<Format> {
272- FORMATS
273- .into_iter()
274- .filter(|(_, stroke, ..)| !stroke.is_empty() && stroke.eq_ignore_ascii_case(key))
275- .find_map(|(row, ..)| same_box(row, current))
276-}
277-
278 /// The boxes one codec may be written into, in the order its container row265 /// The boxes one codec may be written into, in the order its container row
279 /// cycles them. Empty for a codec this program cannot write at all.266 /// cycles them. Empty for a codec this program cannot write at all.
280 pub(crate) fn containers(format: Format) -> &'static [Format] {267 pub(crate) fn containers(format: Format) -> &'static [Format] {
@@ -306,14 +293,6 @@ pub(crate) fn next_container(format: Format) -> Format {
306 .unwrap_or(format)293 .unwrap_or(format)
307 }294 }
308 295
309-/// The next rate the Sound row offers, wrapping -- what its key does, and what
310-/// the row itself names so the stroke is never a guess. [`next_container`]'s
311-/// shape, for the same reason: one place decides what "next" means.
312-pub(crate) fn next_audio_kbps(kbps: u32) -> u32 {
313- let at = AUDIO_KBPS.iter().position(|&k| k == kbps).unwrap_or(0);
314- AUDIO_KBPS[(at + 1) % AUDIO_KBPS.len()]
315-}
316-
317 /// Why the quality rows say nothing about this format, or `None` where they296 /// Why the quality rows say nothing about this format, or `None` where they
318 /// decide the picture. Only a picture encoder is given a bitrate here: the two297 /// decide the picture. Only a picture encoder is given a bitrate here: the two
319 /// lossless audio formats have none to give and MP3 is written at one fixed298 /// lossless audio formats have none to give and MP3 is written at one fixed
@@ -1028,17 +1007,6 @@ pub(crate) fn commit_mbps(text: &str) -> Result<u32, String> {
1028 }1007 }
1029 }1008 }
1030 1009
1031-/// Whether a stroke gets out of a running export. `ctrl+escape` does -- a chord
1032-/// and not the bare key, which used to end an hour of encoding on the stroke a
1033-/// hand reaches for to shut a menu it has already shut. Bare escape does nothing
1034-/// at all here: the progress card is not dismissable, so there is nothing left
1035-/// for it to mean. Whatever the keymap has on cancel works too, so rebinding it
1036-/// adds a way rather than replacing this one -- and that binding is what the
1037-/// card shows.
1038-pub(crate) fn cancels_export(key: &str, ctrl: bool, action: Option<ActionId>) -> bool {
1039- (ctrl && key == ESCAPE) || action == Some(ActionId::CancelExport)
1040-}
1041-
1042 /// A clip's share of the lane. A timeline with no length reads as one full-width1010 /// A clip's share of the lane. A timeline with no length reads as one full-width
1043 /// box rather than as NaN, which gpui would carry into layout.1011 /// box rather than as NaN, which gpui would carry into layout.
1044 /// Why this timeline cannot be written in `format`, if it cannot.1012 /// Why this timeline cannot be written in `format`, if it cannot.
crates/app/src/importing.rsmodified+0 -21
@@ -109,27 +109,6 @@ pub(crate) enum Proxy {
109 Failed,109 Failed,
110 }110 }
111 111
112-impl Proxy {
113- /// What the library row says about it, or nothing at all for a file that
114- /// never wanted one -- a row per source is not the place to announce that
115- /// nothing is happening.
116- pub(crate) fn detail(&self) -> String {
117- match self {
118- Self::Asked | Self::Native => String::new(),
119- // Rounded down: a bar that says 100% while the encoder is still
120- // writing is the one number a progress line must never show.
121- Self::Making(job) => format!("proxy {}%", (job.progress() * 100.) as u32),
122- // Its own word while the worker is still winding down: "no proxy"
123- // the instant the × is clicked would be a claim about a file that
124- // is at that moment still being written.
125- Self::Cancelling(_) => "proxy stopping…".to_string(),
126- Self::Cancelled => "no proxy — stopped".to_string(),
127- Self::Ready => "proxy".to_string(),
128- Self::Failed => "no proxy".to_string(),
129- }
130- }
131-}
132-
133 /// The import a worker is reading, as the line above the panel shows it. No112 /// The import a worker is reading, as the line above the panel shows it. No
134 /// fraction anywhere: neither read reports how far into the file it has come,113 /// fraction anywhere: neither read reports how far into the file it has come,
135 /// so what is honest is the file's name, the stage, and two clocks -- one that114 /// so what is honest is the file's name, the stage, and two clocks -- one that
crates/app/src/interact.rsmodified+4 -20
@@ -194,7 +194,7 @@ pub(crate) fn scrim() -> Div {
194 /// is old too". A plate is `panel` with a seam around it and a 6px radius194 /// is old too". A plate is `panel` with a seam around it and a 6px radius
195 /// (DESIGN §2/§4); the legacy tree keeps its own raised sheet. One function,195 /// (DESIGN §2/§4); the legacy tree keeps its own raised sheet. One function,
196 /// so the next change reaches all three or none.196 /// so the next change reaches all three or none.
197-pub(crate) fn menu_plate(id: &'static str, x: f32, y: f32, darkroom: bool) -> Stateful<Div> {197+pub(crate) fn menu_plate(id: &'static str, x: f32, y: f32) -> Stateful<Div> {
198 div()198 div()
199 .id(id)199 .id(id)
200 .absolute()200 .absolute()
@@ -205,15 +205,9 @@ pub(crate) fn menu_plate(id: &'static str, x: f32, y: f32, darkroom: bool) -> St
205 .flex_col()205 .flex_col()
206 .p(px(crate::layout::MENU_PAD))206 .p(px(crate::layout::MENU_PAD))
207 .rounded(px(6.))207 .rounded(px(6.))
208- .bg(rgb(if darkroom {208+ .bg(rgb(crate::ui::theme::DARK_PANEL()))
209- crate::ui::theme::DARK_PANEL()209+ .border_1()
210- } else {210+ .border_color(rgba(crate::ui::theme::DARK_SEAM()))
211- crate::ui::theme::BG_RAISED()
212- }))
213- .when(darkroom, |d| {
214- d.border_1()
215- .border_color(rgba(crate::ui::theme::DARK_SEAM()))
216- })
217 }211 }
218 212
219 /// The sheet a card with a *slider* in it takes instead: the same scrim, with213 /// The sheet a card with a *slider* in it takes instead: the same scrim, with
@@ -334,13 +328,3 @@ pub(crate) fn repeats(scope: Repeat, key: &str, action: Option<ActionId>) -> boo
334 }328 }
335 }329 }
336 330
337-/// The keys that are only ever half a chord. gpui delivers a lone modifier
338-/// press as a keystroke of its own, and taking one as a binding would leave an
339-/// action that fires the moment the user reaches for any chord that uses it --
340-/// so a capture waits through them instead.
341-pub(crate) fn is_bare_modifier(key: &str) -> bool {
342- matches!(
343- key,
344- "control" | "shift" | "alt" | "super" | "platform" | "function" | "fn" | "meta" | "command"
345- )
346-}
crates/app/src/keymap.rsmodified+20 -105
@@ -969,8 +969,8 @@ pub struct Binding {
969 }969 }
970 970
971 /// Every binding in force, in display order. No chord appears twice -- that is971 /// Every binding in force, in display order. No chord appears twice -- that is
972-/// the invariant [`Keymap::rebind_action`] and [`parse`] both defend, and it is what972+/// the invariant [`parse`] defends, and it is what lets [`Keymap::lookup`]
973-/// lets [`Keymap::lookup`] answer with the first match.973+/// answer with the first match.
974 #[derive(Clone, PartialEq, Eq, Debug)]974 #[derive(Clone, PartialEq, Eq, Debug)]
975 pub struct Keymap {975 pub struct Keymap {
976 bindings: Vec<Binding>,976 bindings: Vec<Binding>,
@@ -1284,9 +1284,9 @@ impl Keymap {
1284 /// The primary chord for `action`, compact ([`Chord::compact`]) -- a1284 /// The primary chord for `action`, compact ([`Chord::compact`]) -- a
1285 /// badge that has room for one token, not [`Keymap::display`]'s sentence.1285 /// badge that has room for one token, not [`Keymap::display`]'s sentence.
1286 /// The first bound stroke wins (`defaults`' own insertion order, and1286 /// The first bound stroke wins (`defaults`' own insertion order, and
1287- /// `rebind_action`'s "makes `chord` the whole of what reaches `action`"1287+ /// [`parse`]'s "no chord appears twice" leaves at most one anyway); an
1288- /// leaves at most one anyway); an action with no stroke reads `--`1288+ /// action with no stroke reads `--` rather than the unbound sentence,
1289- /// rather than the unbound sentence, since a badge is not a warning.1289+ /// since a badge is not a warning.
1290 pub fn chord(&self, action: ActionId) -> String {1290 pub fn chord(&self, action: ActionId) -> String {
1291 self.bindings1291 self.bindings
1292 .iter()1292 .iter()
@@ -1300,35 +1300,6 @@ impl Keymap {
1300 &self.bindings1300 &self.bindings
1301 }1301 }
1302 1302
1303- /// Makes `chord` the whole of what reaches `action`: its other chords go, so
1304- /// what the editor shows for an action is what a rebind replaced. Two
1305- /// strokes for one action stay expressible, but only in the file -- the
1306- /// parser takes as many lines per action as it is given.
1307- ///
1308- /// `Err` names the action that already holds the chord and nothing changes:
1309- /// two actions on one stroke would make the second unreachable, and silently
1310- /// stealing it is worse than refusing. A chord the action already holds is
1311- /// not a conflict with itself -- it collapses the action onto that one.
1312- pub fn rebind_action(&mut self, action: ActionId, chord: Chord) -> Result<(), ActionId> {
1313- if let Some(held) = self
1314- .bindings
1315- .iter()
1316- .find(|b| b.action != action && b.chord == chord)
1317- {
1318- return Err(held.action);
1319- }
1320- self.bindings.retain(|b| b.action != action);
1321- // Back into its own place in the display order rather than onto the end,
1322- // so the file and the editor keep reading in the order of `ALL`.
1323- let at = self
1324- .bindings
1325- .iter()
1326- .position(|b| rank(b.action) > rank(action))
1327- .unwrap_or(self.bindings.len());
1328- self.bindings.insert(at, Binding { action, chord });
1329- Ok(())
1330- }
1331-
1332 /// The keymap in force, and what to tell the user if the file could not be1303 /// The keymap in force, and what to tell the user if the file could not be
1333 /// used. A file that is merely absent is the normal case and says nothing;1304 /// used. A file that is merely absent is the normal case and says nothing;
1334 /// anything else -- unreadable, or a line this parser refuses -- falls back1305 /// anything else -- unreadable, or a line this parser refuses -- falls back
@@ -1414,15 +1385,6 @@ impl Keymap {
1414 }1385 }
1415 }1386 }
1416 1387
1417-/// Where an action sits in the display order, which is the order of
1418-/// [`ActionId::ALL`] and the order the file is written in.
1419-fn rank(action: ActionId) -> usize {
1420- ActionId::ALL
1421- .iter()
1422- .position(|a| *a == action)
1423- .unwrap_or(ActionId::ALL.len())
1424-}
1425-
1426 /// The path rule, with the environment handed in so it can be checked. An1388 /// The path rule, with the environment handed in so it can be checked. An
1427 /// `XDG_CONFIG_HOME` that is empty is one the spec says to ignore; with no1389 /// `XDG_CONFIG_HOME` that is empty is one the spec says to ignore; with no
1428 /// `HOME` either there is nowhere but here, and a relative path is still better1390 /// `HOME` either there is nowhere but here, and a relative path is still better
@@ -1743,67 +1705,13 @@ mod tests {
1743 assert!(!chord("", false).bindable());1705 assert!(!chord("", false).bindable());
1744 assert!(!chord("X", false).bindable());1706 assert!(!chord("X", false).bindable());
1745 assert!(!chord("page up", false).bindable());1707 assert!(!chord("page up", false).bindable());
1746- // A bindable chord is one `rebind_action` may keep: what it writes is1708+ // A bindable chord is one the file's own grammar can spell: what it
1747- // what the next load reads, for every stroke that passes here.1709+ // writes is what the next load reads, for every stroke that passes
1748- let mut k = Keymap::defaults();1710+ // here.
1749- // Any free chord will do here; ctrl+= is the zoom's.1711+ let k = whole("edith-keys 1\nplay ctrl+w\n");
1750- k.rebind_action(ActionId::Play, chord("w", true)).unwrap();
1751 assert_eq!(whole(&emit(&k)), k);1712 assert_eq!(whole(&emit(&k)), k);
1752 }1713 }
1753 1714
1754- #[test]
1755- fn rebinding_refuses_to_steal_another_actions_stroke() {
1756- let mut k = Keymap::defaults();
1757- assert_eq!(
1758- k.rebind_action(ActionId::Export, chord("space", false)),
1759- Err(ActionId::Play)
1760- );
1761- // Refused means unchanged, on both sides of the conflict.
1762- assert_eq!(k.lookup("e", false), Some(ActionId::Export));
1763- assert_eq!(k.lookup("space", false), Some(ActionId::Play));
1764- // And the refusal is a name, not a shrug: it is the holder's own label
1765- // the card prints back at the waiting row (`Player::capture`, "ALREADY
1766- // BOUND — space is Play / Pause").
1767- assert_eq!(ActionId::Play.label(), "Play / Pause");
1768- // A free stroke takes, and the old one stops meaning anything.
1769- assert_eq!(k.rebind_action(ActionId::Export, chord("w", true)), Ok(()));
1770- assert_eq!(k.lookup("w", true), Some(ActionId::Export));
1771- assert_eq!(k.lookup("e", false), None);
1772- assert_eq!(k.display(ActionId::Export), "ctrl+w");
1773- }
1774-
1775- #[test]
1776- fn a_rebound_action_keeps_only_the_new_stroke() {
1777- let mut k = Keymap::defaults();
1778- assert_eq!(k.display(ActionId::Delete), "x or delete");
1779- // One stroke replaces the whole set: what the row showed is what went.
1780- assert_eq!(k.rebind_action(ActionId::Delete, chord("d", true)), Ok(()));
1781- assert_eq!(k.display(ActionId::Delete), "ctrl+d");
1782- assert_eq!(k.lookup("x", false), None);
1783- assert_eq!(k.lookup("delete", false), None);
1784- assert_eq!(k.lookup("d", true), Some(ActionId::Delete));
1785- // One of its own chords is not a conflict with itself -- it collapses
1786- // the action onto that one.
1787- assert_eq!(k.rebind_action(ActionId::Undo, chord("z", true)), Ok(()));
1788- assert_eq!(k.display(ActionId::Undo), "ctrl+z");
1789- assert_eq!(k.lookup("z", false), None);
1790- // The action keeps its place in the display order, and the file keeps
1791- // reading in that order too. Deduped only for safety -- both actions
1792- // this test rebinds (Delete and Undo) started with two default
1793- // chords each, but both rebinds above collapse them to one, so no
1794- // action here still appears twice.
1795- let mut order: Vec<_> = k.entries().iter().map(|b| b.action).collect();
1796- order.dedup();
1797- assert_eq!(order, ActionId::ALL);
1798- assert_eq!(emit(&k), emit(&whole(&emit(&k))));
1799- // With Delete and Undo both collapsed to one chord, every action is
1800- // single-bound: one line each. The stride-10 walk
1801- // (WalkCutNext10/WalkCutPrev10) is its own action now, each bound to
1802- // exactly one literal chord (`>`/`<`), not a second chord on
1803- // WalkCutNext/WalkCutPrev.
1804- assert_eq!(k.entries().len(), ActionId::ALL.len());
1805- }
1806-
1807 #[test]1715 #[test]
1808 fn display_reads_as_a_person_would_say_it() {1716 fn display_reads_as_a_person_would_say_it() {
1809 let k = Keymap::defaults();1717 let k = Keymap::defaults();
@@ -1881,10 +1789,17 @@ mod tests {
1881 // Its own directory, never the real config one: this test writes.1789 // Its own directory, never the real config one: this test writes.
1882 let dir = Scratch::dir("edith-keymap");1790 let dir = Scratch::dir("edith-keymap");
1883 let path = dir.join("edith").join("keybindings");1791 let path = dir.join("edith").join("keybindings");
1884- let mut written = Keymap::defaults();1792+ // A defaults file with Export's own line swapped for a free stroke --
1885- written1793+ // parsed rather than rebound, since nothing left in the API mutates
1886- .rebind_action(ActionId::Export, chord("w", true))1794+ // a `Keymap` in place.
1887- .unwrap();1795+ let text: String = emit(&Keymap::defaults())
1796+ .lines()
1797+ .filter(|l| !l.starts_with("export "))
1798+ .chain(std::iter::once("export ctrl+w"))
1799+ .collect::<Vec<_>>()
1800+ .join("\n")
1801+ + "\n";
1802+ let written = whole(&text);
1888 // The config directory does not exist yet -- the first save makes it.1803 // The config directory does not exist yet -- the first save makes it.
1889 written.save_to(&path).unwrap();1804 written.save_to(&path).unwrap();
1890 let (read, notice) = Keymap::load_from(&path);1805 let (read, notice) = Keymap::load_from(&path);
crates/app/src/layout.rsmodified+0 -141
@@ -21,32 +21,8 @@ pub(crate) const PANEL_H: f32 = 220.;
21 /// timeline that pushes the video off the window is not a timeline.21 /// timeline that pushes the video off the window is not a timeline.
22 pub(crate) const LANES_MAX: usize = 6;22 pub(crate) const LANES_MAX: usize = 6;
23 pub(crate) const LANE_H: f32 = 48.;23 pub(crate) const LANE_H: f32 = 48.;
24-/// A caption lane's own height, thinner than a media one: a subtitle box
25-/// carries a name, a rate badge and the cue band under it
26-/// ([`Player::lane_row`]) and none of a clip's waveform or its full-height
27-/// plate, so the strip that used to draw the whole row's worth of nothing is
28-/// the regression this constant undoes.
29-///
30-/// Floored at [`HIT_MIN`] rather than the 20 px a first pass at "thin" landed
31-/// on: the header's show/hide eye is the row's one surviving click target
32-/// once the remove button moves off it onto the right button
33-/// ([`Player::lane_row`]), and that eye fills the row's full height -- so
34-/// anything under `HIT_MIN` here is a WCAG 2.5.8 target shrunk to chase a
35-/// pixel count, not a thinner lane. This is the whole gap between the two
36-/// harness variants the task asked for: 20 is not shippable at all, 24 is,
37-/// so 24 is the only variant landed.
38-pub(crate) const SUB_LANE_H: f32 = HIT_MIN;
39-/// The lane header column: wide enough for `V1`/`A1` and fixed, so both lanes
40-/// and the ruler above them start at the same pixel and are the same width --
41-/// one x-to-time mapping for the whole timeline. `HEADER_GAP` is part of that
42-/// offset and is therefore shared by all three rows.
43-pub(crate) const HEADER_W: f32 = 40.;
44-pub(crate) const HEADER_GAP: f32 = 4.;
45 /// The label row inside a clip; a waveform paints under it, never through it.24 /// The label row inside a clip; a waveform paints under it, never through it.
46 pub(crate) const LABEL_H: f32 = 15.;25 pub(crate) const LABEL_H: f32 = 15.;
47-/// A clip narrower than this shows no name: two characters and an ellipsis say
48-/// nothing that the tint has not already said, and cost the picture a smear.
49-pub(crate) const LABEL_MIN_W: f32 = 36.;
50 /// Peak buckets per second of source. Fixed and modest on purpose: `peaks`26 /// Peak buckets per second of source. Fixed and modest on purpose: `peaks`
51 /// allocates one bucket per window, so a rate taken from anything the user can27 /// allocates one bucket per window, so a rate taken from anything the user can
52 /// influence is an allocation bomb -- and 40 is already finer than the pixels a28 /// influence is an allocation bomb -- and 40 is already finer than the pixels a
@@ -82,24 +58,11 @@ pub(crate) const HIT_MIN: f32 = 24.;
82 pub(crate) const LIBRARY_FRAC: f32 = 0.2;58 pub(crate) const LIBRARY_FRAC: f32 = 0.2;
83 pub(crate) const LIBRARY_MIN_W: f32 = 120.;59 pub(crate) const LIBRARY_MIN_W: f32 = 120.;
84 pub(crate) const LIBRARY_MAX_W: f32 = 220.;60 pub(crate) const LIBRARY_MAX_W: f32 = 220.;
85-/// A library row: a name over its duration, two lines and a click target, so
86-/// `HIT_MIN` binds it like every other one.
87-pub(crate) const ROW_H: f32 = 32.;
88-/// The tint swatch down the left of a row: the same colour that source's clips
89-/// wear in the lanes, which is the whole of the panel<->timeline association.
90-pub(crate) const SWATCH_W: f32 = 4.;
91-/// How far the encode has come, drawn under the stop square on a library row.
92-/// Inside a `HIT_MIN` cell with a little air each side, so the bar never reaches
93-/// the edge of the target it belongs to.
94-pub(crate) const PROXY_BAR_W: f32 = HIT_MIN - 10.;
95 pub(crate) const CONTROL_H: f32 = 28.;61 pub(crate) const CONTROL_H: f32 = 28.;
96 /// The volume slider beside its button: a hundred steps across it, so a pixel62 /// The volume slider beside its button: a hundred steps across it, so a pixel
97 /// is finer than a step and the drag reads as continuous.63 /// is finer than a step and the drag reads as continuous.
98 pub(crate) const VOLUME_W: f32 = 110.;64 pub(crate) const VOLUME_W: f32 = 110.;
99 pub(crate) const RULER_HIT_H: f32 = HIT_MIN;65 pub(crate) const RULER_HIT_H: f32 = HIT_MIN;
100-/// Wide enough for `HH:MM:SS:FF / HH:MM:SS:FF`, and fixed so changing digits
101-/// cannot push the layout around.
102-pub(crate) const TIME_W: f32 = 200.;
103 /// The keybindings card: a row per action, a title and a status line, inside a66 /// The keybindings card: a row per action, a title and a status line, inside a
104 /// 360 px tall window. The rows are click targets, so `HIT_MIN` binds them too.67 /// 360 px tall window. The rows are click targets, so `HIT_MIN` binds them too.
105 /// Wider than the export card, and for the same reason that one is wider than68 /// Wider than the export card, and for the same reason that one is wider than
@@ -110,16 +73,6 @@ pub(crate) const TIME_W: f32 = 200.;
110 /// than overprinting. Still inside the 640 px floor.73 /// than overprinting. Still inside the 640 px floor.
111 pub(crate) const KEYS_W: f32 = 480.;74 pub(crate) const KEYS_W: f32 = 480.;
112 pub(crate) const KEYS_ROW_H: f32 = HIT_MIN;75 pub(crate) const KEYS_ROW_H: f32 = HIT_MIN;
113-/// How much of the row list is on screen at once; past this it scrolls. What
114-/// keeps the card inside the smallest window no matter how many actions the
115-/// editor grows -- ten rows fit here, and the eleventh is a scroll away.
116-pub(crate) const KEYS_ROWS_H: f32 = 10. * KEYS_ROW_H;
117-/// The same for the export card, which carries two summary lines and a button
118-/// under its list and so has less room: a section header, six codecs, the
119-/// container, five qualities and the destination are more rows than a 360 px
120-/// window holds. Eight on screen, which is the whole format section and its
121-/// header -- what a user picks first is never behind a scroll.
122-pub(crate) const EXPORT_ROWS_H: f32 = 8. * KEYS_ROW_H;
123 /// The export card is wider than the keybindings one: its rows carry a key, a76 /// The export card is wider than the keybindings one: its rows carry a key, a
124 /// name *and* what the choice means, and the two summary lines under them state77 /// name *and* what the choice means, and the two summary lines under them state
125 /// the whole file. At `KEYS_W` every one of those wrapped to two lines, which is78 /// the whole file. At `KEYS_W` every one of those wrapped to two lines, which is
@@ -130,12 +83,6 @@ pub(crate) const EXPORT_W: f32 = 420.;
130 /// in the export card says what picks it, so the card is drivable by keyboard83 /// in the export card says what picks it, so the card is drivable by keyboard
131 /// without a legend to memorise.84 /// without a legend to memorise.
132 pub(crate) const EXPORT_KEY_W: f32 = 26.;85 pub(crate) const EXPORT_KEY_W: f32 = 26.;
133-/// Everything in the export card that is *not* the row list: the title, the
134-/// status line, the head and tail of the summary, the button, the gaps between
135-/// them and the padding around the lot. What the list may be is the window
136-/// minus this -- and never less than [`EXPORT_ROWS_H`], which is the number
137-/// that makes the card fit the 360 px floor.
138-pub(crate) const EXPORT_FIXED_H: f32 = 17. + 28. + 15. + 30. + CONTROL_H + 4. + 10. + 24.;
139 /// The menu a right-click on a clip opens: wide enough for the longest label86 /// The menu a right-click on a clip opens: wide enough for the longest label
140 /// beside the stroke that does the same thing, with the click targets `HIT_MIN`87 /// beside the stroke that does the same thing, with the click targets `HIT_MIN`
141 /// binds like every other list here.88 /// binds like every other list here.
@@ -170,26 +117,10 @@ pub(crate) fn sub_bottom(bars_h: f32) -> f32 {
170 /// the track is empty. The silence preview's marks are floored by it too -- they117 /// the track is empty. The silence preview's marks are floored by it too -- they
171 /// are the same kind of thing, a picture of where something is and no target.118 /// are the same kind of thing, a picture of where something is and no target.
172 pub(crate) const SUB_CUE_MIN_W: f32 = 2.;119 pub(crate) const SUB_CUE_MIN_W: f32 = 2.;
173-/// How much of the subtitle list in the library column is on screen at once,
174-/// past which it scrolls -- the media list above it is what keeps the height.
175-pub(crate) const SUB_ROWS_H: f32 = 3. * ROW_H;
176-/// The row naming the file a block of tracks came out of. Always drawn where
177-/// there is more than one file -- the list already scrolls past `SUB_ROWS_H`,
178-/// so a short window loses tracks under the fold rather than the name saying
179-/// whose they are. A click folds it, so it binds `HIT_MIN` like every other
180-/// target.
181-pub(crate) const SUB_HEAD_H: f32 = HIT_MIN;
182-/// How much of a subtitle row's width the file's name in front of the label may
183-/// take. Half: which file and which language are both worth reading, and a name
184-/// given the whole row is a row where the language is what gets truncated.
185-pub(crate) const SUB_STEM_SHARE: f32 = 0.5;
186 /// Roughly how wide one character of an 11 px list row is. Generous on purpose:120 /// Roughly how wide one character of an 11 px list row is. Generous on purpose:
187 /// the element truncates for real, and a budget that overshoots would have the121 /// the element truncates for real, and a budget that overshoots would have the
188 /// element cut the tail off after [`clip_middle`] had already kept it.122 /// element cut the tail off after [`clip_middle`] had already kept it.
189 pub(crate) const LIST_CHAR_W: f32 = 6.;123 pub(crate) const LIST_CHAR_W: f32 = 6.;
190-/// The fewest characters a clipped name is cut to, however narrow the column
191-/// gets: past this there is nothing on either side of the gap to read.
192-pub(crate) const LIST_CLIP_MIN: usize = 5;
193 /// How long the export card's Subtitles line may get before it counts tracks124 /// How long the export card's Subtitles line may get before it counts tracks
194 /// instead of naming them ([`subtitle_plan`]). Three lines of that row's value125 /// instead of naming them ([`subtitle_plan`]). Three lines of that row's value
195 /// box, at [`LIST_CHAR_W`] to a character: [`EXPORT_W`] less the row's padding126 /// box, at [`LIST_CHAR_W`] to a character: [`EXPORT_W`] less the row's padding
@@ -216,70 +147,6 @@ pub(crate) fn lanes_h(lanes: usize) -> f32 {
216 }147 }
217 }148 }
218 149
219-/// How tall one lane row is: [`LANE_H`] for a media track, [`SUB_LANE_H`] for
220-/// a caption one -- the one place that answer is decided, since
221-/// [`lanes_h_mixed`], [`lanes_shown_mixed`] and [`rows_below_mixed`] all walk
222-/// off it and a track drawn at one height and measured at another is a fold
223-/// line that lands on the wrong row.
224-pub(crate) fn lane_h(kind: LaneKind) -> f32 {
225- match kind {
226- LaneKind::Subtitle => SUB_LANE_H,
227- LaneKind::Video | LaneKind::Audio => LANE_H,
228- }
229-}
230-
231-/// [`lanes_h`] for a real stack of lanes rather than a bare count: a project
232-/// with a caption track in it is shorter than that many `LANE_H` rows, and
233-/// the column, the fold and the affordance below it all have to agree on
234-/// exactly how much shorter, or "N more below" is answering a box nothing
235-/// draws at.
236-pub(crate) fn lanes_h_mixed(kinds: &[LaneKind]) -> f32 {
237- match kinds.len() {
238- 0 => 0.,
239- n => kinds.iter().copied().map(lane_h).sum::<f32>() + (n - 1) as f32 * 8.,
240- }
241-}
242-
243-/// [`lanes_shown`] for a real stack: the largest prefix of `kinds` whose
244-/// drawn height still fits `box_h`, on the same boundary [`lanes_shown`]
245-/// draws it at (`lanes_h(k) <= box_h`) -- so a uniform stack answers exactly
246-/// what [`lanes_shown`] already did, and a mixed one answers the row count
247-/// its own heights actually reach.
248-pub(crate) fn lanes_shown_mixed(kinds: &[LaneKind], box_h: f32) -> usize {
249- (0..=kinds.len())
250- .rev()
251- .find(|&k| lanes_h_mixed(&kinds[..k]) <= box_h)
252- .unwrap_or(0)
253- .max(1)
254-}
255-
256-/// [`rows_below`] for a real stack: `scrolled` read against each row's own
257-/// top rather than a uniform `LANE_H + 8` stride, so a column with a thin
258-/// caption track in it still says the true count once that track has
259-/// scrolled by.
260-pub(crate) fn rows_below_mixed(kinds: &[LaneKind], box_h: f32, scrolled: f32) -> usize {
261- // Row `k`'s own top, in the same units `scrolled` is given in: nothing
262- // for the first row, and every row before it plus the gap that follows
263- // each one for the rest.
264- let top = |k: usize| -> f32 {
265- match k {
266- 0 => 0.,
267- k => lanes_h_mixed(&kinds[..k]) + 8.,
268- }
269- };
270- let past = (0..=kinds.len())
271- .min_by(|&a, &b| {
272- (scrolled - top(a))
273- .abs()
274- .partial_cmp(&(scrolled - top(b)).abs())
275- .unwrap()
276- })
277- .unwrap_or(0);
278- kinds
279- .len()
280- .saturating_sub(past + lanes_shown_mixed(kinds, box_h))
281-}
282-
283 /// The same question for a column whose rows are not one height -- the150 /// The same question for a column whose rows are not one height -- the
284 /// inspector's sections -- answered in pixels off what the scroll itself151 /// inspector's sections -- answered in pixels off what the scroll itself
285 /// reports: how far it may still be taken (`max_offset`) less how far it has152 /// reports: how far it may still be taken (`max_offset`) less how far it has
@@ -342,14 +209,6 @@ pub(crate) const TIMELINE_SHARE: f32 = 171. / 360.;
342 /// own padding, fixed so nothing in it can push the timeline down.209 /// own padding, fixed so nothing in it can push the timeline down.
343 pub(crate) const TOOLBAR_H: f32 = CONTROL_H + 16.;210 pub(crate) const TOOLBAR_H: f32 = CONTROL_H + 16.;
344 211
345-/// The top bar: the project's name on the left, the two file actions on the
346-/// right. Fixed for the reason [`HEADER_H`] is.
347-pub(crate) const TOPBAR_H: f32 = 36.;
348-
349-/// The transport strip under the picture -- play, timecode, volume -- where a
350-/// player's own controls live in every consumer editor.
351-pub(crate) const TRANSPORT_H: f32 = CONTROL_H + 12.;
352-
353 /// One press of a zoom key, or one notch of ctrl+wheel.212 /// One press of a zoom key, or one notch of ctrl+wheel.
354 pub(crate) const ZOOM_STEP: f32 = 1.25;213 pub(crate) const ZOOM_STEP: f32 = 1.25;
355 214
crates/app/src/library_meta.rsmodified+0 -36
@@ -361,42 +361,6 @@ pub(crate) fn library_w(window_w: f32) -> f32 {
361 .min(window_w / 3.)361 .min(window_w / 3.)
362 }362 }
363 363
364-/// What is left of a library column this wide for a row's *words*: the panel's
365-/// padding on both sides, the tint bar, the gap after it and the row's own right
366-/// inset. Every row in the column -- media and subtitle -- is built to this
367-/// shape, so one number answers for both.
368-pub(crate) fn row_text_w(width: f32) -> f32 {
369- // 8 px of panel padding each side, then the bar, the gap after it and the
370- // row's own right inset -- the numbers the rows are built with.
371- width - 16. - SWATCH_W - 6. - 6.
372-}
373-
374-/// A name cut to what a column this wide can hold, out of the *middle*. Two
375-/// files off one release differ in their last characters and nowhere else --
376-/// "…Episode 01" against "…02" -- so a name cut from the right is the same
377-/// name twice and the list stops naming anything. The width decides how much
378-/// survives, not a number of characters somebody guessed: a wider window spells
379-/// more of the file out, and the floor still keeps both ends.
380-///
381-/// The element truncates for real; this only decides where what is lost comes
382-/// out of.
383-pub(crate) fn clip_middle(name: &str, width: f32) -> String {
384- let budget = ((width / LIST_CHAR_W) as usize).max(LIST_CLIP_MIN);
385- let chars: Vec<char> = name.chars().collect();
386- if chars.len() <= budget {
387- return name.to_string();
388- }
389- // The gap costs a character, and what is left of the odd one goes to the
390- // tail: the tail is the half that tells two of them apart.
391- let head = (budget - 1) / 2;
392- let tail = budget - 1 - head;
393- format!(
394- "{}…{}",
395- chars[..head].iter().collect::<String>(),
396- chars[chars.len() - tail..].iter().collect::<String>()
397- )
398-}
399-
400 /// What the window is called: the program, and what is open in it. The name is364 /// What the window is called: the program, and what is open in it. The name is
401 /// what the header shows, so an empty window says the program alone rather than365 /// what the header shows, so an empty window says the program alone rather than
402 /// "no file open — edith".366 /// "no file open — edith".
crates/app/src/main.rsmodified+6 -40
@@ -31,9 +31,6 @@ pub(crate) use interact::*;
31 pub(crate) use layout::*;31 pub(crate) use layout::*;
32 pub(crate) use library_meta::*;32 pub(crate) use library_meta::*;
33 pub(crate) use menus::*;33 pub(crate) use menus::*;
34-// The tests' door to the escape rule; render.rs calls it by its own name.
35-#[cfg(test)]
36-pub(crate) use render::escape_leaves_player_fullscreen;
37 // The Contain letterbox, shared with the subtitle picture overlay34 // The Contain letterbox, shared with the subtitle picture overlay
38 // (ui/preview.rs) so both draw the same fitted rect the same way.35 // (ui/preview.rs) so both draw the same fitted rect the same way.
39 pub(crate) use notices::*;36 pub(crate) use notices::*;
@@ -79,12 +76,6 @@ use gpui::{
79 };76 };
80 77
81 struct Player {78 struct Player {
82- /// DESIGN.md §12 step 2: the stance skeleton behind `EDITH_DARKROOM`, read
83- /// once at startup ([`main`]) and never toggled at runtime -- a mid-session
84- /// flip would mean every region rebuilding under the pointer, which is not
85- /// this flag's job. [`crate::render`] branches its one `Render::render` on
86- /// it; nothing else reads it.
87- darkroom: bool,
88 /// The timeline, once there is one. A run with no file opens without it and79 /// The timeline, once there is one. A run with no file opens without it and
89 /// waits: the first media import or project load is what fills it, and80 /// waits: the first media import or project load is what fills it, and
90 /// until then every action that needs a timeline says so instead of acting.81 /// until then every action that needs a timeline says so instead of acting.
@@ -225,7 +216,7 @@ struct Player {
225 pub(crate) dock_src_active: bool,216 pub(crate) dock_src_active: bool,
226 /// The Sources tab's own filter text (darkroom dock, MOCK-SPEC "Dock" §2)217 /// The Sources tab's own filter text (darkroom dock, MOCK-SPEC "Dock" §2)
227 /// and whether it is the thing typed strokes go to right now -- the same218 /// and whether it is the thing typed strokes go to right now -- the same
228- /// capture-flag shape `keys_search`/`keys_open` already use, so a letter219+ /// capture-flag shape `keys_open` already uses, so a letter
229 /// filters the list instead of firing a spine action while the box is220 /// filters the list instead of firing a spine action while the box is
230 /// focused, and does nothing to the keymap once it is not.221 /// focused, and does nothing to the keymap once it is not.
231 pub(crate) dock_filter: String,222 pub(crate) dock_filter: String,
@@ -512,15 +503,10 @@ struct Player {
512 /// list). Cleared by [`Player::close_card`], the one reset list every503 /// list). Cleared by [`Player::close_card`], the one reset list every
513 /// opener routes through.504 /// opener routes through.
514 settings_open: bool,505 settings_open: bool,
515- /// What has been typed into the card's search box, which is the card's own506+ /// Where the actions list is scrolled to. Held here rather than left to
516- /// input exactly as the export card's digits are (nothing in it takes507+ /// the wheel alone: forty actions are four times what a 360 px window
517- /// focus, so the root's key handler is the field). Emptied every time the508+ /// shows, and the rows past the fold have to be reachable from the
518- /// card opens: a search is a look at the list, not a setting.509+ /// keyboard.
519- keys_search: String,
520- /// Where that list is scrolled to. Held here rather than left to the
521- /// wheel alone: forty actions are four times what a 360 px window shows,
522- /// and the rows past the fold have to be reachable from the keyboard that
523- /// is already typing in the search box.
524 keys_scroll: ScrollHandle,510 keys_scroll: ScrollHandle,
525 /// Where the lane column and the inspector's rows have been taken to. Read511 /// Where the lane column and the inspector's rows have been taken to. Read
526 /// back at render, not only written by the wheel: the line each of them512 /// back at render, not only written by the wheel: the line each of them
@@ -528,7 +514,6 @@ struct Player {
528 /// it, and a scroll that nothing reads is a scroll the affordance cannot514 /// it, and a scroll that nothing reads is a scroll the affordance cannot
529 /// follow.515 /// follow.
530 lanes_scroll: ScrollHandle,516 lanes_scroll: ScrollHandle,
531- inspector_scroll: ScrollHandle,
532 /// And where the equalizer card's own body has been taken to. It is the517 /// And where the equalizer card's own body has been taken to. It is the
533 /// tallest card in the column -- a graph with a row of numbers and a row of518 /// tallest card in the column -- a graph with a row of numbers and a row of
534 /// buttons under it -- and at the 360 px floor its title and its buttons519 /// buttons under it -- and at the 360 px floor its title and its buttons
@@ -744,9 +729,6 @@ struct Player {
744 /// which is what makes the colour card's graph move as a slider is dragged:729 /// which is what makes the colour card's graph move as a slider is dragged:
745 /// each live write reseeks, and the reseek's frame is the next count.730 /// each live write reseeks, and the reseek's frame is the next count.
746 histogram: [[u32; HIST_BINS]; 3],731 histogram: [[u32; HIST_BINS]; 3],
747- /// The action whose row is waiting for a stroke. The next key that is
748- /// neither escape nor a lone modifier becomes the whole of what reaches it.
749- rebinding: Option<ActionId>,
750 /// What the file actions have had to say, oldest first. A *queue* and not a732 /// What the file actions have had to say, oldest first. A *queue* and not a
751 /// slot: two imports that fail back to back used to be one message, because733 /// slot: two imports that fail back to back used to be one message, because
752 /// the second overwrote the first before a frame had drawn it -- the failure734 /// the second overwrote the first before a frame had drawn it -- the failure
@@ -803,19 +785,7 @@ fn main() {
803 // DESIGN.md §1: "the room is the film's" -- darkroom mode owns the785 // DESIGN.md §1: "the room is the film's" -- darkroom mode owns the
804 // palette outright, so the saved pick above is overridden the moment the786 // palette outright, so the saved pick above is overridden the moment the
805 // flag is read, once, before the first paint.787 // flag is read, once, before the first paint.
806- //788+ ui::theme::set(ui::theme::PaletteId::Darkroom);
807- // Darkroom is the default room now (user order: "make darkroom default
808- // no need to pass environment"). `OLD_GUI=1` (any case) is the one door
809- // back into the legacy four-region tree -- `EDITH_DARKROOM` opted IN to
810- // the new room; this opts OUT of it, which is why the sense of the read
811- // below is inverted rather than the flag renamed in place.
812- let old_gui = std::env::vars()
813- .find(|(k, _)| k.eq_ignore_ascii_case("OLD_GUI"))
814- .is_some_and(|(_, v)| v.eq_ignore_ascii_case("1"));
815- let darkroom = !old_gui;
816- if darkroom {
817- ui::theme::set(ui::theme::PaletteId::Darkroom);
818- }
819 // The subtitle style the last session picked, same silence on a missing789 // The subtitle style the last session picked, same silence on a missing
820 // or unreadable file.790 // or unreadable file.
821 let (sub_family, sub_text) = load_subtitle_style();791 let (sub_family, sub_text) = load_subtitle_style();
@@ -875,7 +845,6 @@ fn main() {
875 |window, cx| {845 |window, cx| {
876 let queue = queue.clone();846 let queue = queue.clone();
877 let player = cx.new(|cx| Player {847 let player = cx.new(|cx| Player {
878- darkroom,
879 // Nothing to wait for yet: the file named on the command848 // Nothing to wait for yet: the file named on the command
880 // line is still queued, and the repaint that carries its849 // line is still queued, and the repaint that carries its
881 // poster frame to the screen is asked for when it lands850 // poster frame to the screen is asked for when it lands
@@ -977,10 +946,8 @@ fn main() {
977 keymap: keymap.clone(),946 keymap: keymap.clone(),
978 keys_open: false,947 keys_open: false,
979 settings_open: false,948 settings_open: false,
980- keys_search: String::new(),
981 keys_scroll: ScrollHandle::new(),949 keys_scroll: ScrollHandle::new(),
982 lanes_scroll: ScrollHandle::new(),950 lanes_scroll: ScrollHandle::new(),
983- inspector_scroll: ScrollHandle::new(),
984 eq_scroll: ScrollHandle::new(),951 eq_scroll: ScrollHandle::new(),
985 export_open: false,952 export_open: false,
986 export_grouped: true,953 export_grouped: true,
@@ -1048,7 +1015,6 @@ fn main() {
1048 // Picture and sound, which is what an export was before1015 // Picture and sound, which is what an export was before
1049 // there was anything to pick.1016 // there was anything to pick.
1050 format: Format::default(),1017 format: Format::default(),
1051- rebinding: None,
1052 notices: notice.clone().map(SharedString::from).into_iter().collect(),1018 notices: notice.clone().map(SharedString::from).into_iter().collect(),
1053 exported: None,1019 exported: None,
1054 // The whole of argv, waiting for the first repaint to start1020 // The whole of argv, waiting for the first repaint to start
crates/app/src/menus.rsmodified+0 -50
@@ -240,56 +240,6 @@ pub(crate) fn keys_rows() -> Vec<KeyRow> {
240 rows240 rows
241 }241 }
242 242
243-/// [`keys_rows`] with a search applied: the rows whose label or whose stroke
244-/// carries `needle`, and the heading each one lives under. A heading with
245-/// nothing left beneath it goes with them -- an empty "Playback" over a gap
246-/// reads as a list that lost its rows rather than as a search that found none.
247-///
248-/// Each row keeps the index it has in the unfiltered list, so an element id is
249-/// the same one before and after a keystroke: filtering is a look at the list,
250-/// and gpui's per-element state is keyed on that id.
251-///
252-/// Case-insensitive substring, on both columns: people look for an action by
253-/// what it does ("vol") and for a stroke by what they pressed ("ctrl").
254-pub(crate) fn keys_filter(needle: &str, keymap: &Keymap) -> Vec<(usize, KeyRow)> {
255- let needle = needle.trim().to_lowercase();
256- let rows = keys_rows().into_iter().enumerate();
257- if needle.is_empty() {
258- return rows.collect();
259- }
260- // A chord matches on whole keys, not substrings -- "f1" must not drag in
261- // "f11". A needle that spells a combination still matches the whole chord.
262- let hit = |label: &str, chord: &str| {
263- let chord = chord.to_lowercase();
264- label.to_lowercase().contains(&needle)
265- || chord.split([' ', '+']).any(|part| part == needle)
266- || (needle.contains(['+', ' ']) && chord.contains(&needle))
267- };
268- let mut out: Vec<(usize, KeyRow)> = Vec::new();
269- // The heading above the row being looked at, until a row under it earns it
270- // a place -- then it goes in once, ahead of that row.
271- let mut pending: Option<(usize, KeyRow)> = None;
272- for (i, row) in rows {
273- match &row {
274- KeyRow::Head(_) => pending = Some((i, row)),
275- KeyRow::Act(action) => {
276- if hit(action.label(), &keymap.display(*action)) {
277- out.extend(pending.take());
278- out.push((i, row));
279- }
280- }
281- KeyRow::Fixed(f) => {
282- let fixed = &keymap::FIXED[*f];
283- if hit(fixed.label, &fixed.chord) {
284- out.extend(pending.take());
285- out.push((i, row));
286- }
287- }
288- }
289- }
290- out
291-}
292-
293 /// The character a stroke types into the actions card's search box, if it types243 /// The character a stroke types into the actions card's search box, if it types
294 /// one. gpui reports a printable key as itself and the space bar by name244 /// one. gpui reports a printable key as itself and the space bar by name
295 /// (platform.rs:866), and everything else -- the arrows, the function keys --245 /// (platform.rs:866), and everything else -- the arrows, the function keys --
crates/app/src/notices.rsmodified+0 -11
@@ -7,17 +7,6 @@ use crate::*;
7 /// eight is more than a user will ever answer in a row.7 /// eight is more than a user will ever answer in a row.
8 pub(crate) const NOTICES_MAX: usize = 8;8 pub(crate) const NOTICES_MAX: usize = 8;
9 9
10-/// The narrowest a notice's *message* is allowed to be squeezed before its hint
11-/// gives up the line and drops below it.
12-///
13-/// The bar is a message beside a hint, and at the 640x360 floor the picture
14-/// region it hangs under is narrower than the hint alone -- so the message was
15-/// squeezed to nothing and wrapped one character per line, which is a failure
16-/// rendered as a column of letters. Wide enough that a line of it is a phrase
17-/// rather than a word ladder, and narrow enough to still fit beside the hint in
18-/// any window worth putting two things on a line in.
19-pub(crate) const NOTICE_MIN_W: f32 = 180.;
20-
21 /// The whole of the queue's policy, where it can be read at once and tested10 /// The whole of the queue's policy, where it can be read at once and tested
22 /// without a window: dedupe against the back, a ceiling, oldest out first --11 /// without a window: dedupe against the back, a ceiling, oldest out first --
23 /// except an export's own outcome, which jumps to the front. [`Player::notify_user`]12 /// except an export's own outcome, which jumps to the front. [`Player::notify_user`]
crates/app/src/oracle.rsmodified+0 -6
@@ -446,9 +446,3 @@ pub(crate) fn menu_at(at: Point<Pixels>, viewport: Size<Pixels>, height: f32) ->
446 )446 )
447 }447 }
448 448
449-/// Whether the Add button does anything: a row picked, a timeline to put it on,
450-/// and no export reading that timeline. A button that would do nothing is dimmed
451-/// and takes no click, like every other one here.
452-pub(crate) fn can_add(picked: Option<&(PathBuf, usize)>, timeline: bool, exporting: bool) -> bool {
453- picked.is_some() && timeline && !exporting
454-}
crates/app/src/player/actions.rsmodified+10 -52
@@ -175,9 +175,13 @@ impl Player {
175 ActionId::FocusPanels => {175 ActionId::FocusPanels => {
176 self.focus_surface(crate::ui::stance::Surface::Dock, window, cx);176 self.focus_surface(crate::ui::stance::Surface::Dock, window, cx);
177 }177 }
178- // Nothing to cancel while nothing is exporting; the export guard in178+ // `^esc` (or whatever the keymap now binds it to) reaches here
179- // the key handler is what answers this one while there is.179+ // through the plain `act()` dispatch even while an export is
180- ActionId::CancelExport => {}180+ // running (`ui::stance`'s key handler deliberately leaves
181+ // `exporting()` out of its modal guard so this keeps working):
182+ // was a no-op until now, the real gap the progress card's own
183+ // "the chord as well" doc promised.
184+ ActionId::CancelExport => self.cancel_export(),
181 ActionId::ShowActions => self.show_actions(cx),185 ActionId::ShowActions => self.show_actions(cx),
182 ActionId::Settings => self.open_settings(cx),186 ActionId::Settings => self.open_settings(cx),
183 ActionId::Screenshot => self.take_screenshot(cx),187 ActionId::Screenshot => self.take_screenshot(cx),
@@ -256,13 +260,11 @@ impl Player {
256 }260 }
257 261
258 /// The actions card, from its key, from the panel button, or from its own262 /// The actions card, from its key, from the panel button, or from its own
259- /// row: open, with an empty search box -- a card that opens showing the263+ /// row: open, scrolled to the top -- a card that opens where the last
260- /// last search would hide most of the list for a reason nobody remembers.264+ /// look left it would hide most of the list for a reason nobody remembers.
261 pub(crate) fn show_actions(&mut self, cx: &mut Context<Self>) {265 pub(crate) fn show_actions(&mut self, cx: &mut Context<Self>) {
262 self.keys_open = true;266 self.keys_open = true;
263- self.keys_search.clear();
264 self.scroll_keys(None);267 self.scroll_keys(None);
265- self.rebinding = None;
266 // One card at a time, the rule the other cards follow.268 // One card at a time, the rule the other cards follow.
267 self.export_open = false;269 self.export_open = false;
268 cx.notify();270 cx.notify();
@@ -433,11 +435,7 @@ impl Player {
433 // below, which otherwise repeats nothing.435 // below, which otherwise repeats nothing.
434 if self.mbps_edit.is_some() {436 if self.mbps_edit.is_some() {
435 Repeat::Card437 Repeat::Card
436- } else if self.rebinding.is_some()438+ } else if self.keys_open || self.export_open || self.exporting().is_some() {
437- || self.keys_open
438- || self.export_open
439- || self.exporting().is_some()
440- {
441 Repeat::Nothing439 Repeat::Nothing
442 } else if self.eq_open.is_some()440 } else if self.eq_open.is_some()
443 || self.color_open.is_some()441 || self.color_open.is_some()
@@ -629,46 +627,6 @@ impl Player {
629 self.selected.clear();627 self.selected.clear();
630 cx.notify();628 cx.notify();
631 }629 }
632-
633- /// The stroke a waiting row was after: it becomes the whole of what reaches
634- /// that action, which is what the row was showing. A chord another action
635- /// already holds is refused by the keymap and the row keeps waiting, so the
636- /// next stroke is another try rather than a lost one. A binding that took
637- /// holds either way:
638- /// what a failed write costs is only the next run, which is what the notice
639- /// is for.
640- pub(crate) fn capture(&mut self, action: ActionId, key: &str, ctrl: bool) {
641- let chord = keymap::Chord {
642- key: key.to_string(),
643- ctrl,
644- };
645- // Only a stroke the file can spell and read back as itself: gpui reports
646- // "+" for shift+=, which is the chord grammar's separator, so binding it
647- // would write a line the next load would have to drop. Refused here, in
648- // front of the user, rather than silently costing that binding later.
649- // The row keeps waiting, as it does for a stroke already taken.
650- if !chord.bindable() {
651- let text = format!("THAT KEY CANNOT BE BOUND — {}", chord.pretty());
652- eprintln!("{text}");
653- self.notify_user(text.into());
654- return;
655- }
656- let text = match self.keymap.rebind_action(action, chord.clone()) {
657- Ok(()) => {
658- self.rebinding = None;
659- match self.keymap.save() {
660- Ok(()) => return,
661- Err(e) => format!(
662- "KEYBINDINGS NOT SAVED — {}: {e}",
663- Keymap::config_path().display()
664- ),
665- }
666- }
667- Err(holder) => format!("ALREADY BOUND — {} is {}", chord.pretty(), holder.label()),
668- };
669- eprintln!("{text}");
670- self.notify_user(text.into());
671- }
672 }630 }
673 631
674 /// The half-open range a mark and a mark make, in either order: a person's two632 /// The half-open range a mark and a mark make, in either order: a person's two
crates/app/src/player/cards.rsmodified+24 -2
@@ -1313,8 +1313,6 @@ impl Player {
1313 pub(crate) fn close_card(&mut self) {1313 pub(crate) fn close_card(&mut self) {
1314 self.keys_open = false;1314 self.keys_open = false;
1315 self.settings_open = false;1315 self.settings_open = false;
1316- self.keys_search.clear();
1317- self.rebinding = None;
1318 self.export_open = false;1316 self.export_open = false;
1319 // The two things typed *into* the export card go with it: a field left1317 // The two things typed *into* the export card go with it: a field left
1320 // open would take the next keystroke for a card that is gone.1318 // open would take the next keystroke for a card that is gone.
@@ -1741,6 +1739,30 @@ impl Player {
1741 }1739 }
1742 return true;1740 return true;
1743 }1741 }
1742+ // The export card's custom bitrate field: the mouse door is the
1743+ // steppers and the row's own click (`Player::edit_mbps`), but the
1744+ // `0–9`/backspace/enter/esc chords `keymap::FIXED` already
1745+ // advertises need a keyboard door too, or a hand with no mouse
1746+ // could open the field and never fill it in.
1747+ if self.export_open {
1748+ if let Some(edit) = &mut self.mbps_edit {
1749+ if key == ESCAPE {
1750+ self.mbps_edit = None;
1751+ } else if key == "enter" {
1752+ if let Some(mbps) = edit.commit() {
1753+ self.custom_mbps = mbps;
1754+ self.mbps_edit = None;
1755+ }
1756+ } else if key == "backspace" {
1757+ edit.backspace();
1758+ } else if let Ok(digit) = key.parse::<u32>() {
1759+ edit.digit(digit);
1760+ } else {
1761+ return false;
1762+ }
1763+ return true;
1764+ }
1765+ }
1744 false1766 false
1745 }1767 }
1746 }1768 }
crates/app/src/player/export.rsmodified+0 -45
@@ -414,7 +414,6 @@ impl Player {
414 // was waiting in. Nor may a half-typed number: the card opens on the414 // was waiting in. Nor may a half-typed number: the card opens on the
415 // bitrate it will write, never on digits left behind by a closed one.415 // bitrate it will write, never on digits left behind by a closed one.
416 self.keys_open = false;416 self.keys_open = false;
417- self.rebinding = None;
418 self.mbps_edit = None;417 self.mbps_edit = None;
419 cx.notify();418 cx.notify();
420 }419 }
@@ -465,34 +464,6 @@ impl Player {
465 self.set_format(next_container(self.format));464 self.set_format(next_container(self.format));
466 }465 }
467 466
468- /// The quality rows by keyboard, wrapping. Refused by name where the format
469- /// has no bitrate to pick: a key that silently does nothing is the card
470- /// looking broken.
471- pub(crate) fn cycle_quality(&mut self) {
472- if let Some(why) = bitrate_refusal(self.format) {
473- self.notify_user(why.into());
474- return;
475- }
476- let at = Quality::ALL
477- .iter()
478- .position(|&q| q == self.quality)
479- .unwrap_or(0);
480- self.quality = Quality::ALL[(at + 1) % Quality::ALL.len()];
481- }
482-
483- /// The sound's rate by keyboard, wrapping through the offered ones -- the
484- /// picture's quality row for the other half of the file. Refused by name
485- /// where this timeline in this format has no rate to pick, exactly as
486- /// [`Player::cycle_quality`] is: a key that silently does nothing is the
487- /// card looking broken.
488- pub(crate) fn cycle_audio_kbps(&mut self) {
489- if let Some(why) = self.audio_rate_refusal() {
490- self.notify_user(why.into());
491- return;
492- }
493- self.audio_kbps = next_audio_kbps(self.audio_kbps);
494- }
495-
496 /// Which encoder an export of this project would write the picture with467 /// Which encoder an export of this project would write the picture with
497 /// ([`engine::export::EncoderSeat`]). The session's, because it is saved468 /// ([`engine::export::EncoderSeat`]). The session's, because it is saved
498 /// with the project -- there is no card-local copy to drift from it -- and469 /// with the project -- there is no card-local copy to drift from it -- and
@@ -515,22 +486,6 @@ impl Player {
515 cx.notify();486 cx.notify();
516 }487 }
517 488
518- /// The seat by keyboard, wrapping through the three -- the Sound row's
519- /// rule, for the row beside it. Refused by name with no timeline: a key
520- /// that silently does nothing is the card looking broken.
521- pub(crate) fn cycle_encoder(&mut self, cx: &mut Context<Self>) {
522- let Some(session) = &self.session else {
523- self.notify_user("no timeline to export — open a file first".into());
524- cx.notify();
525- return;
526- };
527- let at = EncoderSeat::ALL
528- .iter()
529- .position(|&s| s == session.encoder_seat())
530- .unwrap_or(0);
531- self.apply_encoder(EncoderSeat::ALL[(at + 1) % EncoderSeat::ALL.len()], cx);
532- }
533-
534 /// Why the sound row is not a choice right now, the engine answering about489 /// Why the sound row is not a choice right now, the engine answering about
535 /// the very project it would export. No session is the same answer as no490 /// the very project it would export. No session is the same answer as no
536 /// sound: there is nothing to write either way.491 /// sound: there is nothing to write either way.
crates/app/src/player/timeline_edit.rsmodified+4 -63
@@ -47,16 +47,11 @@ impl Player {
47 // notice per keystroke would turn the ledger into a firehose,47 // notice per keystroke would turn the ledger into a firehose,
48 // exactly what §8's "one at a time" is against; a single `s` is48 // exactly what §8's "one at a time" is against; a single `s` is
49 // not that.49 // not that.
50- // The legacy room has no ledger reading this queue and never
51- // notified on a split before -- gated so that room's behaviour
52- // stays exactly as it was.
53 let cut = session.cut_at(f64::from(at) / self.fps);50 let cut = session.cut_at(f64::from(at) / self.fps);
54- if self.darkroom {51+ if cut {
55- if cut {52+ self.notify_user("SPLIT".into());
56- self.notify_user("SPLIT".into());53+ } else {
57- } else {54+ self.notify_user("NOTHING TO SPLIT — the playhead is already on a cut".into());
58- self.notify_user("NOTHING TO SPLIT — the playhead is already on a cut".into());
59- }
60 }55 }
61 }56 }
62 self.selected.clear();57 self.selected.clear();
@@ -862,29 +857,6 @@ impl Player {
862 live_idx(session.lane_clips(drag.lane), drag.idx, drag.clip)857 live_idx(session.lane_clips(drag.lane), drag.idx, drag.clip)
863 }858 }
864 859
865- /// The line while the clip is still in the hand: the very answer
866- /// [`Player::drop_frame`] will commit, worked out on every move of the drag,
867- /// so what the eye was promised is where the release puts it. A pointer that
868- /// has wandered off the bed promises nothing.
869- pub(crate) fn preview_drop(
870- &mut self,
871- from: Lane,
872- idx: usize,
873- x: Pixels,
874- cx: &mut Context<Self>,
875- ) {
876- let cue = self.drop_frame(from, idx, x).and_then(|(_, cue)| cue);
877- self.set_cue(cue, x, cx);
878- }
879-
880- /// The same line for a library row on its way to a lane: it goes down at
881- /// the frame it is let go on ([`Player::place_frame`]), so that frame is
882- /// what snaps and what is drawn.
883- pub(crate) fn preview_place(&mut self, x: Pixels, cx: &mut Context<Self>) {
884- let cue = self.place_frame(x).1;
885- self.set_cue(cue, x, cx);
886- }
887-
888 /// The shadow the clip in the hand would fill, on the lane the pointer is860 /// The shadow the clip in the hand would fill, on the lane the pointer is
889 /// over: its head where [`Player::drop_frame`] says the release will put it861 /// over: its head where [`Player::drop_frame`] says the release will put it
890 /// -- the same call the drop makes, so the box drawn and the box committed862 /// -- the same call the drop makes, so the box drawn and the box committed
@@ -1145,37 +1117,6 @@ impl Player {
1145 .unwrap_or(raw)1117 .unwrap_or(raw)
1146 }1118 }
1147 1119
1148- /// Whether the playhead is standing exactly on one: what the timeline's own
1149- /// line says out loud, so "a cut here is copied" is on screen before the cut
1150- /// rather than discovered in the export card afterwards.
1151- ///
1152- /// Asked every repaint, so it walks the *playhead* into each clip's source
1153- /// and looks it up in that source's own sorted grid -- where
1154- /// [`Player::sync_frames`] builds the whole list, which is a film's worth of
1155- /// marks to allocate and sort sixty times a second.
1156- pub(crate) fn on_sync_point(&self) -> bool {
1157- let Some(session) = &self.session else {
1158- return false;
1159- };
1160- let now = frame_at(session.now(), self.fps);
1161- let sources = session.sources();
1162- session.lanes().into_iter().any(|lane| {
1163- lane.kind == LaneKind::Video
1164- && session.lane_clips(lane).iter().any(|clip| {
1165- clip.speed.is_normal()
1166- && (clip.start..clip.start + (clip.out_frame - clip.in_frame))
1167- .contains(&now)
1168- && sources
1169- .get(clip.source)
1170- .and_then(|entry| self.syncs.get(&entry.path))
1171- .is_some_and(|keys| {
1172- keys.binary_search(&(clip.in_frame + (now - clip.start)))
1173- .is_ok()
1174- })
1175- })
1176- })
1177- }
1178-
1179 /// Puts the playhead on the sync point before or after it -- the keyboard's1120 /// Puts the playhead on the sync point before or after it -- the keyboard's
1180 /// half of placing a cut where the export can copy it, and the only way to1121 /// half of placing a cut where the export can copy it, and the only way to
1181 /// reach one exactly on a timeline zoomed out to a whole film, where one1122 /// reach one exactly on a timeline zoomed out to a whole film, where one
crates/app/src/player/view.rsmodified+0 -98
@@ -251,55 +251,6 @@ impl Player {
251 cx.notify();251 cx.notify();
252 }252 }
253 253
254- /// A press on the scrollbar's track: on the thumb, the drag begins from
255- /// wherever in it the hand landed; beside it, the view jumps so the
256- /// thumb's middle is at the press and the drag carries on from there --
257- /// a click is a jump, and holding it is a jump that keeps going.
258- pub(crate) fn scroll_press(&mut self, x: Pixels, cx: &mut Context<Self>) {
259- let view = self.view();
260- if view.bed <= 0. || view.duration <= 0. {
261- return;
262- }
263- let (thumb_x, thumb_w) = scroll_thumb(
264- view.bed,
265- view.duration,
266- view.scale.start.max(0.),
267- view.span(),
268- );
269- let at = px_along(x, self.scroll_track.get());
270- let grab = match (thumb_x..thumb_x + thumb_w).contains(&at) {
271- true => at - thumb_x,
272- // Beside the thumb: jump so its middle is under the pointer --
273- // by the track's own proportion, the very mapping a drag sample
274- // is read through below, so the first move of the drag that
275- // follows lands exactly where the jump left the view and the
276- // thumb never snaps under the hand (a jump worked out in pixels
277- // at the view's own pps landed at span-over-duration of the
278- // target and the snap was the drag correcting it). The thumb is
279- // clamped inside the track by [`scroll_thumb`], so the grab this
280- // leaves is always a real place inside it -- at the thumb's floor
281- // width as much as anywhere else.
282- false => {
283- let start = f64::from((at - thumb_w / 2.).max(0.)) / f64::from(view.bed.max(1.))
284- * view.duration;
285- self.scale = View {
286- scale: Scale {
287- start,
288- ..view.scale
289- },
290- ..view
291- }
292- .settled();
293- thumb_w / 2.
294- }
295- };
296- self.scroll_drag = Some(grab);
297- // The wheel's own claim on the follow: a hand on the scrollbar is
298- // looking away from the playhead on purpose.
299- self.panned = true;
300- cx.notify();
301- }
302-
303 /// A sample of a thumb drag: the window starts where the thumb's grabbed254 /// A sample of a thumb drag: the window starts where the thumb's grabbed
304 /// point sits under the pointer, clamped by the same `settled` every other255 /// point sits under the pointer, clamped by the same `settled` every other
305 /// scroll answers to. No reseek, no worker -- the view is the only thing256 /// scroll answers to. No reseek, no worker -- the view is the only thing
@@ -336,38 +287,6 @@ impl Player {
336 to.clamp(0., max)287 to.clamp(0., max)
337 }288 }
338 289
339- /// A press on the lane stack's scrollbar: on the thumb, the drag begins
340- /// from wherever in it the hand landed; beside it, the stack jumps so the
341- /// thumb's middle is at the press and the drag carries on from there --
342- /// the time axis's own terms ([`Self::scroll_press`]), turned through a
343- /// right angle.
344- pub(crate) fn lanes_press(&mut self, y: Pixels, cx: &mut Context<Self>) {
345- let track = f32::from(self.lanes_scroll.bounds().size.height);
346- let max = f32::from(self.lanes_scroll.max_offset().height);
347- if track <= 0. || max <= 0. {
348- return;
349- }
350- let scrolled = -f32::from(self.lanes_scroll.offset().y);
351- let (thumb_y, thumb_h) = lanes_thumb(track, track + max, track, scrolled);
352- let at = px_down(y, self.lanes_scroll.bounds());
353- let grab = match (thumb_y..thumb_y + thumb_h).contains(&at) {
354- true => at - thumb_y,
355- // Beside the thumb: jump so its middle is under the pointer, at
356- // the press's own share of the stack. The thumb is clamped inside
357- // the track by [`lanes_thumb`], so the grab this leaves is always
358- // a real place inside it.
359- false => {
360- let to =
361- self.lanes_taken((at - thumb_h / 2.).max(0.) / (track - thumb_h).max(1.) * max);
362- self.lanes_scroll
363- .set_offset(point(self.lanes_scroll.offset().x, px(-to)));
364- thumb_h / 2.
365- }
366- };
367- self.lanes_drag = Some(grab);
368- cx.notify();
369- }
370-
371 /// A sample of the lane thumb's drag: the stack is taken to where the290 /// A sample of the lane thumb's drag: the stack is taken to where the
372 /// thumb's grabbed point sits under the pointer, clamped by the same291 /// thumb's grabbed point sits under the pointer, clamped by the same
373 /// `max_offset` the column's own wheel answers to. No reseek, no repaint292 /// `max_offset` the column's own wheel answers to. No reseek, no repaint
@@ -386,23 +305,6 @@ impl Player {
386 cx.notify();305 cx.notify();
387 }306 }
388 307
389- /// The wheel over the lane stack's strip, in the pixels gpui's own scroll
390- /// of the column would move it (`pixel_delta` -- a line a notch, not a
391- /// share of anything): the strip stops the wheel before the column behind
392- /// it sees it, so this is the notch's one path and it moves the stack
393- /// exactly as far as the names' own surface does.
394- pub(crate) fn lanes_wheel(&mut self, dy: f32, cx: &mut Context<Self>) {
395- let max = f32::from(self.lanes_scroll.max_offset().height);
396- if max <= 0. {
397- return;
398- }
399- let scrolled = -f32::from(self.lanes_scroll.offset().y);
400- let to = self.lanes_taken(scrolled - dy);
401- self.lanes_scroll
402- .set_offset(point(self.lanes_scroll.offset().x, px(-to)));
403- cx.notify();
404- }
405-
406 /// One notch of the wheel anywhere over the timeline -- the ruler or a308 /// One notch of the wheel anywhere over the timeline -- the ruler or a
407 /// lane's bed alike, since a hand aims at the clip it is working on and not309 /// lane's bed alike, since a hand aims at the clip it is working on and not
408 /// at the strip above it. Ctrl zooms about the pointer, bare scrolls the310 /// at the strip above it. Ctrl zooms about the pointer, bare scrolls the
crates/app/src/render.rsmodified+1 -489
@@ -3,20 +3,6 @@
3 3
4 use crate::*;4 use crate::*;
5 5
6-/// Whether a stroke leaves player fullscreen. Bare escape does, the same
7-/// stroke every card and menu in this window answers to -- and it is
8-/// answered *first*: the picture-only layout is the chrome itself missing,
9-/// not a card drawn over it, so it goes before a menu close or a preview
10-/// close gets a look at the same key. See the call site in [`Player::render`]
11-/// for the deliberate order this buys with a preview open underneath.
12-pub(crate) fn escape_leaves_player_fullscreen(
13- key: &str,
14- ctrl: bool,
15- player_fullscreen: bool,
16-) -> bool {
17- key == ESCAPE && !ctrl && player_fullscreen
18-}
19-
20 /// The frame `image`, letterboxed/pillarboxed into whatever box it is given,6 /// The frame `image`, letterboxed/pillarboxed into whatever box it is given,
21 /// filling that box on its own axis and leaving the other bare -- the bare7 /// filling that box on its own axis and leaving the other bare -- the bare
22 /// strip is the box's own background (`BG_CANVAS`), never painted here, which8 /// strip is the box's own background (`BG_CANVAS`), never painted here, which
@@ -109,7 +95,6 @@ impl Player {
109 // After the picture, so the plate is drawn over it rather than95 // After the picture, so the plate is drawn over it rather than
110 // under.96 // under.
111 .children(self.subtitle_overlay(position, window))97 .children(self.subtitle_overlay(position, window))
112- .children(self.preview_badge(cx))
113 // The three transient lines hang off the bottom of the picture98 // The three transient lines hang off the bottom of the picture
114 // rather than taking a row of the column: a notice that arrives99 // rather than taking a row of the column: a notice that arrives
115 // must not push the transport, the toolbar and the timeline down100 // must not push the transport, the toolbar and the timeline down
@@ -126,14 +111,6 @@ impl Player {
126 .gap(px(2.))111 .gap(px(2.))
127 .children(self.import_bar(cx))112 .children(self.import_bar(cx))
128 .children(self.seek_bar())113 .children(self.seek_bar())
129- // DESIGN §8: no full-width bar over the picture, ever.
130- // The darkroom stance has its own §8-conformant notice
131- // plate above the ledger (`ui::stance::notice_plate`) --
132- // this legacy bar would otherwise paint a second,
133- // picture-covering copy of the same notice underneath
134- // it. The legacy (non-darkroom) room keeps this bar
135- // exactly as it was.
136- .children((!self.darkroom).then(|| self.notice_bar(cx)).flatten())
137 // How tall the lot came out, for the cue plate above to114 // How tall the lot came out, for the cue plate above to
138 // step over ([`sub_bottom`]) -- the bars are over the115 // step over ([`sub_bottom`]) -- the bars are over the
139 // picture, and a message drawn across the line being116 // picture, and a message drawn across the line being
@@ -248,471 +225,6 @@ impl Render for Player {
248 self.panned = false;225 self.panned = false;
249 }226 }
250 227
251- // DESIGN.md §12 step 2: the stance skeleton, on by default now228+ ui::stance::render(self, window, cx)
252- // (`OLD_GUI=1` opts back into the tree below).
253- // `.into_any_element()` on both arms is the one thing this branch
254- // costs the legacy tree below -- an `impl IntoElement` return can
255- // only be one concrete type, and the two trees are not the same one.
256- if self.darkroom {
257- return ui::stance::render(self, window, cx).into_any_element();
258- }
259-
260- (div()
261- .track_focus(&self.focus)
262- .on_key_down(cx.listener(|this, event: &KeyDownEvent, window, cx| {
263- let key = event.keystroke.key.as_str();
264- let ctrl = event.keystroke.modifiers.control;
265- // `is_held` is the auto-repeat, and a value is the one thing
266- // worth running on it: a held arrow on a card moves the slider
267- // it picked, and a held volume key runs the volume. Everything
268- // else is filtered exactly as it always was -- a repeat that
269- // toggled playback, or cut the timeline, many times a second is
270- // what this guard is for, and a row waiting for a stroke takes
271- // none of it either (it would bind the key, then fire what it
272- // just bound). See [`repeats`].
273- if event.is_held
274- && !repeats(this.repeat_scope(), key, this.keymap.lookup(key, ctrl))
275- {
276- return;
277- }
278- // The recovery notice is the one bar that reads a key as more
279- // than "answered": `enter` loads the sidecar it named, and
280- // every other key declines it -- the way any other key
281- // dismisses any other notice. Asked before the generic
282- // dismiss below shares the same door with it, not instead of
283- // it: this recovers or declines, that pops the bar.
284- if this.recovery_sidecar.is_some() {
285- if key == "enter" {
286- this.recover_from_sidecar(cx);
287- } else if let Some(sidecar) = this.recovery_sidecar.take() {
288- Player::discard_sidecar(&sidecar);
289- }
290- }
291- // Any key answers the message on the bar and brings the next of
292- // them up, whatever it was -- and owes
293- // the repaint itself: a notice no longer keeps the render loop
294- // alive, and the arms below that do notify are not all of them
295- // (an unbound key, or the copy chord, changes nothing else).
296- if this.dismiss_notice() {
297- cx.notify();
298- }
299- // A row is waiting for a stroke, and while it is, that stroke is
300- // data: it means the binding and nothing else, which is why this
301- // answers before the export guard and before the keymap is
302- // consulted at all.
303- if let Some(action) = this.rebinding {
304- if key == ESCAPE {
305- this.rebinding = None;
306- } else if !is_bare_modifier(key) {
307- this.capture(action, key, ctrl);
308- }
309- cx.notify();
310- return;
311- }
312- // On linux gpui reports the copy chord as key "c" with the
313- // control modifier set (the control code is mapped back), which
314- // is why the keymap is keyed on the pair and never on the key
315- // alone.
316- let action = this.keymap.lookup(key, ctrl);
317- // An export is reading the edit list every other action here
318- // would change, so cancelling is the only one that means
319- // anything until it is over.
320- if this.exporting().is_some() {
321- if cancels_export(key, ctrl, action) {
322- this.cancel_export();
323- }
324- cx.notify();
325- return;
326- }
327- // The overlay owns the keyboard while it is up -- but it types
328- // now: a printable stroke is the search box's, which is why
329- // nothing here reaches the keymap. A waiting row is answered
330- // above and still wins, so a rebind onto "v" binds the key
331- // rather than typing it.
332- if this.keys_open {
333- if key == ESCAPE {
334- // Two steps out, the way a search box anywhere gets
335- // out: the filter first -- the whole list back --
336- // and the card only once there is no search to clear.
337- if this.keys_search.is_empty() {
338- this.keys_open = false;
339- } else {
340- this.keys_search.clear();
341- this.scroll_keys(None);
342- }
343- // The rows past the fold, without a wheel: forty actions
344- // are four times what the viewport shows, and the hand
345- // typing in the search box is already on the keyboard.
346- } else if key == "up" {
347- this.scroll_keys(Some(KEYS_ROW_H));
348- } else if key == "down" {
349- this.scroll_keys(Some(-KEYS_ROW_H));
350- } else if key == "backspace" {
351- this.keys_search.pop();
352- this.scroll_keys(None);
353- } else if let Some(c) = typed(key) {
354- this.keys_search.push(c);
355- this.scroll_keys(None);
356- }
357- cx.notify();
358- return;
359- }
360- // The dock's Sources filter (MOCK-SPEC "Dock" §2): owns the
361- // keyboard only while it was clicked into, exactly the
362- // `keys_search` shape above -- a letter typed anywhere else in
363- // the room still means what the spine says it means.
364- if this.dock_filter_edit {
365- if key == "escape" || key == "enter" {
366- this.dock_filter_edit = false;
367- } else if key == "backspace" {
368- this.dock_filter.pop();
369- } else if let Some(c) = typed(key) {
370- this.dock_filter.push(c);
371- }
372- cx.notify();
373- return;
374- }
375- // `↵` adds the picked source at the playhead (MOCK-SPEC "Dock"
376- // hint paragraph, gesture 2) -- the keyboard door beside the
377- // legacy "Add at playhead" button's pointer one, live only
378- // where a row is actually picked so a bare enter elsewhere
379- // keeps meaning whatever it already means below.
380- if key == "enter"
381- && this.dock_src_active
382- && this.selected_asset.is_some()
383- && this.exporting().is_none()
384- {
385- if let Some((path, stream)) = this.selected_asset.clone() {
386- this.insert_source(&path, stream, None, None, cx);
387- }
388- cx.notify();
389- return;
390- }
391- // The export card owns it the same way, and for the same
392- // reason. Escape closes it -- nothing has been written yet, so
393- // there is nothing here to cancel -- and the card's own letters
394- // are its input: it has no widget that takes focus (nothing in
395- // it does), so this listener is its keyboard, exactly as it is
396- // a waiting row's.
397- if this.export_open {
398- // A list open over the card is the innermost thing on
399- // screen, so it is what a stroke closes first -- the rule
400- // every menu here follows, said before the card's own keys
401- // so escape does not take the card out from under it.
402- if this.picker.take().is_some() {
403- cx.notify();
404- return;
405- }
406- // A number being typed is the next thing in: while the
407- // field is open every stroke is text, which is what makes
408- // it a field and not a capture -- the card's letters cannot
409- // fire under it, and escape gives up the edit before it
410- // touches the card.
411- if let Some(edit) = &mut this.mbps_edit {
412- if key == ESCAPE {
413- this.mbps_edit = None;
414- } else if key == "enter" {
415- // Committed or refused in its own words; a refused
416- // one stays open on what was typed, so the number
417- // can be fixed rather than typed again.
418- if let Some(mbps) = edit.commit() {
419- this.custom_mbps = mbps;
420- this.quality = Quality::Custom;
421- this.mbps_edit = None;
422- }
423- } else if key == "backspace" {
424- edit.backspace();
425- } else if key == "up" {
426- edit.step(1);
427- } else if key == "down" {
428- edit.step(-1);
429- } else if let Ok(digit) = key.parse::<u32>() {
430- edit.digit(digit);
431- }
432- cx.notify();
433- return;
434- }
435- if key == ESCAPE {
436- this.export_open = false;
437- } else if key == "enter" {
438- // The card's own button, by keyboard: the one thing in
439- // it that writes a file must not be pointer-only either.
440- this.start_export(cx);
441- } else if let Some(format) = format_key(key, this.format) {
442- // The codec rows by their own letter, so the card can be
443- // driven without a mouse -- the same card-local input
444- // the typed bitrate is, and for the same reason: a
445- // choice reachable only by pointer is not reachable by
446- // everyone. Not a keymap binding: it means nothing
447- // outside this card, exactly like the digits.
448- this.set_format(format);
449- } else if key == "c" {
450- this.cycle_container();
451- } else if key == "q" {
452- this.cycle_quality();
453- } else if key == "b" {
454- // The sound's rate, `q`'s pair for the other half of
455- // the file. Not a digit: those are the picture's.
456- this.cycle_audio_kbps();
457- } else if key == "e" {
458- // Which encoder writes the picture, `b`'s neighbour for
459- // the other thing about the file a person picks rather
460- // than types. Card-local like the rest of these.
461- this.cycle_encoder(cx);
462- } else if key == "d" {
463- // The save dialog, which was the one row here a
464- // keyboard could not open.
465- this.pick_destination(cx);
466- } else if let Some(preset) = ExportPreset::ALL
467- .into_iter()
468- .find(|p| p.key() == key)
469- // `Custom` shares `s` with Advanced below, which already
470- // handles that key -- reaching it here too would only
471- // race the same assignment against itself.
472- .filter(|p| *p != ExportPreset::Custom)
473- {
474- this.pick_preset(preset);
475- } else if key == "g" {
476- this.export_grouped = !this.export_grouped;
477- } else if key == "r" {
478- this.export_refusals_inline = !this.export_refusals_inline;
479- } else if key == "s" {
480- // The Advanced pane, by keyboard: the primary pane's
481- // own row for it opens the same way a click does.
482- this.export_advanced_open = !this.export_advanced_open;
483- } else if key == "n" {
484- // The custom row's field, by keyboard. The digits used
485- // to do this from anywhere in the card, which meant a
486- // stray keystroke changed the bitrate with nothing on
487- // screen to say it had: now a digit outside the field
488- // means nothing at all, and this is the way in.
489- this.edit_mbps();
490- }
491- cx.notify();
492- return;
493- }
494- // Every param card's own key branch, factored into
495- // `Player::param_card_key` (`player/cards.rs`) so this tree and
496- // the darkroom stance drive the same logic rather than a
497- // second, divergent copy.
498- if this.param_card_key(key, event.keystroke.modifiers.shift, cx) {
499- cx.notify();
500- return;
501- }
502- // A clip menu names an index, and every edit below moves
503- // indices -- so a stroke closes it before it acts. Escape means
504- // that and nothing else, which is the `esc` the keys menu
505- // already lists (keymap.rs `FIXED`).
506- // Both menus, taken rather than short-circuited: the library's
507- // one names a row the edits below can remove, so it closes on a
508- // stroke exactly as the clip menu does.
509- // A choice list goes the same way and for the same reason: it
510- // names a clip index too, and escape is the way out of it.
511- // An open list is the innermost thing on screen, so it takes
512- // the keys before anything under it does: ↑↓ walk it, enter
513- // takes the row, and escape falls through to the close below --
514- // the same three strokes every list in this editor answers.
515- // The picture-only layout is the outermost thing on screen --
516- // it is the chrome itself that is missing, not a card drawn
517- // over it -- so its own escape is answered before any menu or
518- // preview below gets a look at the stroke. Deliberate order:
519- // with a preview open *and* the player fullscreen, the first
520- // Escape only leaves fullscreen (the preview keeps playing,
521- // now behind the chrome again), and it takes a second Escape
522- // to stop the preview -- one stroke, one effect, same as
523- // every other card in this chain.
524- if escape_leaves_player_fullscreen(key, ctrl, this.player_fullscreen) {
525- this.player_fullscreen = false;
526- window.toggle_fullscreen();
527- cx.notify();
528- return;
529- }
530- if let Some(mut picker) = this.picker {
531- let rows = this.choices(picker.of);
532- if !rows.is_empty() && matches!(key, "up" | "down" | "enter") {
533- match key {
534- "down" => picker.sel = (picker.sel + 1) % rows.len(),
535- "up" => picker.sel = (picker.sel + rows.len() - 1) % rows.len(),
536- _ => {
537- let (choice, ..) = rows[picker.sel.min(rows.len() - 1)];
538- this.choose(choice, cx);
539- cx.notify();
540- return;
541- }
542- }
543- this.picker = Some(picker);
544- cx.notify();
545- return;
546- }
547- }
548- let clip_menu = this.context_menu.take().is_some();
549- let row_menu = this.library_menu.take().is_some();
550- let list = this.picker.take().is_some();
551- if clip_menu || row_menu || list {
552- cx.notify();
553- if key == ESCAPE {
554- return;
555- }
556- }
557- // The innermost thing left on screen once no menu is up: a
558- // preview takes the picture over the timeline's own, and
559- // escape is its own way out, same as every card above it.
560- if key == ESCAPE && !ctrl && this.preview_session.is_some() {
561- this.close_preview(cx);
562- return;
563- }
564- if let Some(action) = action {
565- this.act(action, window, cx);
566- }
567- }))
568- // The whole window is the drop target: gpui turns an external file
569- // drop into an `ExternalPaths` drag (window.rs:3626) delivered as a
570- // mouse-up to every hovered hitbox, and the root's is the only one
571- // that covers the picture as well as the panel.
572- .on_drop(cx.listener(|this, paths: &gpui::ExternalPaths, _, cx| {
573- // The overlay owns the pointer as well as the keyboard, and a
574- // drop is a click the scrim cannot swallow: gpui delivers it to
575- // the root's hitbox, which is under the scrim but is not a
576- // sibling it can stop. The export card is over the timeline for
577- // the same reason: importing under it would change the very
578- // edit list the card is about to write out.
579- if this.modal() {
580- return;
581- }
582- for path in paths.paths() {
583- // One queue for all of them, in arrival order: the fork --
584- // a project replaces the timeline, media joins the library
585- // -- is made when each one's worker starts ([`arrival`]),
586- // and neither is read on this thread.
587- this.import(path, cx);
588- }
589- }))
590- // A drop event carries no path of its own -- gpui only tells the
591- // target that something landed -- so the line that promises where
592- // it will land is fed by the drag's own moves, which do carry the
593- // pointer (gpui div.rs:282). On the root, because a drag crosses
594- // the window: it starts on a clip or on a library row and ends over
595- // a lane, and only an ancestor of both hears all of it.
596- .on_drag_move(cx.listener(|this, event: &DragMoveEvent<ClipDrag>, _, cx| {
597- // The clip the payload named, wherever an edit mid-drag has
598- // since put it ([`Player::dragged`]): the line has to promise a
599- // landing for the take actually in the hand.
600- let drag = *event.drag(cx);
601- if let Some(idx) = this.dragged(&drag) {
602- this.preview_drop(drag.lane, idx, event.event.position.x, cx);
603- }
604- // The shadow belongs to a *lane*, and which lane the pointer is
605- // over is the one thing this element cannot see. Cleared here
606- // and drawn again by the lane the pointer is actually inside
607- // (`lane_row`), which gpui runs straight after this one: the
608- // capture phase goes parent first, so a pointer over no lane at
609- // all -- up in the library, say -- promises nothing.
610- this.set_ghost(Vec::new(), cx);
611- }))
612- .on_drag_move(
613- cx.listener(|this, event: &DragMoveEvent<AssetDrag>, _, cx| {
614- this.preview_place(event.event.position.x, cx);
615- this.set_ghost(Vec::new(), cx);
616- }),
617- )
618- // The same pair for the two subtitle gestures, for the same reason:
619- // a palette row starts up in the library and a caption starts on a
620- // lane, and both are let go somewhere else entirely.
621- .on_drag_move(cx.listener(|this, event: &DragMoveEvent<SubPick>, _, cx| {
622- this.preview_place(event.event.position.x, cx);
623- this.set_ghost(Vec::new(), cx);
624- }))
625- .on_drag_move(cx.listener(|this, event: &DragMoveEvent<SubDrag>, _, cx| {
626- // The placement gpui froze into the payload, whose *length* is
627- // all the line needs; which caption it is is the drop's
628- // question ([`Player::dragged_sub`]).
629- let (drag, x) = (*event.drag(cx), event.event.position.x);
630- let cue = this.sub_drop_frame(drag.sub, x).1;
631- this.set_cue(cue, x, cx);
632- this.set_ghost(Vec::new(), cx);
633- }))
634- // Scrubbing is tracked on the root because the pointer leaves the
635- // 6 px ruler on the first drag and its own listeners then stop
636- // firing; the root's hitbox is the whole window.
637- .on_mouse_move(cx.listener(Self::drag_move))
638- .on_mouse_up(MouseButton::Left, cx.listener(Self::drag_release))
639- .size_full()
640- .flex()
641- .flex_col()
642- .bg(rgb(BG_CANVAS()))
643- .text_color(rgb(FG_PRIMARY()))
644- .text_size(px(12.))
645- // Four regions, the arrangement every consumer editor shares:
646- // library left, picture centre, inspector right, and the timeline
647- // full width along the bottom with its edit toolbar directly above
648- // it. Nothing here moves when the state changes -- the regions are
649- // fixed and the panels keep their room whether or not anything is
650- // open in them.
651- // Player fullscreen: the picture and nothing else -- what
652- // `Fullscreen` gives every consumer video player. The four-region
653- // layout is skipped rather than hidden under it (a hidden library
654- // and inspector would still lay out and take the split's own
655- // room), and the picture div itself is untouched either way --
656- // [`Player::picture_area`] is the same call in both arms.
657- .when(self.player_fullscreen, |d| {
658- d.child(self.picture_area(position, window, cx))
659- })
660- .when(!self.player_fullscreen, |d| {
661- d.child(self.topbar(window, cx))
662- .child(
663- div()
664- .flex_1()
665- .min_h(px(0.))
666- .flex()
667- .child(
668- self.library(
669- self.split_px(Split::Library, window.viewport_size()),
670- cx,
671- ),
672- )
673- // The seams, one per pair of regions: what a hand
674- // drags to give a panel more room and its
675- // neighbour less ([`divider`]).
676- .child(divider(Split::Library, cx))
677- .child(
678- div()
679- .flex_1()
680- .min_w(px(0.))
681- .flex()
682- .flex_col()
683- .child(self.picture_area(position, window, cx))
684- .child(self.transport_bar(state, window.viewport_size(), cx)),
685- )
686- .child(divider(Split::Inspector, cx))
687- // The settings cards live in here rather than over
688- // the timeline: adjusting a clip must not hide the
689- // clip.
690- .child(self.inspector(window.viewport_size(), cx)),
691- )
692- // Above the toolbar rather than under it: the toolbar is
693- // a fixed strip belonging to the timeline, so the pair
694- // moves as one and the edge the hand is pulling is the
695- // edge under the pointer.
696- .child(divider(Split::Timeline, cx))
697- .child(self.toolbar(cx))
698- .child(self.timeline(position, state, window.viewport_size(), cx))
699- })
700- // Over the region they were opened on, and under the modal cards:
701- // they are only ever up while none of those is (`modal`).
702- .children(self.context_card(window.viewport_size(), cx))
703- .children(self.library_card(window.viewport_size(), cx))
704- // The two that are genuinely modal -- the whole registry, and the
705- // card that writes a file -- are the only sheets left over the
706- // window.
707- .children(self.keys_overlay(cx))
708- .children(self.export_card(window.viewport_size(), cx))
709- // The same sheet once the card has been answered: the running
710- // export is the one state in this window where nothing may be
711- // edited, so it is drawn as what it is rather than as a strip.
712- .children(self.export_progress_card(cx))
713- // Last, so it floats over whatever opened it -- an inspector row or
714- // a clip menu -- rather than under it.
715- .children(self.picker_card(window.viewport_size(), cx)))
716- .into_any_element()
717 }229 }
718 }230 }
crates/app/src/tests/cards.rsmodified+16 -161
@@ -3,7 +3,7 @@
3 3
4 use super::*;4 use super::*;
5 use crate::audio_cards::EQ_GRAPH_MAX_H;5 use crate::audio_cards::EQ_GRAPH_MAX_H;
6-use crate::ui::inspector::transition_of;6+use crate::ui::dock_stance::transition_of;
7 use std::sync::atomic::Ordering;7 use std::sync::atomic::Ordering;
8 8
9 /// FAULT 2's general shape (not just the source dot's menu): `overlaid()`9 /// FAULT 2's general shape (not just the source dot's menu): `overlaid()`
@@ -29,7 +29,7 @@ fn no_overlaid_state_in_the_stance_goes_modal_without_painting_something() {
29 );29 );
30 }30 }
31 let guard_at = stance31 let guard_at = stance
32- .find("if this.rebinding.is_some()\n || this.card_open()")32+ .find("if this.card_open()\n || this.context_menu.is_some()")
33 .expect("the stance's modal guard");33 .expect("the stance's modal guard");
34 let guard = &stance[guard_at..guard_at + 1600];34 let guard = &stance[guard_at..guard_at + 1600];
35 for field in [35 for field in [
@@ -39,7 +39,7 @@ fn no_overlaid_state_in_the_stance_goes_modal_without_painting_something() {
39 ] {39 ] {
40 assert!(40 assert!(
41 guard.contains(field),41 guard.contains(field),
42- "the overlaid()/rebinding branch no longer clears {field} on every key -- \42+ "the overlaid() branch no longer clears {field} on every key -- \
43 a menu can go modal and unrecoverable again (FAULT 2)"43 a menu can go modal and unrecoverable again (FAULT 2)"
44 );44 );
45 }45 }
@@ -139,7 +139,7 @@ fn every_modal_field_has_a_mounted_surface_somewhere_in_the_darkroom() {
139 fn the_stances_key_guard_does_not_swallow_a_bare_export_before_the_oracle_is_asked() {139 fn the_stances_key_guard_does_not_swallow_a_bare_export_before_the_oracle_is_asked() {
140 let stance = src_text("ui/stance.rs");140 let stance = src_text("ui/stance.rs");
141 let guard_at = stance141 let guard_at = stance
142- .find("if this.rebinding.is_some()\n || this.card_open()")142+ .find("if this.card_open()\n || this.context_menu.is_some()")
143 .expect("the stance's modal guard moved -- update this test's search string");143 .expect("the stance's modal guard moved -- update this test's search string");
144 let guard_line = &stance[guard_at..guard_at + 200];144 let guard_line = &stance[guard_at..guard_at + 200];
145 assert!(145 assert!(
@@ -159,58 +159,6 @@ fn the_stances_key_guard_does_not_swallow_a_bare_export_before_the_oracle_is_ask
159 );159 );
160 }160 }
161 161
162-#[test]
163-fn a_bare_escape_leaves_player_fullscreen_before_anything_under_it() {
164- // Fires while the picture-only layout is up, on the same bare escape
165- // every menu and preview close on -- and only that key: a chord, or an
166- // escape while not fullscreen, means nothing to it.
167- assert!(escape_leaves_player_fullscreen("escape", false, true));
168- assert!(!escape_leaves_player_fullscreen("escape", false, false));
169- assert!(!escape_leaves_player_fullscreen("escape", true, true));
170- assert!(!escape_leaves_player_fullscreen("q", false, true));
171-}
172-
173-#[test]
174-fn only_a_chord_gets_out_of_an_export() {
175- use keymap::ActionId;
176- // What this guards: bare escape is the stroke a hand throws at anything on
177- // screen, and while an export ran it deleted the encode. The way out is the
178- // same key with control on it, and the card says so.
179- assert!(cancels_export("escape", true, Some(ActionId::CancelExport)));
180- assert!(!cancels_export("escape", false, None));
181- // Even if something else were ever bound to bare escape, it is not this.
182- assert!(!cancels_export("escape", false, Some(ActionId::Play)));
183- // A rebound cancel works as well -- it adds a way out, never replaces the
184- // chord, and the keymap is what decides whether that one carries control.
185- assert!(cancels_export("q", false, Some(ActionId::CancelExport)));
186- // Nothing else does, whatever it means outside an export.
187- assert!(!cancels_export("e", false, Some(ActionId::Export)));
188- assert!(!cancels_export("space", false, Some(ActionId::Play)));
189- assert!(!cancels_export("q", false, None));
190- // The default keymap is what the handler feeds this: the chord reaches
191- // CancelExport, the bare key reaches Deselect instead -- neither of which
192- // this guard lets cancel a running export.
193- let k = keymap::Keymap::defaults();
194- assert!(cancels_export("escape", true, k.lookup("escape", true)));
195- assert!(!cancels_export("escape", false, k.lookup("escape", false)));
196-}
197-
198-#[test]
199-fn a_capture_waits_through_a_lone_modifier() {
200- // gpui delivers these on their own; taking one as a binding would make
201- // the action fire on the way to every chord that uses it.
202- for key in [
203- "control", "shift", "alt", "super", "platform", "function", "fn", "meta", "command",
204- ] {
205- assert!(is_bare_modifier(key), "{key}");
206- }
207- // Everything a binding is actually made of, escape included -- the
208- // capture branch turns that one away itself.
209- for key in ["c", "x", "space", "escape", "delete", "f1", "z"] {
210- assert!(!is_bare_modifier(key), "{key}");
211- }
212-}
213-
214 /// The whole point of the card: there is no action a pointer cannot reach.162 /// The whole point of the card: there is no action a pointer cannot reach.
215 /// It renders [`keys_rows`] and nothing else, so this reads the same list163 /// It renders [`keys_rows`] and nothing else, so this reads the same list
216 /// the card does -- add an `ActionId` and forget to surface it and this164 /// the card does -- add an `ActionId` and forget to surface it and this
@@ -263,78 +211,10 @@ fn every_action_is_on_the_actions_card() {
263 assert!(!action.label().is_empty(), "{action:?}");211 assert!(!action.label().is_empty(), "{action:?}");
264 assert_ne!(keymap.display(action), "unbound", "{action:?}");212 assert_ne!(keymap.display(action), "unbound", "{action:?}");
265 }213 }
266- // The list scrolls inside a card the smallest window holds, so a
267- // thirty-fourth action costs no height at all.
268- assert!(
269- rows.len() as f32 * KEYS_ROW_H > KEYS_ROWS_H,
270- "no cap needed?"
271- );
272 // Both halves of a row are click targets, so WCAG 2.5.8 binds them.214 // Both halves of a row are click targets, so WCAG 2.5.8 binds them.
273 assert!(KEYS_ROW_H >= HIT_MIN);215 assert!(KEYS_ROW_H >= HIT_MIN);
274 }216 }
275 217
276-/// The search box: what a typed word leaves standing. Forty actions is more
277-/// than a 360 px window shows at once, so this is the card's answer to
278-/// "where is the one I want" -- and a heading with nothing under it would
279-/// be worse than no filter at all.
280-#[test]
281-fn a_search_leaves_the_rows_it_names_under_their_own_headings() {
282- use keymap::{ActionId, Category, Keymap};
283- let keymap = Keymap::defaults();
284- let acts = |found: &[(usize, KeyRow)]| -> Vec<ActionId> {
285- found
286- .iter()
287- .filter_map(|(_, r)| match r {
288- KeyRow::Act(a) => Some(*a),
289- _ => None,
290- })
291- .collect()
292- };
293- let heads = |found: &[(usize, KeyRow)]| -> Vec<Category> {
294- found
295- .iter()
296- .filter_map(|(_, r)| match r {
297- KeyRow::Head(c) => Some(*c),
298- _ => None,
299- })
300- .collect()
301- };
302- // Nothing typed hides nothing, and every row keeps its place in the
303- // unfiltered list: an element id must not move under a keystroke.
304- let all = keys_filter("", &keymap);
305- assert_eq!(all.len(), keys_rows().len());
306- assert!(all.iter().enumerate().all(|(n, (i, _))| n == *i));
307- // The word the user types is the word on the row. The mix card names
308- // the track volumes, so it is an honest hit; the fixed row about the
309- // volume keys is another, and each comes with its own heading only.
310- let vol = keys_filter("vol", &keymap);
311- assert_eq!(
312- acts(&vol),
313- vec![ActionId::VolumeUp, ActionId::VolumeDown, ActionId::Mix]
314- );
315- assert_eq!(heads(&vol), vec![Category::Audio, Category::View]);
316- // Case is not part of the question, in either direction.
317- assert_eq!(keys_filter("VoL", &keymap).len(), vol.len());
318- // The stroke column is searched too -- "what did ctrl do again" -- and
319- // an unbound-looking word finds nothing rather than everything.
320- let ctrl = keys_filter("ctrl+", &keymap);
321- assert!(acts(&ctrl).contains(&ActionId::Save));
322- assert!(!acts(&ctrl).contains(&ActionId::Play));
323- assert!(
324- keys_filter("qzx", &keymap).is_empty(),
325- "headings left behind"
326- );
327- // The card's own door is on the card, by name and by stroke.
328- assert_eq!(
329- acts(&keys_filter("?", &keymap)),
330- vec![ActionId::ShowActions]
331- );
332- assert_eq!(
333- acts(&keys_filter("all actions", &keymap)),
334- vec![ActionId::ShowActions]
335- );
336-}
337-
338 /// What a keystroke means to that box: a letter is a letter, and a word218 /// What a keystroke means to that box: a letter is a letter, and a word
339 /// gpui reports for a key that prints nothing is not typed letter by219 /// gpui reports for a key that prints nothing is not typed letter by
340 /// letter into the search.220 /// letter into the search.
@@ -364,24 +244,9 @@ fn the_keybindings_card_fits_the_smallest_window() {
364 // The line the list scrolls under: margin, rule, padding.244 // The line the list scrolls under: margin, rule, padding.
365 let separator = 4. + 1. + 4.;245 let separator = 4. + 1. + 4.;
366 assert!(246 assert!(
367- title + status + search + separator + KEYS_ROWS_H + gaps + padding <= 360.,247+ title + status + search + separator + 10. * KEYS_ROW_H + gaps + padding <= 360.,
368 "card too tall"248 "card too tall"
369 );249 );
370- // ...and the list is the only part that grows with the editor, so the
371- // rows past the fold are reached by scrolling that viewport (and, with
372- // forty of them, by the search box above it) rather than by a card
373- // taller than the window.
374- assert!(
375- keys_rows().len() as f32 * KEYS_ROW_H > KEYS_ROWS_H,
376- "the list outgrew the viewport long ago; the cap must still scroll"
377- );
378- // The cap is only honest if it is the taller list that scrolls, not the
379- // card that grows: every action must be reachable by scrolling, and
380- // enough of them visible that the list reads as a list.
381- assert!(
382- KEYS_ROWS_H / KEYS_ROW_H >= 8.,
383- "too few rows visible to scan"
384- );
385 assert!(KEYS_W <= 640., "card too wide");250 assert!(KEYS_W <= 640., "card too wide");
386 // The rows are clickable, so WCAG 2.5.8 binds them like every other251 // The rows are clickable, so WCAG 2.5.8 binds them like every other
387 // target in this window.252 // target in this window.
@@ -507,7 +372,7 @@ fn the_equalizer_graph_puts_a_band_where_a_drag_reads_it_and_fits_the_smallest_w
507 "card too tall"372 "card too tall"
508 );373 );
509 assert!(374 assert!(
510- EQ_GRAPH_H <= EXPORT_ROWS_H,375+ EQ_GRAPH_H <= (8. * KEYS_ROW_H),
511 "graph taller than a card of rows"376 "graph taller than a card of rows"
512 );377 );
513 // What is dragged is the whole graph -- the handle is a 10 px dot, but378 // What is dragged is the whole graph -- the handle is a 10 px dot, but
@@ -789,7 +654,7 @@ fn a_colour_drag_lands_where_it_paints_and_the_card_fits_the_smallest_window() {
789 // The label still has room beside the bar and the readout, which is654 // The label still has room beside the bar and the readout, which is
790 // what the buttons coming off the row bought.655 // what the buttons coming off the row bought.
791 let row = COLOR_W - padding - 12. - 2. * 8. - COLOR_BAR_W - 44.;656 let row = COLOR_W - padding - 12. - 2. * 8. - COLOR_BAR_W - 44.;
792- assert!(row >= LABEL_MIN_W, "no room left for a label: {row}px");657+ assert!(row >= 36., "no room left for a label: {row}px");
793 // What is dragged is the whole row's height, not the 4 px the bar is658 // What is dragged is the whole row's height, not the 4 px the bar is
794 // drawn as (WCAG 2.5.8) -- the same split the ruler makes.659 // drawn as (WCAG 2.5.8) -- the same split the ruler makes.
795 assert!(KEYS_ROW_H >= HIT_MIN);660 assert!(KEYS_ROW_H >= HIT_MIN);
@@ -1117,16 +982,6 @@ fn the_sound_row_carries_its_rate_into_both_kinds_of_file() {
1117 }982 }
1118 // A rate no row holds marks none of them, rather than the wrong one.983 // A rate no row holds marks none of them, rather than the wrong one.
1119 assert!(audio_rate_choices(7).iter().all(|(.., picked)| !picked));984 assert!(audio_rate_choices(7).iter().all(|(.., picked)| !picked));
1120-
1121- // The wrap the row's key does, which is the row's own step function.
1122- assert_eq!(
1123- next_audio_kbps(AUDIO_KBPS[AUDIO_KBPS.len() - 1]),
1124- AUDIO_KBPS[0]
1125- );
1126- assert_eq!(next_audio_kbps(DEFAULT_AUDIO_KBPS), 320);
1127- // A rate no list holds (a stale one, say) lands back on the first row
1128- // rather than nowhere.
1129- assert_eq!(next_audio_kbps(7), AUDIO_KBPS[1]);
1130 }985 }
1131 986
1132 #[test]987 #[test]
@@ -1209,7 +1064,7 @@ fn a_typed_bitrate_is_a_field_and_not_a_key_capture() {
1209 assert!(detail.starts_with("6▏"), "{detail}");1064 assert!(detail.starts_with("6▏"), "{detail}");
1210 }1065 }
1211 1066
1212-/// [`crate::ui::inspector::transition_of`]: the inspector's duration row1067+/// [`crate::ui::dock_stance::transition_of`]: the dock's duration row
1213 /// appears only for an anchor that actually carries a dissolve or a1068 /// appears only for an anchor that actually carries a dissolve or a
1214 /// crossfade, and the room it offers is capped at what the successor clip1069 /// crossfade, and the room it offers is capped at what the successor clip
1215 /// actually has -- the same clamp [`engine::project::Project::set_transition_out`]/1070 /// actually has -- the same clamp [`engine::project::Project::set_transition_out`]/
@@ -1600,25 +1455,25 @@ fn the_export_card_fits_the_smallest_window() {
1600 let gaps = 5. * 2.;1455 let gaps = 5. * 2.;
1601 let padding = 24.;1456 let padding = 24.;
1602 assert_eq!(1457 assert_eq!(
1603- EXPORT_FIXED_H,1458+ (17. + 28. + 15. + 30. + CONTROL_H + 4. + 10. + 24.),
1604 title + status + summary + CONTROL_H + 4. + gaps + padding1459 title + status + summary + CONTROL_H + 4. + gaps + padding
1605 );1460 );
1606- assert!(EXPORT_FIXED_H + EXPORT_ROWS_H <= 360., "card too tall");1461+ assert!((17. + 28. + 15. + 30. + CONTROL_H + 4. + 10. + 24.) + (8. * KEYS_ROW_H) <= 360., "card too tall");
1607 // The list grows with a window that has the room -- and never shrinks1462 // The list grows with a window that has the room -- and never shrinks
1608 // below the cap that made the floor fit, whatever arithmetic the window1463 // below the cap that made the floor fit, whatever arithmetic the window
1609 // hands it.1464 // hands it.
1610- let cap = |h: f32| (h - EXPORT_FIXED_H - 24.).max(EXPORT_ROWS_H);1465+ let cap = |h: f32| (h - (17. + 28. + 15. + 30. + CONTROL_H + 4. + 10. + 24.) - 24.).max(8. * KEYS_ROW_H);
1611- assert_eq!(cap(360.), EXPORT_ROWS_H);1466+ assert_eq!(cap(360.), (8. * KEYS_ROW_H));
1612- assert_eq!(cap(0.), EXPORT_ROWS_H);1467+ assert_eq!(cap(0.), (8. * KEYS_ROW_H));
1613- assert!(cap(720.) > EXPORT_ROWS_H);1468+ assert!(cap(720.) > (8. * KEYS_ROW_H));
1614- assert!(EXPORT_FIXED_H + cap(720.) <= 720.);1469+ assert!((17. + 28. + 15. + 30. + CONTROL_H + 4. + 10. + 24.) + cap(720.) <= 720.);
1615 // ...and inside the 640 px floor with the scrim showing either side.1470 // ...and inside the 640 px floor with the scrim showing either side.
1616 assert!(EXPORT_W + 2. * 12. <= 640.);1471 assert!(EXPORT_W + 2. * 12. <= 640.);
1617 // The cap is only honest if enough of the list is on screen to read as1472 // The cap is only honest if enough of the list is on screen to read as
1618 // one -- and the whole format section is: its header and every codec1473 // one -- and the whole format section is: its header and every codec
1619 // row, so nothing that is picked *first* is behind a scroll.1474 // row, so nothing that is picked *first* is behind a scroll.
1620 let codecs = FORMATS.iter().filter(|(row, ..)| !row.is_empty()).count();1475 let codecs = FORMATS.iter().filter(|(row, ..)| !row.is_empty()).count();
1621- assert!(EXPORT_ROWS_H / KEYS_ROW_H >= 1. + codecs as f32);1476+ assert!((8. * KEYS_ROW_H) / KEYS_ROW_H >= 1. + codecs as f32);
1622 // Clickable rows, so WCAG 2.5.8 binds them as it binds the panel's --1477 // Clickable rows, so WCAG 2.5.8 binds them as it binds the panel's --
1623 // and the bitrate steppers are `HIT_MIN` squares sitting inside a row,1478 // and the bitrate steppers are `HIT_MIN` squares sitting inside a row,
1624 // which only fits while the row is at least as tall as one.1479 // which only fits while the row is at least as tall as one.
crates/app/src/tests/editing.rsmodified+12 -25
@@ -2303,17 +2303,6 @@ fn a_project_that_makes_no_proxies_by_itself_starts_none_until_it_is_cut_on_them
2303 assert!(proxies_to_start(true, true, &sources, &seen).is_empty());2303 assert!(proxies_to_start(true, true, &sources, &seen).is_empty());
2304 }2304 }
2305 2305
2306-#[test]
2307-fn the_add_button_is_dead_unless_it_would_do_something() {
2308- let picked = (PathBuf::from("/m/0.mp4"), 0);
2309- assert!(can_add(Some(&picked), true, false));
2310- // Nothing picked, nothing to put it on, or an export reading the very
2311- // edit list this would change.
2312- assert!(!can_add(None, true, false));
2313- assert!(!can_add(Some(&picked), false, false));
2314- assert!(!can_add(Some(&picked), true, true));
2315-}
2316-
2317 #[test]2306 #[test]
2318 fn the_media_column_never_takes_the_picture_over() {2307 fn the_media_column_never_takes_the_picture_over() {
2319 for window in [360., 640., 1280., 1920., 3840.] {2308 for window in [360., 640., 1280., 1920., 3840.] {
@@ -2326,10 +2315,6 @@ fn the_media_column_never_takes_the_picture_over() {
2326 }2315 }
2327 // It yields: a narrower window gives the list less, never the same.2316 // It yields: a narrower window gives the list less, never the same.
2328 assert!(crate::library_w(640.) < crate::library_w(1280.));2317 assert!(crate::library_w(640.) < crate::library_w(1280.));
2329- // Rows are clickable, so WCAG 2.5.8 binds them like every other target,
2330- // and a name over a timecode has to fit inside one.
2331- assert!(ROW_H >= HIT_MIN);
2332- assert!(SWATCH_W < LIBRARY_MIN_W);
2333 }2318 }
2334 2319
2335 #[test]2320 #[test]
@@ -2460,28 +2445,30 @@ fn should_loop_restart_is_play_state_blind_the_pump_gates_it() {
2460 /// are still there once it is gone.2445 /// are still there once it is gone.
2461 #[test]2446 #[test]
2462 fn escape_closes_a_card_before_it_can_ever_reach_deselect() {2447 fn escape_closes_a_card_before_it_can_ever_reach_deselect() {
2463- let render_rs = src_text("render.rs");2448+ // The legacy handler this test named (`render.rs`) is gone; the same
2464- let dispatch = render_rs2449+ // ordering now lives in the darkroom's own root key handler
2465- .find("if let Some(action) = action {")2450+ // (`ui::stance::render`'s `on_key_down`). Player fullscreen is no
2451+ // longer a "picture-only" layout escape leaves a special way -- it is
2452+ // real OS fullscreen now (`ActionId::Fullscreen`, toggled on `f11`),
2453+ // so that guard has nothing left to name here.
2454+ let stance_rs = src_text("ui/stance.rs");
2455+ let dispatch = stance_rs
2456+ .find("if let Some(action) = this.keymap.lookup(key, ctrl) {")
2466 .expect("the keymap fallthrough that fires Deselect");2457 .expect("the keymap fallthrough that fires Deselect");
2467 for (guard, label) in [2458 for (guard, label) in [
2468- ("if this.keys_open {", "the keys overlay"),
2469 ("if this.dock_filter_edit {", "the dock filter"),2459 ("if this.dock_filter_edit {", "the dock filter"),
2470 (2460 (
2471 "if this.param_card_key(key, event.keystroke.modifiers.shift, cx) {",2461 "if this.param_card_key(key, event.keystroke.modifiers.shift, cx) {",
2472 "a param card",2462 "a param card",
2473 ),2463 ),
2474- (2464+ ("if this.card_open()", "a card (keys overlay/export/eq/color/...)"),
2475- "if escape_leaves_player_fullscreen(key, ctrl, this.player_fullscreen) {",2465+ ("|| this.context_menu.is_some()", "the clip/row menu or a list"),
2476- "player fullscreen",
2477- ),
2478- ("let clip_menu = this.context_menu.take().is_some();", "the clip/row menu or a list"),
2479 (2466 (
2480 "if key == ESCAPE && !ctrl && this.preview_session.is_some() {",2467 "if key == ESCAPE && !ctrl && this.preview_session.is_some() {",
2481 "an open preview",2468 "an open preview",
2482 ),2469 ),
2483 ] {2470 ] {
2484- let at = render_rs2471+ let at = stance_rs
2485 .find(guard)2472 .find(guard)
2486 .unwrap_or_else(|| panic!("{label}'s own escape guard moved or was renamed"));2473 .unwrap_or_else(|| panic!("{label}'s own escape guard moved or was renamed"));
2487 assert!(2474 assert!(
crates/app/src/tests/layout.rsmodified+112 -323
@@ -3,47 +3,6 @@
3 3
4 use super::*;4 use super::*;
5 5
6-/// The edit toolbar against the 640x360 floor the whole editor is measured
7-/// at. It does not fit and cannot be made to -- so what it may never do is
8-/// *hide* the tail: the row scrolls, and the door to everything scrolled
9-/// off it is pinned outside the scrolling box.
10-#[test]
11-fn toolbar_fits_the_smallest_window() {
12- let toolbar = src_text("ui/toolbar.rs");
13- let row = &toolbar[toolbar.find("pub(crate) fn toolbar(").expect("the toolbar")..];
14- // Every button in the row is a hit target, so none of them is narrower
15- // than `HIT_MIN`, and they sit in 8 px gaps inside the row's own 12 px
16- // padding.
17- let buttons = row.matches("action_control(").count();
18- assert!(buttons >= 11, "the row's buttons moved; this scan is blind");
19- // The row is shorter than it was -- the project's own settings (size,
20- // rate, HDR) are the inspector's now and the transport is the
21- // picture's -- so whether it fits at 640 px depends on the words in it
22- // and is not something this scan can measure. What it can hold to is
23- // the rule: "it scrolls" is not "it can be found", so the door to
24- // whatever is off the right edge is pinned outside the scrolling box
25- // and the card it opens carries every action there is
26- // (`every_action_is_on_the_actions_card`).
27- assert!(
28- row.contains("\"controls-more\""),
29- "nothing pinned beside the scrolling row: the tail is unreachable at 640 px"
30- );
31- assert_eq!(row.matches("overflow_x_scroll").count(), 1);
32- assert!(
33- row.find("\"controls-more\"") > row.find("overflow_x_scroll"),
34- "the pinned door is inside the row it is meant to outlive"
35- );
36- // ...and nothing in the row decides for itself whether it can act: the
37- // oracle does, once, for the key and the button alike. A raw `control(`
38- // in here is a button that can go dead while its stroke still fires --
39- // the bug this redesign was called in for.
40- assert_eq!(
41- row.matches("\n .child(control(").count(),
42- 0,
43- "a toolbar button bypassing the availability oracle"
44- );
45-}
46-
47 /// The class the user reported twice in one day ("some menus are belongs to6 /// The class the user reported twice in one day ("some menus are belongs to
48 /// old ui ... for example resolution picker", then "right click menu in7 /// old ui ... for example resolution picker", then "right click menu in
49 /// library is old too"): a surface that paints a *role* token8 /// library is old too"): a surface that paints a *role* token
@@ -164,30 +123,6 @@ fn the_line_about_what_is_below_the_fold_counts_what_is_still_below_it() {
164 "{} px of chrome and a lane will not fit {floor} px",123 "{} px of chrome and a lane will not fit {floor} px",
165 timeline_fixed_h(true)124 timeline_fixed_h(true)
166 );125 );
167- // The lane questions, asked of the mixed math the render actually walks
168- // (the uniform lanes_shown/rows_below pair went with their last caller;
169- // a lane in the stack may be a thinner
170- // caption one: a uniform stack answers exactly what the plain
171- // functions above do, and a mixed one answers off the real heights,
172- // never the media one alone.
173- let uniform = [LaneKind::Video, LaneKind::Audio];
174- assert_eq!(lanes_h_mixed(&uniform), lanes_h(2));
175- assert_eq!(lanes_shown_mixed(&uniform, LANE_H), 1);
176- let mixed = [LaneKind::Video, LaneKind::Audio, LaneKind::Subtitle];
177- assert_eq!(
178- lanes_h_mixed(&mixed),
179- 2. * LANE_H + SUB_LANE_H + 2. * 8.,
180- "a caption lane is not counted as a full LANE_H row"
181- );
182- // A box exactly tall enough for the two media lanes and no more: the
183- // thinner third lane still does not fit above it.
184- assert_eq!(lanes_shown_mixed(&mixed, lanes_h(2)), 2);
185- // ...and with room for the caption lane too, all three show and
186- // nothing is below the fold.
187- assert_eq!(lanes_shown_mixed(&mixed, lanes_h_mixed(&mixed)), 3);
188- assert_eq!(rows_below_mixed(&mixed, lanes_h_mixed(&mixed), 0.), 0);
189- assert_eq!(rows_below_mixed(&mixed, lanes_h(2), 0.), 1);
190-
191 // The inspector's rows are not one height, so its own line is measured126 // The inspector's rows are not one height, so its own line is measured
192 // in pixels off the scroll instead: gpui keeps the offset negative going127 // in pixels off the scroll instead: gpui keeps the offset negative going
193 // down, and at the bottom the two cancel out exactly.128 // down, and at the bottom the two cancel out exactly.
@@ -287,11 +222,12 @@ fn a_message_wears_the_colour_its_own_words_say() {
287 /// overlay again, whatever it looked like on the day it was written.222 /// overlay again, whatever it looked like on the day it was written.
288 #[test]223 #[test]
289 fn an_inspector_section_occludes_no_timeline() {224 fn an_inspector_section_occludes_no_timeline() {
290- let inspector = src_text("ui/inspector.rs");
291 // Whichever file the root render has come to live in, from the impl to the225 // Whichever file the root render has come to live in, from the impl to the
292 // end of it -- found rather than named, so moving the root does not quietly226 // end of it -- found rather than named, so moving the root does not quietly
293 // leave this rule reading a file the render is no longer in.227 // leave this rule reading a file the render is no longer in.
294 let render = source_from("impl Render for Player");228 let render = source_from("impl Render for Player");
229+ let dock = src_text("ui/dock_stance.rs");
230+ let stance = src_text("ui/stance.rs");
295 for card in [231 for card in [
296 "eq_card",232 "eq_card",
297 "color_card",233 "color_card",
@@ -300,56 +236,48 @@ fn an_inspector_section_occludes_no_timeline() {
300 "mix_card",236 "mix_card",
301 "subtitle_style_card",237 "subtitle_style_card",
302 ] {238 ] {
239+ // Docked (unmaximized), the card is a section of the dock's own
240+ // narrow column; maximized, it escapes to `stance-centre`'s window-
241+ // space positioning context instead -- either way it is mounted
242+ // through the darkroom's own structure, never straight off the
243+ // root render.
303 assert!(244 assert!(
304- inspector.contains(&format!("self.{card}(")),245+ dock.contains(&format!("player.{card}("))
305- "{card} is not a section of the inspector"246+ || stance.contains(&format!("player.{card}(")),
247+ "{card} is not mounted anywhere in the darkroom"
306 );248 );
307 assert!(249 assert!(
308 !render.contains(&format!("self.{card}(")),250 !render.contains(&format!("self.{card}(")),
309 "{card} is drawn from the root again -- it is an overlay over the timeline"251 "{card} is drawn from the root again -- it is an overlay over the timeline"
310 );252 );
311 }253 }
312- // The docked cards are placed against the inspector's own box, which is254+ // The docked cards are placed against the dock's own box, and the
313- // what turns `scrim()` (`absolute().inset_0()`) from a window-wide sheet255+ // maximized escape against `stance-centre` -- both positioning contexts,
314- // into this column.256+ // which is what turns `scrim()` (`absolute().inset_0()`) from a
257+ // window-wide sheet into a contained one.
315 assert!(258 assert!(
316- inspector.contains(".relative()"),259+ stance.contains(".relative()"),
317- "the inspector is not a positioning context: its cards would cover the window"260+ "the darkroom has no positioning context: its cards would cover the window"
318 );261 );
319 }262 }
320 263
321-/// MUST 1, on the two named offenders: the button that relabels itself
322-/// mid-export and the one that used to read "Muted 80%". Both live in a
323-/// rect that is reserved once, so the words change and the box does not.
324 #[test]264 #[test]
325 fn a_stateful_button_keeps_its_rect() {265 fn a_stateful_button_keeps_its_rect() {
326- use crate::ui::toolbar::{EXPORT_SLOT_W, SNAP_SLOT_W, VOLUME_SLOT_W};266+ // A toggle's own state must never gate whether the button exists --
327- // Widest word each slot can hold, at the 12 px text this window is set267+ // only how it looks. Flip the state and the pointer's target (the
328- // in -- ~7 px a character plus the 16 px of padding.268+ // element the hitmap id names, and the rect a click lands on) is
329- let fits = |slot: f32, word: &str| slot >= word.chars().count() as f32 * 7. + 16.;269+ // unchanged; only the label and the `active` styling read the flag.
330- for word in ["Export", "Cancel"] {270+ // "eq-spectrum" and "export-cancel" are the darkroom's own stateful
331- assert!(fits(EXPORT_SLOT_W, word), "{word} overflows its rect");271+ // toggles: the first flips `self.eq_spectrum`, the second reads
332- }272+ // `armed` (whether cancel is armed), and neither may gate its own
333- for word in ["Snap on", "Snap off", "No subs", "Subs off"] {273+ // button out of the tree.
334- assert!(fits(SNAP_SLOT_W, word), "{word} overflows its rect");274+ let cards = src_text("ui/cards.rs");
335- }275+ for (id, flag) in [("\"eq-spectrum\"", "self.eq_spectrum"), ("\"export-cancel\"", "armed")] {
336- for word in ["100%", "× 100%"] {276+ let at = cards.find(id).unwrap_or_else(|| panic!("no {id} button"));
337- assert!(fits(VOLUME_SLOT_W, word), "{word} overflows its rect");277+ let before = &cards[at.saturating_sub(350)..at];
338- }
339- // And the rect is passed, not hoped for: every stateful control in the
340- // three chrome rows names its width.
341- let toolbar = src_text("ui/toolbar.rs");
342- for (id, slot) in [
343- ("\"export\"", "EXPORT_SLOT_W"),
344- ("\"snap\"", "SNAP_SLOT_W"),
345- ("\"subs\"", "SNAP_SLOT_W"),
346- ("\"volume\"", "VOLUME_SLOT_W"),
347- ("\"zoom-fit\"", "ZOOM_SLOT_W"),
348- ] {
349- let at = toolbar.find(id).unwrap_or_else(|| panic!("no {id} button"));
350 assert!(278 assert!(
351- toolbar[at..at + 120].contains(slot),279+ !before.contains(&format!(".when({flag}")) && !before.contains(&format!(".when(!{flag}")),
352- "{id} does not reserve {slot}"280+ "{id} is gated on the very flag it flips -- its rect would move when the state does"
353 );281 );
354 }282 }
355 }283 }
@@ -361,11 +289,6 @@ fn nothing_clickable_is_smaller_than_the_wcag_minimum() {
361 assert!(CONTROL_H >= HIT_MIN);289 assert!(CONTROL_H >= HIT_MIN);
362 assert!(RULER_HIT_H >= HIT_MIN);290 assert!(RULER_HIT_H >= HIT_MIN);
363 assert!(LANE_H >= HIT_MIN);291 assert!(LANE_H >= HIT_MIN);
364- // A caption lane's header carries exactly one hit target now (the
365- // show/hide eye; remove moved to its right button), and that target
366- // fills the whole row -- so the row is never allowed to undercut the
367- // target it *is*.
368- assert!(SUB_LANE_H >= HIT_MIN);
369 // A clip box is a hit target too, and its two trim strips occlude it:292 // A clip box is a hit target too, and its two trim strips occlude it:
370 // on a box narrower than the pair there is no body left to press, so293 // on a box narrower than the pair there is no body left to press, so
371 // the clip cannot be selected, dragged or menued at all -- which is294 // the clip cannot be selected, dragged or menued at all -- which is
@@ -388,9 +311,6 @@ fn nothing_clickable_is_smaller_than_the_wcag_minimum() {
388 311
389 #[test]312 #[test]
390 fn a_lane_row_is_a_fixed_header_and_a_bed_that_can_be_hit() {313 fn a_lane_row_is_a_fixed_header_and_a_bed_that_can_be_hit() {
391- // The header column is what the ruler is offset by as well, so both
392- // numbers are shared rather than repeated per row (A-MUST1/A-MUST2).
393- assert!(HEADER_W > 0. && HEADER_GAP >= 0.);
394 // Two lanes, a ruler, a button row and the timecode line, inside the314 // Two lanes, a ruler, a button row and the timecode line, inside the
395 // panel the window is sized for.315 // panel the window is sized for.
396 assert!(316 assert!(
@@ -420,64 +340,6 @@ fn a_lane_row_is_a_fixed_header_and_a_bed_that_can_be_hit() {
420 assert_eq!(lanes_h(2), 2. * LANE_H + 8.);340 assert_eq!(lanes_h(2), 2. * LANE_H + 8.);
421 }341 }
422 342
423-/// The scrollbar's thumb: the visible share of the timeline at its own
424-/// place on the track, full width with nothing to scroll, never narrower than
425-/// a hand can hold, and never off the ends.
426-#[test]
427-fn the_scroll_thumb_is_the_visible_share_at_its_own_place() {
428- use crate::SCROLL_THUMB_MIN;
429- use crate::scroll_thumb;
430-
431- // Nothing to scroll: the strip fills and says so.
432- assert_eq!(scroll_thumb(400., 10., 0., 12.), (0., 400.));
433- assert_eq!(scroll_thumb(400., 0., 0., 0.), (0., 400.));
434- // Half the timeline on the bed: a half-width thumb, halfway along for a
435- // window starting halfway in.
436- assert_eq!(scroll_thumb(400., 20., 0., 10.), (0., 200.));
437- assert_eq!(scroll_thumb(400., 20., 10., 10.), (200., 200.));
438- // The floor width: however long the timeline, the thumb stays holdable --
439- // and the clamp keeps it on the track, not the caller.
440- let (x, w) = scroll_thumb(400., 1_000_000., 999_000., 100.);
441- assert_eq!(w, SCROLL_THUMB_MIN);
442- assert_eq!(x, 400. - SCROLL_THUMB_MIN);
443- assert_eq!(scroll_thumb(400., 1_000_000., 0., 100.).0, 0.);
444-}
445-
446-/// A press beside the time axis's thumb jumps so the thumb's middle is under
447-/// the pointer, and the drag that carries on from the press must land exactly
448-/// where the jump left the view: both are read through the track's own
449-/// proportion (a jump worked out in pixels at the view's pps used to land at
450-/// span-over-duration of the target, and the snap on the first move was the
451-/// drag correcting it). The equality below is the no-snap invariant, at the
452-/// thumb's own width and at its floor width alike.
453-#[test]
454-fn a_beside_thumb_press_jumps_by_the_tracks_own_proportion() {
455- use crate::scroll_thumb;
456-
457- let bed = 400.;
458- // The mapping both halves of the gesture share: a place on the track is
459- // that share of the drawn duration.
460- let jump = |at: f32, thumb_w: f32| (at - thumb_w / 2.).max(0.) / bed;
461- for (duration, span) in [(100_f32, 20_f32), (1_000_000_f32, 100_f32)] {
462- let (_, thumb_w) = scroll_thumb(bed, f64::from(duration), 0., f64::from(span));
463- let at = 3. * bed / 4.;
464- let start = jump(at, thumb_w) * duration;
465- // The jump centres the thumb on the press (the far end of a million
466- // seconds is the clamp's to hold, so the pin is measured from the
467- // thumb the track actually shows).
468- let (x, w) = scroll_thumb(bed, f64::from(duration), f64::from(start), f64::from(span));
469- let centre = (x + w / 2.).min(bed - w / 2.);
470- assert!(
471- (centre - at.min(bed - w / 2.)).abs() < 1.,
472- "thumb centre {centre} not at the press {at}"
473- );
474- // The drag's first sample from that press -- the grabbed middle, the
475- // same track proportion -- is the same start, whatever the width.
476- let grab = thumb_w / 2.;
477- assert_eq!(jump(at, 2. * grab) * duration, start);
478- }
479-}
480-
481 /// The strip's row is furniture only while there is somewhere to scroll to:343 /// The strip's row is furniture only while there is somewhere to scroll to:
482 /// zoomed out to the whole timeline the strip is not drawn and neither is its344 /// zoomed out to the whole timeline the strip is not drawn and neither is its
483 /// height -- out of every budget at once (the region, the box the lanes are345 /// height -- out of every budget at once (the region, the box the lanes are
@@ -505,10 +367,7 @@ fn the_scroll_strip_row_comes_and_goes_with_the_zoom() {
505 // either face of the zoom boundary.367 // either face of the zoom boundary.
506 let floor = split_size(Split::Timeline, Some(0.), 2, window, scroll);368 let floor = split_size(Split::Timeline, Some(0.), 2, window, scroll);
507 let box_h = floor - timeline_fixed_h(scroll);369 let box_h = floor - timeline_fixed_h(scroll);
508- assert!(370+ assert!(box_h < lanes_h(2), "no line to pay for at the floor");
509- 2 > lanes_shown_mixed(&[LaneKind::Video, LaneKind::Audio], box_h),
510- "no line to pay for at the floor"
511- );
512 assert!(371 assert!(
513 box_h - LABEL_H - 8. >= LANE_H,372 box_h - LABEL_H - 8. >= LANE_H,
514 "the floor leaves {} px for a {LANE_H} px lane",373 "the floor leaves {} px for a {LANE_H} px lane",
@@ -554,57 +413,6 @@ fn the_lane_thumb_is_the_visible_share_of_the_stack() {
554 assert_eq!(lanes_thumb(200., 1_000_000., 200., 0.).0, 0.);413 assert_eq!(lanes_thumb(200., 1_000_000., 200., 0.).0, 0.);
555 }414 }
556 415
557-/// A caption's box wears the rate its window plays at, derived off the
558-/// placement itself: unity placements -- including odd widths whose frames
559-/// came off `frames_of_us` rounding -- do not badge, and a re-rate does, with
560-/// the rate surviving the group coming apart.
561-#[test]
562-fn a_caption_box_wears_the_rate_its_window_plays_at() {
563- use crate::caption_rate;
564-
565- let sub = |frames: u32, out_us: i64| SubClip {
566- start: 0,
567- frames,
568- track: 0,
569- in_us: 0,
570- out_us,
571- link: None,
572- };
573- // Unity, exact and rounded: neither is a re-timing.
574- assert_eq!(caption_rate(sub(300, 10_000_000), 30.), None);
575- assert_eq!(
576- caption_rate(sub(100, 3_333_333), 30.),
577- None,
578- "placement rounding is not a re-timing"
579- );
580- // ...and rounding on SHORT tracks, where half a frame is a large share of
581- // the window: `frames_of_us` of 1,016,667µs gives 31 frames (16,667µs of
582- // error -- 16 permille, but half a frame), and of 5,015,000µs gives 150
583- // (15,000µs). Both are unity; a relative gate badges one 0.98x and the
584- // other a self-contradicting 1.00x.
585- assert_eq!(
586- caption_rate(sub(31, 1_016_667), 30.),
587- None,
588- "half a frame off a one-second window is still unity"
589- );
590- assert_eq!(
591- caption_rate(sub(150, 5_015_000), 30.),
592- None,
593- "a hair under five seconds rounds to 150 frames and stays unity"
594- );
595- // A 2x re-rate: a 5s span holding the same 10s of words.
596- assert_eq!(
597- caption_rate(sub(150, 10_000_000), 30.).map(|s| s.permille()),
598- Some(2000)
599- );
600- // ...and a slowed one -- a 20s span for the same words -- which the badge
601- // keeps after any detach: the proportion is the placement's own.
602- assert_eq!(
603- caption_rate(sub(600, 10_000_000), 30.).map(|s| s.permille()),
604- Some(500)
605- );
606-}
607-
608 /// The selection itself: clicks in order, the anchor under the hand, the416 /// The selection itself: clicks in order, the anchor under the hand, the
609 /// toggle that assembles a group, and the plain click that replaces it all.417 /// toggle that assembles a group, and the plain click that replaces it all.
610 #[test]418 #[test]
@@ -720,18 +528,6 @@ fn a_click_marks_the_whole_group_and_nothing_else() {
720 assert!(!marked(v, Some(1), &[], &[]));528 assert!(!marked(v, Some(1), &[], &[]));
721 }529 }
722 530
723-#[test]
724-fn a_name_is_dropped_rather_than_smeared_across_a_thin_clip() {
725- assert!(show_label(LABEL_MIN_W));
726- assert!(show_label(400.));
727- assert!(!show_label(LABEL_MIN_W - 0.1));
728- // The label test is the box's own width in pixels now, which is what
729- // the scale hands it -- no bed width, and so nothing to be zero.
730- let scale = Scale::default();
731- assert!(show_label(scale.width_px(LABEL_MIN_W as f64 / PPS_DEFAULT)));
732- assert!(!show_label(scale.width_px(0.)));
733-}
734-
735 #[test]531 #[test]
736 fn an_envelope_stays_inside_the_box_it_is_drawn_in() {532 fn an_envelope_stays_inside_the_box_it_is_drawn_in() {
737 // A ramp: silence at the start, full scale at the end.533 // A ramp: silence at the start, full scale at the end.
@@ -785,17 +581,7 @@ fn an_envelope_never_costs_more_points_than_a_screen_can_show() {
785 // ...and the slice actually painted is the part of the box on the bed,581 // ...and the slice actually painted is the part of the box on the bed,
786 // which is where that width stops mattering: a column per two visible582 // which is where that width stops mattering: a column per two visible
787 // pixels, at every zoom.583 // pixels, at every zoom.
788- let (x, w) = visible_slice(-huge / 2., huge, 1200.);584+ assert_eq!(envelope(&peaks, 0., 5., 1200., 30.).len(), 601);
789- assert_eq!((x, w), (huge / 2., 1200.));
790- assert_eq!(envelope(&peaks, 0., 5., w, 30.).len(), 601);
791- // A box entirely off the bed has no slice, and one that has never been
792- // measured is drawn whole -- what was drawn before there was a bed.
793- assert_eq!(visible_slice(2000., 500., 1200.), (0., 0.));
794- assert_eq!(visible_slice(-3000., 500., 1200.), (500., 0.));
795- assert_eq!(visible_slice(-40., 500., 0.), (0., 500.));
796- // Half on, at either edge.
797- assert_eq!(visible_slice(-100., 500., 1200.), (100., 400.));
798- assert_eq!(visible_slice(1000., 500., 1200.), (0., 200.));
799 }585 }
800 586
801 /// The box a trim draws is the box its release commits, at every speed. The587 /// The box a trim draws is the box its release commits, at every speed. The
@@ -1416,33 +1202,41 @@ fn the_subtitles_toggle_says_what_is_placed_and_never_the_picked_row() {
1416 }1202 }
1417 1203
1418 /// The door this editor answers "don't make me import the film again" with,1204 /// The door this editor answers "don't make me import the film again" with,
1419-/// and it is in the panel where the tracks it adds are listed: the Text1205+/// and it is in the dock's IMPORT section beside the other two imports
1420-/// tab's own button reads a file's subtitle tracks onto the open timeline1206+/// (`ui/dock_stance.rs`'s own doc comment: it moved off the spine's crowded
1207+/// TRACK group here): reads a file's subtitle tracks onto the open timeline
1421 /// -- a release's `.mkv`, an `.srt` beside it -- while the file itself1208 /// -- a release's `.mkv`, an `.srt` beside it -- while the file itself
1422 /// joins nothing. It is the *action* and not a second implementation of it,1209 /// joins nothing. It is the *action* and not a second implementation of it,
1423 /// so the button, the stroke and the actions card cannot drift apart, and1210 /// so the button, the stroke and the actions card cannot drift apart, and
1424-/// it is oracle-gated like every other action button, so with no timeline1211+/// it is oracle-gated like every other verb in the dock, so with no timeline
1425 /// open it dims and says why instead of opening a chooser for nothing.1212 /// open it dims and says why instead of opening a chooser for nothing.
1426 #[test]1213 #[test]
1427 fn the_text_tab_carries_the_add_subtitles_door() {1214 fn the_text_tab_carries_the_add_subtitles_door() {
1428- let library = src_text("ui/library.rs");1215+ let dock = src_text("ui/dock_stance.rs");
1429- let at = library1216+ let at = dock
1430- .find("\"add-subtitles\"")1217+ .find("\"dock-import-subtitles\"")
1431- .expect("no add-subtitles control in the library column");1218+ .expect("no import-subtitles control in the dock");
1432- let block = &library[at..(at + 1600).min(library.len())];1219+ let block = &dock[at..(at + 500).min(dock.len())];
1433 assert!(1220 assert!(
1434 block.contains("ActionId::ImportSubtitles"),1221 block.contains("ActionId::ImportSubtitles"),
1435 "the button is a door of its own rather than the action: {block}"1222 "the button is a door of its own rather than the action: {block}"
1436 );1223 );
1437 assert!(1224 assert!(
1438- block.contains("pick_and_add_subtitles"),1225+ block.contains("this.act(ActionId::ImportSubtitles"),
1439- "the button does not open the subtitle chooser: {block}"1226+ "the button does not dispatch through the action oracle: {block}"
1227+ );
1228+ // `act(ActionId::ImportSubtitles, ...)` routes to `pick_and_add_subtitles`
1229+ // -- the button names the action, not a second implementation of it.
1230+ let actions = src_text("player/actions.rs");
1231+ assert!(
1232+ actions.contains("ActionId::ImportSubtitles => self.pick_and_add_subtitles(cx)"),
1233+ "ImportSubtitles no longer opens the subtitle chooser"
1440 );1234 );
1441- // `action_control` is the oracle-gated one: dimmed with the refusal in1235+ // `ghost_verb` is the oracle-gated one: dimmed with the refusal in the
1442- // the oracle's own words. `control` alone would be lit with no timeline.1236+ // oracle's own words (`player.enable(action, None)` in its own body).
1443 assert!(1237 assert!(
1444- library[..at].ends_with("self.action_control(\n "),1238+ dock[..at].ends_with("ghost_verb(\n "),
1445- "the add-subtitles button is not oracle-gated"1239+ "the add-subtitles button is not built from the oracle-gated ghost_verb"
1446 );1240 );
1447 // ...and the empty tab names that button, rather than pointing at a1241 // ...and the empty tab names that button, rather than pointing at a
1448 // toolbar the person is not looking at.1242 // toolbar the person is not looking at.
@@ -1484,34 +1278,26 @@ fn the_darkroom_subtitle_palette_drags_tracks_to_subtitle_lanes() {
1484 );1278 );
1485 }1279 }
1486 1280
1487-/// A source's group header in the library must not vanish on a short1281+/// A subtitle group's header in the dock must not vanish on a short
1488-/// window: it is drawn whenever there is more than one source1282+/// window: `subtitle_palette` draws one per group unconditionally -- there
1489-/// (`several_files`), never gated on the viewport's height, and the list1283+/// is no viewport-height gate on it at all any more, so the list under it
1490-/// under it is what scrolls instead ([`SUB_ROWS_H`]). And it has to be a1284+/// is what would scroll instead, never the header itself. And it has to be
1491-/// real fold, not the click-cycling pattern this codebase has already1285+/// a real fold, not the click-cycling pattern this codebase has already
1492 /// thrown out once: one click toggles `sub_folded` shut or open, it never1286 /// thrown out once: one click toggles `sub_folded` shut or open, it never
1493 /// steps through more than those two states.1287 /// steps through more than those two states.
1494 #[test]1288 #[test]
1495 fn a_subtitle_group_header_is_never_gated_on_window_height() {1289 fn a_subtitle_group_header_is_never_gated_on_window_height() {
1496- let timeline = src_text("ui/timeline.rs");1290+ let dock = src_text("ui/dock_stance.rs");
1497 assert!(1291 assert!(
1498- !timeline.contains("sub_headers_fit"),1292+ !dock.contains("sub_headers_fit"),
1499 "the header is still gated on the viewport's height"1293 "the header is still gated on the viewport's height"
1500 );1294 );
1501- let at = timeline
1502- .find("let headed = ")
1503- .expect("no `headed` computed in subtitle_section");
1504- let line = &timeline[at..(at + 80).min(timeline.len())];
1505- assert!(
1506- line.contains("several_files") && !line.contains("viewport"),
1507- "headed depends on something other than the file count: {line}"
1508- );
1509 // The header is a click target that flips membership in a set --1295 // The header is a click target that flips membership in a set --
1510 // `remove` else `insert` -- not a value stepped through several states.1296 // `remove` else `insert` -- not a value stepped through several states.
1511- let head_at = timeline1297+ let head_at = dock
1512- .find("subtitle-group-head")1298+ .find("\"dock-subtitle-group\"")
1513 .expect("no id on the group header");1299 .expect("no id on the group header");
1514- let block = &timeline[head_at..(head_at + 2400).min(timeline.len())];1300+ let block = &dock[head_at..(head_at + 2700).min(dock.len())];
1515 assert!(1301 assert!(
1516 block.contains("sub_folded.remove"),1302 block.contains("sub_folded.remove"),
1517 "no fold-open path: {block}"1303 "no fold-open path: {block}"
@@ -1521,7 +1307,7 @@ fn a_subtitle_group_header_is_never_gated_on_window_height() {
1521 "no fold-shut path: {block}"1307 "no fold-shut path: {block}"
1522 );1308 );
1523 assert!(1309 assert!(
1524- block.contains("\"1 track\"") || block.contains("tracks"),1310+ block.contains("{track_count} track"),
1525 "the header does not say how many tracks it holds: {block}"1311 "the header does not say how many tracks it holds: {block}"
1526 );1312 );
1527 }1313 }
@@ -1895,10 +1681,7 @@ fn a_dragged_divider_stops_before_either_panel_disappears() {
1895 // ([`Player::timeline`]): what the affordance costs comes off the box, and1681 // ([`Player::timeline`]): what the affordance costs comes off the box, and
1896 // a whole lane is still standing under it.1682 // a whole lane is still standing under it.
1897 let lanes_box = floor - timeline_fixed_h(true);1683 let lanes_box = floor - timeline_fixed_h(true);
1898- assert!(1684+ assert!(lanes_box < lanes_h(2), "no line to pay for at the floor");
1899- 2 > lanes_shown_mixed(&[LaneKind::Video, LaneKind::Audio], lanes_box),
1900- "no line to pay for at the floor"
1901- );
1902 assert!(1685 assert!(
1903 lanes_box - LABEL_H - 8. >= LANE_H,1686 lanes_box - LABEL_H - 8. >= LANE_H,
1904 "the floor leaves {} px for a {LANE_H} px lane",1687 "the floor leaves {} px for a {LANE_H} px lane",
@@ -2263,13 +2046,10 @@ fn a_missing_stance_splits_file_leaves_every_region_at_its_default() {
2263 /// window's own share is a panel whose divider moves nothing.2046 /// window's own share is a panel whose divider moves nothing.
2264 #[test]2047 #[test]
2265 fn every_seam_in_the_layout_has_a_divider_on_it() {2048 fn every_seam_in_the_layout_has_a_divider_on_it() {
2266- let render = src_text("render.rs");2049+ // The darkroom collapsed Library/Inspector/Timeline into rooms with no
2267- for split in ["Split::Library", "Split::Inspector", "Split::Timeline"] {2050+ // seam of their own; render.rs no longer draws any divider at all --
2268- assert!(2051+ // ui::stance::render is the whole root now -- so the only two seams a
2269- render.contains(&format!("divider({split}")),2052+ // hand can still drag are the ones the stance itself owns.
2270- "{split} has no divider to drag"
2271- );
2272- }
2273 let stance = src_text("ui/stance.rs");2053 let stance = src_text("ui/stance.rs");
2274 for split in ["Split::Dock", "Split::Bench"] {2054 for split in ["Split::Dock", "Split::Bench"] {
2275 assert!(2055 assert!(
@@ -2284,17 +2064,15 @@ fn every_seam_in_the_layout_has_a_divider_on_it() {
2284 interact.contains("cursor_col_resize") && interact.contains("cursor_row_resize"),2064 interact.contains("cursor_col_resize") && interact.contains("cursor_row_resize"),
2285 "a divider with no resize cursor on it"2065 "a divider with no resize cursor on it"
2286 );2066 );
2287- // ...and nothing lays a region out off the untouched share any more.2067+ // ...and nothing lays a region out off the untouched share any more:
2288- for (file, stale) in [2068+ // the legacy panels that read `library_w`/`inspector_w` (`ui/library.rs`,
2289- ("ui/inspector.rs", "inspector_w("),2069+ // `ui/inspector.rs`, `ui/toolbar.rs`) are gone or gone from the render
2290- ("ui/toolbar.rs", "library_w("),2070+ // path, so what remains is layout.rs's own Split::Library/Inspector
2291- ("render.rs", "library_w("),2071+ // arms -- kept for save-file compat, never drawn.
2292- ] {2072+ assert!(
2293- assert!(2073+ !src_text("render.rs").contains("library_w("),
2294- !src_text(file).contains(stale),2074+ "render.rs still measures a panel with library_w("
2295- "{file} still measures a panel with {stale}"2075+ );
2296- );
2297- }
2298 }2076 }
2299 2077
2300 /// DESIGN.md §12 step 2: the stance skeleton draws its six regions -- spine,2078 /// DESIGN.md §12 step 2: the stance skeleton draws its six regions -- spine,
@@ -2353,13 +2131,17 @@ fn the_stance_renders_its_six_regions_in_the_documented_order() {
2353 "render() does not compose the six regions in DESIGN §5's order: {composed:?}"2131 "render() does not compose the six regions in DESIGN §5's order: {composed:?}"
2354 );2132 );
2355 2133
2356- // The flag has to reach it, or the skeleton is dead code behind a door2134+ // The skeleton is reached unconditionally now -- the darkroom is the
2357- // nobody opens. Darkroom is the default room now (`OLD_GUI=1` is the2135+ // only room, and `self.darkroom`'s branch is gone with the legacy tree
2358- // opt-out) -- `Player::darkroom` is still the field render.rs reads.2136+ // it used to choose between.
2359 let render_rs = src_text("render.rs");2137 let render_rs = src_text("render.rs");
2360 assert!(2138 assert!(
2361- render_rs.contains("if self.darkroom") && render_rs.contains("ui::stance::render("),2139+ render_rs.contains("ui::stance::render("),
2362- "Player::darkroom never reaches ui::stance::render"2140+ "render.rs no longer reaches ui::stance::render"
2141+ );
2142+ assert!(
2143+ !render_rs.contains("self.darkroom"),
2144+ "render.rs still branches on self.darkroom after the legacy tree was removed"
2363 );2145 );
2364 }2146 }
2365 2147
@@ -2405,25 +2187,20 @@ fn the_picture_letterboxes_through_a_canvas_never_a_plain_img_object_fit() {
2405 /// picture on the darkroom path too -- measured live covering the bottom 10%2187 /// picture on the darkroom path too -- measured live covering the bottom 10%
2406 /// of the frame (rows 300-333 of 335) *underneath* the stance's own2188 /// of the frame (rows 300-333 of 335) *underneath* the stance's own
2407 /// §8-conformant plate (`ui::stance::notice_plate`), which drew the same2189 /// §8-conformant plate (`ui::stance::notice_plate`), which drew the same
2408-/// notice a second time above the ledger. The legacy (non-darkroom) room2190+/// notice a second time above the ledger. The legacy full-width `notice_bar`
2409-/// keeps its full-width `notice_bar` exactly as it always has -- this only2191+/// and its non-darkroom caller are gone with the rest of the old tree now,
2410-/// pins the darkroom path off it.2192+/// so this pins the sole remaining channel (`notice_plate`) off the
2193+/// picture for good.
2411 #[test]2194 #[test]
2412 fn the_darkroom_path_never_lets_a_notice_surface_reach_the_picture() {2195 fn the_darkroom_path_never_lets_a_notice_surface_reach_the_picture() {
2196+ // `notice_bar` and its legacy (non-darkroom) caller are gone with the
2197+ // rest of the old tree -- the darkroom's own `ui::stance::notice_plate`
2198+ // is the only notice channel left, and the stronger invariant now is
2199+ // that picture_area's body never draws a second one over the picture.
2413 let body = fn_body("picture_area");2200 let body = fn_body("picture_area");
2414 assert!(2201 assert!(
2415- body.contains("self.notice_bar(cx)"),2202+ !body.contains("notice_bar"),
2416- "picture_area no longer draws notice_bar at all; re-check the darkroom gate still applies"2203+ "picture_area draws a notice surface over the picture again (the old occlusion defect)"
2417- );
2418- let at = body.find("self.notice_bar(cx)").expect("checked above");
2419- // Whatever gates the call, it has to name `darkroom` and it has to be
2420- // upstream of the call itself -- a gate written after the call, or one
2421- // that never mentions the flag, is not a gate on this method.
2422- let before = &body[..at];
2423- assert!(
2424- before.contains("self.darkroom") || before.contains("!self.darkroom"),
2425- "notice_bar in picture_area is not gated on self.darkroom any more -- \
2426- the darkroom stance would paint it over the picture again"
2427 );2204 );
2428 }2205 }
2429 2206
@@ -2717,6 +2494,18 @@ fn every_action_has_a_darkroom_widget_home_or_explicit_owner() {
2717 "clicking empty timeline space already clears the selection with the mouse; \2494 "clicking empty timeline space already clears the selection with the mouse; \
2718 bare escape is a keyboard-only accelerator for that existing door, not a new one",2495 bare escape is a keyboard-only accelerator for that existing door, not a new one",
2719 ),2496 ),
2497+ (
2498+ ActionId::SelectNext,
2499+ "clicking a clip already selects it with the mouse; `}` is a keyboard-only \
2500+ accelerator for cycling that existing selection, not a new door -- legacy had no \
2501+ toolbar button for it either",
2502+ ),
2503+ (
2504+ ActionId::SelectPrev,
2505+ "clicking a clip already selects it with the mouse; `{` is a keyboard-only \
2506+ accelerator for cycling that existing selection, not a new door -- legacy had no \
2507+ toolbar button for it either",
2508+ ),
2720 ];2509 ];
2721 let darkroom = [2510 let darkroom = [
2722 "ui/bench_stance.rs",2511 "ui/bench_stance.rs",
@@ -2727,7 +2516,6 @@ fn every_action_has_a_darkroom_widget_home_or_explicit_owner() {
2727 "ui/spine_stance.rs",2516 "ui/spine_stance.rs",
2728 "ui/stance.rs",2517 "ui/stance.rs",
2729 "ui/timeband_stance.rs",2518 "ui/timeband_stance.rs",
2730- "ui/timeline.rs",
2731 "menus.rs",2519 "menus.rs",
2732 ]2520 ]
2733 .map(src_text)2521 .map(src_text)
@@ -2871,7 +2659,8 @@ fn hitmap_names_every_darkroom_pointer_entry_surface() {
2871 "menu.{action:?}",2659 "menu.{action:?}",
2872 "menu.properties",2660 "menu.properties",
2873 "theme.{n}.row",2661 "theme.{n}.row",
2874- "hitmap::action(action, refusal.yes())",2662+ "let enabled = refusal.yes()",
2663+ "hitmap::dynamic(\n move || (format!(\"menu.{action:?}\"",
2875 ][..],2664 ][..],
2876 ),2665 ),
2877 (2666 (
crates/app/src/tests/media.rsmodified+0 -81
@@ -587,11 +587,6 @@ fn every_codec_row_is_offered_or_says_why_not() {
587 // that cannot has one: the card is drivable without a pointer.587 // that cannot has one: the card is drivable without a pointer.
588 assert_eq!(!row.is_empty(), !stroke.is_empty(), "{label}");588 assert_eq!(!row.is_empty(), !stroke.is_empty(), "{label}");
589 if let Some(&first) = row.first() {589 if let Some(&first) = row.first() {
590- assert_eq!(
591- format_key(stroke, first),
592- Some(first),
593- "{label} keys to itself"
594- );
595 assert!(590 assert!(
596 stroke.parse::<u32>().is_err(),591 stroke.parse::<u32>().is_err(),
597 "{label} takes a digit the bitrate needs"592 "{label} takes a digit the bitrate needs"
@@ -620,29 +615,6 @@ fn every_codec_row_is_offered_or_says_why_not() {
620 "{key} is already the card's own"615 "{key} is already the card's own"
621 );616 );
622 }617 }
623- assert_eq!(
624- format_key("a", Format::Mp4),
625- Some(Format::Av1Mp4),
626- "the box already chosen is kept"
627- );
628- assert_eq!(
629- format_key("a", Format::Wav),
630- Some(Format::Av1),
631- "and a codec with no such box takes its first"
632- );
633- assert_eq!(format_key("h", Format::Av1Mp4), Some(Format::HevcMp4));
634- assert_eq!(format_key("p", Format::Mp4), Some(Format::Mp3));
635- assert_eq!(
636- format_key("m", Format::Mp3),
637- Some(Format::Mp4),
638- "not MP3, which is p"
639- );
640- assert_eq!(
641- format_key("x", Format::Mp4),
642- None,
643- "a stroke no row carries"
644- );
645- assert_eq!(format_key("o", Format::Mp4), Some(Format::Ogg));
646 // The one codec left that this program reads and cannot write is a row618 // The one codec left that this program reads and cannot write is a row
647 // of its own, refused by name rather than absent: VP9, because AV1 is619 // of its own, refused by name rather than absent: VP9, because AV1 is
648 // the row that replaced it. Its reason travels with it, in the row or in620 // the row that replaced it. Its reason travels with it, in the row or in
@@ -921,17 +893,6 @@ fn the_subtitle_plate_and_lanes_fit_the_smallest_window() {
921 // is a target and binds `HIT_MIN` like every other lane's -- the whole893 // is a target and binds `HIT_MIN` like every other lane's -- the whole
922 // reason it is a lane and no longer a 16 px strip.894 // reason it is a lane and no longer a 16 px strip.
923 assert!(LANE_H >= HIT_MIN);895 assert!(LANE_H >= HIT_MIN);
924- // The library's own list of tracks scrolls past three rather than
925- // taking the media list's room.
926- assert_eq!(SUB_ROWS_H / ROW_H, 3.);
927- assert!(ROW_H >= HIT_MIN, "a subtitle row is clicked to pick it");
928- // A header is always drawn with more than one file, floor included: the
929- // list scrolls past `SUB_ROWS_H` instead of a short window losing the
930- // name saying whose tracks these are.
931- assert!(SUB_HEAD_H + 2. * ROW_H <= SUB_ROWS_H);
932- // A header folds its group on a click now, so it binds `HIT_MIN` like
933- // every other target rather than being let off it as a bare label.
934- assert!(SUB_HEAD_H >= HIT_MIN);
935 }896 }
936 897
937 /// The subtitle style file, round-tripped through a scratch config directory898 /// The subtitle style file, round-tripped through a scratch config directory
@@ -1042,48 +1003,6 @@ fn the_cue_line_height_scales_with_its_size() {
1042 }1003 }
1043 }1004 }
1044 1005
1045-/// What the rows of both lists do with a name too long for the column: two
1046-/// episodes off one release differ in their last two characters, and a name
1047-/// cut from the right is the same row twice.
1048-#[test]
1049-fn a_long_name_is_cut_out_of_its_middle_so_two_episodes_stay_two_rows() {
1050- let (a, b) = (
1051- "A Long Release Name Of A Series 01",
1052- "A Long Release Name Of A Series 02",
1053- );
1054- // The two call sites at the narrowest the column ever is: a media row's
1055- // name gets the row's whole width, a subtitle row's file prefix gets a
1056- // share of it because the language has to fit beside it.
1057- let media = row_text_w(LIBRARY_MIN_W);
1058- let prefix = media * SUB_STEM_SHARE;
1059- for width in [media, prefix] {
1060- assert!(width > 0., "the floor leaves a row no words at all");
1061- assert_ne!(
1062- clip_middle(a, width),
1063- clip_middle(b, width),
1064- "{width}px: two episodes read as one row"
1065- );
1066- // Both ends survive: the release's name at the front, the number
1067- // that tells them apart at the back.
1068- assert!(clip_middle(a, width).starts_with(&a[..2]));
1069- assert!(clip_middle(a, width).ends_with("01"));
1070- assert!(clip_middle(a, width).contains('…'));
1071- // Never wider than the column can hold, gap included.
1072- assert!(clip_middle(a, width).chars().count() <= (width / 6.) as usize + 1);
1073- }
1074- // A name the width holds is left exactly as it is -- no gap, nothing
1075- // dropped -- and so is a name at any width once the column is wide.
1076- assert_eq!(clip_middle("eng.srt", 400.), "eng.srt");
1077- assert_eq!(clip_middle(a, 4000.), a);
1078- // Nothing panics at a width no column ever has, and something of both
1079- // ends is still there.
1080- assert_eq!(clip_middle(a, 0.).chars().count(), 5);
1081- assert!(clip_middle(a, 0.).ends_with('1'));
1082- // Counted in characters and not bytes: a name in another script is cut
1083- // between its letters, not through one.
1084- assert_eq!(clip_middle("ααααααααααααααα", 24.), "αα…αα");
1085-}
1086-
1087 /// The two doors subtitles arrive through, end to end on the fixtures: a1006 /// The two doors subtitles arrive through, end to end on the fixtures: a
1088 /// file beside the media and the tracks inside an mkv, what the overlay then1007 /// file beside the media and the tracks inside an mkv, what the overlay then
1089 /// says at a given moment, and where the strip draws it.1008 /// says at a given moment, and where the strip draws it.
crates/app/src/tests/mod.rsmodified+29 -34
@@ -13,49 +13,44 @@ use super::{
13 ACCENT_PRIMARY, AUDIO_KBPS, BG_RAISED, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W,13 ACCENT_PRIMARY, AUDIO_KBPS, BG_RAISED, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W,
14 CONTROL_H, Clip, Ctx, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH,14 CONTROL_H, Clip, Ctx, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH,
15 EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW,15 EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW,
16- EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, EXPORT_DONE, EXPORT_FIXED_H,16+ EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, EXPORT_DONE, EXPORT_W, Enable,
17- EXPORT_ROWS_H, EXPORT_W, Enable, EncoderSeat, ExportPreset, FORMATS, Format, HEADER_GAP,17+ EncoderSeat, ExportPreset, FORMATS, Format, HEADER_H, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN,
18- HEADER_H, HEADER_W, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, KEYS_ROW_H, KEYS_ROWS_H, KEYS_W,18+ KEYS_ROW_H, KEYS_W, KeyRow, LABEL_H, LANE_H, LANES_MAX, LATE_RESYNC, LIBRARY_MAX_W,
19- KeyRow, LABEL_H, LABEL_MIN_W, LANE_H, LANES_MAX, LATE_RESYNC, LIBRARY_MAX_W, LIBRARY_MIN_W,19+ LIBRARY_MIN_W, Lane, MB_FLOOR, MBPS_DIGITS, MBPS_MAX, MBPS_MIN, MENU_ITEMS, MENU_PAD,
20- Lane, MB_FLOOR, MBPS_DIGITS, MBPS_MAX, MBPS_MIN, MENU_ITEMS, MENU_PAD, MENU_ROW_H, MENU_W,20+ MENU_ROW_H, MENU_W, NO_FILE, NOTICES_MAX, NumberEdit, OVERLAID, PANEL_H, Quality, RESYNC_GAP,
21- NO_FILE, NOTICES_MAX, NumberEdit, OVERLAID, PANEL_H, Quality, RESYNC_GAP, ROW_H, ROW_ITEMS,21+ ROW_ITEMS, RULER_HIT_H, RowCtx, RowItem, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS,
22- RULER_HIT_H, RowCtx, RowItem, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS, SPEED_PRESETS,22+ SPEED_PRESETS, SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_PLAN_CHARS,
23- SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_LANE_H, SUB_PLAN_CHARS, SWATCH_W,
24 Source, Speed, StreamInfo, TIMELINE_SHARE, Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL,23 Source, Speed, StreamInfo, TIMELINE_SHARE, Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL,
25- WAVE_COLS_MAX, Wave, active_lane, band_label, bitrate_detail, bitrate_refusal, can_add,24+ WAVE_COLS_MAX, Wave, ZOOM_MIN_FRAMES, active_lane, band_label, bitrate_detail, bitrate_refusal,
26- cancels_export, clipboard_after_remove, color_snap, commit_mbps, containers, enable,25+ clipboard_after_remove, color_snap, commit_mbps, containers, enable, enable_lane, envelope,
27- enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y,26+ eq_card_w, eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, estimated_bytes,
28- escape_leaves_player_fullscreen, estimated_bytes, export_path, export_settings, format_key,27+ export_path, export_settings, format_line, format_refusal, fps_choices, fps_label, frac_along,
29- format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at,28+ frac_down, frame_at, frame_rate_ladder, histogram, inserted_band, is_project, keymap,
30- frame_rate_ladder, histogram, inserted_band, is_bare_modifier, is_project, keymap, keys_filter,29+ keys_rows, lanes_h, marked, menu_at, menu_items, menu_rows_h, next_container, normalise,
31- keys_rows, lanes_h, lanes_h_mixed, lanes_shown_mixed, marked, menu_at, menu_items, menu_rows_h,30+ nothing_to_play, notice_tone, panel_h, project_path, proxies_to_start, push_notice, px_below,
32- next_audio_kbps, next_container, normalise, nothing_to_play, notice_tone, panel_h,31+ retarget, row_enable, row_items, scrub_due, secs_label, should_resync, silence_rate,
33- project_path, proxies_to_start, push_notice, px_below, retarget, row_enable, row_items,32+ size_label, snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at,
34- rows_below_mixed, scrub_due, secs_label, should_resync, show_label, silence_rate, size_label,33+ sub_pick_after_removal, subtitle_plan, summary_head, summary_tail, timecode, timeline_fixed_h,
35- snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at, sub_pick_after_removal,34+ tip_may_paint, transport, typed, unseen_paths, unseen_sources, whole_take, window_title,
36- subtitle_plan, summary_head, summary_tail, timecode, timeline_fixed_h, tip_may_paint,
37- transport, typed, unseen_paths, unseen_sources, whole_take, window_title,
38 };35 };
39 36
40 use super::{37 use super::{
41 ActionId, Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, IMPORT_STALL, Import, ImportStage,38 ActionId, Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, IMPORT_STALL, Import, ImportStage,
42 Landing, LaneKind, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, SAMPLE_RATES, SEEK_STALL,39 Landing, LaneKind, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, SAMPLE_RATES, SEEK_STALL,
43- Scale, ScanKey, ScanPlan, SilenceScan, SubClip, View, ZOOM_MIN_FRAMES, ZOOM_OUT_MARGIN,40+ Scale, ScanKey, ScanPlan, SilenceScan, SubClip, View, ZOOM_OUT_MARGIN, ZOOM_STEP, arrival,
44- ZOOM_STEP, arrival, audio_rate_choices, av1_hw_warning, clip_width, clock, encoder_choices,41+ audio_rate_choices, av1_hw_warning, clip_width, clock, encoder_choices, encoder_label,
45- encoder_label, eta_secs, file_name, file_uri, fit_choices, frames_of_us, full_scan_key,42+ eta_secs, file_name, file_uri, fit_choices, frames_of_us, full_scan_key, import_line, landing,
46- import_line, landing, lane_refuses, launch_queue, library_rows, live_idx, next_fit,43+ lane_refuses, launch_queue, library_rows, live_idx, next_fit, next_resolution, note_progress,
47- next_resolution, note_progress, pending_fps_choices, pending_resolution_choices, px_along,44+ pending_fps_choices, pending_resolution_choices, px_along, read_ahead, repeats,
48- read_ahead, repeats, resolution_choices, resolution_ladder, sample_rate_choices, scan_plan,45+ resolution_choices, resolution_ladder, sample_rate_choices, scan_plan, seek_line,
49- seek_line, silence_cached, silence_line, slice_whole_levels, source_secs, span_label,46+ silence_cached, silence_line, slice_whole_levels, source_secs, stash_or_write, tone_choices,
50- stash_or_write, tone_choices, tone_label, trimmed_clip, trimmed_sub, trims, unscannable,47+ tone_label, trimmed_clip, trimmed_sub, trims, unscannable, unusable,
51- unusable, visible_slice,
52 };48 };
53 49
54 use super::{50 use super::{
55- SUB_BOTTOM, SUB_CUE_MIN_W, SUB_HEAD_H, SUB_LINE_H, SUB_ROWS_H, SUB_STEM_SHARE, SUB_TEXT, Subs,51+ SUB_BOTTOM, SUB_CUE_MIN_W, SUB_LINE_H, SUB_TEXT, Subs, carries_subtitles, cue_box, cues_at,
56- carries_subtitles, clip_middle, cue_box, cues_at, file_tint, is_subtitle, lang_human,52+ file_tint, is_subtitle, lang_human, sub_bottom, sub_pick_name, subtitle_detail,
57- row_text_w, sub_bottom, sub_pick_name, subtitle_detail, subtitle_notice, subtitle_rows,53+ subtitle_notice, subtitle_rows, subtitle_tail, subtitle_toggle_notice, walk_subtitles,
58- subtitle_tail, subtitle_toggle_notice, walk_subtitles,
59 };54 };
60 55
61 use engine::PlaybackSession;56 use engine::PlaybackSession;
crates/app/src/tests/view.rsmodified+0 -18
@@ -869,24 +869,6 @@ fn a_clip_is_drawn_the_same_width_whatever_else_is_on_the_timeline() {
869 /// that tells two zooms apart.869 /// that tells two zooms apart.
870 #[test]870 #[test]
871 fn the_zoom_button_says_how_much_is_on_the_bed() {871 fn the_zoom_button_says_how_much_is_on_the_bed() {
872- assert_eq!(span_label(4.5), "4.5s");
873- assert_eq!(span_label(22.5), "22s");
874- assert_eq!(span_label(90.), "1.5m");
875- assert_eq!(span_label(3600.), "1.0h");
876- // The span a five hour timeline is zoomed all the way out to.
877- assert_eq!(span_label(5. * 3600. * 1.05), "5.2h");
878- // Before the first paint there is no bed and so no answer to give.
879- assert_eq!(span_label(0.), "—");
880- assert_eq!(span_label(f64::NAN), "—");
881- // A span under a second is a span: the tightest zoom is
882- // `ZOOM_MIN_FRAMES` across the bed, which on 240 fps slow-motion is
883- // 0.03s, and "0.0s" would be the pill saying nothing is on the bed.
884- for fps in [60., 120., 240., 1000.] {
885- let label = span_label(ZOOM_MIN_FRAMES / fps);
886- assert_ne!(label, "0.0s", "{fps} fps");
887- assert_ne!(label, "0.00s", "{fps} fps");
888- }
889- assert_eq!(span_label(ZOOM_MIN_FRAMES / 240.), "0.03s");
890 // A frame of quiet at 60 fps, which the silence card says out loud.872 // A frame of quiet at 60 fps, which the silence card says out loud.
891 assert_eq!(secs_label(1. / 60.), "0.02s");873 assert_eq!(secs_label(1. / 60.), "0.02s");
892 assert_eq!(secs_label(4.5), "4.5s");874 assert_eq!(secs_label(4.5), "4.5s");
crates/app/src/timeline_math.rsmodified+2 -72
@@ -166,59 +166,10 @@ impl Selection {
166 }166 }
167 }167 }
168 168
169-/// The rate a caption's box plays its window at, read off the placement
170-/// itself: how long the words are, against how much timeline they cross. A
171-/// clip's badge comes from its own `speed`; a caption has none, so its box
172-/// derives one -- and keeps it even after the group that re-timed it comes
173-/// apart, because the proportion is the placement's own. `None` at unity:
174-/// placement rounding leaves an odd-width window a frame or so off real time,
175-/// and a badge is for a box that was *re-timed*, not one that rounds.
176-pub(crate) fn caption_rate(sub: SubClip, fps: f64) -> Option<Speed> {
177- if !(fps.is_finite() && fps > 0.0) || sub.window_us() <= 0 {
178- return None;
179- }
180- let (span_us, window_us) = (f64::from(sub.frames) / fps * 1e6, sub.window_us() as f64);
181- // The unity gate is absolute, in frames of the timeline: placement
182- // rounding (`frames_of_us`) leaves a short track up to half a frame off
183- // real time, which against a one-second window is fifteen permille -- a
184- // relative gate would badge most palette drops under two and a half
185- // seconds. Unity is "the window lands within a frame and a half of the
186- // span"; the permille is only ever the rate the badge shows.
187- if (span_us - window_us).abs() <= 1.5 / fps * 1e6 {
188- return None;
189- }
190- // The rate is the window over the span -- content per timeline, a clip's
191- // own `speed` in the same spelling: 10s of words crossing 5s of timeline
192- // is 2.00x.
193- let permille = (window_us / span_us * 1000.).round();
194- Some(Speed::from_permille(permille.clamp(
195- f64::from(Speed::MIN.permille()),
196- f64::from(Speed::MAX.permille()),
197- ) as u16))
198-}
199-
200-/// The scrollbar's thumb over a track `w` px wide: `(x, width)` of the box
201-/// standing for the visible share of a timeline `duration` long whose window
202-/// starts at `start` and spans `span`. Full width when nothing is off-screen
203-/// (there is nothing to scroll and the strip says so by filling), never
204-/// narrower than [`SCROLL_THUMB_MIN`] when there is (a thumb a pixel wide is a
205-/// thumb no hand can hold), and never off the track either way -- the clamp,
206-/// not the caller, owns that, because a drag's samples arrive raw.
207-pub(crate) fn scroll_thumb(w: f32, duration: f64, start: f64, span: f64) -> (f32, f32) {
208- if w <= 0. || duration <= 0. || span >= duration {
209- return (0., w.max(0.));
210- }
211- let share = f64::from(w);
212- let width = ((span / duration) * share).clamp(f64::from(SCROLL_THUMB_MIN), f64::from(w));
213- let x = (start / duration * share).clamp(0., f64::from(w) - width);
214- (x as f32, width as f32)
215-}
216-
217 /// The lane stack's thumb over a track `h` px tall: `(y, height)` of the box169 /// The lane stack's thumb over a track `h` px tall: `(y, height)` of the box
218 /// standing for the visible share of a stack `content` px tall in a box170 /// standing for the visible share of a stack `content` px tall in a box
219-/// `box_h` px tall, taken down by `scrolled` px -- the time axis's171+/// `box_h` px tall, taken down by `scrolled` px. Full track when the whole
220-/// [`scroll_thumb`] turned through a right angle, and on the same terms:172+/// stack is on screen, never shorter than
221-/// full track when the whole stack is on screen, never shorter than
222 /// [`SCROLL_THUMB_MIN`] when it is not, and never off the track either way.173 /// [`SCROLL_THUMB_MIN`] when it is not, and never off the track either way.
223 pub(crate) fn lanes_thumb(track: f32, content: f32, box_h: f32, scrolled: f32) -> (f32, f32) {174 pub(crate) fn lanes_thumb(track: f32, content: f32, box_h: f32, scrolled: f32) -> (f32, f32) {
224 if track <= 0. || content <= 0. || box_h >= content {175 if track <= 0. || content <= 0. || box_h >= content {
@@ -257,11 +208,6 @@ pub(crate) fn marked(
257 picks.contains(&here) || (link.is_some() && pick_links.contains(&link))208 picks.contains(&here) || (link.is_some() && pick_links.contains(&link))
258 }209 }
259 210
260-/// Whether a clip is wide enough to be worth naming.
261-pub(crate) fn show_label(w: f32) -> bool {
262- w >= LABEL_MIN_W
263-}
264-
265 /// The clip a trim is *showing*, worked out the way `Project::trim` will write211 /// The clip a trim is *showing*, worked out the way `Project::trim` will write
266 /// it: the timeline room the edge leaves is turned into source frames by the one212 /// it: the timeline room the edge leaves is turned into source frames by the one
267 /// conversion that exists for it ([`Speed::fit`]), and the box is drawn from213 /// conversion that exists for it ([`Speed::fit`]), and the box is drawn from
@@ -481,22 +427,6 @@ pub(crate) fn sub_mark(subs: &[SubClip], start: u32) -> Option<usize> {
481 subs.iter().position(|s| s.start == start)427 subs.iter().position(|s| s.start == start)
482 }428 }
483 429
484-/// The part of a clip's box that is on the bed, in the box's own pixels:
485-/// `(left, width)` of its intersection with the visible strip. Everything drawn
486-/// *inside* a box -- its waveform, its name, its speed badge -- is placed in
487-/// here rather than at the box's own edges, which at a deep zoom sit thousands
488-/// of pixels off either side of the screen: a label out there is a label nobody
489-/// can read, and a waveform out there is a path with a point per two pixels of a
490-/// width nobody can see. A bed that has not been measured yet answers with the
491-/// whole box, which is what was drawn before there was a bed to clip to.
492-pub(crate) fn visible_slice(left: f32, width: f32, bed: f32) -> (f32, f32) {
493- if bed <= 0. {
494- return (0., width);
495- }
496- let from = (-left).clamp(0., width);
497- let to = (bed - left).clamp(from, width);
498- (from, to - from)
499-}
500 430
501 /// Scales an envelope to its own loudest sample, so a quietly mastered source431 /// Scales an envelope to its own loudest sample, so a quietly mastered source
502 /// still draws as a shape. The fixtures peak around an eighth of full scale, and432 /// still draws as a shape. The fixtures peak around an eighth of full scale, and
crates/app/src/ui/cards.rsmodified+346 -1086

Diff too large; view file

@@ -7,9 +7,8 @@ use crate::*;
7 7
8 /// DESIGN §3/§4 atoms shared by every param/setting card below (colour,8 /// DESIGN §3/§4 atoms shared by every param/setting card below (colour,
9 /// transform, speed, EQ, silence, mix, subtitle style): what a row's label9 /// transform, speed, EQ, silence, mix, subtitle style): what a row's label
10-/// and value paint as once `self.darkroom` is on, so the seven card bodies10+/// and value paint in the darkroom, so the seven card bodies each pick
11-/// each pick tokens rather than reimplement the same font/colour swap seven11+/// tokens rather than reimplement the same font/colour swap seven times.
12-/// times (`export_card`'s own `dark`-branch technique, one level up).
13 ///12 ///
14 /// A row label is what the room says about the control -- Archivo, §3's13 /// A row label is what the room says about the control -- Archivo, §3's
15 /// label-row size, `ink2` at rest / `ink1` picked (no permanent pill: the14 /// label-row size, `ink2` at rest / `ink1` picked (no permanent pill: the
@@ -68,7 +67,7 @@ fn dark_row_value(text: impl Into<SharedString>) -> Div {
68 /// ([`Player::toggle_maximize`]) -- mouse and key reach the same switch.67 /// ([`Player::toggle_maximize`]) -- mouse and key reach the same switch.
69 // `+ use<>` (edition 2024 precise capturing): without it, the elided68 // `+ use<>` (edition 2024 precise capturing): without it, the elided
70 // lifetime on `cx` would be captured into the returned opaque type by69 // lifetime on `cx` would be captured into the returned opaque type by
71-// default, so a hoisted `let head = dark.then(|| dark_card_head(..., cx));`70+// default, so a hoisted `let head = true.then(|| dark_card_head(..., cx));`
72 // would keep `cx` borrowed until `head` is finally consumed -- fighting71 // would keep `cx` borrowed until `head` is finally consumed -- fighting
73 // every other `cx.listener(...)` call built in between, which is exactly72 // every other `cx.listener(...)` call built in between, which is exactly
74 // the E0500/E0501 chain this card's own hoist is here to avoid.73 // the E0500/E0501 chain this card's own hoist is here to avoid.
@@ -288,34 +287,22 @@ impl Player {
288 // The cap is what keeps the card inside the smallest window; a taller287 // The cap is what keeps the card inside the smallest window; a taller
289 // one gets a taller list rather than a scroll past empty space, and the288 // one gets a taller list rather than a scroll past empty space, and the
290 // card is still only as tall as the rows it has.289 // card is still only as tall as the rows it has.
291- // DEFECT 1 (MOCK-SPEC.md / DESIGN §4): the darkroom draws this same290+ // DESIGN §4: plate surface, mono for what the film says, ghost rows,
292- // card in its own language -- plate surface, mono for what the film291+ // one bordered chip for the commit action.
293- // says, ghost rows, one bordered chip for the commit action -- while292+ let ink_secondary = INK3();
294- // the legacy tree (`OLD_GUI=1`) keeps the rounded sheet verbatim.293+ let bg_hover = DARK_RAISED();
295- // Branched here rather than in a second function so the ~350 lines294+ let bg_selected = DARK_RAISED();
296- // of row-building *logic* below (which preset is picked, which
297- // format is refused, what a click does) stay written once; only the
298- // few tokens a paint reads differ.
299- let dark = self.darkroom;
300- let rows_h = match dark {
301- // The corner plate sits over the bench+ledger footprint (§11
302- // check 6), which is a fraction of the window a centred modal
303- // was sized against -- a fixed, smaller cap rather than
304- // `viewport.height`-derived room the plate does not have.
305- true => (EXPORT_ROWS_H / 2.).max(4. * KEYS_ROW_H),
306- false => (f32::from(viewport.height) - EXPORT_FIXED_H - 24.).max(EXPORT_ROWS_H),
307- };
308- let ink_secondary = if dark { INK3() } else { FG_SECONDARY() };
309- let ink_primary = if dark { INK1() } else { FG_PRIMARY() };
310- let bg_hover = if dark { DARK_RAISED() } else { BG_HOVER() };
311- let bg_selected = if dark { DARK_RAISED() } else { BG_SELECTED() };
312 // Archivo for what the row *says as a verb* (its label), mono for295 // Archivo for what the row *says as a verb* (its label), mono for
313 // what the film says through it (its detail/key) -- DESIGN §3.296 // what the film says through it (its detail/key) -- DESIGN §3.
314- let label_style =297+ let label_style = Some(type_scale::label(
315- dark.then(|| type_scale::label(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM));298+ type_scale::LABEL_ROW_PX,
316- let mono_style = dark299+ gpui::FontWeight::MEDIUM,
317- .then(|| type_scale::mono(type_scale::CHORD_METADATA_MAX_PX, gpui::FontWeight::MEDIUM));300+ ));
318- let head_style = dark.then(type_scale::head);301+ let mono_style = Some(type_scale::mono(
302+ type_scale::CHORD_METADATA_MAX_PX,
303+ gpui::FontWeight::MEDIUM,
304+ ));
305+ let head_style = Some(type_scale::head());
319 let row = |id: (&'static str, usize)| {306 let row = |id: (&'static str, usize)| {
320 div()307 div()
321 .id(id)308 .id(id)
@@ -370,19 +357,12 @@ impl Player {
370 // picked, `ink2` resting), detail follows one step behind357 // picked, `ink2` resting), detail follows one step behind
371 // (`ink2` picked, `ink2` resting -- never `ink3`, which stays358 // (`ink2` picked, `ink2` resting -- never `ink3`, which stays
372 // for the key column and the summary's small print).359 // for the key column and the summary's small print).
373- let ink = match (dark, picked) {360+ let ink = INK2();
374- (true, true) => INK2(),361+ let label_ink = match picked {
375- (true, false) => INK2(),362+ true => INK1(),
376- (false, true) => ink_primary,363+ false => INK2(),
377- (false, false) => ink_secondary,
378 };364 };
379- let label_ink = match (dark, picked) {365+ let key_ink = INK3();
380- (true, true) => INK1(),
381- (true, false) => INK2(),
382- (false, true) => ink_primary,
383- (false, false) => ink_secondary,
384- };
385- let key_ink = if dark { INK3() } else { ink_secondary };
386 live(row(id), enabled)366 live(row(id), enabled)
387 .when(picked, |d| d.bg(rgb(bg_selected)))367 .when(picked, |d| d.bg(rgb(bg_selected)))
388 .child(368 .child(
@@ -412,9 +392,7 @@ impl Player {
412 // every row and a wrapped line reads as if it392 // every row and a wrapped line reads as if it
413 // began left of the label it belongs to.393 // began left of the label it belongs to.
414 div()394 div()
415- .when(dark, |d| {395+ .map(|d| d.w(px(92.)).flex_none().text_color(rgb(label_ink)))
416- d.w(px(92.)).flex_none().text_color(rgb(label_ink))
417- })
418 .when_some(label_style.clone(), |d, style| {396 .when_some(label_style.clone(), |d, style| {
419 d.font(style.font).text_size(style.size)397 d.font(style.font).text_size(style.size)
420 })398 })
@@ -927,225 +905,60 @@ impl Player {
927 false => "↵ exports · esc closes · s Advanced".into(),905 false => "↵ exports · esc closes · s Advanced".into(),
928 },906 },
929 };907 };
930- if dark {908+ // The darkroom's own language, not the corner-card sheet the legacy
931- // DEFECT 1: the darkroom's own language, not the legacy sheet --909+ // tree drew before it was removed --
932- // a plate (canvas-on-panel, §4), positioned over the bench+910+ // a plate (canvas-on-panel, §4), positioned over the bench+
933- // ledger footprint it can sit over rather than centred over the911+ // ledger footprint it can sit over rather than centred over the
934- // whole window (§11 check 6: the picture stays uncovered). The912+ // whole window (§11 check 6: the picture stays uncovered). The
935- // click-catcher behind it is `size_full` so a click anywhere913+ // click-catcher behind it is `size_full` so a click anywhere
936- // still closes the card exactly as the legacy scrim's does, but914+ // still closes the card exactly as the legacy scrim's does, but
937- // paints nothing (`SCRIM()` is deliberately not applied here) --915+ // paints nothing (`SCRIM()` is deliberately not applied here) --
938- // an invisible catcher changes zero picture pixels while a916+ // an invisible catcher changes zero picture pixels while a
939- // dimming one would still tint the screen it must never cover.917+ // dimming one would still tint the screen it must never cover.
940- // The plate is the room's below-picture footprint, not a 340px918+ // The plate is the room's below-picture footprint, not a 340px
941- // corner card (user 2026-08-21: "export section is not aligning919+ // corner card (user 2026-08-21: "export section is not aligning
942- // with our design"). Measured at 1280x720 the corner card's own920+ // with our design"). Measured at 1280x720 the corner card's own
943- // max-height was ~9px taller than the footprint it had to fit921+ // max-height was ~9px taller than the footprint it had to fit
944- // in, so its scrolling row list collapsed to a single visible922+ // in, so its scrolling row list collapsed to a single visible
945- // row: the presets, Advanced and every codec row under them were923+ // row: the presets, Advanced and every codec row under them were
946- // unreachable by pointer, and the long status sentence wrapped to924+ // unreachable by pointer, and the long status sentence wrapped to
947- // three lines over the top of them. Two columns instead -- rows925+ // three lines over the top of them. Two columns instead -- rows
948- // left, what-it-adds-up-to and the one bordered chip right --926+ // left, what-it-adds-up-to and the one bordered chip right --
949- // inside the same bench+ledger footprint every menu already927+ // inside the same bench+ledger footprint every menu already
950- // hangs in, so the picture stays uncovered (§11 check 6) and the928+ // hangs in, so the picture stays uncovered (§11 check 6) and the
951- // list gets the whole height rather than a fraction of it.929+ // list gets the whole height rather than a fraction of it.
952- let floor = crate::ui::stance::below_picture_floor(930+ let floor = crate::ui::stance::below_picture_floor(
953- f32::from(viewport.height),931+ f32::from(viewport.height),
954- self.split_px(Split::Bench, viewport),932+ self.split_px(Split::Bench, viewport),
955- );933+ );
956- let summary = |text: SharedString, ink: u32| {934+ let summary = |text: SharedString, ink: u32| {
957- div()935+ div()
958- .flex_none()936+ .flex_none()
959- .px(px(6.))937+ .px(px(6.))
960- .type_style(type_scale::mono(938+ .type_style(type_scale::mono(
961- type_scale::CHORD_METADATA_MAX_PX,939+ type_scale::CHORD_METADATA_MAX_PX,
962- gpui::FontWeight::MEDIUM,940+ gpui::FontWeight::MEDIUM,
963- ))941+ ))
964- .text_color(rgb(ink))942+ .text_color(rgb(ink))
965- .child(text)943+ .child(text)
966- };944+ };
967- return Some(
968- div()
969- .id("export-click-catcher")
970- .absolute()
971- .top_0()
972- .bottom_0()
973- .left_0()
974- .right_0()
975- .flex()
976- // Below the time band, not merely below the picture: the
977- // transport and the Export chip that opened this card are
978- // on that band, and a sheet drawn over them hides the
979- // control the editor just pressed. The bench and the
980- // ledger are what this plate is allowed to cover.
981- .pt(px(floor + crate::ui::stance::TIME_BAND_H + 6.))
982- .pb(px(6.))
983- .px(px(6.))
984- .on_mouse_down(
985- MouseButton::Left,
986- cx.listener(|this, _: &MouseDownEvent, _, cx| {
987- this.close_card();
988- cx.notify();
989- cx.stop_propagation();
990- }),
991- )
992- .child(
993- div()
994- .id("export-plate")
995- .flex_1()
996- .min_w(px(0.))
997- .on_mouse_down(MouseButton::Left, swallow)
998- .flex()
999- .flex_col()
1000- .gap(px(4.))
1001- .p(px(10.))
1002- .rounded(px(4.))
1003- .bg(rgb(DARK_PANEL()))
1004- .border_1()
1005- .border_color(rgba(DARK_SEAM()))
1006- .child(
1007- div()
1008- .flex_none()
1009- .flex()
1010- .items_baseline()
1011- .justify_between()
1012- .gap(px(12.))
1013- .px(px(6.))
1014- .child(
1015- div()
1016- .type_style(type_scale::head())
1017- .text_color(rgb(INK3()))
1018- .child("EXPORT"),
1019- )
1020- .child(
1021- div()
1022- .min_w(px(0.))
1023- .truncate()
1024- .type_style(type_scale::mono(
1025- type_scale::CHORD_METADATA_MAX_PX,
1026- gpui::FontWeight::MEDIUM,
1027- ))
1028- .text_color(rgb(INK2()))
1029- .child(status_line),
1030- ),
1031- )
1032- .child(
1033- div()
1034- .flex_1()
1035- .min_h(px(0.))
1036- .flex()
1037- .gap(px(10.))
1038- .child(
1039- div()
1040- .id("export-rows")
1041- .flex_1()
1042- .min_w(px(0.))
1043- .h_full()
1044- .flex()
1045- .flex_col()
1046- .gap(px(2.))
1047- .overflow_y_scroll()
1048- .children(list),
1049- )
1050- .child(
1051- div()
1052- .flex_none()
1053- .w(px(300.))
1054- .h_full()
1055- .flex()
1056- .flex_col()
1057- .justify_end()
1058- .gap(px(4.))
1059- .border_l_1()
1060- .border_color(rgb(DARK_HAIRLINE()))
1061- .pl(px(8.))
1062- .child(summary(head.into(), INK2()))
1063- .children(self.range.map(|(start, end)| {
1064- summary(
1065- format!(
1066- "RANGE {}\u{2013}{} ({})",
1067- timecode(
1068- f64::from(start) / self.fps,
1069- self.fps
1070- ),
1071- timecode(f64::from(end) / self.fps, self.fps),
1072- frames_timecode(end - start, self.fps),
1073- )
1074- .into(),
1075- INK3(),
1076- )
1077- }))
1078- .child(summary(tail.into(), INK3()))
1079- // §4: "the single bordered chip in
1080- // the whole room" -- ghosts
1081- // everywhere else in this card, one
1082- // border here, wearing its chord
1083- // live off the keymap so a rebind
1084- // cannot leave it stale.
1085- .child(
1086- div()
1087- .id("export-confirm")
1088- .mt(px(4.))
1089- .flex()
1090- .items_center()
1091- .justify_center()
1092- .gap(px(6.))
1093- .h(px(CONTROL_H))
1094- .px(px(10.))
1095- .rounded(px(3.))
1096- .border_1()
1097- .border_color(rgb(match blocked.is_some() {
1098- true => INK4(),
1099- false => INK2(),
1100- }))
1101- .when(blocked.is_none(), |d| d.cursor_pointer())
1102- .when(blocked.is_some(), |d| {
1103- d.cursor_not_allowed()
1104- })
1105- .hover(|s| s.bg(rgb(DARK_RAISED())))
1106- .on_click(cx.listener(
1107- |this, _: &ClickEvent, _, cx| {
1108- this.start_export(cx)
1109- },
1110- ))
1111- .type_style(type_scale::label(
1112- type_scale::LABEL_ROW_PX,
1113- gpui::FontWeight::MEDIUM,
1114- ))
1115- .text_color(rgb(match blocked.is_some() {
1116- true => INK4(),
1117- false => INK1(),
1118- }))
1119- .child(action)
1120- .when(blocked.is_none(), |d| {
1121- d.child(
1122- div()
1123- .type_style(type_scale::mono(
1124- type_scale::CHORD_METADATA_MIN_PX,
1125- gpui::FontWeight::MEDIUM,
1126- ))
1127- .text_color(rgb(INK3()))
1128- .child(
1129- self.keymap
1130- .chord(ActionId::Export),
1131- ),
1132- )
1133- }),
1134- ),
1135- ),
1136- )
1137- .into_any_element(),
1138- )
1139- .into_any_element(),
1140- );
1141- }
1142 Some(945 Some(
1143- scrim()946+ div()
947+ .id("export-click-catcher")
948+ .absolute()
949+ .top_0()
950+ .bottom_0()
951+ .left_0()
952+ .right_0()
1144 .flex()953 .flex()
1145- .justify_center()954+ // Below the time band, not merely below the picture: the
1146- .items_center()955+ // transport and the Export chip that opened this card are
1147- .bg(rgba(SCRIM()))956+ // on that band, and a sheet drawn over them hides the
1148- // Click away closes it, as on every card here.957+ // control the editor just pressed. The bench and the
958+ // ledger are what this plate is allowed to cover.
959+ .pt(px(floor + crate::ui::stance::TIME_BAND_H + 6.))
960+ .pb(px(6.))
961+ .px(px(6.))
1149 .on_mouse_down(962 .on_mouse_down(
1150 MouseButton::Left,963 MouseButton::Left,
1151 cx.listener(|this, _: &MouseDownEvent, _, cx| {964 cx.listener(|this, _: &MouseDownEvent, _, cx| {
@@ -1156,89 +969,144 @@ impl Player {
1156 )969 )
1157 .child(970 .child(
1158 div()971 div()
1159- .w(px(EXPORT_W))972+ .id("export-plate")
973+ .flex_1()
974+ .min_w(px(0.))
1160 .on_mouse_down(MouseButton::Left, swallow)975 .on_mouse_down(MouseButton::Left, swallow)
1161 .flex()976 .flex()
1162 .flex_col()977 .flex_col()
1163- .gap(px(2.))978+ .gap(px(4.))
1164- .p(px(12.))979+ .p(px(10.))
1165- .rounded(px(6.))980+ .rounded(px(4.))
1166- .bg(rgb(BG_RAISED()))981+ .bg(rgb(DARK_PANEL()))
1167- .child(div().flex_none().px(px(6.)).child("Export"))982+ .border_1()
1168- // The status line, where a refusal from the save dialog983+ .border_color(rgba(DARK_SEAM()))
1169- // lands: the notice bar it would otherwise take is under
1170- // the scrim. The keys are on the rows, so this says how
1171- // the card as a whole is answered rather than listing
1172- // them a second time.
1173 .child(984 .child(
1174 div()985 div()
1175 .flex_none()986 .flex_none()
1176- .px(px(6.))
1177- .text_size(px(11.))
1178- .text_color(rgb(FG_SECONDARY()))
1179- .child(status_line),
1180- )
1181- // Capped and scrolling like the keybindings list: the
1182- // rows are more than a 360 px window has room for, and
1183- // it is the list that scrolls, never the card that
1184- // grows -- the summary and the button below stay put.
1185- .child(
1186- div()
1187- .id("export-rows")
1188 .flex()987 .flex()
1189- .flex_col()988+ .items_baseline()
1190- .gap(px(2.))989+ .justify_between()
1191- .max_h(px(rows_h))990+ .gap(px(12.))
1192- .overflow_y_scroll()
1193- .children(list),
1194- )
1195- .child(div().flex_none().px(px(6.)).text_size(px(11.)).child(head))
1196- // The mark, in and out and how long that is -- only
1197- // when there is one: an unmarked export writes the
1198- // whole timeline, the summary it always had.
1199- .children(self.range.map(|(start, end)| {
1200- div()
1201- .flex_none()
1202- .px(px(6.))
1203- .text_size(px(11.))
1204- .text_color(rgb(FG_SECONDARY()))
1205- .child(format!(
1206- "RANGE {}\u{2013}{} ({})",
1207- timecode(f64::from(start) / self.fps, self.fps),
1208- timecode(f64::from(end) / self.fps, self.fps),
1209- frames_timecode(end - start, self.fps),
1210- ))
1211- }))
1212- .child(
1213- div()
1214- .flex_none()
1215 .px(px(6.))991 .px(px(6.))
1216- .text_size(px(11.))992+ .child(
1217- .text_color(rgb(FG_SECONDARY()))993+ div()
1218- .child(tail),994+ .type_style(type_scale::head())
995+ .text_color(rgb(INK3()))
996+ .child("EXPORT"),
997+ )
998+ .child(
999+ div()
1000+ .min_w(px(0.))
1001+ .truncate()
1002+ .type_style(type_scale::mono(
1003+ type_scale::CHORD_METADATA_MAX_PX,
1004+ gpui::FontWeight::MEDIUM,
1005+ ))
1006+ .text_color(rgb(INK2()))
1007+ .child(status_line),
1008+ ),
1219 )1009 )
1220 .child(1010 .child(
1221 div()1011 div()
1222- .id("export-confirm")1012+ .flex_1()
1223- .mt(px(4.))1013+ .min_h(px(0.))
1224 .flex()1014 .flex()
1225- .h(px(CONTROL_H))1015+ .gap(px(10.))
1226- .items_center()1016+ .child(
1227- .justify_center()1017+ div()
1228- .rounded(px(3.))1018+ .id("export-rows")
1229- .bg(rgb(match blocked.is_some() {1019+ .flex_1()
1230- true => BG_PANEL(),1020+ .min_w(px(0.))
1231- false => BG_SELECTED(),1021+ .h_full()
1232- }))1022+ .flex()
1233- .cursor_pointer()1023+ .flex_col()
1234- .hover(|s| s.bg(rgb(BG_HOVER())))1024+ .gap(px(2.))
1235- .on_click(1025+ .overflow_y_scroll()
1236- cx.listener(|this, _: &ClickEvent, _, cx| {1026+ .children(list),
1237- this.start_export(cx)
1238- }),
1239 )1027 )
1240- .child(action),1028+ .child(
1241- ),1029+ div()
1030+ .flex_none()
1031+ .w(px(300.))
1032+ .h_full()
1033+ .flex()
1034+ .flex_col()
1035+ .justify_end()
1036+ .gap(px(4.))
1037+ .border_l_1()
1038+ .border_color(rgb(DARK_HAIRLINE()))
1039+ .pl(px(8.))
1040+ .child(summary(head.into(), INK2()))
1041+ .children(self.range.map(|(start, end)| {
1042+ summary(
1043+ format!(
1044+ "RANGE {}\u{2013}{} ({})",
1045+ timecode(f64::from(start) / self.fps, self.fps),
1046+ timecode(f64::from(end) / self.fps, self.fps),
1047+ frames_timecode(end - start, self.fps),
1048+ )
1049+ .into(),
1050+ INK3(),
1051+ )
1052+ }))
1053+ .child(summary(tail.into(), INK3()))
1054+ // §4: "the single bordered chip in
1055+ // the whole room" -- ghosts
1056+ // everywhere else in this card, one
1057+ // border here, wearing its chord
1058+ // live off the keymap so a rebind
1059+ // cannot leave it stale.
1060+ .child(
1061+ div()
1062+ .id("export-confirm")
1063+ .mt(px(4.))
1064+ .flex()
1065+ .items_center()
1066+ .justify_center()
1067+ .gap(px(6.))
1068+ .h(px(CONTROL_H))
1069+ .px(px(10.))
1070+ .rounded(px(3.))
1071+ .border_1()
1072+ .border_color(rgb(match blocked.is_some() {
1073+ true => INK4(),
1074+ false => INK2(),
1075+ }))
1076+ .when(blocked.is_none(), |d| d.cursor_pointer())
1077+ .when(blocked.is_some(), |d| d.cursor_not_allowed())
1078+ .hover(|s| s.bg(rgb(DARK_RAISED())))
1079+ .on_click(cx.listener(
1080+ |this, _: &ClickEvent, _, cx| {
1081+ this.start_export(cx)
1082+ },
1083+ ))
1084+ .type_style(type_scale::label(
1085+ type_scale::LABEL_ROW_PX,
1086+ gpui::FontWeight::MEDIUM,
1087+ ))
1088+ .text_color(rgb(match blocked.is_some() {
1089+ true => INK4(),
1090+ false => INK1(),
1091+ }))
1092+ .child(action)
1093+ .when(blocked.is_none(), |d| {
1094+ d.child(
1095+ div()
1096+ .type_style(type_scale::mono(
1097+ type_scale::CHORD_METADATA_MIN_PX,
1098+ gpui::FontWeight::MEDIUM,
1099+ ))
1100+ .text_color(rgb(INK3()))
1101+ .child(
1102+ self.keymap.chord(ActionId::Export),
1103+ ),
1104+ )
1105+ }),
1106+ ),
1107+ ),
1108+ )
1109+ .into_any_element(),
1242 )1110 )
1243 .into_any_element(),1111 .into_any_element(),
1244 )1112 )
@@ -1258,7 +1126,6 @@ impl Player {
1258 /// chord as well ([`cancels_export`]).1126 /// chord as well ([`cancels_export`]).
1259 pub(crate) fn export_progress_card(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {1127 pub(crate) fn export_progress_card(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
1260 let export = self.exporting()?;1128 let export = self.exporting()?;
1261- let dark = self.darkroom;
1262 let progress = export.progress().clamp(0., 1.);1129 let progress = export.progress().clamp(0., 1.);
1263 let elapsed = self1130 let elapsed = self
1264 .export_started1131 .export_started
@@ -1276,16 +1143,7 @@ impl Player {
1276 [one] => file_name(&one.path),1143 [one] => file_name(&one.path),
1277 [first, rest @ ..] => format!("{} +{} more", file_name(&first.path), rest.len()),1144 [first, rest @ ..] => format!("{} +{} more", file_name(&first.path), rest.len()),
1278 };1145 };
1279- let note = |text: SharedString| match dark {1146+ let note = |text: SharedString| dark_help(text).into_any_element();
1280- true => dark_help(text).into_any_element(),
1281- false => div()
1282- .flex_none()
1283- .px(px(6.))
1284- .text_size(px(11.))
1285- .text_color(rgb(FG_SECONDARY()))
1286- .child(text)
1287- .into_any_element(),
1288- };
1289 let armed = self.cancel_armed;1147 let armed = self.cancel_armed;
1290 let percent_line: SharedString = format!(1148 let percent_line: SharedString = format!(
1291 "{}% · {} elapsed · {left}",1149 "{}% · {} elapsed · {left}",
@@ -1312,14 +1170,9 @@ impl Player {
1312 .gap(px(6.))1170 .gap(px(6.))
1313 .p(px(12.))1171 .p(px(12.))
1314 .rounded(px(6.))1172 .rounded(px(6.))
1315- .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() }))1173+ .bg(rgb(DARK_PANEL()))
1316- .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM())))1174+ .map(|d| d.border_1().border_color(rgba(DARK_SEAM())))
1317- .when(dark, |d| {1175+ .map(|d| d.child(dark_card_head("Exporting", None, None, None, cx)))
1318- d.child(dark_card_head("Exporting", None, None, None, cx))
1319- })
1320- .when(!dark, |d| {
1321- d.child(div().flex_none().px(px(6.)).child("Exporting"))
1322- })
1323 // The bar itself: the same number as the percentage1176 // The bar itself: the same number as the percentage
1324 // below it, and it only ever moves forward -- the1177 // below it, and it only ever moves forward -- the
1325 // worker's progress is a monotone `fetch_max`.1178 // worker's progress is a monotone `fetch_max`.
@@ -1329,7 +1182,7 @@ impl Player {
1329 .mx(px(6.))1182 .mx(px(6.))
1330 .h(px(6.))1183 .h(px(6.))
1331 .rounded(px(3.))1184 .rounded(px(3.))
1332- .bg(rgb(if dark { DARK_HAIRLINE() } else { BG_PANEL() }))1185+ .bg(rgb(DARK_HAIRLINE()))
1333 .child(1186 .child(
1334 div()1187 div()
1335 .h_full()1188 .h_full()
@@ -1338,16 +1191,7 @@ impl Player {
1338 .bg(rgb(STATUS_PROGRESS())),1191 .bg(rgb(STATUS_PROGRESS())),
1339 ),1192 ),
1340 )1193 )
1341- .when(dark, |d| d.child(dark_row_value(percent_line.clone())))1194+ .map(|d| d.child(dark_row_value(percent_line.clone())))
1342- .when(!dark, |d| {
1343- d.child(
1344- div()
1345- .flex_none()
1346- .px(px(6.))
1347- .text_size(px(11.))
1348- .child(percent_line.clone()),
1349- )
1350- })
1351 // The row that was picked, then the seats the worker1195 // The row that was picked, then the seats the worker
1352 // actually opened -- so a fallback to the software1196 // actually opened -- so a fallback to the software
1353 // encoder shows here rather than being invisible.1197 // encoder shows here rather than being invisible.
@@ -1386,7 +1230,7 @@ impl Player {
1386 .flex()1230 .flex()
1387 .gap(px(6.))1231 .gap(px(6.))
1388 .justify_end()1232 .justify_end()
1389- .when(armed && dark, |d| {1233+ .when(armed, |d| {
1390 d.child(dark_ghost_button(1234 d.child(dark_ghost_button(
1391 "export-keep",1235 "export-keep",
1392 "Keep exporting",1236 "Keep exporting",
@@ -1398,22 +1242,7 @@ impl Player {
1398 }),1242 }),
1399 ))1243 ))
1400 })1244 })
1401- .when(armed && !dark, |d| {1245+ .map(|d| {
1402- d.child(control(
1403- "export-keep",
1404- 140.,
1405- ACCENT_PRIMARY(),
1406- None,
1407- "Keep exporting",
1408- "leaves the export running".to_string(),
1409- true,
1410- cx.listener(|this, _: &ClickEvent, _, cx| {
1411- this.cancel_armed = false;
1412- cx.notify();
1413- }),
1414- ))
1415- })
1416- .when(dark, |d| {
1417 d.child(dark_ghost_button(1246 d.child(dark_ghost_button(
1418 "export-cancel",1247 "export-cancel",
1419 "Cancel export",1248 "Cancel export",
@@ -1427,31 +1256,6 @@ impl Player {
1427 cx.notify();1256 cx.notify();
1428 }),1257 }),
1429 ))1258 ))
1430- })
1431- .when(!dark, |d| {
1432- d.child(control(
1433- "export-cancel",
1434- 140.,
1435- BG_RAISED(),
1436- None,
1437- "Cancel export",
1438- match armed {
1439- true => "stops the worker and deletes the part file"
1440- .to_string(),
1441- false => {
1442- "asks first -- one press only offers the choice"
1443- .to_string()
1444- }
1445- },
1446- true,
1447- cx.listener(move |this, _: &ClickEvent, _, cx| {
1448- match this.cancel_armed {
1449- true => this.cancel_export(),
1450- false => this.cancel_armed = true,
1451- }
1452- cx.notify();
1453- }),
1454- ))
1455 }),1259 }),
1456 ),1260 ),
1457 ),1261 ),
@@ -1512,7 +1316,6 @@ impl Player {
1512 cx: &mut Context<Self>,1316 cx: &mut Context<Self>,
1513 ) -> Option<impl IntoElement> {1317 ) -> Option<impl IntoElement> {
1514 let (lane, idx) = self.eq_open?;1318 let (lane, idx) = self.eq_open?;
1515- let dark = self.darkroom;
1516 // The rate the engine filters this timeline at, so the drawn curve is1319 // The rate the engine filters this timeline at, so the drawn curve is
1517 // the one those coefficients make -- near the top of the axis a 44.1 kHz1320 // the one those coefficients make -- near the top of the axis a 44.1 kHz
1518 // clip and a 48 kHz one are not the same shape.1321 // clip and a 48 kHz one are not the same shape.
@@ -1547,12 +1350,7 @@ impl Player {
1547 .w(px(EQ_HANDLE))1350 .w(px(EQ_HANDLE))
1548 .h(px(EQ_HANDLE))1351 .h(px(EQ_HANDLE))
1549 .rounded(px(EQ_HANDLE / 2.))1352 .rounded(px(EQ_HANDLE / 2.))
1550- .bg(rgb(match (dark, i == self.eq_band) {1353+ .bg(rgb(if i == self.eq_band { INK1() } else { INK3() }))
1551- (true, true) => INK1(),
1552- (true, false) => INK3(),
1553- (false, true) => ACCENT_PRIMARY(),
1554- (false, false) => FG_SECONDARY(),
1555- }))
1556 })1354 })
1557 .collect();1355 .collect();
1558 // Maximized used to claim a fixed 320 px slice for the graph1356 // Maximized used to claim a fixed 320 px slice for the graph
@@ -1564,7 +1362,7 @@ impl Player {
1564 // rows below it claim their own natural height first, the same1362 // rows below it claim their own natural height first, the same
1565 // leftover-space idiom `dock_stance::dock_sources` already uses for1363 // leftover-space idiom `dock_stance::dock_sources` already uses for
1566 // its own scroll region.1364 // its own scroll region.
1567- let graph_maximized = dark && self.card_maximized;1365+ let graph_maximized = self.card_maximized;
1568 let graph = div()1366 let graph = div()
1569 // Ided like the band rows it replaces: what the pointer presses on1367 // Ided like the band rows it replaces: what the pointer presses on
1570 // is one element with its own hitbox, which is what a drag is1368 // is one element with its own hitbox, which is what a drag is
@@ -1576,11 +1374,7 @@ impl Player {
1576 })1374 })
1577 .when(!graph_maximized, |d| d.flex_none().h(px(eq_graph_h(false))))1375 .when(!graph_maximized, |d| d.flex_none().h(px(eq_graph_h(false))))
1578 .rounded(px(3.))1376 .rounded(px(3.))
1579- .bg(rgb(if dark {1377+ .bg(rgb(DARK_HAIRLINE()))
1580- DARK_HAIRLINE()
1581- } else {
1582- BG_HOVER_DIM()
1583- }))
1584 .cursor_pointer()1378 .cursor_pointer()
1585 // The press picks the band under it *and* is already the first1379 // The press picks the band under it *and* is already the first
1586 // sample of the drag, so a plain click sets a value. A second click1380 // sample of the drag, so a plain click sets a value. A second click
@@ -1615,7 +1409,7 @@ impl Player {
1615 .left(relative(eq_x(*freq)))1409 .left(relative(eq_x(*freq)))
1616 .w(px(1.))1410 .w(px(1.))
1617 .h_full()1411 .h_full()
1618- .bg(rgb(if dark { DARK_HAIRLINE() } else { EQ_GRID() }))1412+ .bg(rgb(DARK_HAIRLINE()))
1619 })1413 })
1620 .collect::<Vec<_>>(),1414 .collect::<Vec<_>>(),
1621 )1415 )
@@ -1627,22 +1421,19 @@ impl Player {
1627 .top(relative(eq_y(db)))1421 .top(relative(eq_y(db)))
1628 .w_full()1422 .w_full()
1629 .h(px(1.))1423 .h(px(1.))
1630- .bg(rgb(if dark { DARK_HAIRLINE() } else { EQ_GRID() }))1424+ .bg(rgb(DARK_HAIRLINE()))
1631 .child(1425 .child(
1632 div()1426 div()
1633 .absolute()1427 .absolute()
1634 .left(px(4.))1428 .left(px(4.))
1635 .top(px(-11.))1429 .top(px(-11.))
1636- .when(dark, |d| {1430+ .map(|d| {
1637 d.type_style(type_scale::mono(1431 d.type_style(type_scale::mono(
1638 type_scale::CHORD_METADATA_MIN_PX,1432 type_scale::CHORD_METADATA_MIN_PX,
1639 gpui::FontWeight::MEDIUM,1433 gpui::FontWeight::MEDIUM,
1640 ))1434 ))
1641 .text_color(rgb(INK3()))1435 .text_color(rgb(INK3()))
1642 })1436 })
1643- .when(!dark, |d| {
1644- d.text_size(px(9.)).text_color(rgb(FG_SECONDARY()))
1645- })
1646 .child(format!("{db:+.0}")),1437 .child(format!("{db:+.0}")),
1647 )1438 )
1648 }))1439 }))
@@ -1653,7 +1444,7 @@ impl Player {
1653 .top(relative(0.5))1444 .top(relative(0.5))
1654 .w_full()1445 .w_full()
1655 .h(px(1.))1446 .h(px(1.))
1656- .bg(rgb(if dark { DARK_HAIRLINE() } else { BG_HOVER() })),1447+ .bg(rgb(DARK_HAIRLINE())),
1657 )1448 )
1658 .child(eq_curve(self.eq_params.clone(), sample_rate))1449 .child(eq_curve(self.eq_params.clone(), sample_rate))
1659 .children(handles)1450 .children(handles)
@@ -1672,11 +1463,7 @@ impl Player {
1672 // a box narrower than the text. `.whitespace_nowrap()` is1463 // a box narrower than the text. `.whitespace_nowrap()` is
1673 // the platform's own backstop, so a mis-measured box clips1464 // the platform's own backstop, so a mis-measured box clips
1674 // or overhangs instead of silently wrapping again.1465 // or overhangs instead of silently wrapping again.
1675- let end_px = if dark {1466+ let end_px = type_scale::CHORD_METADATA_MIN_PX;
1676- type_scale::CHORD_METADATA_MIN_PX
1677- } else {
1678- 9.
1679- };
1680 let div = div().absolute().bottom(px(1.)).whitespace_nowrap();1467 let div = div().absolute().bottom(px(1.)).whitespace_nowrap();
1681 let div = if i == 0 {1468 let div = if i == 0 {
1682 div.w(px(eq_tick_end_w(label, end_px)))1469 div.w(px(eq_tick_end_w(label, end_px)))
@@ -1692,16 +1479,13 @@ impl Player {
1692 .ml(px(-12.))1479 .ml(px(-12.))
1693 .text_align(TextAlign::Center)1480 .text_align(TextAlign::Center)
1694 };1481 };
1695- div.when(dark, |d| {1482+ div.map(|d| {
1696 d.type_style(type_scale::mono(1483 d.type_style(type_scale::mono(
1697 type_scale::CHORD_METADATA_MIN_PX,1484 type_scale::CHORD_METADATA_MIN_PX,
1698 gpui::FontWeight::MEDIUM,1485 gpui::FontWeight::MEDIUM,
1699 ))1486 ))
1700 .text_color(rgb(INK3()))1487 .text_color(rgb(INK3()))
1701 })1488 })
1702- .when(!dark, |d| {
1703- d.text_size(px(9.)).text_color(rgb(FG_SECONDARY()))
1704- })
1705 .child(*label)1489 .child(*label)
1706 }))1490 }))
1707 .child(1491 .child(
@@ -1709,16 +1493,13 @@ impl Player {
1709 .absolute()1493 .absolute()
1710 .top(px(2.))1494 .top(px(2.))
1711 .left(px(4.))1495 .left(px(4.))
1712- .when(dark, |d| {1496+ .map(|d| {
1713 d.type_style(type_scale::mono(1497 d.type_style(type_scale::mono(
1714 type_scale::CHORD_METADATA_MIN_PX,1498 type_scale::CHORD_METADATA_MIN_PX,
1715 gpui::FontWeight::MEDIUM,1499 gpui::FontWeight::MEDIUM,
1716 ))1500 ))
1717 .text_color(rgb(INK3()))1501 .text_color(rgb(INK3()))
1718 })1502 })
1719- .when(!dark, |d| {
1720- d.text_size(px(9.)).text_color(rgb(FG_SECONDARY()))
1721- })
1722 .child(format!("+{EQ_GAIN_LIMIT:.0} dB")),1503 .child(format!("+{EQ_GAIN_LIMIT:.0} dB")),
1723 );1504 );
1724 // The bottom of the axis is not named: -12 dB would land in the same1505 // The bottom of the axis is not named: -12 dB would land in the same
@@ -1782,8 +1563,8 @@ impl Player {
1782 .gap(px(2.))1563 .gap(px(2.))
1783 .p(px(12.))1564 .p(px(12.))
1784 .rounded(px(6.))1565 .rounded(px(6.))
1785- .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() }))1566+ .bg(rgb(DARK_PANEL()))
1786- .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM())))1567+ .map(|d| d.border_1().border_color(rgba(DARK_SEAM())))
1787 .child(1568 .child(
1788 div()1569 div()
1789 .id("eq-card-rows")1570 .id("eq-card-rows")
@@ -1798,7 +1579,7 @@ impl Player {
1798 .gap(px(2.))1579 .gap(px(2.))
1799 // Which clip, because the card is modal and the lane it1580 // Which clip, because the card is modal and the lane it
1800 // was opened from is behind a scrim by the time it is up.1581 // was opened from is behind a scrim by the time it is up.
1801- .when(dark, |d| {1582+ .map(|d| {
1802 d.child(dark_card_head(1583 d.child(dark_card_head(
1803 "Equalizer",1584 "Equalizer",
1804 Some(format!("{} clip {}", lane.label(), idx + 1).into()),1585 Some(format!("{} clip {}", lane.label(), idx + 1).into()),
@@ -1807,28 +1588,11 @@ impl Player {
1807 cx,1588 cx,
1808 ))1589 ))
1809 })1590 })
1810- .when(!dark, |d| {1591+
1811- d.child(div().flex_none().px(px(6.)).child(format!(1592+ .when(self.notices.front().is_some(), |d| {
1812- "Equalizer — {} clip {}",
1813- lane.label(),
1814- idx + 1
1815- )))
1816- })
1817- .when(dark && self.notices.front().is_some(), |d| {
1818 d.child(dark_help(self.notices.front().cloned().unwrap_or_default()))1593 d.child(dark_help(self.notices.front().cloned().unwrap_or_default()))
1819 })1594 })
1820- .when(!dark, |d| {1595+
1821- d.child(
1822- div()
1823- .flex_none()
1824- .px(px(6.))
1825- .text_size(px(11.))
1826- .text_color(rgb(FG_SECONDARY()))
1827- .child(self.notices.front().cloned().unwrap_or_else(|| {
1828- "drag a handle, or a digit picks a band — ←→ moves it, ↑↓ its gain, shift+←→ its width; a adds, x removes, f flattens it, r all, s spectrum; a click away or esc closes".into()
1829- })),
1830- )
1831- })
1832 .child(graph)1596 .child(graph)
1833 // Which band the keyboard is holding and every number it1597 // Which band the keyboard is holding and every number it
1834 // is set to, each with the pair of buttons that moves it:1598 // is set to, each with the pair of buttons that moves it:
@@ -1847,7 +1611,7 @@ impl Player {
1847 // by its key alone.1611 // by its key alone.
1848 .flex_wrap()1612 .flex_wrap()
1849 .gap(px(4.))1613 .gap(px(4.))
1850- .when(dark, |d| {1614+ .map(|d| {
1851 d.child(dark_ghost_button(1615 d.child(dark_ghost_button(
1852 "eq-reset",1616 "eq-reset",
1853 "Flatten all",1617 "Flatten all",
@@ -1861,33 +1625,12 @@ impl Player {
1861 }),1625 }),
1862 ))1626 ))
1863 })1627 })
1864- .when(!dark, |d| {1628+
1865- d.child(
1866- div()
1867- .id("eq-reset")
1868- .flex()
1869- .flex_1()
1870- .h(px(CONTROL_H))
1871- .items_center()
1872- .justify_center()
1873- .rounded(px(3.))
1874- .bg(rgb(BG_SELECTED()))
1875- .cursor_pointer()
1876- .hover(|s| s.bg(rgb(BG_HOVER())))
1877- .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
1878- for band in &mut this.eq_params.bands {
1879- band.gain_db = 0.;
1880- }
1881- this.commit_eq(cx);
1882- }))
1883- .child("Flatten all"),
1884- )
1885- })
1886 // The two that change how many bands there are.1629 // The two that change how many bands there are.
1887 // The engine takes any cascade -- the count was1630 // The engine takes any cascade -- the count was
1888 // only ever fixed because this card had no way1631 // only ever fixed because this card had no way
1889 // to say otherwise.1632 // to say otherwise.
1890- .when(dark, |d| {1633+ .map(|d| {
1891 d.child(dark_ghost_button(1634 d.child(dark_ghost_button(
1892 "eq-add",1635 "eq-add",
1893 "Add band",1636 "Add band",
@@ -1898,26 +1641,8 @@ impl Player {
1898 }),1641 }),
1899 ))1642 ))
1900 })1643 })
1901- .when(!dark, |d| {1644+
1902- d.child(1645+ .map(|d| {
1903- div()
1904- .id("eq-add")
1905- .flex()
1906- .flex_1()
1907- .h(px(CONTROL_H))
1908- .items_center()
1909- .justify_center()
1910- .rounded(px(3.))
1911- .bg(rgb(BG_PANEL()))
1912- .cursor_pointer()
1913- .hover(|s| s.bg(rgb(BG_HOVER())))
1914- .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
1915- this.add_band(cx)
1916- }))
1917- .child("Add band"),
1918- )
1919- })
1920- .when(dark, |d| {
1921 d.child(dark_ghost_button(1646 d.child(dark_ghost_button(
1922 "eq-remove",1647 "eq-remove",
1923 "Remove band",1648 "Remove band",
@@ -1928,30 +1653,12 @@ impl Player {
1928 }),1653 }),
1929 ))1654 ))
1930 })1655 })
1931- .when(!dark, |d| {1656+
1932- d.child(
1933- div()
1934- .id("eq-remove")
1935- .flex()
1936- .flex_1()
1937- .h(px(CONTROL_H))
1938- .items_center()
1939- .justify_center()
1940- .rounded(px(3.))
1941- .bg(rgb(BG_PANEL()))
1942- .cursor_pointer()
1943- .hover(|s| s.bg(rgb(BG_HOVER())))
1944- .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
1945- this.remove_band(cx)
1946- }))
1947- .child("Remove band"),
1948- )
1949- })
1950 // The analyser's switch, next to the one other1657 // The analyser's switch, next to the one other
1951 // button the card has: `s` does the same, and a1658 // button the card has: `s` does the same, and a
1952 // toggle only a keystroke can reach is one most1659 // toggle only a keystroke can reach is one most
1953 // people never find.1660 // people never find.
1954- .when(dark, |d| {1661+ .map(|d| {
1955 d.child(dark_ghost_button(1662 d.child(dark_ghost_button(
1956 "eq-spectrum",1663 "eq-spectrum",
1957 match self.eq_spectrum {1664 match self.eq_spectrum {
@@ -1966,63 +1673,19 @@ impl Player {
1966 }),1673 }),
1967 ))1674 ))
1968 })1675 })
1969- .when(!dark, |d| {1676+ ,
1970- d.child(
1971- div()
1972- .id("eq-spectrum")
1973- .flex()
1974- .flex_1()
1975- .h(px(CONTROL_H))
1976- .items_center()
1977- .justify_center()
1978- .rounded(px(3.))
1979- .bg(rgb(match self.eq_spectrum {
1980- true => BG_SELECTED(),
1981- false => BG_HOVER_DIM(),
1982- }))
1983- .cursor_pointer()
1984- .hover(|s| s.bg(rgb(BG_HOVER())))
1985- .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
1986- this.eq_spectrum = !this.eq_spectrum;
1987- cx.notify();
1988- }))
1989- .child(match self.eq_spectrum {
1990- true => "Spectrum on",
1991- false => "Spectrum off",
1992- }),
1993- )
1994- }),
1995 ),1677 ),
1996 )1678 )
1997 // The column's own line, on the card that needs it for1679 // The column's own line, on the card that needs it for
1998 // the column's reason: a row nobody knows is under the1680 // the column's reason: a row nobody knows is under the
1999 // fold is a row that is not there.1681 // fold is a row that is not there.
2000- .when(can_scroll && dark, |d| {1682+ .when(can_scroll, |d| {
2001 d.child(dark_help(match below > 1. {1683 d.child(dark_help(match below > 1. {
2002 true => "more below — scroll the card",1684 true => "more below — scroll the card",
2003 false => "the end — scroll up for the rest",1685 false => "the end — scroll up for the rest",
2004 }))1686 }))
2005 })1687 })
2006- .when(can_scroll && !dark, |d| {1688+ ,
2007- d.child(
2008- div()
2009- .flex_none()
2010- .h(px(LABEL_H))
2011- .flex()
2012- .items_center()
2013- .justify_end()
2014- .px(px(6.))
2015- .text_size(px(10.))
2016- .text_color(rgb(match below > 1. {
2017- true => ACCENT_PRIMARY(),
2018- false => FG_SECONDARY(),
2019- }))
2020- .child(match below > 1. {
2021- true => "more below — scroll the card",
2022- false => "the end — scroll up for the rest",
2023- }),
2024- )
2025- }),
2026 ),1689 ),
2027 )1690 )
2028 }1691 }
@@ -2037,7 +1700,6 @@ impl Player {
2037 picked: Option<&Band>,1700 picked: Option<&Band>,
2038 cx: &mut Context<Self>,1701 cx: &mut Context<Self>,
2039 ) -> impl IntoElement {1702 ) -> impl IntoElement {
2040- let dark = self.darkroom;
2041 let row = div()1703 let row = div()
2042 .flex_none()1704 .flex_none()
2043 .flex()1705 .flex()
@@ -2047,13 +1709,9 @@ impl Player {
2047 .flex_wrap()1709 .flex_wrap()
2048 .items_center()1710 .items_center()
2049 .gap(px(10.))1711 .gap(px(10.))
2050- .px(px(6.))1712+ .px(px(6.));
2051- .when(!dark, |d| d.text_size(px(11.)));
2052 let Some(band) = picked.copied() else {1713 let Some(band) = picked.copied() else {
2053- return match dark {1714+ return row.child(dark_help("no bands — a adds one"));
2054- true => row.child(dark_help("no bands — a adds one")),
2055- false => row.child("no bands — a adds one"),
2056- };
2057 };1715 };
2058 let step = |id: &'static str,1716 let step = |id: &'static str,
2059 label: &'static str,1717 label: &'static str,
@@ -2061,23 +1719,7 @@ impl Player {
2061 cx: &mut Context<Self>| {1719 cx: &mut Context<Self>| {
2062 let on_click =1720 let on_click =
2063 cx.listener(move |this, _: &ClickEvent, _, cx| this.nudge_band(change, cx));1721 cx.listener(move |this, _: &ClickEvent, _, cx| this.nudge_band(change, cx));
2064- match dark {1722+ dark_step_glyph(id, label == "+", on_click).into_any_element()
2065- true => dark_step_glyph(id, label == "+", on_click).into_any_element(),
2066- false => div()
2067- .id(id)
2068- .flex()
2069- .w(px(HIT_MIN))
2070- .h(px(HIT_MIN))
2071- .items_center()
2072- .justify_center()
2073- .rounded(px(3.))
2074- .bg(rgb(BG_PANEL()))
2075- .cursor_pointer()
2076- .hover(|s| s.bg(rgb(BG_HOVER())))
2077- .on_click(on_click)
2078- .child(label)
2079- .into_any_element(),
2080- }
2081 };1723 };
2082 let number = |value: String,1724 let number = |value: String,
2083 ids: (&'static str, &'static str),1725 ids: (&'static str, &'static str),
@@ -2087,27 +1729,18 @@ impl Player {
2087 .flex()1729 .flex()
2088 .items_center()1730 .items_center()
2089 .gap(px(4.))1731 .gap(px(4.))
2090- .child(match dark {1732+ .child(dark_row_value(value).into_any_element())
2091- true => dark_row_value(value).into_any_element(),
2092- false => div().child(value).into_any_element(),
2093- })
2094 .child(step(ids.0, "−", by.0, cx))1733 .child(step(ids.0, "−", by.0, cx))
2095 .child(step(ids.1, "+", by.1, cx))1734 .child(step(ids.1, "+", by.1, cx))
2096 };1735 };
2097- row.child(match dark {1736+ row.child(
2098- true => dark_help(format!(1737+ dark_help(format!(
2099 "Band {} of {}",1738 "Band {} of {}",
2100 self.eq_band + 1,1739 self.eq_band + 1,
2101 self.eq_params.bands.len()1740 self.eq_params.bands.len()
2102 ))1741 ))
2103 .into_any_element(),1742 .into_any_element(),
2104- false => format!(1743+ )
2105- "Band {} of {}",
2106- self.eq_band + 1,
2107- self.eq_params.bands.len()
2108- )
2109- .into_any_element(),
2110- })
2111 .child(number(1744 .child(number(
2112 band_label(&band),1745 band_label(&band),
2113 ("eq-freq-down", "eq-freq-up"),1746 ("eq-freq-down", "eq-freq-up"),
@@ -2165,7 +1798,6 @@ impl Player {
2165 ) -> Option<impl IntoElement> {1798 ) -> Option<impl IntoElement> {
2166 let (lane, idx) = self.color_open?;1799 let (lane, idx) = self.color_open?;
2167 let params = self.color_params();1800 let params = self.color_params();
2168- let dark = self.darkroom;
2169 let rows: Vec<_> = COLOR_BANDS1801 let rows: Vec<_> = COLOR_BANDS
2170 .iter()1802 .iter()
2171 .enumerate()1803 .enumerate()
@@ -2186,9 +1818,8 @@ impl Player {
2186 // Darkroom: no permanent pill under a label -- the picked1818 // Darkroom: no permanent pill under a label -- the picked
2187 // row is a 1px `ink1` rule (§4's focus ring), never a fill.1819 // row is a 1px `ink1` rule (§4's focus ring), never a fill.
2188 // Hover is the one fill step §4 allows.1820 // Hover is the one fill step §4 allows.
2189- .when(dark && picked, |d| d.border_l_2().border_color(rgb(INK1())))1821+ .when(picked, |d| d.border_l_2().border_color(rgb(INK1())))
2190- .when(!dark && picked, |d| d.bg(rgb(BG_SELECTED())))1822+ .hover(|s| s.bg(rgb(DARK_RAISED())))
2191- .hover(|s| s.bg(rgb(if dark { DARK_RAISED() } else { BG_HOVER() })))
2192 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {1823 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
2193 this.color_band = i;1824 this.color_band = i;
2194 cx.notify();1825 cx.notify();
@@ -2198,8 +1829,7 @@ impl Player {
2198 .flex_1()1829 .flex_1()
2199 .min_w(px(0.))1830 .min_w(px(0.))
2200 .truncate()1831 .truncate()
2201- .when(dark, |d| d.child(dark_row_label(label, picked)))1832+ .map(|d| d.child(dark_row_label(label, picked))),
2202- .when(!dark, |d| d.child(label)),
2203 )1833 )
2204 .child(1834 .child(
2205 // The bar is 4 px to look at and a whole row to hit1835 // The bar is 4 px to look at and a whole row to hit
@@ -2230,7 +1860,7 @@ impl Player {
2230 .w_full()1860 .w_full()
2231 .h(px(4.))1861 .h(px(4.))
2232 .rounded(px(2.))1862 .rounded(px(2.))
2233- .bg(rgb(if dark { DARK_PANEL() } else { BG_PANEL() }))1863+ .bg(rgb(DARK_PANEL()))
2234 .child(1864 .child(
2235 div()1865 div()
2236 .h_full()1866 .h_full()
@@ -2243,14 +1873,7 @@ impl Player {
2243 .child(1873 .child(
2244 div()1874 div()
2245 .w(px(44.))1875 .w(px(44.))
2246- .when(dark, |d| {1876+ .map(|d| d.child(dark_row_value(format!("{:.0}%", value * 100.)))),
2247- d.child(dark_row_value(format!("{:.0}%", value * 100.)))
2248- })
2249- .when(!dark, |d| {
2250- d.text_size(px(11.))
2251- .text_color(rgb(FG_SECONDARY()))
2252- .child(format!("{:.0}%", value * 100.))
2253- }),
2254 )1877 )
2255 })1878 })
2256 .collect();1879 .collect();
@@ -2292,9 +1915,9 @@ impl Player {
2292 .gap(px(2.))1915 .gap(px(2.))
2293 .p(px(12.))1916 .p(px(12.))
2294 .rounded(px(6.))1917 .rounded(px(6.))
2295- .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() }))1918+ .bg(rgb(DARK_PANEL()))
2296- .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM())))1919+ .map(|d| d.border_1().border_color(rgba(DARK_SEAM())))
2297- .when(dark, |d| {1920+ .map(|d| {
2298 d.child(dark_card_head(1921 d.child(dark_card_head(
2299 "Colour",1922 "Colour",
2300 Some(head_meta.clone()),1923 Some(head_meta.clone()),
@@ -2303,23 +1926,6 @@ impl Player {
2303 cx,1926 cx,
2304 ))1927 ))
2305 })1928 })
2306- .when(!dark, |d| {
2307- d.child(div().flex_none().px(px(6.)).child(format!(
2308- "Colour — {} clip {}",
2309- lane.label(),
2310- idx + 1
2311- )))
2312- })
2313- .when(!dark, |d| {
2314- d.child(
2315- div()
2316- .flex_none()
2317- .px(px(6.))
2318- .text_size(px(11.))
2319- .text_color(rgb(FG_SECONDARY()))
2320- .child(help_text),
2321- )
2322- })
2323 // The frame as it is being graded, over the controls1929 // The frame as it is being graded, over the controls
2324 // grading it: the three lines are what the picture is1930 // grading it: the three lines are what the picture is
2325 // made of, and every sample of a drag reseeks, so they1931 // made of, and every sample of a drag reseeks, so they
@@ -2329,16 +1935,12 @@ impl Player {
2329 .flex_none()1935 .flex_none()
2330 .h(px(HIST_H))1936 .h(px(HIST_H))
2331 .rounded(px(3.))1937 .rounded(px(3.))
2332- .bg(rgb(if dark {1938+ .bg(rgb(DARK_HAIRLINE()))
2333- DARK_HAIRLINE()
2334- } else {
2335- BG_HOVER_DIM()
2336- }))
2337 .relative()1939 .relative()
2338 .child(hist_curves(self.histogram)),1940 .child(hist_curves(self.histogram)),
2339 )1941 )
2340 .children(rows)1942 .children(rows)
2341- .when(dark, |d| {1943+ .map(|d| {
2342 d.child(dark_ghost_button(1944 d.child(dark_ghost_button(
2343 "color-reset",1945 "color-reset",
2344 "Reset",1946 "Reset",
@@ -2348,25 +1950,6 @@ impl Player {
2348 this.set_color(ColorParams::default(), cx);1950 this.set_color(ColorParams::default(), cx);
2349 }),1951 }),
2350 ))1952 ))
2351- })
2352- .when(!dark, |d| {
2353- d.child(
2354- div()
2355- .id("color-reset")
2356- .mt(px(4.))
2357- .flex()
2358- .h(px(CONTROL_H))
2359- .items_center()
2360- .justify_center()
2361- .rounded(px(3.))
2362- .bg(rgb(BG_SELECTED()))
2363- .cursor_pointer()
2364- .hover(|s| s.bg(rgb(BG_HOVER())))
2365- .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
2366- this.set_color(ColorParams::default(), cx);
2367- }))
2368- .child("Reset"),
2369- )
2370 }),1953 }),
2371 ),1954 ),
2372 )1955 )
@@ -2382,7 +1965,6 @@ impl Player {
2382 ) -> Option<impl IntoElement> {1965 ) -> Option<impl IntoElement> {
2383 let (lane, idx) = self.transform_open?;1966 let (lane, idx) = self.transform_open?;
2384 let params = self.transform_params();1967 let params = self.transform_params();
2385- let dark = self.darkroom;
2386 let rows: Vec<_> = TRANSFORM_BANDS1968 let rows: Vec<_> = TRANSFORM_BANDS
2387 .iter()1969 .iter()
2388 .enumerate()1970 .enumerate()
@@ -2400,9 +1982,8 @@ impl Player {
2400 .px(px(6.))1982 .px(px(6.))
2401 .rounded(px(3.))1983 .rounded(px(3.))
2402 .cursor_pointer()1984 .cursor_pointer()
2403- .when(dark && picked, |d| d.border_l_2().border_color(rgb(INK1())))1985+ .when(picked, |d| d.border_l_2().border_color(rgb(INK1())))
2404- .when(!dark && picked, |d| d.bg(rgb(BG_SELECTED())))1986+ .hover(|s| s.bg(rgb(DARK_RAISED())))
2405- .hover(|s| s.bg(rgb(if dark { DARK_RAISED() } else { BG_HOVER() })))
2406 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {1987 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
2407 this.transform_band = i;1988 this.transform_band = i;
2408 cx.notify();1989 cx.notify();
@@ -2412,8 +1993,7 @@ impl Player {
2412 .flex_1()1993 .flex_1()
2413 .min_w(px(0.))1994 .min_w(px(0.))
2414 .truncate()1995 .truncate()
2415- .when(dark, |d| d.child(dark_row_label(label, picked)))1996+ .map(|d| d.child(dark_row_label(label, picked))),
2416- .when(!dark, |d| d.child(label)),
2417 )1997 )
2418 .child(1998 .child(
2419 div()1999 div()
@@ -2439,7 +2019,7 @@ impl Player {
2439 .w_full()2019 .w_full()
2440 .h(px(4.))2020 .h(px(4.))
2441 .rounded(px(2.))2021 .rounded(px(2.))
2442- .bg(rgb(if dark { DARK_PANEL() } else { BG_PANEL() }))2022+ .bg(rgb(DARK_PANEL()))
2443 .child(2023 .child(
2444 div()2024 div()
2445 .h_full()2025 .h_full()
@@ -2452,14 +2032,7 @@ impl Player {
2452 .child(2032 .child(
2453 div()2033 div()
2454 .w(px(44.))2034 .w(px(44.))
2455- .when(dark, |d| {2035+ .map(|d| d.child(dark_row_value(transform_row_value(i, value)))),
2456- d.child(dark_row_value(transform_row_value(i, value)))
2457- })
2458- .when(!dark, |d| {
2459- d.text_size(px(11.))
2460- .text_color(rgb(FG_SECONDARY()))
2461- .child(transform_row_value(i, value))
2462- }),
2463 )2036 )
2464 })2037 })
2465 .collect();2038 .collect();
@@ -2500,9 +2073,9 @@ impl Player {
2500 .gap(px(2.))2073 .gap(px(2.))
2501 .p(px(12.))2074 .p(px(12.))
2502 .rounded(px(6.))2075 .rounded(px(6.))
2503- .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() }))2076+ .bg(rgb(DARK_PANEL()))
2504- .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM())))2077+ .map(|d| d.border_1().border_color(rgba(DARK_SEAM())))
2505- .when(dark, |d| {2078+ .map(|d| {
2506 d.child(dark_card_head(2079 d.child(dark_card_head(
2507 "Transform",2080 "Transform",
2508 Some(head_meta.clone()),2081 Some(head_meta.clone()),
@@ -2511,25 +2084,8 @@ impl Player {
2511 cx,2084 cx,
2512 ))2085 ))
2513 })2086 })
2514- .when(!dark, |d| {
2515- d.child(div().flex_none().px(px(6.)).child(format!(
2516- "Transform — {} clip {}",
2517- lane.label(),
2518- idx + 1
2519- )))
2520- })
2521- .when(!dark, |d| {
2522- d.child(
2523- div()
2524- .flex_none()
2525- .px(px(6.))
2526- .text_size(px(11.))
2527- .text_color(rgb(FG_SECONDARY()))
2528- .child(help_text),
2529- )
2530- })
2531 .children(rows)2087 .children(rows)
2532- .when(dark, |d| {2088+ .map(|d| {
2533 d.child(dark_ghost_button(2089 d.child(dark_ghost_button(
2534 "transform-reset",2090 "transform-reset",
2535 "Reset",2091 "Reset",
@@ -2539,25 +2095,6 @@ impl Player {
2539 this.set_transform(TransformParams::default(), cx);2095 this.set_transform(TransformParams::default(), cx);
2540 }),2096 }),
2541 ))2097 ))
2542- })
2543- .when(!dark, |d| {
2544- d.child(
2545- div()
2546- .id("transform-reset")
2547- .mt(px(4.))
2548- .flex()
2549- .h(px(CONTROL_H))
2550- .items_center()
2551- .justify_center()
2552- .rounded(px(3.))
2553- .bg(rgb(BG_SELECTED()))
2554- .cursor_pointer()
2555- .hover(|s| s.bg(rgb(BG_HOVER())))
2556- .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
2557- this.set_transform(TransformParams::default(), cx);
2558- }))
2559- .child("Reset"),
2560- )
2561 }),2098 }),
2562 ),2099 ),
2563 )2100 )
@@ -2581,7 +2118,6 @@ impl Player {
2581 let speed = self.card_speed();2118 let speed = self.card_speed();
2582 let session = self.session.as_ref()?;2119 let session = self.session.as_ref()?;
2583 let clip = session.lane_clips(lane).get(idx).copied()?;2120 let clip = session.lane_clips(lane).get(idx).copied()?;
2584- let dark = self.darkroom;
2585 let lo = f32::from(Speed::MIN.permille());2121 let lo = f32::from(Speed::MIN.permille());
2586 let hi = f32::from(Speed::MAX.permille());2122 let hi = f32::from(Speed::MAX.permille());
2587 let frac = ((f32::from(speed.permille()) - lo) / (hi - lo)).clamp(0., 1.);2123 let frac = ((f32::from(speed.permille()) - lo) / (hi - lo)).clamp(0., 1.);
@@ -2598,20 +2134,13 @@ impl Player {
2598 .items_center()2134 .items_center()
2599 .justify_center()2135 .justify_center()
2600 .rounded(px(3.))2136 .rounded(px(3.))
2601- .when(dark && picked, |d| d.bg(rgb(DARK_RAISED())))2137+ .when(picked, |d| d.bg(rgb(DARK_RAISED())))
2602- .when(!dark, |d| {
2603- d.bg(rgb(match picked {
2604- true => BG_SELECTED(),
2605- false => BG_PANEL(),
2606- }))
2607- })
2608 .cursor_pointer()2138 .cursor_pointer()
2609- .hover(|s| s.bg(rgb(if dark { DARK_RAISED() } else { BG_HOVER() })))2139+ .hover(|s| s.bg(rgb(DARK_RAISED())))
2610 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {2140 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
2611 this.set_speed(at, cx);2141 this.set_speed(at, cx);
2612 }))2142 }))
2613- .when(dark, |d| d.child(dark_row_value(format!("{at}"))))2143+ .map(|d| d.child(dark_row_value(format!("{at}"))))
2614- .when(!dark, |d| d.child(format!("{at}")))
2615 })2144 })
2616 .collect();2145 .collect();
2617 let head_meta: SharedString = format!("{} clip {}", lane.label(), idx + 1).into();2146 let head_meta: SharedString = format!("{} clip {}", lane.label(), idx + 1).into();
@@ -2658,9 +2187,9 @@ impl Player {
2658 .gap(px(6.))2187 .gap(px(6.))
2659 .p(px(12.))2188 .p(px(12.))
2660 .rounded(px(6.))2189 .rounded(px(6.))
2661- .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() }))2190+ .bg(rgb(DARK_PANEL()))
2662- .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM())))2191+ .map(|d| d.border_1().border_color(rgba(DARK_SEAM())))
2663- .when(dark, |d| {2192+ .map(|d| {
2664 d.child(dark_card_head(2193 d.child(dark_card_head(
2665 "Speed (tape)",2194 "Speed (tape)",
2666 Some(head_meta.clone()),2195 Some(head_meta.clone()),
@@ -2669,23 +2198,6 @@ impl Player {
2669 cx,2198 cx,
2670 ))2199 ))
2671 })2200 })
2672- .when(!dark, |d| {
2673- d.child(div().flex_none().px(px(6.)).child(format!(
2674- "Speed (tape) — {} clip {}",
2675- lane.label(),
2676- idx + 1
2677- )))
2678- })
2679- .when(!dark, |d| {
2680- d.child(
2681- div()
2682- .flex_none()
2683- .px(px(6.))
2684- .text_size(px(11.))
2685- .text_color(rgb(FG_SECONDARY()))
2686- .child(help_text),
2687- )
2688- })
2689 .child(2201 .child(
2690 // 4 px to look at and a whole row to hit (WCAG2202 // 4 px to look at and a whole row to hit (WCAG
2691 // 2.5.8), the split the colour sliders and the ruler2203 // 2.5.8), the split the colour sliders and the ruler
@@ -2711,7 +2223,7 @@ impl Player {
2711 .w_full()2223 .w_full()
2712 .h(px(4.))2224 .h(px(4.))
2713 .rounded(px(2.))2225 .rounded(px(2.))
2714- .bg(rgb(if dark { DARK_PANEL() } else { BG_PANEL() }))2226+ .bg(rgb(DARK_PANEL()))
2715 .child(2227 .child(
2716 div()2228 div()
2717 .h_full()2229 .h_full()
@@ -2722,20 +2234,7 @@ impl Player {
2722 ),2234 ),
2723 )2235 )
2724 .child(div().flex().gap(px(4.)).children(presets))2236 .child(div().flex().gap(px(4.)).children(presets))
2725- .when(dark, |d| d.child(dark_help(tail_text.clone())))2237+ .map(|d| d.child(dark_help(tail_text.clone()))),
2726- .when(!dark, |d| {
2727- d.child(
2728- div()
2729- .flex_none()
2730- .px(px(6.))
2731- .text_size(px(11.))
2732- .text_color(rgb(FG_SECONDARY()))
2733- // What the choice *is*, in the numbers the
2734- // timeline is measured in: the source range
2735- // never moves, the room it takes does.
2736- .child(tail_text),
2737- )
2738- }),
2739 ),2238 ),
2740 )2239 )
2741 }2240 }
@@ -2764,7 +2263,6 @@ impl Player {
2764 if !self.mix_open {2263 if !self.mix_open {
2765 return None;2264 return None;
2766 }2265 }
2767- let dark = self.darkroom;
2768 let session = self.session.as_ref();2266 let session = self.session.as_ref();
2769 let lanes = self.mix_lanes();2267 let lanes = self.mix_lanes();
2770 let limiter = session.map_or_else(Limiter::default, PlaybackSession::limiter);2268 let limiter = session.map_or_else(Limiter::default, PlaybackSession::limiter);
@@ -2802,70 +2300,31 @@ impl Player {
2802 .justify_between()2300 .justify_between()
2803 .px(px(6.))2301 .px(px(6.))
2804 .rounded(px(3.))2302 .rounded(px(3.))
2805- .when(dark && picked, |d| d.border_l_2().border_color(rgb(INK1())))2303+ .when(picked, |d| d.border_l_2().border_color(rgb(INK1())))
2806- .when(!dark, |d| {
2807- d.bg(rgb(match picked {
2808- true => BG_SELECTED(),
2809- false => BG_PANEL(),
2810- }))
2811- })
2812 .cursor_pointer()2304 .cursor_pointer()
2813- .hover(|s| s.bg(rgb(if dark { DARK_RAISED() } else { BG_HOVER() })))2305+ .hover(|s| s.bg(rgb(DARK_RAISED())))
2814 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {2306 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
2815 this.mix_field = n;2307 this.mix_field = n;
2816 cx.notify();2308 cx.notify();
2817 }))2309 }))
2818- .child(2310+ .child(div().map(|d| d.child(dark_row_label(label.clone(), picked))))
2819- div()
2820- .when(dark, |d| d.child(dark_row_label(label.clone(), picked)))
2821- .when(!dark, |d| d.text_color(rgb(FG_SECONDARY())).child(label)),
2822- )
2823 .child(2311 .child(
2824 div()2312 div()
2825 .flex()2313 .flex()
2826 .items_center()2314 .items_center()
2827 .gap(px(4.))2315 .gap(px(4.))
2828- .when(dark, |d| d.child(dark_row_value(value.clone())))2316+ .map(|d| d.child(dark_row_value(value.clone())))
2829- .when(!dark, |d| d.child(value))
2830 .children([-1, 1].map(|steps: i32| {2317 .children([-1, 1].map(|steps: i32| {
2831 let id = ("mix-step", n * 2 + usize::from(steps > 0));2318 let id = ("mix-step", n * 2 + usize::from(steps > 0));
2832- match dark {2319+ dark_step_glyph(
2833- true => dark_step_glyph(2320+ id,
2834- id,2321+ steps > 0,
2835- steps > 0,2322+ cx.listener(move |this, _: &ClickEvent, _, cx| {
2836- cx.listener(move |this, _: &ClickEvent, _, cx| {2323+ this.mix_field = n;
2837- this.mix_field = n;2324+ this.nudge_mix(steps, cx);
2838- this.nudge_mix(steps, cx);2325+ }),
2839- }),2326+ )
2840- )2327+ .into_any_element()
2841- .into_any_element(),
2842- false => div()
2843- .id(id)
2844- .flex_none()
2845- .w(px(HIT_MIN))
2846- .h(px(KEYS_ROW_H))
2847- .flex()
2848- .items_center()
2849- .justify_center()
2850- .rounded(px(3.))
2851- .bg(rgb(BG_PANEL()))
2852- .cursor_pointer()
2853- .hover(|s| s.bg(rgb(BG_HOVER())))
2854- .on_click(cx.listener(
2855- move |this, _: &ClickEvent, _, cx| {
2856- // Picked as well as moved, the silence
2857- // card's rule: the row a press lands on
2858- // is the row the arrows carry on from.
2859- this.mix_field = n;
2860- this.nudge_mix(steps, cx);
2861- },
2862- ))
2863- .child(match steps > 0 {
2864- true => "+",
2865- false => "−",
2866- })
2867- .into_any_element(),
2868- }
2869 })),2328 })),
2870 )2329 )
2871 })2330 })
@@ -2914,9 +2373,9 @@ impl Player {
2914 .gap(px(6.))2373 .gap(px(6.))
2915 .p(px(12.))2374 .p(px(12.))
2916 .rounded(px(6.))2375 .rounded(px(6.))
2917- .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() }))2376+ .bg(rgb(DARK_PANEL()))
2918- .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM())))2377+ .map(|d| d.border_1().border_color(rgba(DARK_SEAM())))
2919- .when(dark, |d| {2378+ .map(|d| {
2920 d.child(dark_card_head(2379 d.child(dark_card_head(
2921 "Mix",2380 "Mix",
2922 None,2381 None,
@@ -2925,24 +2384,6 @@ impl Player {
2925 cx,2384 cx,
2926 ))2385 ))
2927 })2386 })
2928- .when(!dark, |d| {
2929- d.child(
2930- div()
2931- .flex_none()
2932- .px(px(6.))
2933- .child("Mix — track volumes and the master limiter"),
2934- )
2935- })
2936- .when(!dark, |d| {
2937- d.child(
2938- div()
2939- .flex_none()
2940- .px(px(6.))
2941- .text_size(px(11.))
2942- .text_color(rgb(FG_SECONDARY()))
2943- .child(help_text),
2944- )
2945- })
2946 .child(2387 .child(
2947 div()2388 div()
2948 .id("mix-rows")2389 .id("mix-rows")
@@ -2952,20 +2393,7 @@ impl Player {
2952 .overflow_y_scroll()2393 .overflow_y_scroll()
2953 .children(rows),2394 .children(rows),
2954 )2395 )
2955- .when(dark, |d| d.child(dark_help(tail_text.clone())))2396+ .map(|d| d.child(dark_help(tail_text.clone()))),
2956- .when(!dark, |d| {
2957- d.child(
2958- div()
2959- .flex_none()
2960- .px(px(6.))
2961- .text_size(px(11.))
2962- .text_color(rgb(FG_SECONDARY()))
2963- // What the choice *is*: the limiter's own line,
2964- // because "on" alone says nothing about what it
2965- // does to a mix that never reaches the ceiling.
2966- .child(tail_text),
2967- )
2968- }),
2969 ),2397 ),
2970 )2398 )
2971 }2399 }
@@ -2985,17 +2413,14 @@ impl Player {
2985 if !self.subtitle_style_open {2413 if !self.subtitle_style_open {
2986 return None;2414 return None;
2987 }2415 }
2988- let dark = self.darkroom;
2989 let help_text = "− and + move the size, or ↑↓ picks a row and ←→ moves it (held or pressed); a family row picks it outright — a click away or esc closes";2416 let help_text = "− and + move the size, or ↑↓ picks a row and ←→ moves it (held or pressed); a family row picks it outright — a click away or esc closes";
2990- let head = dark.then(|| {2417+ let head = Some(dark_card_head(
2991- dark_card_head(2418+ "Subtitle style",
2992- "Subtitle style",2419+ None,
2993- None,2420+ Some(help_text.into()),
2994- Some(help_text.into()),2421+ Some(self.card_maximized),
2995- Some(self.card_maximized),2422+ cx,
2996- cx,2423+ ));
2997- )
2998- });
2999 let size_picked = self.subtitle_style_field == 0;2424 let size_picked = self.subtitle_style_field == 0;
3000 let size_row = div()2425 let size_row = div()
3001 .id("subtitle-size-row")2426 .id("subtitle-size-row")
@@ -3006,63 +2431,25 @@ impl Player {
3006 .justify_between()2431 .justify_between()
3007 .px(px(6.))2432 .px(px(6.))
3008 .rounded(px(3.))2433 .rounded(px(3.))
3009- .when(dark && size_picked, |d| {2434+ .when(size_picked, |d| d.border_l_2().border_color(rgb(INK1())))
3010- d.border_l_2().border_color(rgb(INK1()))2435+ .child(div().map(|d| d.child(dark_row_label("Size", size_picked))))
3011- })
3012- .when(!dark, |d| {
3013- d.bg(rgb(match size_picked {
3014- true => BG_SELECTED(),
3015- false => BG_PANEL(),
3016- }))
3017- })
3018- .child(
3019- div()
3020- .when(dark, |d| d.child(dark_row_label("Size", size_picked)))
3021- .when(!dark, |d| d.text_color(rgb(FG_SECONDARY())).child("Size")),
3022- )
3023 .child(2436 .child(
3024 div()2437 div()
3025 .flex()2438 .flex()
3026 .items_center()2439 .items_center()
3027 .gap(px(4.))2440 .gap(px(4.))
3028- .when(dark, |d| {2441+ .map(|d| d.child(dark_row_value(format!("{:.0}px", self.sub_text))))
3029- d.child(dark_row_value(format!("{:.0}px", self.sub_text)))
3030- })
3031- .when(!dark, |d| d.child(format!("{:.0}px", self.sub_text)))
3032 .children([-1, 1].map(|steps: i32| {2442 .children([-1, 1].map(|steps: i32| {
3033 let id = ("subtitle-size-step", usize::from(steps > 0));2443 let id = ("subtitle-size-step", usize::from(steps > 0));
3034- match dark {2444+ dark_step_glyph(
3035- true => dark_step_glyph(2445+ id,
3036- id,2446+ steps > 0,
3037- steps > 0,2447+ cx.listener(move |this, _: &ClickEvent, _, cx| {
3038- cx.listener(move |this, _: &ClickEvent, _, cx| {2448+ this.subtitle_style_field = 0;
3039- this.subtitle_style_field = 0;2449+ this.nudge_sub_size(steps, cx);
3040- this.nudge_sub_size(steps, cx);2450+ }),
3041- }),2451+ )
3042- )2452+ .into_any_element()
3043- .into_any_element(),
3044- false => div()
3045- .id(id)
3046- .flex_none()
3047- .w(px(HIT_MIN))
3048- .h(px(KEYS_ROW_H))
3049- .flex()
3050- .items_center()
3051- .justify_center()
3052- .rounded(px(3.))
3053- .bg(rgb(BG_PANEL()))
3054- .cursor_pointer()
3055- .hover(|s| s.bg(rgb(BG_HOVER())))
3056- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
3057- this.subtitle_style_field = 0;
3058- this.nudge_sub_size(steps, cx);
3059- }))
3060- .child(match steps > 0 {
3061- true => "+",
3062- false => "−",
3063- })
3064- .into_any_element(),
3065- }
3066 })),2453 })),
3067 );2454 );
3068 let default_picked = self.subtitle_style_field == 1;2455 let default_picked = self.subtitle_style_field == 1;
@@ -3074,24 +2461,13 @@ impl Player {
3074 .items_center()2461 .items_center()
3075 .px(px(6.))2462 .px(px(6.))
3076 .rounded(px(3.))2463 .rounded(px(3.))
3077- .when(dark && default_picked, |d| {2464+ .when(default_picked, |d| d.border_l_2().border_color(rgb(INK1())))
3078- d.border_l_2().border_color(rgb(INK1()))
3079- })
3080- .when(!dark, |d| {
3081- d.bg(rgb(match default_picked {
3082- true => BG_SELECTED(),
3083- false => BG_PANEL(),
3084- }))
3085- })
3086 .cursor_pointer()2465 .cursor_pointer()
3087- .hover(|s| s.bg(rgb(if dark { DARK_RAISED() } else { BG_HOVER() })))2466+ .hover(|s| s.bg(rgb(DARK_RAISED())))
3088 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {2467 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
3089 this.set_sub_family(None, cx);2468 this.set_sub_family(None, cx);
3090 }))2469 }))
3091- .when(dark, |d| {2470+ .map(|d| d.child(dark_row_label("System default", default_picked)));
3092- d.child(dark_row_label("System default", default_picked))
3093- })
3094- .when(!dark, |d| d.child("System default"));
3095 let family_rows = self.subtitle_fonts.iter().enumerate().map(|(n, name)| {2471 let family_rows = self.subtitle_fonts.iter().enumerate().map(|(n, name)| {
3096 let picked = self.subtitle_style_field == n + 22472 let picked = self.subtitle_style_field == n + 2
3097 || self.sub_family.as_deref() == Some(name.as_str());2473 || self.sub_family.as_deref() == Some(name.as_str());
@@ -3103,23 +2479,16 @@ impl Player {
3103 .items_center()2479 .items_center()
3104 .px(px(6.))2480 .px(px(6.))
3105 .rounded(px(3.))2481 .rounded(px(3.))
3106- .when(dark && picked, |d| d.border_l_2().border_color(rgb(INK1())))2482+ .when(picked, |d| d.border_l_2().border_color(rgb(INK1())))
3107- .when(!dark, |d| {
3108- d.bg(rgb(match picked {
3109- true => BG_SELECTED(),
3110- false => BG_PANEL(),
3111- }))
3112- })
3113 .cursor_pointer()2483 .cursor_pointer()
3114- .hover(|s| s.bg(rgb(if dark { DARK_RAISED() } else { BG_HOVER() })))2484+ .hover(|s| s.bg(rgb(DARK_RAISED())))
3115 .on_click(cx.listener({2485 .on_click(cx.listener({
3116 let name = name.clone();2486 let name = name.clone();
3117 move |this, _: &ClickEvent, _, cx| {2487 move |this, _: &ClickEvent, _, cx| {
3118 this.set_sub_family(Some(name.clone()), cx);2488 this.set_sub_family(Some(name.clone()), cx);
3119 }2489 }
3120 }))2490 }))
3121- .when(dark, |d| d.child(dark_row_label(name.clone(), picked)))2491+ .map(|d| d.child(dark_row_label(name.clone(), picked)))
3122- .when(!dark, |d| d.child(name.clone()))
3123 });2492 });
3124 Some(2493 Some(
3125 scrim()2494 scrim()
@@ -3156,27 +2525,9 @@ impl Player {
3156 .gap(px(6.))2525 .gap(px(6.))
3157 .p(px(12.))2526 .p(px(12.))
3158 .rounded(px(6.))2527 .rounded(px(6.))
3159- .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() }))2528+ .bg(rgb(DARK_PANEL()))
3160- .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM())))2529+ .map(|d| d.border_1().border_color(rgba(DARK_SEAM())))
3161- .when(dark, move |d| d.child(head.unwrap()))2530+ .map(move |d| d.child(head.unwrap()))
3162- .when(!dark, |d| {
3163- d.child(
3164- div()
3165- .flex_none()
3166- .px(px(6.))
3167- .child("Subtitle style — font and size of the cue plate"),
3168- )
3169- })
3170- .when(!dark, |d| {
3171- d.child(
3172- div()
3173- .flex_none()
3174- .px(px(6.))
3175- .text_size(px(11.))
3176- .text_color(rgb(FG_SECONDARY()))
3177- .child(help_text),
3178- )
3179- })
3180 .child(size_row)2531 .child(size_row)
3181 .child(2532 .child(
3182 div()2533 div()
@@ -3205,18 +2556,15 @@ impl Player {
3205 cx: &mut Context<Self>,2556 cx: &mut Context<Self>,
3206 ) -> Option<impl IntoElement> {2557 ) -> Option<impl IntoElement> {
3207 let (lane, idx) = self.silence_open?;2558 let (lane, idx) = self.silence_open?;
3208- let dark = self.darkroom;
3209 let head_meta: SharedString = format!("{} clip {}", lane.label(), idx + 1).into();2559 let head_meta: SharedString = format!("{} clip {}", lane.label(), idx + 1).into();
3210 let help_text = "− and + move a setting, or ↑↓ picks one and ←→ moves it (hold to run it) — the marks on the lane are what would go; a click away or esc closes";2560 let help_text = "− and + move a setting, or ↑↓ picks one and ←→ moves it (hold to run it) — the marks on the lane are what would go; a click away or esc closes";
3211- let head = dark.then(|| {2561+ let head = Some(dark_card_head(
3212- dark_card_head(2562+ "Silences",
3213- "Silences",2563+ Some(head_meta.clone()),
3214- Some(head_meta.clone()),2564+ Some(help_text.into()),
3215- Some(help_text.into()),2565+ Some(self.card_maximized),
3216- Some(self.card_maximized),2566+ cx,
3217- cx,2567+ ));
3218- )
3219- });
3220 let cfg = self.silence;2568 let cfg = self.silence;
3221 // The unit is a label, never a conversion: the threshold is a level2569 // The unit is a label, never a conversion: the threshold is a level
3222 // below full scale whichever of the two the row says (`silence_dbfs`).2570 // below full scale whichever of the two the row says (`silence_dbfs`).
@@ -3280,24 +2628,14 @@ impl Player {
3280 .justify_between()2628 .justify_between()
3281 .px(px(6.))2629 .px(px(6.))
3282 .rounded(px(3.))2630 .rounded(px(3.))
3283- .when(dark && picked, |d| d.border_l_2().border_color(rgb(INK1())))2631+ .when(picked, |d| d.border_l_2().border_color(rgb(INK1())))
3284- .when(!dark, |d| {
3285- d.bg(rgb(match picked {
3286- true => BG_SELECTED(),
3287- false => BG_PANEL(),
3288- }))
3289- })
3290 .cursor_pointer()2632 .cursor_pointer()
3291- .hover(|s| s.bg(rgb(if dark { DARK_RAISED() } else { BG_HOVER() })))2633+ .hover(|s| s.bg(rgb(DARK_RAISED())))
3292 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {2634 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
3293 this.silence_field = n;2635 this.silence_field = n;
3294 cx.notify();2636 cx.notify();
3295 }))2637 }))
3296- .child(2638+ .child(div().map(|d| d.child(dark_row_label(label, picked))))
3297- div()
3298- .when(dark, |d| d.child(dark_row_label(label, picked)))
3299- .when(!dark, |d| d.text_color(rgb(FG_SECONDARY())).child(label)),
3300- )
3301 // The value and the two steps that move it. Every other2639 // The value and the two steps that move it. Every other
3302 // card has something to drag or press; this one had the2640 // card has something to drag or press; this one had the
3303 // arrow keys and nothing else, so a row was a setting a2641 // arrow keys and nothing else, so a row was a setting a
@@ -3309,49 +2647,19 @@ impl Player {
3309 .flex()2647 .flex()
3310 .items_center()2648 .items_center()
3311 .gap(px(4.))2649 .gap(px(4.))
3312- .when(dark, |d| d.child(dark_row_value(value.clone())))2650+ .map(|d| d.child(dark_row_value(value.clone())))
3313- .when(!dark, |d| d.child(value))
3314 .children([-1, 1].map(|steps: i32| {2651 .children([-1, 1].map(|steps: i32| {
3315 let id = ("silence-step", n * 2 + usize::from(steps > 0));2652 let id = ("silence-step", n * 2 + usize::from(steps > 0));
3316- match dark {2653+ dark_step_glyph(
3317- true => dark_step_glyph(2654+ id,
3318- id,2655+ steps > 0,
3319- steps > 0,2656+ cx.listener(move |this, _: &ClickEvent, _, cx| {
3320- cx.listener(move |this, _: &ClickEvent, _, cx| {2657+ this.silence_field = n;
3321- this.silence_field = n;2658+ this.nudge_silence(steps);
3322- this.nudge_silence(steps);2659+ cx.notify();
3323- cx.notify();2660+ }),
3324- }),2661+ )
3325- )2662+ .into_any_element()
3326- .into_any_element(),
3327- false => div()
3328- .id(id)
3329- .flex_none()
3330- .w(px(HIT_MIN))
3331- .h(px(KEYS_ROW_H))
3332- .flex()
3333- .items_center()
3334- .justify_center()
3335- .rounded(px(3.))
3336- .bg(rgb(BG_PANEL()))
3337- .cursor_pointer()
3338- .hover(|s| s.bg(rgb(BG_HOVER())))
3339- .on_click(cx.listener(
3340- move |this, _: &ClickEvent, _, cx| {
3341- // Picked as well as moved: the row a
3342- // press lands on is the row the arrows
3343- // carry on from.
3344- this.silence_field = n;
3345- this.nudge_silence(steps);
3346- cx.notify();
3347- },
3348- ))
3349- .child(match steps > 0 {
3350- true => "+",
3351- false => "−",
3352- })
3353- .into_any_element(),
3354- }
3355 })),2663 })),
3356 )2664 )
3357 })2665 })
@@ -3360,33 +2668,14 @@ impl Player {
3360 // one of them behind the other, and there are only two.2668 // one of them behind the other, and there are only two.
3361 let button = |n: usize, text: String, act: fn(&mut Self, &mut Context<Self>)| {2669 let button = |n: usize, text: String, act: fn(&mut Self, &mut Context<Self>)| {
3362 let enabled = found != 0;2670 let enabled = found != 0;
3363- match dark {2671+ dark_ghost_button(
3364- true => dark_ghost_button(2672+ ("silence-apply", n),
3365- ("silence-apply", n),2673+ text,
3366- text,2674+ "",
3367- "",2675+ enabled,
3368- enabled,2676+ cx.listener(move |this, _: &ClickEvent, _, cx| act(this, cx)),
3369- cx.listener(move |this, _: &ClickEvent, _, cx| act(this, cx)),2677+ )
3370- )2678+ .into_any_element()
3371- .into_any_element(),
3372- false => div()
3373- .id(("silence-apply", n))
3374- .flex_1()
3375- .flex()
3376- .min_h(px(KEYS_ROW_H))
3377- .items_center()
3378- .justify_center()
3379- .rounded(px(3.))
3380- .bg(rgb(match found {
3381- 0 => BG_PANEL(),
3382- _ => BG_SELECTED(),
3383- }))
3384- .cursor_pointer()
3385- .hover(|s| s.bg(rgb(BG_HOVER())))
3386- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| act(this, cx)))
3387- .child(text)
3388- .into_any_element(),
3389- }
3390 };2679 };
3391 Some(2680 Some(
3392 scrim()2681 scrim()
@@ -3427,40 +2716,11 @@ impl Player {
3427 .gap(px(6.))2716 .gap(px(6.))
3428 .p(px(12.))2717 .p(px(12.))
3429 .rounded(px(6.))2718 .rounded(px(6.))
3430- .bg(rgb(if dark { DARK_PANEL() } else { BG_RAISED() }))2719+ .bg(rgb(DARK_PANEL()))
3431- .when(dark, |d| d.border_1().border_color(rgba(DARK_SEAM())))2720+ .map(|d| d.border_1().border_color(rgba(DARK_SEAM())))
3432- .when(dark, move |d| d.child(head.unwrap()))2721+ .map(move |d| d.child(head.unwrap()))
3433- .when(!dark, |d| {
3434- d.child(div().flex_none().px(px(6.)).child(format!(
3435- "Silences — {} clip {}",
3436- lane.label(),
3437- idx + 1
3438- )))
3439- })
3440- .when(!dark, |d| {
3441- d.child(
3442- div()
3443- .flex_none()
3444- .px(px(6.))
3445- .text_size(px(11.))
3446- .text_color(rgb(FG_SECONDARY()))
3447- .child(help_text),
3448- )
3449- })
3450 .children(rows)2722 .children(rows)
3451- .when(dark, |d| d.child(dark_help(status.clone())))2723+ .map(|d| d.child(dark_help(status.clone())))
3452- .when(!dark, |d| {
3453- d.child(
3454- div()
3455- .flex_none()
3456- .px(px(6.))
3457- .text_color(rgb(match (&self.silence_scan, found) {
3458- (None, 1..) => ACCENT_PRIMARY(),
3459- _ => FG_SECONDARY(),
3460- }))
3461- .child(status),
3462- )
3463- })
3464 .child(div().flex().gap(px(4.)).children([2724 .child(div().flex().gap(px(4.)).children([
crates/app/src/ui/dock_stance.rsmodified+29 -9
@@ -1077,20 +1077,40 @@ fn sources_tab(
1077 })1077 })
1078 }1078 }
1079 1079
1080-/// The transition duration row, in the darkroom's own idiom: the darkroom is1080+/// The transition a clip carries into its immediate successor, if any -- a
1081-/// the default surface (`main.rs`'s `OLD_GUI` gate), so a row that only ever1081+/// dissolve on a video lane ([`Clip::transition_out`]) or a crossfade on an
1082-/// drew in the legacy inspector (`ui::inspector::transition_duration_row`)1082+/// audio lane, told apart from a plain one-sided fade drag by
1083-/// was a control a shipped user could never reach after a dissolve1083+/// [`Project::crossfade`]'s own signature: both ends of the join set
1084-/// (ctrl+x) or crossfade (ctrl+f). Same facts as that row --1084+/// together, not just this clip's tail. `cap` is what the pair actually
1085-/// [`ui::inspector::transition_of`] picks the anchor's transition and its cap,1085+/// offers -- the shorter of the two clips' own lengths -- the same ceiling
1086-/// [`Player::nudge_transition`] does the clamped step -- only the paint is1086+/// [`Project::set_transition_out`]/[`Project::crossfade`] clamp to, so the
1087-/// this tab's own (`ghost_verb`'s row height and ink tokens, not legacy grey).1087+/// row this feeds never claims more room than a step could land in.
1088+pub(crate) fn transition_of(
1089+ lane_kind: LaneKind,
1090+ clip: &Clip,
1091+ next: Option<&Clip>,
1092+) -> Option<(&'static str, u32, u32)> {
1093+ let next = next.filter(|n| n.start == clip.end())?;
1094+ let cap = clip.frames().min(next.frames());
1095+ match lane_kind {
1096+ LaneKind::Video if clip.transition_out > 0 => Some(("Dissolve", clip.transition_out, cap)),
1097+ LaneKind::Audio if clip.fade_out > 0 && next.fade_in > 0 => {
1098+ Some(("Crossfade", clip.fade_out, cap))
1099+ }
1100+ _ => None,
1101+ }
1102+}
1103+
1104+/// The transition duration row: `transition_of` picks the anchor's
1105+/// transition and its cap, [`Player::nudge_transition`] does the clamped
1106+/// step -- only the paint is this tab's own (`ghost_verb`'s row height and
1107+/// ink tokens).
1088 fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl IntoElement> {1108 fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl IntoElement> {
1089 let (lane, idx) = player.selected.anchor()?;1109 let (lane, idx) = player.selected.anchor()?;
1090 let session = player.session.as_ref()?;1110 let session = player.session.as_ref()?;
1091 let clips = session.lane_clips(lane);1111 let clips = session.lane_clips(lane);
1092 let (label_text, frames, cap) =1112 let (label_text, frames, cap) =
1093- crate::ui::inspector::transition_of(lane.kind, clips.get(idx)?, clips.get(idx + 1))?;1113+ transition_of(lane.kind, clips.get(idx)?, clips.get(idx + 1))?;
1094 let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);1114 let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
1095 let step = |id: &'static str, label: &'static str, glyph: &'static str, by: i32, cx: &mut Context<Player>| {1115 let step = |id: &'static str, label: &'static str, glyph: &'static str, by: i32, cx: &mut Context<Player>| {
1096 div()1116 div()
crates/app/src/ui/inspector.rsdeleted+0 -536
@@ -1,536 +0,0 @@
1-//! The right-hand region: what is selected, and what can be done to it.
2-//!
3-//! Every consumer editor has this column, and edith's settings used to be
4-//! floating cards *over the timeline* instead -- so adjusting a clip hid the
5-//! very clip being adjusted. The cards are docked in here now: the equalizer,
6-//! the grade, the speed, the silence scan and the mix are children of this
7-//! panel, and opening one occludes zero timeline pixels
8-//! (`an_inspector_section_occludes_no_timeline`).
9-
10-use crate::ui::toolbar::{TONE_SLOT_W, ZOOM_SLOT_W};
11-use crate::*;
12-
13-impl Player {
14- /// The inspector column. Two sections that are always there -- the
15- /// selection's and the project's -- and, over them, whichever settings card
16- /// is open, which is a section of this panel rather than a sheet over the
17- /// window.
18- pub(crate) fn inspector(
19- &self,
20- viewport: Size<Pixels>,
21- cx: &mut Context<Self>,
22- ) -> impl IntoElement {
23- let width = self.split_px(Split::Inspector, viewport);
24- // The cards measure themselves against the room they are given, and the
25- // room they are given is this column -- not the window.
26- let room = size(px(width), viewport.height);
27- // The same affordance the lanes carry, on the column that needs it for
28- // the same reason: at the 640x360 floor the project section is below the
29- // fold, and a section nobody knows is there is a section that is not
30- // there. Rows here are not a fixed height, so the column is asked how
31- // far it can still be taken rather than counted -- and it answers with
32- // the previous frame's layout, which is what makes the line live.
33- let can_scroll = f32::from(self.inspector_scroll.max_offset().height) > 1.;
34- let below = px_below(
35- f32::from(self.inspector_scroll.max_offset().height),
36- f32::from(self.inspector_scroll.offset().y),
37- );
38- div()
39- .id("inspector")
40- .flex_none()
41- .w(px(width))
42- .h_full()
43- // The bed the docked cards are placed against: `scrim()` is
44- // `absolute().inset_0()`, so it covers this panel and nothing else.
45- .relative()
46- .flex()
47- .flex_col()
48- .bg(rgb(BG_PANEL()))
49- .border_l_1()
50- .border_color(rgb(STROKE_DIVIDER()))
51- .child(section_head("Inspector"))
52- .child(
53- div()
54- .id("inspector-rows")
55- .flex_1()
56- .min_h(px(0.))
57- .overflow_y_scroll()
58- .track_scroll(&self.inspector_scroll)
59- .flex()
60- .flex_col()
61- .gap(px(8.))
62- .p(px(8.))
63- .child(self.selection_section(cx))
64- .child(self.project_section(cx)),
65- )
66- .when(can_scroll, |d| {
67- d.child(
68- div()
69- .flex_none()
70- .h(px(LABEL_H))
71- .flex()
72- .items_center()
73- .justify_end()
74- .px(px(8.))
75- .text_size(px(10.))
76- .text_color(rgb(match below > 1. {
77- true => ACCENT_PRIMARY(),
78- false => FG_SECONDARY(),
79- }))
80- .child(match below > 1. {
81- true => "more below — scroll the inspector",
82- false => "the end — scroll up for the rest",
83- }),
84- )
85- })
86- .children(self.eq_card(room, cx))
87- .children(self.color_card(room, cx))
88- .children(self.transform_card(room, cx))
89- .children(self.speed_card(room, cx))
90- .children(self.silence_card(room, cx))
91- .children(self.mix_card(room, cx))
92- .children(self.subtitle_style_card(room, cx))
93- }
94-
95- /// What is marked, and the settings that belong to *it*. A dump of every
96- /// property regardless of what is selected is the anti-pattern this avoids:
97- /// with nothing marked the section says how to get one, and each button is
98- /// dimmed with the oracle's reason rather than missing.
99- fn selection_section(&self, cx: &mut Context<Self>) -> impl IntoElement {
100- let picked = self.selected.anchor().and_then(|(lane, idx)| {
101- let session = self.session.as_ref()?;
102- let clip = session.lane_clips(lane).get(idx).copied()?;
103- let source = session.sources().get(clip.source);
104- let image = source.is_some_and(|s| engine::is_image(&s.path));
105- Some((
106- lane,
107- clip,
108- source.map_or_else(|| lane.label().to_string(), |s| file_name(&s.path)),
109- image,
110- ))
111- });
112- // A subtitle lane holds no `Clip`, so the read above answers `None` on a
113- // marked caption -- while the bed draws that caption in the selection's
114- // own colours and this panel's Delete lifts it. The panel says what is
115- // marked or it is telling the user the opposite of what they can see.
116- let caption = self
117- .selected
118- .anchor()
119- .filter(|_| picked.is_none())
120- .and_then(|(lane, idx)| {
121- let sub = self.session.as_ref()?.sub_lane(lane).get(idx).copied()?;
122- Some((lane, sub))
123- });
124- // The transition the anchor's clip carries into its successor, if
125- // any -- a dissolve on a video lane ([`Clip::transition_out`]) or a
126- // crossfade on an audio lane, told apart from a plain one-sided fade
127- // by [`Project::crossfade`]'s own signature: both ends of the join
128- // set together. `cap` is what the pair actually offers, the same
129- // ceiling the engine's own setters clamp to, so the row never claims
130- // more room than a step could land in.
131- let transition = self.selected.anchor().and_then(|(lane, idx)| {
132- let session = self.session.as_ref()?;
133- let clips = session.lane_clips(lane);
134- let (label, frames, cap) = transition_of(lane.kind, clips.get(idx)?, clips.get(idx + 1))?;
135- Some((lane, idx, label, frames, cap))
136- });
137- // A multi-selection is named for its anchor and counted: what the
138- // panel shows is the anchor's settings, and the count says there is
139- // more in hand than the panel is showing.
140- let more = self.selected.len().saturating_sub(1);
141- let head = match (&picked, &caption) {
142- (Some((lane, _, name, _)), _) => format!("{} · {}", lane.label(), name),
143- (None, Some((lane, _))) => format!("{} · caption", lane.label()),
144- (None, None) => "Nothing selected".to_string(),
145- };
146- let head = match more {
147- 0 => head,
148- n => format!("{head} · and {n} more picked"),
149- };
150- let detail = match &picked {
151- Some((_, clip, _, _)) => format!(
152- "{} → {} · {} · {}",
153- timecode(f64::from(clip.start) / self.fps, self.fps),
154- timecode(f64::from(clip.start + clip.frames()) / self.fps, self.fps),
155- span_label(f64::from(clip.frames()) / self.fps),
156- clip.speed,
157- ),
158- // The words' own span, in the same shape a clip's is written in --
159- // and no speed, because a caption has none to change.
160- None => match &caption {
161- Some((_, sub)) => format!(
162- "{} → {} · {} · words",
163- timecode(f64::from(sub.start) / self.fps, self.fps),
164- timecode(f64::from(sub.end()) / self.fps, self.fps),
165- span_label(f64::from(sub.frames) / self.fps),
166- ),
167- None => "Click a clip on the timeline to see its settings".to_string(),
168- },
169- };
170- div()
171- .flex()
172- .flex_col()
173- .gap(px(6.))
174- .p(px(8.))
175- .rounded(px(4.))
176- .bg(rgb(BG_HOVER_DIM()))
177- .child(
178- div()
179- .flex_none()
180- .truncate()
181- .text_color(rgb(match picked.is_some() || caption.is_some() {
182- true => FG_PRIMARY(),
183- false => FG_SECONDARY(),
184- }))
185- // The kind's own colour, the same one its clip wears on the
186- // timeline: the panel and the box are about the same thing.
187- .when_some(picked.as_ref(), |d, (lane, _, _, image)| {
188- d.border_l_2()
189- .border_color(rgb(clip_kind(lane.kind, *image)))
190- .pl(px(6.))
191- })
192- .when_some(caption.as_ref(), |d, (lane, _)| {
193- d.border_l_2()
194- .border_color(rgb(clip_kind(lane.kind, false)))
195- .pl(px(6.))
196- })
197- .child(head),
198- )
199- .child(
200- div()
201- .flex_none()
202- .text_size(px(11.))
203- .text_color(rgb(FG_SECONDARY()))
204- .child(detail),
205- )
206- // The duration field: a value and its own two steppers, the
207- // shape `mbps_steppers` already draws for the export card's
208- // bitrate -- present only while the anchor carries a transition,
209- // since a row for a number that means nothing is a row lying
210- // about what is selected.
211- .when_some(transition, |d, (lane, idx, label, frames, cap)| {
212- d.child(self.transition_duration_row(lane, idx, label, frames, cap, cx))
213- })
214- .child(
215- div()
216- .flex()
217- .flex_wrap()
218- .gap(px(6.))
219- .child(self.action_control(
220- "inspect-speed",
221- 0.,
222- BG_RAISED(),
223- None,
224- "Speed",
225- "how fast this clip and its group play",
226- ActionId::Speed,
227- cx.listener(|this, _: &ClickEvent, _, cx| this.open_speed(cx)),
228- ))
229- .child(self.action_control(
230- "inspect-color",
231- 0.,
232- BG_RAISED(),
233- None,
234- "Colour",
235- "exposure, contrast, saturation and temperature",
236- ActionId::Color,
237- cx.listener(|this, _: &ClickEvent, _, cx| this.open_color(cx)),
238- ))
239- .child(self.action_control(
240- "inspect-transform",
241- 0.,
242- BG_RAISED(),
243- None,
244- "Transform",
245- "position, scale, rotation and crop for this clip",
246- ActionId::Transform,
247- cx.listener(|this, _: &ClickEvent, _, cx| this.open_transform(cx)),
248- ))
249- .child(self.action_control(
250- "inspect-eq",
251- 0.,
252- BG_RAISED(),
253- None,
254- "Equalizer",
255- "the bands this clip's sound is filtered through",
256- ActionId::Equalizer,
257- cx.listener(|this, _: &ClickEvent, _, cx| this.open_eq(cx)),
258- ))
259- .child(self.action_control(
260- "inspect-silence",
261- 0.,
262- BG_RAISED(),
263- None,
264- "Silence",
265- "finds the quiet stretches and cuts or speeds them",
266- ActionId::Silence,
267- cx.listener(|this, _: &ClickEvent, _, cx| this.open_silence(cx)),
268- ))
269- .child(self.action_control(
270- "inspect-fit",
271- 0.,
272- BG_RAISED(),
273- None,
274- "Fit",
275- "how this picture is placed on the project canvas",
276- ActionId::Fit,
277- cx.listener(|this, _: &ClickEvent, _, cx| this.cycle_fit(cx)),
278- ))
279- .child(self.action_control(
280- "inspect-delete",
281- 0.,
282- BG_RAISED(),
283- None,
284- "Delete",
285- "takes this clip off the timeline",
286- ActionId::Delete,
287- cx.listener(|this, _: &ClickEvent, _, cx| this.delete_selected(cx)),
288- )),
289- )
290- }
291-
292- /// The duration row a transition-carrying anchor grows under
293- /// `selection_section`'s detail line: `frames` as the engine counts it,
294- /// flanked by the −/+ steppers [`Player::mbps_steppers`] already draws
295- /// for the export card's bitrate row -- a field, not the drag handle
296- /// `659770a` deliberately shrank the join's hit target away from. Each
297- /// press nudges by one frame ([`Player::nudge_transition`]); the engine's
298- /// own setters clamp to `cap`, so a run of presses past what the
299- /// successor offers stops there rather than erroring.
300- fn transition_duration_row(
301- &self,
302- lane: Lane,
303- idx: usize,
304- label: &'static str,
305- frames: u32,
306- cap: u32,
307- cx: &mut Context<Self>,
308- ) -> impl IntoElement {
309- let step = |id: &'static str, glyph: &'static str, by: i32, cx: &mut Context<Self>| {
310- div()
311- .id(id)
312- .flex()
313- .w(px(HIT_MIN))
314- .h(px(HIT_MIN))
315- .items_center()
316- .justify_center()
317- .rounded(px(3.))
318- .bg(rgb(BG_RAISED()))
319- .cursor_pointer()
320- .hover(|s| s.bg(rgb(BG_HOVER())))
321- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
322- this.nudge_transition(lane, idx, by, cx);
323- }))
324- .child(glyph)
325- };
326- div()
327- .flex_none()
328- .flex()
329- .items_center()
330- .gap(px(6.))
331- .child(
332- div()
333- .flex_1()
334- .text_size(px(11.))
335- .text_color(rgb(FG_SECONDARY()))
336- .child(format!("{label} {frames}f (of {cap}f offered)")),
337- )
338- .child(step("transition-down", "−", -1, cx))
339- .child(step("transition-up", "+", 1, cx))
340- }
341-
342- /// The settings that are the *project's* rather than any clip's: the canvas
343- /// every clip is composed onto, the rate it is cut at, the HDR rendition it
344- /// is watched in, and the mix everything sums into. They used to be four
345- /// more buttons in a toolbar row that already did not fit the floor.
346- fn project_section(&self, cx: &mut Context<Self>) -> impl IntoElement {
347- let resolution = self.session.as_ref().map(PlaybackSession::resolution);
348- div()
349- .flex()
350- .flex_col()
351- .gap(px(6.))
352- .p(px(8.))
353- .rounded(px(4.))
354- .bg(rgb(BG_HOVER_DIM()))
355- .child(
356- div()
357- .flex_none()
358- .text_size(px(11.))
359- .text_color(rgb(FG_SECONDARY()))
360- .child("PROJECT"),
361- )
362- .child(
363- div()
364- .flex()
365- .flex_wrap()
366- .gap(px(6.))
367- .child(self.action_control(
368- "resolution",
369- ZOOM_SLOT_W,
370- BG_RAISED(),
371- None,
372- match resolution.or(self.pending_settings.0) {
373- Some((_, h)) => format!("{h}p"),
374- None => "Size".to_string(),
375- },
376- "the canvas every clip is composed onto, and the size the export comes out at",
377- ActionId::Resolution,
378- cx.listener(|this, event: &ClickEvent, _, cx| {
379- this.open_picker(Pick::Resolution, event.position(), cx)
380- }),
381- ))
382- .child(self.action_control(
383- "fps",
384- ZOOM_SLOT_W,
385- BG_RAISED(),
386- None,
387- match (self.session.is_some(), self.pending_settings.1) {
388- (true, _) => format!("{} fps", fps_label(self.fps)),
389- (false, Some(fps)) => format!("{} fps", fps_label(fps)),
390- (false, None) => "Rate".to_string(),
391- },
392- "the rate the whole timeline is cut and written at",
393- ActionId::Resolution,
394- cx.listener(|this, event: &ClickEvent, _, cx| {
395- this.open_picker(Pick::Fps, event.position(), cx)
396- }),
397- ))
398- .child(self.action_control(
399- "sample-rate",
400- ZOOM_SLOT_W,
401- BG_RAISED(),
402- None,
403- match self.session.as_ref().map_or(self.pending_settings.2, |s| s.sample_rate()) {
404- Some(rate) => format!("{rate} Hz"),
405- None => "Source".to_string(),
406- },
407- "the rate the project's own sound mix is run at; source derives it from \
408- the first audio source",
409- ActionId::Resolution,
410- cx.listener(|this, event: &ClickEvent, _, cx| {
411- this.open_picker(Pick::SampleRate, event.position(), cx)
412- }),
413- ))
414- .child(self.action_control(
415- "tonemap",
416- TONE_SLOT_W,
417- BG_RAISED(),
418- None,
419- match &self.session {
420- Some(session) => format!("HDR {}", tone_label(session.tone())),
421- None => "HDR".to_string(),
422- },
423- "which rendition HDR media is watched in; SDR media is untouched",
424- ActionId::Resolution,
425- cx.listener(|this, event: &ClickEvent, _, cx| {
426- this.open_picker(Pick::Tone, event.position(), cx)
427- }),
428- ))
429- // Its own rect and a label that *is* the state, the rule
430- // the snap toggle writes down: a button that resized itself
431- // on every press made the row shuffle under the pointer.
432- .child(self.action_control(
433- "proxies",
434- TONE_SLOT_W,
435- BG_RAISED(),
436- None,
437- // The window's own switch and not the session's: it is
438- // answerable with nothing open, so a label that read
439- // "Proxies" there would be a control whose state was a
440- // secret until a file arrived.
441- match self.proxies_on {
442- true => format!("Proxies on{}", self.proxy_tail()),
443- false => format!("Proxies off{}", self.proxy_tail()),
444- },
445- "cuts on small stand-ins of the big films; the sound and every export \
446- stay the film's own",
447- ActionId::ToggleProxies,
448- cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_proxies(cx)),
449- ))
450- // Beside it, because the two are one subject: that one is
451- // what the picture is decoded from, this one is whether the
452- // stand-in is ever made. Two states and no cycle, the rule
453- // the switch beside it keeps.
454- .child(self.action_control(
455- "auto-proxies",
456- TONE_SLOT_W,
457- BG_RAISED(),
458- None,
459- match self.auto_proxies_on {
460- true => "Auto proxies on",
461- false => "Auto proxies off",
462- },
463- "makes a stand-in for every big film as it is imported; with it off, \
464- turning Proxies on is what asks for them",
465- ActionId::ToggleAutoProxies,
466- cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_auto_proxies(cx)),
467- ))
468- .child(self.action_control(
469- "inspect-mix",
470- 0.,
471- BG_RAISED(),
472- None,
473- "Mix",
474- "a fader per track and the limiter over the sum of them",
475- ActionId::Mix,
476- cx.listener(|this, _: &ClickEvent, _, cx| this.open_mix(None, cx)),
477- ))
478- .child(self.action_control(
479- "inspect-subtitle-style",
480- 0.,
481- BG_RAISED(),
482- None,
483- "Font",
484- "the cue plate's own font and size",
485- ActionId::SubtitleStyle,
486- cx.listener(|this, _: &ClickEvent, _, cx| this.open_subtitle_style(cx)),
487- )),
488- )
489- }
490-}
491-
492-/// The transition a clip carries into its immediate successor, if any -- a
493-/// dissolve on a video lane ([`Clip::transition_out`]) or a crossfade on an
494-/// audio lane, told apart from a plain one-sided fade drag by
495-/// [`Project::crossfade`]'s own signature: both ends of the join set
496-/// together, not just this clip's tail. `cap` is what the pair actually
497-/// offers -- the shorter of the two clips' own lengths -- the same ceiling
498-/// [`Project::set_transition_out`]/[`Project::crossfade`] clamp to, so the
499-/// row this feeds never claims more room than a step could land in.
500-///
501-/// Free of `Context` and of [`PlaybackSession`] alike, so it is testable
502-/// without either -- this test binary has neither a `TestAppContext` nor
503-/// real media to open one with (`split_drag_owes_save`'s own reason for
504-/// being pulled out the same way).
505-pub(crate) fn transition_of(
506- lane_kind: LaneKind,
507- clip: &Clip,
508- next: Option<&Clip>,
509-) -> Option<(&'static str, u32, u32)> {
510- let next = next.filter(|n| n.start == clip.end())?;
511- let cap = clip.frames().min(next.frames());
512- match lane_kind {
513- LaneKind::Video if clip.transition_out > 0 => Some(("Dissolve", clip.transition_out, cap)),
514- LaneKind::Audio if clip.fade_out > 0 && next.fade_in > 0 => {
515- Some(("Crossfade", clip.fade_out, cap))
516- }
517- _ => None,
518- }
519-}
520-
521-/// A region's own title bar: the same 24 px strip in the library and the
522-/// inspector, so the two columns read as the pair they are.
523-pub(crate) fn section_head(title: &'static str) -> impl IntoElement {
524- div()
525- .flex_none()
526- .h(px(24.))
527- .flex()
528- .items_center()
529- .px(px(8.))
530- .bg(rgb(BG_PANEL()))
531- .border_b_1()
532- .border_color(rgb(STROKE_DIVIDER()))
533- .text_size(px(11.))
534- .text_color(rgb(FG_SECONDARY()))
535- .child(title)
536-}
crates/app/src/ui/library.rsmodified+6 -544
@@ -6,538 +6,6 @@ use crate::ui::widgets::*;
6 use crate::*;6 use crate::*;
7 7
8 impl Player {8 impl Player {
9- /// The media library: a row per source the timeline knows, in the order
10- /// they arrived, each wearing the tint its clips wear in the lanes -- the
11- /// swatch *is* what says which boxes down there came from this file. A
12- /// click picks a row, the button under the list drops that source in at the
13- /// playhead, and a row dragged onto either lane does the same thing through
14- /// the same call.
15- ///
16- /// Import lives here, because this is the list it adds to. Plain divs like
17- /// the rest of this window: nothing in it takes focus, so the root keeps
18- /// the keyboard and the play key still works after a row is clicked
19- /// (ledger:182).
20- pub(crate) fn library(&self, width: f32, cx: &mut Context<Self>) -> impl IntoElement {
21- let exporting = self.exporting().is_some();
22- let sources = self
23- .session
24- .as_ref()
25- .map_or(&[][..], PlaybackSession::sources);
26- // Every source matches the first in size and rate or it was refused at
27- // the door (the import policy, ledger:436), so the session's own meta
28- // describes every row and nothing has to be probed to say so.
29- let meta = self.session.as_ref().map(PlaybackSession::meta);
30- // Its own length, not one derived from what is on the lanes: a row
31- // imported and never placed is a row with a length, and it is the
32- // length a drag would put down.
33- let rows: Vec<_> = library_rows(
34- sources,
35- &self.streams,
36- &self.decoders,
37- self.timeline_audio(),
38- |path| {
39- self.session
40- .as_ref()
41- .map_or(0, |session| session.file_frames(path))
42- },
43- )
44- .into_iter()
45- // The tab is the one filter: `enumerate` stays *before* it, so a row's
46- // index is still its index in the whole library and the tints, the
47- // menus and the drags all keep naming the same file whichever tab is
48- // open.
49- .enumerate()
50- .filter(|(_, row)| self.library_tab.holds(&row.path))
51- .map(|(i, row)| {
52- let picked = self
53- .selected_asset
54- .as_ref()
55- .is_some_and(|p| *p == (row.path.clone(), row.stream));
56- let name: SharedString = row.name.clone().into();
57- let says: String = match (&row.unusable, meta) {
58- // A greyed row says why in full, where its length would be:
59- // the list is the one place the file's own tracks are named.
60- (Some(why), _) => format!("{} — {why}", row.path.display()),
61- // A file with no picture has no size and no frame rate to
62- // report, and only one lane it can go on: saying so is the
63- // difference between a hint and a lie.
64- (None, _) if engine::is_audio(&row.path) => format!(
65- "{} — audio only · drag onto the audio lane, or Add at playhead",
66- row.path.display()
67- ),
68- // A still is the mirror: its own size (the timeline's meta
69- // describes video, and a picture placed on that canvas is not
70- // the same shape), no frame rate, and one kind of lane.
71- (None, _) if engine::is_image(&row.path) => format!(
72- "{} — still image{} · drag onto a video lane, or Add at playhead",
73- row.path.display(),
74- match self.sizes.get(&row.path).copied().flatten() {
75- Some((w, h)) => format!(" · {w}x{h}"),
76- None => String::new(),
77- }
78- ),
79- // The file's *own* frame rate, not the timeline's: a clip shot
80- // at another rate plays at the speed it was shot at, and the
81- // row that says where it came from has to say which rate that
82- // was.
83- (None, Some(meta)) => format!(
84- "{} — {}x{} @ {:.2} fps · drag it where you want it, or Add at playhead",
85- row.path.display(),
86- meta.width,
87- meta.height,
88- self.session
89- .as_ref()
90- .map_or(meta.frame_rate, |session| session.file_fps(&row.path))
91- ),
92- (None, None) => row.path.display().to_string(),
93- };
94- // The menu is the third way into a row, after the click and the
95- // drag, and a right-click nothing advertises is one nobody finds.
96- let tip: SharedString = format!("{says} · right-click for more").into();
97- let ghost = name.clone();
98- // What the second line says: the stream, then either its length or
99- // the reason it cannot be used.
100- let under = match &row.unusable {
101- Some(why) => join_detail(&row.detail, why),
102- // A still has no length to report -- the ten minutes it is
103- // *held* to is a wall, not a duration -- so the line says what
104- // it is and how big it is instead.
105- None if engine::is_image(&row.path) => join_detail(
106- &row.detail,
107- &match self.sizes.get(&row.path).copied().flatten() {
108- Some((w, h)) => format!("still image · {w}x{h}"),
109- None => "still image".to_string(),
110- },
111- ),
112- None => join_detail(
113- &row.detail,
114- &timecode(f64::from(row.frames) / self.fps, self.fps),
115- ),
116- };
117- // ...and what this file's stand-in is up to, after its length: a
118- // percentage while one is being made, the word while there is one,
119- // and nothing at all for a film that wants none ([`Proxy::detail`]).
120- let under = join_detail(
121- &under,
122- &self
123- .proxies
124- .get(&row.path)
125- .map_or_else(String::new, Proxy::detail),
126- );
127- // A stand-in being made is minutes of this machine, and the row
128- // that says how far it has got is where the way out of it belongs.
129- // Gone the moment the worker settles, like the percentage beside
130- // it: there is nothing left to stop.
131- // The switch, and what it is showing. One control for the whole
132- // life of a stand-in ([`Player::toggle_proxy`]): a filled dot for
133- // one that exists, a stop square while one is being made -- with
134- // how far it has got drawn under it -- and a hollow dot for a row
135- // that has none. Never an ×: that shape means the file leaves the
136- // library, and taking a *stand-in* off a row is not that.
137- let (glyph, proxy_on, progress, waiting) = match self.proxies.get(&row.path) {
138- Some(Proxy::Ready) => ("●", true, None, false),
139- Some(Proxy::Making(job)) => ("■", true, Some(job.progress()), false),
140- // Asked for and already winding down: the same square, dimmed,
141- // so a second click does not look like the first one missed.
142- Some(Proxy::Cancelling(_)) => ("■", true, None, true),
143- Some(Proxy::Asked) => ("○", false, None, true),
144- _ => ("○", false, None, false),
145- };
146- // What the row is drawing right now, carried into the click: a
147- // stand-in that finishes between this paint and the pointer going
148- // down must not turn a stop into a deletion
149- // ([`Player::toggle_proxy`]).
150- let showed_stop = glyph == "■";
151- let stop_path = row.path.clone();
152- let stop_tip: SharedString = match self.proxies.get(&row.path) {
153- Some(Proxy::Making(_)) => format!(
154- "Stop making the stand-in for {} — nothing of it is kept, and the film itself \
155- is what plays",
156- row.name
157- ),
158- Some(Proxy::Cancelling(_)) => {
159- format!("Stopping the stand-in for {}…", row.name)
160- }
161- Some(Proxy::Ready) => format!(
162- "Stand-in ON for {} — click to delete it; the film itself is what plays after \
163- that, and nothing of the film is touched",
164- row.name
165- ),
166- _ => format!("Stand-in OFF for {} — click to make one", row.name),
167- }
168- .into();
169- let usable = row.unusable.is_none();
170- // What is left of the row for words: the switch and the gap before
171- // it, on the rows that carry one. Both lines are held to it -- the
172- // name alone was, and the detail line under it ran on under the
173- // switch and was cut mid-word -- and an unusable row draws no switch
174- // and so pays nothing for one.
175- // Two switches now sit at the end of a usable row -- the preview
176- // play button beside the stand-in toggle -- so the text gives up
177- // twice the room it gave up for one.
178- let text_w = row_text_w(width)
179- - match usable {
180- true => 2. * (HIT_MIN + 6.),
181- false => 0.,
182- };
183- let (path, stream) = (row.path.clone(), row.stream);
184- let dragged = (path.clone(), stream);
185- let menu_path = path.clone();
186- let preview_path = path.clone();
187- let preview_tip: SharedString = format!(
188- "Preview {} — plays it without touching the timeline",
189- row.name
190- )
191- .into();
192- div()
193- .id(("asset", i))
194- .flex_none()
195- .h(px(ROW_H))
196- .flex()
197- .items_center()
198- .gap(px(6.))
199- .pr(px(6.))
200- .rounded(px(3.))
201- // A row that cannot be placed takes no click and no drag, and
202- // reads as unavailable rather than merely unlucky.
203- .when(!usable, |d| d.text_color(rgb(FG_SECONDARY())).opacity(0.55))
204- .when(usable, |d| {
205- d.cursor_pointer()
206- .hover(|s| s.bg(rgb(BG_HOVER())))
207- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
208- this.selected_asset = Some((path.clone(), stream));
209- cx.notify();
210- }))
211- // The drag carries the row's file and stream and the
212- // row's name: one for the drop to insert, one for the
213- // pointer to carry, so what is being dragged is legible
214- // on the way down.
215- .on_drag(AssetDrag(dragged.0, dragged.1), move |_, _, _, cx| {
216- cx.new(|_| Tip(ghost.clone()))
217- })
218- })
219- // The right button hangs the row's own menu at the pointer.
220- // Every row takes it, greyed ones included: a file that cannot
221- // join this timeline can still be revealed, described and taken
222- // out of the list, and Add is the one item that then refuses --
223- // in the engine's words, where the row's grey already says why.
224- .on_mouse_down(
225- MouseButton::Right,
226- cx.listener(move |this, event: &MouseDownEvent, _, cx| {
227- if this.modal() {
228- return;
229- }
230- // Picked as a left-click would pick it, so the row the
231- // menu is about is the row that reads as chosen -- but
232- // only a row that *can* be picked, which is what keeps
233- // the Add button under the list honest.
234- if usable {
235- this.selected_asset = Some((menu_path.clone(), stream));
236- }
237- this.library_menu = Some(LibraryMenu {
238- path: menu_path.clone(),
239- stream,
240- at: event.position,
241- details: false,
242- });
243- cx.notify();
244- }),
245- )
246- .when(picked, |d| d.bg(rgb(BG_SELECTED())).border_1())
247- .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into())
248- // Full height and hard against the edge: the tint reads as
249- // the lane's colour continuing into the list, not as a chip
250- // that happens to be near it.
251- .child(
252- div()
253- .flex_none()
254- .w(px(SWATCH_W))
255- .h_full()
256- .rounded(px(2.))
257- .bg(rgb(source_tint(row.tint))),
258- )
259- .child(
260- div()
261- .flex_1()
262- .min_w(px(0.))
263- .flex()
264- .flex_col()
265- // Two lines rather than two columns: at the width
266- // this panel yields to, a name and a timecode side
267- // by side leave room for neither.
268- // Cut out of the middle, not the end: two episodes off
269- // one release are the same words up to the number, and
270- // the number is at the end.
271- .child(
272- div()
273- .truncate()
274- .text_size(px(11.))
275- // Less the stand-in switch and the gap before
276- // it: a media row carries one where a subtitle
277- // row -- built to the same `row_text_w` -- does
278- // not, so the difference is taken here.
279- .child(clip_middle(&name, text_w)),
280- )
281- .child(
282- div()
283- .truncate()
284- .text_size(px(10.))
285- .text_color(rgb(FG_SECONDARY()))
286- .child(clip_middle(&under, text_w)),
287- ),
288- )
289- // The stand-in switch, on every row that can carry one. A
290- // `HIT_MIN` target that stops the click there: the row under it
291- // picks the file, and turning a stand-in on or off is not a way
292- // of choosing what to place. The selection language the rest of
293- // the window speaks says which way it is set -- lit like a
294- // picked row when there is one, dimmed like an unusable one
295- // when there is not.
296- .when(usable, |d| {
297- d.child(
298- div()
299- .id(("preview-play", i))
300- .flex_none()
301- .w(px(HIT_MIN))
302- .h_full()
303- .flex()
304- .items_center()
305- .justify_center()
306- .rounded(px(3.))
307- .text_size(px(11.))
308- .cursor_pointer()
309- .hover(|s| s.bg(rgb(BG_HOVER())))
310- .tooltip(move |_, cx| cx.new(|_| Tip(preview_tip.clone())).into())
311- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
312- cx.stop_propagation();
313- this.open_preview(&preview_path, stream, cx);
314- }))
315- .child("▶"),
316- )
317- })
318- .when(usable, |d| {
319- d.child(
320- div()
321- .id(("proxy-toggle", i))
322- .flex_none()
323- .w(px(HIT_MIN))
324- .h_full()
325- .flex()
326- .flex_col()
327- .items_center()
328- .justify_center()
329- .gap(px(2.))
330- .rounded(px(3.))
331- .text_size(px(10.))
332- .when(proxy_on, |d| d.bg(rgb(BG_SELECTED())))
333- .when(!proxy_on, |d| d.text_color(rgb(FG_SECONDARY())))
334- .when(waiting, |d| d.opacity(0.55))
335- .cursor_pointer()
336- .hover(|s| s.bg(rgb(BG_HOVER())))
337- .tooltip(move |_, cx| cx.new(|_| Tip(stop_tip.clone())).into())
338- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
339- cx.stop_propagation();
340- this.toggle_proxy(&stop_path, showed_stop, cx);
341- }))
342- .child(glyph)
343- // How far the encode has come, under the stop it is
344- // stopped with: a bar rather than only the row's
345- // "proxy 37%", so the control reads as a job that is
346- // running and not as a thing that removes something.
347- .children(progress.map(|p| {
348- div()
349- .flex_none()
350- .w(px(PROXY_BAR_W))
351- .h(px(2.))
352- .rounded(px(1.))
353- .bg(rgb(BG_RAISED()))
354- .child(
355- div()
356- .h_full()
357- .w(px(PROXY_BAR_W * p.clamp(0., 1.)))
358- .rounded(px(1.))
359- .bg(rgb(ACCENT_PRIMARY())),
360- )
361- })),
362- )
363- })
364- })
365- .collect();
366- div()
367- .id("library")
368- .flex_none()
369- .w(px(width))
370- .h_full()
371- .flex()
372- .flex_col()
373- .gap(px(6.))
374- .p(px(8.))
375- .bg(rgb(BG_PANEL()))
376- // The column itself scrolls at a short window. Its five stacked
377- // things want 140 px and the 640x360 floor gives the region 136, so
378- // the list -- the only child that may shrink -- was being squeezed to
379- // nothing: tabs, an Import button, a way to add at the playhead, and
380- // no sight of what had been imported. Everything keeps its own size
381- // and the column carries the remainder, which is the same answer the
382- // lanes and the inspector give.
383- .overflow_y_scroll()
384- .child(
385- div().flex_none().flex().items_center().gap(px(6.)).child(
386- div()
387- .flex_1()
388- .min_w(px(0.))
389- .flex()
390- // Wraps rather than clipping: at the 640 px floor
391- // this column is 128 px wide and the third tab
392- // would hang off its edge, which is a control the
393- // pointer cannot reach.
394- .flex_wrap()
395- .gap(px(2.))
396- .children(LIBRARY_TABS.map(|tab| {
397- let on = tab == self.library_tab;
398- div()
399- .id(("library-tab", tab as usize))
400- .flex_none()
401- .h(px(HIT_MIN))
402- .px(px(6.))
403- .flex()
404- .items_center()
405- .rounded(px(3.))
406- .text_size(px(11.))
407- .text_color(rgb(match on {
408- true => FG_PRIMARY(),
409- false => FG_SECONDARY(),
410- }))
411- // One selection language everywhere: the
412- // same stroke a picked clip and a picked
413- // row wear.
414- .when(on, |d| {
415- d.bg(rgb(BG_SELECTED()))
416- .border_b_2()
417- .border_color(rgb(STROKE_SELECTED()))
418- })
419- .cursor_pointer()
420- .hover(|s| s.bg(rgb(BG_HOVER())))
421- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
422- this.library_tab = tab;
423- cx.notify();
424- }))
425- .child(tab.label())
426- })),
427- ),
428- )
429- // The tab says what the one full-width control is for. Text holds
430- // no rows of its own ([`LibraryTab::holds`]) -- it is the tracks
431- // under it -- and what a person opens it to do is put subtitles on
432- // this timeline: off a release's `.mkv`, off an `.srt` beside it,
433- // without the file itself joining the library or a lane. So that is
434- // the button there, where the tracks it adds are listed; media goes
435- // on getting in from the other two tabs, from a drop, and from the
436- // actions card.
437- .when(self.library_tab == LibraryTab::Text, |d| {
438- d.child(div().flex_none().child(self.action_control(
439- "add-subtitles",
440- width - 16.,
441- match self.session.as_ref().is_some_and(|s| !s.subtitles().is_empty()) {
442- // The primary action of this tab while it has nothing:
443- // the same rule the Import button follows one tab over.
444- false => ACCENT_PRIMARY(),
445- true => BG_RAISED(),
446- },
447- None,
448- // The column is 128 px at the 640x360 floor and the whole
449- // name does not fit it: a centred label wider than its
450- // button is clipped at *both* ends ("d subtitles from a
451- // fil"), which is a button that says nothing. The short
452- // form there; the full name is what the tooltip, the
453- // actions card and the stroke go on saying either way.
454- match (width - 16.) / LIST_CHAR_W >= 26. {
455- true => "Add subtitles from a file…",
456- false => "Add subtitles",
457- },
458- "reads a file's subtitle tracks into the palette below — drag one onto an S \
459- track to place it; the file itself joins nothing",
460- ActionId::ImportSubtitles,
461- cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_add_subtitles(cx)),
462- )))
463- })
464- .when(self.library_tab != LibraryTab::Text, |d| {
465- d.child(div().flex_none().child(control(
466- "import",
467- // Full width of the column: the way media gets in is
468- // the one affordance of the tabs that hold media,
469- // however narrow the window is.
470- width - 16.,
471- // Filled with the accent while there is nothing to work
472- // on, because with an empty library this *is* the
473- // primary action -- and Export, which wears the accent
474- // the rest of the time, is dimmed until something is
475- // imported. One live accent in the window either way.
476- match rows.is_empty() {
477- true => ACCENT_PRIMARY(),
478- false => BG_RAISED(),
479- },
480- None,
481- "Import",
482- "adds a file to this list — or drop one on the window".to_string(),
483- !exporting,
484- cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_import(cx)),
485- )))
486- })
487- .child(
488- div()
489- .id("library-rows")
490- .flex_1()
491- // Never nothing: a media list with no room left is a library
492- // column that has stopped being a library column.
493- .min_h(px(ROW_H))
494- .flex()
495- .flex_col()
496- .gap(px(2.))
497- .overflow_y_scroll()
498- // Never a blank column: with nothing imported the list is
499- // where the way in is said.
500- .when(rows.is_empty(), |d| {
501- d.child(
502- div()
503- .text_size(px(11.))
504- .text_color(rgb(FG_SECONDARY()))
505- .child(self.library_tab.empty()),
506- )
507- })
508- .children(rows),
509- )
510- // Under the media it belongs to: a subtitle track is not a source --
511- // it goes on no lane and is dragged nowhere -- but it is a thing the
512- // timeline holds, and this is the list of those.
513- .when(self.library_tab == LibraryTab::Text, |d| {
514- d.children(self.subtitle_section(width, cx))
515- })
516- .child(control(
517- "add-asset",
518- 0.,
519- BG_RAISED(),
520- None,
521- "Add at playhead",
522- match self.selected_asset {
523- Some(_) => "inserts the picked file at the playhead".to_string(),
524- None => "click a file above first — or drag one where you want it".to_string(),
525- },
526- can_add(
527- self.selected_asset.as_ref(),
528- self.session.is_some(),
529- exporting,
530- ),
531- cx.listener(|this, _: &ClickEvent, _, cx| {
532- if let Some((path, stream)) = this.selected_asset.clone() {
533- // No lane: the button means "wherever this belongs",
534- // which for a file with no picture is the audio lane.
535- this.insert_source(&path, stream, None, None, cx);
536- }
537- }),
538- ))
539- }
540-
541 /// The menu a right-click on a library row opens: what can be done with the9 /// The menu a right-click on a library row opens: what can be done with the
542 /// *file* rather than with a clip of it, and a turn-over side saying what10 /// *file* rather than with a clip of it, and a turn-over side saying what
543 /// that file is. Built like [`Player::context_card`] down to the scrim, the11 /// that file is. Built like [`Player::context_card`] down to the scrim, the
@@ -552,8 +20,7 @@ impl Player {
552 let path = menu.path.clone();20 let path = menu.path.clone();
553 // DESIGN §9: the same plate row treatment `Player::context_card`21 // DESIGN §9: the same plate row treatment `Player::context_card`
554 // draws with -- one function, so a copy-paste sibling menu cannot22 // draws with -- one function, so a copy-paste sibling menu cannot
555- // drift from it (darkroom only; `OLD_GUI=1` is unchanged).23+ // drift from it.
556- let darkroom = self.darkroom;
557 let row = move |n: usize| {24 let row = move |n: usize| {
558 div()25 div()
559 .id(("library-menu", n))26 .id(("library-menu", n))
@@ -564,7 +31,7 @@ impl Player {
564 .gap(px(12.))31 .gap(px(12.))
565 .px(px(6.))32 .px(px(6.))
566 .rounded(px(3.))33 .rounded(px(3.))
567- .when(darkroom, |d| {34+ .map(|d| {
568 d.type_style(crate::ui::type_scale::label(35 d.type_style(crate::ui::type_scale::label(
569 crate::ui::type_scale::LABEL_ROW_PX,36 crate::ui::type_scale::LABEL_ROW_PX,
570 gpui::FontWeight::MEDIUM,37 gpui::FontWeight::MEDIUM,
@@ -573,7 +40,7 @@ impl Player {
573 })40 })
574 };41 };
575 let chord_style = |d: Div| -> Div {42 let chord_style = |d: Div| -> Div {
576- d.when(darkroom, |d| {43+ d.map(|d| {
577 d.type_style(crate::ui::type_scale::mono(44 d.type_style(crate::ui::type_scale::mono(
578 crate::ui::type_scale::CHORD_METADATA_MIN_PX,45 crate::ui::type_scale::CHORD_METADATA_MIN_PX,
579 gpui::FontWeight::MEDIUM,46 gpui::FontWeight::MEDIUM,
@@ -659,7 +126,7 @@ impl Player {
659 // DESIGN §9: destructive verbs sit below a rule line. One126 // DESIGN §9: destructive verbs sit below a rule line. One
660 // hairline, drawn once, above whichever of the two removes127 // hairline, drawn once, above whichever of the two removes
661 // this row context offers.128 // this row context offers.
662- if matches!(item, RowItem::Remove | RowItem::RemoveWithClips) && darkroom {129+ if matches!(item, RowItem::Remove | RowItem::RemoveWithClips) {
663 rows.push(130 rows.push(
664 div()131 div()
665 .flex_none()132 .flex_none()
@@ -700,12 +167,7 @@ impl Player {
700 // floor clamp and the room the list sizes against are `menu_floor`'s,167 // floor clamp and the room the list sizes against are `menu_floor`'s,
701 // so a menu taller than the footprint scrolls instead of climbing168 // so a menu taller than the footprint scrolls instead of climbing
702 // back over the picture.169 // back over the picture.
703- let (at, room) = menu_floor(170+ let (at, room) = menu_floor(menu.at, viewport, self.split_px(Split::Bench, viewport));
704- menu.at,
705- viewport,
706- darkroom,
707- self.split_px(Split::Bench, viewport),
708- );
709 let list_h = menu_rows_h(rows.len(), room);171 let list_h = menu_rows_h(rows.len(), room);
710 let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h);172 let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h);
711 let full: SharedString = path.display().to_string().into();173 let full: SharedString = path.display().to_string().into();
@@ -728,7 +190,7 @@ impl Player {
728 }),190 }),
729 )191 )
730 .child(192 .child(
731- menu_plate("library-menu-card", x, y, darkroom)193+ menu_plate("library-menu-card", x, y)
732 // Painted after the scrim, so this listener runs first194 // Painted after the scrim, so this listener runs first
733 // and a press meant for an item never closes the menu195 // and a press meant for an item never closes the menu
734 // out from under its own click (`context_card`).196 // out from under its own click (`context_card`).
crates/app/src/ui/mod.rsmodified+0 -3
@@ -7,7 +7,6 @@ pub mod bench_stance;
7 pub mod cards;7 pub mod cards;
8 pub mod dock_stance;8 pub mod dock_stance;
9 pub mod hitmap;9 pub mod hitmap;
10-pub mod inspector;
11 pub mod library;10 pub mod library;
12 pub mod overlays;11 pub mod overlays;
13 pub mod preview;12 pub mod preview;
@@ -16,7 +15,5 @@ pub mod spine_stance;
16 pub mod stance;15 pub mod stance;
17 pub mod theme;16 pub mod theme;
18 pub mod timeband_stance;17 pub mod timeband_stance;
19-pub mod timeline;
20-pub mod toolbar;
21 pub mod type_scale;18 pub mod type_scale;
22 pub mod widgets;19 pub mod widgets;
crates/app/src/ui/overlays.rsmodified+14 -388
@@ -107,352 +107,6 @@ impl Player {
107 )107 )
108 }108 }
109 109
110- /// A notice holds its own bar, full width, until it is answered: any key
111- /// retires it (the key handler) and so does a click on it. Its own surface
112- /// because the message is the point -- a failure cut to the timecode's slot
113- /// is a failure nobody read.
114- ///
115- /// The export's own line is more than a message: it names a file that is
116- /// now on disk, so the same click that retires it shows that file in the
117- /// desktop's file manager.
118- pub(crate) fn notice_bar(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
119- let notice = self.notices.front().cloned()?;
120- // The path travels with the text it was written for: a later notice
121- // holds the bar and the click is a plain dismissal again.
122- let exported = self
123- .exported
124- .clone()
125- .filter(|_| notice.starts_with(EXPORT_DONE));
126- // How many are waiting behind this one, said out loud: a queue nobody is
127- // told about is a queue whose second message reads as the first one
128- // failing to go away.
129- let behind = self.notices.len() - 1;
130- let hint = match (exported.is_some(), behind) {
131- (true, _) => "click — open file location".to_string(),
132- (false, 0) => "click or press any key to dismiss".to_string(),
133- (false, 1) => "click or press any key — 1 more message behind this".to_string(),
134- (false, n) => format!("click or press any key — {n} more messages behind this"),
135- };
136- // What the message *is*, by colour, before it is read: the words the
137- // editor shouts a failure in are the ones it opens with, so the bar can
138- // colour itself off the same text every one of them already carries.
139- let tone = notice_tone(&notice);
140- Some(
141- div()
142- .id("notice")
143- .when(exported.is_some(), |d| {
144- d.tooltip(|_, cx| {
145- cx.new(|_| {
146- Tip("Open file location — shows the export in the file manager".into())
147- })
148- .into()
149- })
150- })
151- .flex_none()
152- .flex()
153- // The hint keeps its own width, and at the 640x360 floor the
154- // picture region is narrower than the hint alone: with both on
155- // one line the message was squeezed to nothing and wrapped a
156- // character per line -- a notice rendered as a column of
157- // letters. Wrapping puts the hint on its own line instead, so
158- // the message keeps the whole width and the queue counter
159- // stays on screen under it.
160- .flex_wrap()
161- .items_start()
162- .gap(px(12.))
163- .px(px(12.))
164- .py(px(6.))
165- .bg(rgb(BG_RAISED()))
166- // The tone is a stripe down the leading edge rather than the
167- // whole bar's colour: a full red bar at every refusal is an
168- // alarm, and most of these are answers.
169- .border_l(px(3.))
170- .border_color(rgb(tone))
171- .cursor_pointer()
172- .hover(|s| s.bg(rgb(BG_HOVER())))
173- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
174- // Another process starting: off the UI thread, and it
175- // outlives the notice it was asked from.
176- if let Some(path) = exported.clone() {
177- cx.background_executor()
178- .spawn(async move { show_in_file_manager(&path) })
179- .detach();
180- }
181- this.dismiss_notice();
182- cx.notify();
183- }))
184- // Shrinkable, because a gpui text element measures its
185- // min-content as the *whole line* (`TextLayout::layout` only
186- // wraps against a definite width) -- without a `min_w` the
187- // message would refuse to shrink at all and run off the region
188- // instead. With a floor under it, it shrinks to that floor,
189- // which pushes the hint onto its own line and leaves the
190- // message the width it needs to wrap like a sentence.
191- .child(div().flex_1().min_w(px(NOTICE_MIN_W)).child(notice))
192- .child(
193- div()
194- .flex_none()
195- .text_size(px(11.))
196- .text_color(rgb(FG_SECONDARY()))
197- .child(hint),
198- ),
199- )
200- }
201-
202- /// Every binding, and the way to change one: a row per entry, click it and
203- /// the next stroke becomes its chord. Over the whole window, because while
204- /// it is up nothing under it may answer -- the scrim stops the clicks
205- /// (gpui dispatches mouse listeners topmost-first, window.rs:3705) and the
206- /// key handler's own branch stops the strokes.
207- ///
208- /// Plain divs, like every control here: nothing in it takes focus, so the
209- /// root is still the one reading the keyboard -- which is exactly what a
210- /// waiting row depends on.
211- pub(crate) fn keys_overlay(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
212- if !self.keys_open {
213- return None;
214- }
215- // The way out, spelled the way the rows spell a chord.
216- let out = keymap::Chord {
217- key: ESCAPE.to_string(),
218- ctrl: false,
219- }
220- .pretty();
221- // Every action there is, under its heading, and the strokes the modal
222- // cards answer to beside them -- `keys_rows` is the whole of the order
223- // and every word in it comes off the registry.
224- //
225- // A row is two targets, not one: its label *does* the action, which is
226- // the pointer's way to the ones no button carries, and its stroke
227- // changes that stroke. An action with two strokes reads as one line
228- // ("x or delete") and a rebind replaces that whole set.
229- let mut rows: Vec<AnyElement> = Vec::new();
230- let row = || {
231- div()
232- .flex()
233- // The floor, not the height: a row that needed two lines
234- // would otherwise paint over the one under it -- which it did
235- // anyway until this said `flex_none`, a row inside a capped
236- // scrolling list being shrunk to fit by default (the export
237- // card's rows had the same shape and the same overlap).
238- .flex_none()
239- .min_h(px(KEYS_ROW_H))
240- .items_center()
241- .justify_between()
242- .gap(px(12.))
243- .px(px(6.))
244- .rounded(px(3.))
245- };
246- let found = keys_filter(&self.keys_search, &self.keymap);
247- // What the search box says: the typed text, and how much of the list is
248- // left under it -- a filter that found nothing has to say so, or the
249- // card reads as a list that lost its rows.
250- let search = if self.keys_search.is_empty() {
251- "search: type to filter · ↑ ↓ scroll the list · a click away closes".to_string()
252- } else {
253- let rows = found
254- .iter()
255- .filter(|(_, r)| !matches!(r, KeyRow::Head(_)))
256- .count();
257- match rows {
258- 0 => format!(
259- "search: {} — nothing matches · {out} clears",
260- self.keys_search
261- ),
262- n => format!("search: {} — {n} shown · {out} clears", self.keys_search),
263- }
264- };
265- for (i, key_row) in found {
266- rows.push(match key_row {
267- KeyRow::Head(category) => div()
268- .flex_none()
269- .px(px(6.))
270- .pt(px(4.))
271- .text_size(px(11.))
272- .text_color(rgb(FG_SECONDARY()))
273- .child(category.label())
274- .into_any_element(),
275- KeyRow::Act(action) => {
276- let capturing = self.rebinding == Some(action);
277- // Why the label half will not answer, if it will not: the
278- // registry's one answer, the same the clip menu dims by.
279- let refusal = self.enable(action, None);
280- let out = out.clone();
281- row()
282- .when(capturing, |d| d.bg(rgb(BG_SELECTED())))
283- .child(
284- div()
285- .id(("do", i))
286- .flex_1()
287- .min_w(px(0.))
288- .flex()
289- .min_h(px(KEYS_ROW_H))
290- .items_center()
291- // One line, cut where the stroke's column
292- // starts: a label longer than the room it has
293- // printed straight over the stroke beside it,
294- // and two overprinted words are less readable
295- // than one truncated one.
296- .truncate()
297- .child(action.label())
298- .children(hitmap::action(action, refusal.yes()))
299- // The reason rides on the label rather than in
300- // the stroke column, which the rebind half
301- // needs whatever the editor's state is: an
302- // action nobody can ask for right now is still
303- // one whose key may be changed.
304- .when_some(refusal.why(), |d, why| {
305- let why: SharedString = why.into();
306- d.tooltip(move |_, cx| cx.new(|_| Tip(why.clone())).into())
307- })
308- .when(!refusal.yes(), |d| d.opacity(0.4).cursor_not_allowed())
309- .when(refusal.yes(), |d| {
310- d.cursor_pointer()
311- .hover(|s| s.bg(rgb(BG_HOVER())))
312- .on_click(cx.listener(
313- move |this, _: &ClickEvent, window, cx| {
314- // The card goes first: several of
315- // these open a card of their own,
316- // and every edit moves the indices
317- // the menus are holding.
318- this.keys_open = false;
319- this.rebinding = None;
320- this.act(action, window, cx);
321- cx.notify();
322- },
323- ))
324- }),
325- )
326- .child(
327- // corner-cut: the column is as wide as the stroke it
328- // prints, so a one-character chord gives this half a
329- // hit area under the 24px WCAG 2.5.8 floor -- tall
330- // enough, narrow. Upgrade: a min_w of HIT_MIN here.
331- div()
332- .id(("bind", i))
333- .flex_none()
334- .flex()
335- .min_h(px(KEYS_ROW_H))
336- .items_center()
337- .cursor_pointer()
338- .hover(|s| s.bg(rgb(BG_HOVER())))
339- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
340- this.rebinding = Some(action);
341- cx.notify();
342- }))
343- .child(if capturing {
344- div()
345- .text_color(rgb(FG_SECONDARY()))
346- .child(format!("press a key — {out} cancels"))
347- } else {
348- div().child(self.keymap.display(action))
349- }),
350- )
351- .into_any_element()
352- }
353- KeyRow::Fixed(f) => {
354- let f = &keymap::FIXED[f];
355- row()
356- .child(f.label)
357- // Dim, and no hover: this one is not a row you can click.
358- .child(div().text_color(rgb(FG_SECONDARY())).child(f.chord.clone()))
359- .into_any_element()
360- }
361- });
362- }
363- Some(
364- scrim()
365- .flex()
366- .justify_center()
367- .items_center()
368- // The picture behind is out of reach, and looks it. The press is
369- // swallowed here so a button under the scrim cannot take it --
370- // and it closes the card on the way, which is the pointer's exit
371- // from every card here ([`Player::close_card`]).
372- .bg(rgba(SCRIM()))
373- .on_mouse_down(
374- MouseButton::Left,
375- cx.listener(|this, _: &MouseDownEvent, _, cx| {
376- this.close_card();
377- cx.notify();
378- cx.stop_propagation();
379- }),
380- )
381- .child(
382- div()
383- .w(px(KEYS_W))
384- .on_mouse_down(MouseButton::Left, swallow)
385- .flex()
386- .flex_col()
387- .gap(px(2.))
388- .p(px(12.))
389- .rounded(px(6.))
390- .bg(rgb(BG_RAISED()))
391- // Title and instruction are two children, never one
392- // wrapping line: a fixed-height slot whose text wrapped
393- // painted its second line over the first row.
394- .child(div().flex_none().px(px(6.)).child("Actions & keys"))
395- // One status line, under the title where the eye starts.
396- // A refusal takes it over -- it is the more urgent of the
397- // two, and the notice bar it would otherwise appear in is
398- // under the scrim.
399- //
400- // The row list below is capped and scrolls, so neither a
401- // wrapped refusal here nor another action added to `ALL`
402- // can push the card past a 360 px window any more.
403- .child(
404- div()
405- .flex_none()
406- .px(px(6.))
407- .text_size(px(11.))
408- .text_color(rgb(FG_SECONDARY()))
409- .child(self.notices.front().cloned().unwrap_or_else(|| {
410- "click an action to do it · click its key to change it".into()
411- })),
412- )
413- // The search box: no focus and no text field -- the
414- // card's key handler is the field, exactly as the
415- // export card's bitrate is typed into it. Its own line
416- // above the list, so the rows below it are always the
417- // answer to what it says.
418- .child(
419- div()
420- .flex_none()
421- .px(px(6.))
422- .text_size(px(11.))
423- .text_color(rgb(FG_SECONDARY()))
424- .child(search),
425- )
426- // Capped and scrolling rather than as tall as the action
427- // list happens to be: the list grows with the editor,
428- // the smallest window does not.
429- .child(
430- div()
431- .id("keys-rows")
432- .flex()
433- .flex_col()
434- .gap(px(2.))
435- .max_h(px(KEYS_ROWS_H))
436- // The line the list scrolls under: a row half
437- // out of the viewport sat against the search
438- // line with nothing between them, and read as a
439- // row painted over the heading rather than as a
440- // list with more above it.
441- .mt(px(4.))
442- .border_t_1()
443- .border_color(rgb(BG_PANEL()))
444- .pt(px(4.))
445- .overflow_y_scroll()
446- // The wheel's offset and the arrow keys' are
447- // the same one, so the two cannot disagree
448- // about where the list is.
449- .track_scroll(&self.keys_scroll)
450- .children(rows),
451- ),
452- ),
453- )
454- }
455-
456 /// The menu a right-click on a clip opens: what that clip can be given,110 /// The menu a right-click on a clip opens: what that clip can be given,
457 /// each item beside the stroke that does the very same thing, and a111 /// each item beside the stroke that does the very same thing, and a
458 /// turn-over side that says what the clip *is*. An item that would do112 /// turn-over side that says what the clip *is*. An item that would do
@@ -484,10 +138,7 @@ impl Player {
484 let secs = |frames: u32| timecode(f64::from(frames) / self.fps, self.fps);138 let secs = |frames: u32| timecode(f64::from(frames) / self.fps, self.fps);
485 // DESIGN §9/§3: a menu row is a plate row, Archivo at the room's139 // DESIGN §9/§3: a menu row is a plate row, Archivo at the room's
486 // 10.5px row size -- `ink2`, dimmed to `ink3` on the disabled ones140 // 10.5px row size -- `ink2`, dimmed to `ink3` on the disabled ones
487- // below by the same `.opacity` every row already carried. Gated on141+ // below by the same `.opacity` every row already carried.
488- // `self.darkroom` so `OLD_GUI=1` keeps its own unstyled rows exactly
489- // as they draw today.
490- let darkroom = self.darkroom;
491 let row = move |n: usize| {142 let row = move |n: usize| {
492 div()143 div()
493 .id(("menu", n))144 .id(("menu", n))
@@ -500,7 +151,7 @@ impl Player {
500 .gap(px(12.))151 .gap(px(12.))
501 .px(px(6.))152 .px(px(6.))
502 .rounded(px(3.))153 .rounded(px(3.))
503- .when(darkroom, |d| {154+ .map(|d| {
504 d.type_style(type_scale::label(155 d.type_style(type_scale::label(
505 type_scale::LABEL_ROW_PX,156 type_scale::LABEL_ROW_PX,
506 gpui::FontWeight::MEDIUM,157 gpui::FontWeight::MEDIUM,
@@ -513,7 +164,7 @@ impl Player {
513 // than a room verb goes through this rather than the row's ambient164 // than a room verb goes through this rather than the row's ambient
514 // Archivo.165 // Archivo.
515 let chord_style = |d: Div| -> Div {166 let chord_style = |d: Div| -> Div {
516- d.when(darkroom, |d| {167+ d.map(|d| {
517 d.type_style(type_scale::mono(168 d.type_style(type_scale::mono(
518 type_scale::CHORD_METADATA_MIN_PX,169 type_scale::CHORD_METADATA_MIN_PX,
519 gpui::FontWeight::MEDIUM,170 gpui::FontWeight::MEDIUM,
@@ -731,17 +382,11 @@ impl Player {
731 // §5/§11 check 6: the picture is never covered. A right-click high on382 // §5/§11 check 6: the picture is never covered. A right-click high on
732 // the window would otherwise hang the menu at the pointer, straight383 // the window would otherwise hang the menu at the pointer, straight
733 // over the screen -- clamped below it into the bench/ledger/dock384 // over the screen -- clamped below it into the bench/ledger/dock
734- // footprint instead, darkroom only (the legacy tree has no such385+ // footprint instead. The list is sized against that same
735- // fixed split to clamp against). The list is sized against that same
736 // footprint (`room`), not the whole window, so a menu taller than386 // footprint (`room`), not the whole window, so a menu taller than
737 // the footprint scrolls inside its own plate instead of walking its387 // the footprint scrolls inside its own plate instead of walking its
738 // clamped top edge back up over the picture ([`menu_floor`]).388 // clamped top edge back up over the picture ([`menu_floor`]).
739- let (at, room) = menu_floor(389+ let (at, room) = menu_floor(menu.at, viewport, self.split_px(Split::Bench, viewport));
740- menu.at,
741- viewport,
742- self.darkroom,
743- self.split_px(Split::Bench, viewport),
744- );
745 let list_h = menu_rows_h(rows.len(), room);390 let list_h = menu_rows_h(rows.len(), room);
746 let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h);391 let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h);
747 let full: SharedString = source392 let full: SharedString = source
@@ -774,7 +419,7 @@ impl Player {
774 // One plate shape for all three hanging menus419 // One plate shape for all three hanging menus
775 // ([`menu_plate`]) -- the id is still this menu's own, so420 // ([`menu_plate`]) -- the id is still this menu's own, so
776 // the details side keeps its tooltip.421 // the details side keeps its tooltip.
777- menu_plate("menu-card", x, y, darkroom)422+ menu_plate("menu-card", x, y)
778 // Painted after the scrim, so this listener runs first423 // Painted after the scrim, so this listener runs first
779 // (gpui bubbles mouse events in reverse, window.rs:3705)424 // (gpui bubbles mouse events in reverse, window.rs:3705)
780 // and a press meant for an item never closes the menu425 // and a press meant for an item never closes the menu
@@ -818,7 +463,6 @@ impl Player {
818 cx: &mut Context<Self>,463 cx: &mut Context<Self>,
819 ) -> Option<impl IntoElement> {464 ) -> Option<impl IntoElement> {
820 let picker = self.picker?;465 let picker = self.picker?;
821- let darkroom = self.darkroom;
822 let theme_picker = picker.of == Pick::Theme;466 let theme_picker = picker.of == Pick::Theme;
823 let rows: Vec<AnyElement> = self467 let rows: Vec<AnyElement> = self
824 .choices(picker.of)468 .choices(picker.of)
@@ -842,7 +486,7 @@ impl Player {
842 .gap(px(12.))486 .gap(px(12.))
843 .px(px(6.))487 .px(px(6.))
844 .rounded(px(3.))488 .rounded(px(3.))
845- .when(darkroom, |d| {489+ .map(|d| {
846 d.type_style(type_scale::label(490 d.type_style(type_scale::label(
847 type_scale::LABEL_ROW_PX,491 type_scale::LABEL_ROW_PX,
848 gpui::FontWeight::MEDIUM,492 gpui::FontWeight::MEDIUM,
@@ -859,27 +503,19 @@ impl Player {
859 // plate grammar `context_card`/`library_card` already503 // plate grammar `context_card`/`library_card` already
860 // draw: one `raised` fill step for hover, `ink1` for the504 // draw: one `raised` fill step for hover, `ink1` for the
861 // row in force, no second grey.505 // row in force, no second grey.
862- .hover(|s| s.bg(rgb(if darkroom { DARK_RAISED() } else { BG_HOVER() })))506+ .hover(|s| s.bg(rgb(DARK_RAISED())))
863 // The mark is a glyph as well as a highlight, like the507 // The mark is a glyph as well as a highlight, like the
864 // export card's rows: a background alone is gone under a508 // export card's rows: a background alone is gone under a
865 // hover and invisible to anyone who cannot tell the two509 // hover and invisible to anyone who cannot tell the two
866 // greys apart (WCAG 1.4.1).510 // greys apart (WCAG 1.4.1).
867 .when(picked, |d| {511 .when(picked, |d| {
868- d.bg(rgb(if darkroom {512+ d.bg(rgb(DARK_RAISED())).map(|d| d.text_color(rgb(INK1())))
869- DARK_RAISED()
870- } else {
871- BG_SELECTED()
872- }))
873- .when(darkroom, |d| d.text_color(rgb(INK1())))
874 })513 })
875 // Where the keyboard is, said after the mark so the cursor514 // Where the keyboard is, said after the mark so the cursor
876 // is visible on the picked row too -- and as a border in515 // is visible on the picked row too -- and as a border in
877 // the darkroom (DESIGN §4's 1px `ink1` focus ring) rather516 // the darkroom (DESIGN §4's 1px `ink1` focus ring) rather
878 // than a second grey nobody can tell from the first.517 // than a second grey nobody can tell from the first.
879- .when(n == picker.sel, |d| match darkroom {518+ .when(n == picker.sel, |d| d.border_1().border_color(rgb(INK1())))
880- true => d.border_1().border_color(rgb(INK1())),
881- false => d.bg(rgb(BG_HOVER())),
882- })
883 .child(519 .child(
884 div()520 div()
885 .flex()521 .flex()
@@ -899,13 +535,8 @@ impl Player {
899 .text_size(px(11.))535 .text_size(px(11.))
900 // On the picked row the dim ink sits on the536 // On the picked row the dim ink sits on the
901 // highlight, where it is only 3.3:1 (WCAG 1.4.3).537 // highlight, where it is only 3.3:1 (WCAG 1.4.3).
902- .text_color(rgb(match (darkroom, picked) {538+ .text_color(rgb(if picked { INK2() } else { INK3() }))
903- (true, true) => INK2(),539+ .map(|d| {
904- (true, false) => INK3(),
905- (false, true) => FG_PRIMARY(),
906- (false, false) => FG_SECONDARY(),
907- }))
908- .when(darkroom, |d| {
909 d.type_style(type_scale::mono(540 d.type_style(type_scale::mono(
910 type_scale::CHORD_METADATA_MIN_PX,541 type_scale::CHORD_METADATA_MIN_PX,
911 gpui::FontWeight::MEDIUM,542 gpui::FontWeight::MEDIUM,
@@ -925,12 +556,7 @@ impl Player {
925 .collect();556 .collect();
926 // The window's own room, and the list scrolls only where the window has557 // The window's own room, and the list scrolls only where the window has
927 // none -- the clip menu's rule, one function for both.558 // none -- the clip menu's rule, one function for both.
928- let (at, room) = menu_floor(559+ let (at, room) = menu_floor(picker.at, viewport, self.split_px(Split::Bench, viewport));
929- picker.at,
930- viewport,
931- darkroom,
932- self.split_px(Split::Bench, viewport),
933- );
934 let list_h = menu_rows_h(rows.len(), room);560 let list_h = menu_rows_h(rows.len(), room);
935 let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h);561 let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h);
936 Some(562 Some(
@@ -954,7 +580,7 @@ impl Player {
954 }),580 }),
955 )581 )
956 .child(582 .child(
957- menu_plate("picker-card", x, y, darkroom)583+ menu_plate("picker-card", x, y)
958 // Painted after the scrim, so this listener runs first584 // Painted after the scrim, so this listener runs first
959 // and a press meant for a row never closes the list out585 // and a press meant for a row never closes the list out
960 // from under its own click (`context_card`).586 // from under its own click (`context_card`).
crates/app/src/ui/preview.rsmodified+12 -86
@@ -6,64 +6,17 @@ use crate::*;
6 use std::path::{Path, PathBuf};6 use std::path::{Path, PathBuf};
7 7
8 impl Player {8 impl Player {
9- /// The one thing that says a preview is up rather than the timeline: a9+ /// The darkroom's own preview indicator (MOCK-SPEC.md): a plate
10- /// banner over the top of the picture, and a click of its own -- the10+ /// (canvas-on-panel, §4), mono for what the film says, and a ghost
11- /// keyboard has `esc`, and a hand with only a mouse needs a way out too.11+ /// `Stop` wearing its `esc` chord rather than a bordered button -- no
12+ /// fill, no border, hover lifts one step like every other ghost in the
13+ /// room.
12 ///14 ///
13- /// Legacy-only now (DEFECT 2, MOCK-SPEC.md): this is a full-width band15+ /// Mounted in `ui::stance::screen` as a flex sibling below the picture's
14- /// drawn *on* the frame, which DESIGN §5 forbids for the darkroom16+ /// own child, the way `two_up` is, so the frame's box shrinks to make
15- /// ("nothing else over the picture, ever"). [`Player::preview_plate`] is17+ /// room rather than being drawn over.
16- /// the darkroom's own restyle of the same information, built as a flex
17- /// sibling so the picture's own box shrinks for it rather than being
18- /// painted over -- the same fix `two_up`'s doc comment describes for the
19- /// OUT|IN plates. `OLD_GUI=1` keeps drawing this banner unchanged.
20- pub(crate) fn preview_badge(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
21- (!self.darkroom && self.preview_session.is_some()).then(|| {
22- div()
23- .absolute()
24- .top_0()
25- .left_0()
26- .right_0()
27- .flex()
28- .items_center()
29- .justify_center()
30- .gap(px(8.))
31- .p(px(4.))
32- .bg(rgba(SUB_SHADE()))
33- .text_size(px(11.))
34- .text_color(rgb(FG_PRIMARY()))
35- .child("PREVIEW — not on the timeline")
36- .child(
37- div()
38- .id("preview-stop")
39- .px(px(6.))
40- .rounded(px(3.))
41- .cursor_pointer()
42- .bg(rgb(BG_RAISED()))
43- .hover(|s| s.bg(rgb(BG_HOVER())))
44- .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.close_preview(cx)))
45- .children(hitmap::control("preview.stop", "Stop preview", true))
46- .child("Stop (esc)"),
47- )
48- })
49- }
50-
51- /// The darkroom's own preview indicator (DEFECT 2, MOCK-SPEC.md): a
52- /// plate (canvas-on-panel, §4), mono for what the film says, and a ghost
53- /// `Stop` wearing its `esc` chord rather than the legacy bordered
54- /// button -- no fill, no border, hover lifts one step like every other
55- /// ghost in the room.
56- ///
57- /// corner-cut: built and unit-shaped but **not yet mounted** -- it needs
58- /// to sit as a flex sibling of the picture inside `ui::stance::screen`
59- /// (the box `two_up`'s own doc comment already fixed this exact way for
60- /// the OUT|IN plates), which is `stance.rs`, out of this task's file
61- /// ownership while another builder has it open concurrently. `#[allow
62- /// It is mounted in `ui::stance::screen` as a flex sibling below the
63- /// picture's own child, the way `two_up` is, so the frame's box shrinks to
64- /// make room rather than being drawn over.
65 pub(crate) fn preview_plate(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {18 pub(crate) fn preview_plate(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
66- (self.darkroom && self.preview_session.is_some()).then(|| {19+ self.preview_session.is_some().then(|| {
67 div()20 div()
68 .id("preview-plate")21 .id("preview-plate")
69 .flex_none()22 .flex_none()
@@ -414,13 +367,10 @@ impl Player {
414 /// the layout box is not) keeps the strip's room reserved instead of367 /// the layout box is not) keeps the strip's room reserved instead of
415 /// collapsing it, which is what let the picture's own `flex_1` above it368 /// collapsing it, which is what let the picture's own `flex_1` above it
416 /// resize on every cut walk (404px resting on a cut, 335px a frame off369 /// resize on every cut walk (404px resting on a cut, 335px a frame off
417- /// one, springing back on the very next). Only `!self.darkroom` still370+ /// one, springing back on the very next). The darkroom is the only room
418- /// returns `None`: the legacy tree never reserved this room and does not371+ /// now, so the sole remaining `None` cases are off a cut or with
419- /// start now.372+ /// nothing marked.
420 pub(crate) fn two_up(&self) -> Option<impl IntoElement> {373 pub(crate) fn two_up(&self) -> Option<impl IntoElement> {
421- if !self.darkroom {
422- return None;
423- }
424 let resting = (|| {374 let resting = (|| {
425 let (lane, idx) = self.selected.anchor()?;375 let (lane, idx) = self.selected.anchor()?;
426 let session = self.session.as_ref()?;376 let session = self.session.as_ref()?;
@@ -494,30 +444,6 @@ impl Player {
494 .child(plate("IN", in_label)),444 .child(plate("IN", in_label)),
495 )445 )
496 }446 }
497-
498- /// What is decoding the picture right now, for the transport line: the
499- /// backend is the running worker's own (it is written where a hardware
500- /// session falls back to software, so this follows reality), and the codec
501- /// comes from the clip under the playhead. Empty when nothing is playing --
502- /// the question is about what is happening, not about what would.
503- pub(crate) fn live_decode(&self, position: f64, playing: bool) -> String {
504- let Some(session) = self.session.as_ref().filter(|_| playing) else {
505- return String::new();
506- };
507- let backend = session.decode_backend();
508- let codec = session
509- .video_clip_at(position)
510- .and_then(|(lane, idx)| session.lane_clips(lane).get(idx).map(|clip| clip.source))
511- .and_then(|source| session.sources().get(source))
512- .and_then(|source| self.decoders.get(&source.path).copied().flatten())
513- .and_then(|(codec, _)| codec);
514- match backend {
515- // Neither is a decode, and saying "SW" of them would be a lie.
516- Backend::Gap => "gap · nothing to decode".to_string(),
517- Backend::Still => "still · one decode, held".to_string(),
518- _ => format!("{} decode", decode_label(codec, backend)),
519- }
520- }
521 }447 }
522 448
523 /// `~/Pictures/edith`, or `.` with no `HOME` -- [`keymap::config_path_in`]'s449 /// `~/Pictures/edith`, or `.` with no `HOME` -- [`keymap::config_path_in`]'s
crates/app/src/ui/spine_stance.rsmodified+14 -14
@@ -311,20 +311,6 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
311 player,311 player,
312 cx,312 cx,
313 ))313 ))
314- // ToggleSnap (homeless per this task's audit): editing-adjacent --
315- // it decides where a drag lands (keymap.rs's own category puts it
316- // under Editing, not View) -- so it earns the CUT group beside the
317- // trim/loop-trim it changes the feel of, not the quiet ROOM cluster
318- // below. Active fill mirrors loop-trim's own on/off convention.
319- .child(glyph(
320- "spine-toggle-snap",
321- "Sn",
322- ActionId::ToggleSnap,
323- player.snap,
324- false,
325- player,
326- cx,
327- ))
328 // VIEW group, added this task: ZoomIn/ZoomOut/ZoomFit (keymap.rs) had314 // VIEW group, added this task: ZoomIn/ZoomOut/ZoomFit (keymap.rs) had
329 // real, already-working handlers (`Player::zoom`/`zoom_fit`, wired315 // real, already-working handlers (`Player::zoom`/`zoom_fit`, wired
330 // into the legacy `ui/toolbar.rs`) but no home anywhere in the316 // into the legacy `ui/toolbar.rs`) but no home anywhere in the
@@ -363,6 +349,20 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
363 player,349 player,
364 cx,350 cx,
365 ))351 ))
352+ // ToggleSnap: decides where a drag lands, which is what the eye
353+ // reads the zoom scale against -- placed as the VIEW group's last
354+ // row, beside the zoom controls above it, rather than off in CUT
355+ // where nothing else answers "what scale/behaviour am I looking
356+ // at". Active fill mirrors loop-trim's own on/off convention.
357+ .child(glyph(
358+ "snap",
359+ "Sn",
360+ ActionId::ToggleSnap,
361+ player.snap,
362+ false,
363+ player,
364+ cx,
365+ ))
366 .child(group_head("track"))366 .child(group_head("track"))
367 .child(pair(367 .child(pair(
368 glyph(368 glyph(
crates/app/src/ui/stance.rsmodified+46 -37
@@ -1,7 +1,7 @@
1-//! DESIGN.md §5 -- the stance: fixed geography, drawn by default now1+//! DESIGN.md §5 -- the stance: fixed geography, the only room now the
2-//! (`OLD_GUI=1` opts back into the legacy four-region tree), whole here2+//! legacy four-region tree is gone (`self.darkroom` no longer branches
3-//! rather than folded into that tree so the two can be told apart, and3+//! anything in `render.rs`), whole here as its own module rather than
4-//! swapped, with a single `if` in `render.rs`.4+//! folded into that tree.
5 //!5 //!
6 //! This step lays out the six regions and nothing else: correct geometry,6 //! This step lays out the six regions and nothing else: correct geometry,
7 //! correct surfaces, a section-head label per region. No content, no7 //! correct surfaces, a section-head label per region. No content, no
@@ -99,22 +99,12 @@ impl Player {
99 /// exactly as the tab's own click does (`dock_stance::dock_tab`'s99 /// exactly as the tab's own click does (`dock_stance::dock_tab`'s
100 /// `on_click`), so the ring and a mouse click can't disagree about100 /// `on_click`), so the ring and a mouse click can't disagree about
101 /// which tab was last chosen.101 /// which tab was last chosen.
102- ///
103- /// The ring is darkroom-only UI -- the legacy tree never mounts
104- /// `focus_dock`/`focus_bench`/`focus_inspector` (only `track_focus`
105- /// sites live in this module and `dock_stance.rs`), so under
106- /// `OLD_GUI=1` a `window.focus` here would land on an unmounted
107- /// handle and kill the root key listener (`main.rs`'s fallback focus)
108- /// until the next mouse click. No-op there instead.
109 pub(crate) fn focus_surface(102 pub(crate) fn focus_surface(
110 &mut self,103 &mut self,
111 surface: Surface,104 surface: Surface,
112 window: &mut Window,105 window: &mut Window,
113 cx: &mut Context<Self>,106 cx: &mut Context<Self>,
114 ) {107 ) {
115- if !self.darkroom {
116- return;
117- }
118 if let Some(src_active) = surface_wants_src_active(surface) {108 if let Some(src_active) = surface_wants_src_active(surface) {
119 self.dock_src_active = src_active;109 self.dock_src_active = src_active;
120 crate::ui::dock_stance::save(src_active);110 crate::ui::dock_stance::save(src_active);
@@ -202,16 +192,11 @@ pub(crate) fn maximized_card_top(viewport_h: f32, bench_h: f32) -> f32 {
202 /// room *below the floor* instead means it never needs more than that room,192 /// room *below the floor* instead means it never needs more than that room,
203 /// so `menu_at` never has a reason to walk it back up; a list still taller193 /// so `menu_at` never has a reason to walk it back up; a list still taller
204 /// than the room scrolls inside its own plate, same as the keys overlay.194 /// than the room scrolls inside its own plate, same as the keys overlay.
205-/// Darkroom only -- the legacy tree has no fixed split to clamp against.
206 pub(crate) fn menu_floor(195 pub(crate) fn menu_floor(
207 at: Point<Pixels>,196 at: Point<Pixels>,
208 viewport: Size<Pixels>,197 viewport: Size<Pixels>,
209- darkroom: bool,
210 bench_h: f32,198 bench_h: f32,
211 ) -> (Point<Pixels>, Size<Pixels>) {199 ) -> (Point<Pixels>, Size<Pixels>) {
212- if !darkroom {
213- return (at, viewport);
214- }
215 let floor = below_picture_floor(f32::from(viewport.height), bench_h);200 let floor = below_picture_floor(f32::from(viewport.height), bench_h);
216 let at = point(at.x, px(f32::from(at.y).max(floor)));201 let at = point(at.x, px(f32::from(at.y).max(floor)));
217 let room = size(viewport.width, px(f32::from(viewport.height) - floor));202 let room = size(viewport.width, px(f32::from(viewport.height) - floor));
@@ -233,7 +218,7 @@ mod menu_floor_tests {
233 fn a_menu_taller_than_the_footprint_stays_pinned_to_the_floor_not_walked_back_over_it() {218 fn a_menu_taller_than_the_footprint_stays_pinned_to_the_floor_not_walked_back_over_it() {
234 let viewport = size(px(1280.), px(720.));219 let viewport = size(px(1280.), px(720.));
235 let floor = below_picture_floor(f32::from(viewport.height), BENCH_H);220 let floor = below_picture_floor(f32::from(viewport.height), BENCH_H);
236- let (at, room) = menu_floor(point(px(300.), px(20.)), viewport, true, BENCH_H);221+ let (at, room) = menu_floor(point(px(300.), px(20.)), viewport, BENCH_H);
237 assert_eq!(f32::from(at.y), floor);222 assert_eq!(f32::from(at.y), floor);
238 // 396px of rows (the charter's measured menu height) does not fit in223 // 396px of rows (the charter's measured menu height) does not fit in
239 // the 316px footprint room, so it must be capped to it, not the224 // the 316px footprint room, so it must be capped to it, not the
@@ -394,8 +379,14 @@ fn section_head(label: &str) -> impl IntoElement {
394 /// A ghost command (DESIGN §4): borderless glyph (`ink2`) + dim chord379 /// A ghost command (DESIGN §4): borderless glyph (`ink2`) + dim chord
395 /// (`ink3`), read live off the keymap so a rebind can never leave the spine380 /// (`ink3`), read live off the keymap so a rebind can never leave the spine
396 /// showing a stroke that no longer fires it.381 /// showing a stroke that no longer fires it.
397-fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement {382+fn ghost(
383+ player: &Player,
384+ glyph: &str,
385+ action: ActionId,
386+ cx: &mut Context<Player>,
387+) -> impl IntoElement {
398 div()388 div()
389+ .id("keys")
399 .flex_none()390 .flex_none()
400 .flex()391 .flex()
401 .flex_col()392 .flex_col()
@@ -403,6 +394,11 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement {
403 .gap(px(2.))394 .gap(px(2.))
404 .py(px(6.))395 .py(px(6.))
405 .rounded(px(3.))396 .rounded(px(3.))
397+ .cursor_pointer()
398+ .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1())))
399+ .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| {
400+ this.act(action, window, cx)
401+ }))
406 .type_style(type_scale::label(402 .type_style(type_scale::label(
407 type_scale::LABEL_ROW_PX,403 type_scale::LABEL_ROW_PX,
408 gpui::FontWeight::MEDIUM,404 gpui::FontWeight::MEDIUM,
@@ -434,8 +430,11 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement {
434 /// on the press (bypassing the modal `overlaid()` guard, which would430 /// on the press (bypassing the modal `overlaid()` guard, which would
435 /// otherwise swallow the second `?` down while the first is still up) and431 /// otherwise swallow the second `?` down while the first is still up) and
436 /// its `on_key_up` closes it on release, so this is the room dimming one432 /// its `on_key_up` closes it on release, so this is the room dimming one
437-/// fill step for as long as the key is held, never a latch (DESIGN §9: "no433+/// fill step for as long as the key is held, never a latch (DESIGN §9:
438-/// modal cheat-sheet").434+/// hold-to-peek, click also dismisses). The scrim also closes on a press,
435+/// same contract every other card's scrim answers, so a hand that lets go
436+/// of `?` before reading the list still has a door out without touching the
437+/// keyboard again.
439 ///438 ///
440 /// corner-cut, named explicitly in DESIGN §9's own 2026-08-20 amendment439 /// corner-cut, named explicitly in DESIGN §9's own 2026-08-20 amendment
441 /// rather than silently shipped against the section's original text: it440 /// rather than silently shipped against the section's original text: it
@@ -445,7 +444,7 @@ fn ghost(player: &Player, glyph: &str, action: ActionId) -> impl IntoElement {
445 /// Ceiling: DESIGN §12 step 7's full geographic pass (each region draws its444 /// Ceiling: DESIGN §12 step 7's full geographic pass (each region draws its
446 /// own rows while held) -- §9's amendment names the 56 actions still445 /// own rows while held) -- §9's amendment names the 56 actions still
447 /// without a home.446 /// without a home.
448-fn keys_overlay(player: &Player) -> impl IntoElement {447+fn keys_overlay(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
449 div()448 div()
450 .id("stance-keys-overlay")449 .id("stance-keys-overlay")
451 .absolute()450 .absolute()
@@ -455,6 +454,18 @@ fn keys_overlay(player: &Player) -> impl IntoElement {
455 .h(px(BENCH_H + LEDGER_H))454 .h(px(BENCH_H + LEDGER_H))
456 .bg(rgba(SCRIM()))455 .bg(rgba(SCRIM()))
457 .flex()456 .flex()
457+ // Click also dismisses (DESIGN §9): the hold-`?`-release above is
458+ // the fast door, this is the same scrim-press-closes contract every
459+ // other card's scrim answers, so a hand that let go of `?` before
460+ // reading the list still has a way to shut it without the keyboard.
461+ .on_mouse_down(
462+ MouseButton::Left,
463+ cx.listener(|this, _: &MouseDownEvent, _, cx| {
464+ this.close_card();
465+ cx.notify();
466+ cx.stop_propagation();
467+ }),
468+ )
458 .child(469 .child(
459 div()470 div()
460 .id("stance-keys-list")471 .id("stance-keys-list")
@@ -467,6 +478,7 @@ fn keys_overlay(player: &Player) -> impl IntoElement {
467 .bg(rgb(DARK_PANEL()))478 .bg(rgb(DARK_PANEL()))
468 .border_1()479 .border_1()
469 .border_color(rgba(DARK_SEAM()))480 .border_color(rgba(DARK_SEAM()))
481+ .on_mouse_down(MouseButton::Left, swallow)
470 .flex()482 .flex()
471 .flex_col()483 .flex_col()
472 .gap(px(3.))484 .gap(px(3.))
@@ -558,7 +570,7 @@ fn spine(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
558 .gap(px(4.))570 .gap(px(4.))
559 .child(section_head("spine"))571 .child(section_head("spine"))
560 .child(spine_stance::render(player, cx))572 .child(spine_stance::render(player, cx))
561- .child(ghost(player, "?", ActionId::ShowActions))573+ .child(ghost(player, "?", ActionId::ShowActions, cx))
562 }574 }
563 575
564 /// The picture region: top of the centre column, takes the remaining space,576 /// The picture region: top of the centre column, takes the remaining space,
@@ -1017,14 +1029,13 @@ pub(crate) fn render(
1017 cx.notify();1029 cx.notify();
1018 return;1030 return;
1019 }1031 }
1020- // Same modal guard the legacy handler's rebinding/keys_open/1032+ // Same modal guard the legacy handler's keys_open/export_open/
1021- // export_open/colour/transform/speed/EQ/silence/mix/1033+ // colour/transform/speed/EQ/silence/mix/subtitle-style/menu
1022- // subtitle-style/menu chain (`render.rs`) amounts to, read as1034+ // chain (`render.rs`) amounts to, read as one bool instead of
1023- // one bool instead of re-copied field by field: while a card, a1035+ // re-copied field by field: while a card or a menu owns the
1024- // rebind capture, or a menu owns the keyboard, the darkroom1036+ // keyboard, the darkroom stance yields to it exactly as the
1025- // stance yields to it exactly as the legacy tree does. This is1037+ // legacy tree does. This is the fix for the stance's
1026- // the fix for the stance's `Home`-inside-the-Colour-card1038+ // `Home`-inside-the-Colour-card misfire.
1027- // misfire.
1028 //1039 //
1029 // `exporting()` alone is deliberately left out of this list1040 // `exporting()` alone is deliberately left out of this list
1030 // (`Player::card_open` is `modal()` minus it): a running export1041 // (`Player::card_open` is `modal()` minus it): a running export
@@ -1038,8 +1049,7 @@ pub(crate) fn render(
1038 // branch, and the six it leaves live (Theme, Fullscreen,1049 // branch, and the six it leaves live (Theme, Fullscreen,
1039 // SubtitleStyle, CancelExport, ...) are exactly the ones meant1050 // SubtitleStyle, CancelExport, ...) are exactly the ones meant
1040 // to keep working.1051 // to keep working.
1041- if this.rebinding.is_some()1052+ if this.card_open()
1042- || this.card_open()
1043 || this.context_menu.is_some()1053 || this.context_menu.is_some()
1044 || this.library_menu.is_some()1054 || this.library_menu.is_some()
1045 || this.picker.is_some()1055 || this.picker.is_some()
@@ -1048,7 +1058,6 @@ pub(crate) fn render(
1048 // the same list `overlaid`/`modal` read) -- blocking every1058 // the same list `overlaid`/`modal` read) -- blocking every
1049 // key while a card is open must not also lock the card open.1059 // key while a card is open must not also lock the card open.
1050 if key == ESCAPE {1060 if key == ESCAPE {
1051- this.rebinding = None;
1052 this.close_card();1061 this.close_card();
1053 }1062 }
1054 // FAULT 2, general shape: `context_menu`/`library_menu`/1063 // FAULT 2, general shape: `context_menu`/`library_menu`/
@@ -1125,7 +1134,7 @@ pub(crate) fn render(
1125 .when_some(player.notices.back().cloned(), |el, n| {1134 .when_some(player.notices.back().cloned(), |el, n| {
1126 el.child(notice_plate(n, bench_h))1135 el.child(notice_plate(n, bench_h))
1127 })1136 })
1128- .when(player.keys_open, |el| el.child(keys_overlay(player)))1137+ .when(player.keys_open, |el| el.child(keys_overlay(player, cx)))
1129 .when(player.settings_open, |el| {1138 .when(player.settings_open, |el| {
1130 el.child(settings_stance::render(player, window_size, cx))1139 el.child(settings_stance::render(player, window_size, cx))
1131 })1140 })
crates/app/src/ui/theme.rsmodified+0 -15
@@ -40,7 +40,6 @@
40 //! ([`BG_PANEL()`]): one relaxed load and one field read off a `'static`40 //! ([`BG_PANEL()`]): one relaxed load and one field read off a `'static`
41 //! table, which is what "the palette can be swapped whole" costs at paint time.41 //! table, which is what "the palette can be swapped whole" costs at paint time.
42 42
43-use engine::project::LaneKind;
44 use std::path::PathBuf;43 use std::path::PathBuf;
45 use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};44 use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
46 45
@@ -1444,20 +1443,6 @@ pub const GLYPH_SLOT: f32 = 14.;
1444 /// families share it.1443 /// families share it.
1445 pub const GHOST_ALPHA: u32 = 0x66;1444 pub const GHOST_ALPHA: u32 = 0x66;
1446 1445
1447-/// What a clip on `kind` is painted: the timeline's whole colour language in
1448-/// one call, so a lane added later cannot invent a shade of its own.
1449-pub fn clip_kind(kind: LaneKind, image: bool) -> u32 {
1450- match kind {
1451- LaneKind::Audio => CLIP_AUDIO(),
1452- LaneKind::Video if image => CLIP_IMAGE(),
1453- LaneKind::Video => CLIP_VIDEO(),
1454- // The purple every editor paints a title track, and the one clip colour
1455- // this palette already carried and nothing drew: a caption's box is now
1456- // that box.
1457- LaneKind::Subtitle => CLIP_TEXT(),
1458- }
1459-}
1460-
1461 /// Which of the feedback colours a message wears. Read off the words rather1446 /// Which of the feedback colours a message wears. Read off the words rather
1462 /// than carried alongside them: every message in this editor already opens with1447 /// than carried alongside them: every message in this editor already opens with
1463 /// what it is ("EXPORT DONE", "SCAN FAILED", "NOTHING DETACHED"), and a second1448 /// what it is ("EXPORT DONE", "SCAN FAILED", "NOTHING DETACHED"), and a second
crates/app/src/ui/timeline.rsdeleted+0 -2018

Diff too large; view file

@@ -1,2018 +0,0 @@
1-//! The bottom region: the ruler, the lanes and the subtitle strip.
2-
3-use crate::ui::widgets::*;
4-use crate::*;
5-
6-impl Player {
7- /// The bottom region, full width under everything else: the timecode and
8- /// what is decoding, the ruler, the lanes and the subtitle strip. The edit
9- /// buttons are the row directly above it ([`Player::toolbar`]) -- the
10- /// arrangement every consumer editor shares, and the reason this is no
11- /// longer one "panel" that owned both.
12- pub(crate) fn timeline(
13- &self,
14- position: f64,
15- state: Transport,
16- viewport: Size<Pixels>,
17- cx: &mut Context<Self>,
18- ) -> impl IntoElement {
19- // Where the playhead is *on the bed*, in pixels from its left edge.
20- // Clamped to the bed because it is drawn as a width as well as an
21- // offset, and the view follows the playhead anyway, so it is never off
22- // the bed for long.
23- let bed_w = f32::from(self.ruler.get().size.width);
24- let filled = self.scale.px_at(position).clamp(0., bed_w);
25- let key = |action| self.keymap.display(action);
26- // The lanes the project has, or the pair a fresh one starts with so the
27- // panel reads the same before a file is open as after.
28- let lanes = self
29- .session
30- .as_ref()
31- .map_or_else(|| vec![Lane::V1, Lane::A1], PlaybackSession::lanes);
32- // A loop rather than a `map`: each row takes `cx` in turn, where a
33- // closure would hold it for as long as the iterator lives.
34- let mut rows = Vec::new();
35- for &lane in &lanes {
36- rows.push(self.lane_row(lane, filled, cx));
37- }
38- let (hint, filled) = if let Some(export) = self.exporting() {
39- // The words are the card's now ([`Player::export_progress_card`]):
40- // the export is modal, so this line is under its scrim and a second
41- // copy of the clocks there is one that can only be read dimmed. The
42- // ruler keeps the number -- it is the one part of the progress the
43- // card does not cover, and it costs nothing.
44- (String::new(), export.progress())
45- } else {
46- // The strokes no button carries; the rest ride on the buttons'
47- // tooltips. Keys first: at a 640 px window the tail is what a
48- // truncation eats, and the two hints at the end are also on the
49- // ruler's and Import's tooltips.
50- // While it plays, what is decoding it goes first: it is the
51- // answer that changes as the playhead crosses a cut, and the tail
52- // of this line is what a narrow window truncates.
53- // ...and ahead of even that, where the playhead is standing when
54- // that is a frame a cut is free at: it decides whether an export of
55- // this film is minutes of copying or hours of encoding, which is
56- // the one thing on this line worth interrupting the hints for.
57- let sync = match self.on_sync_point() {
58- true => "SYNC POINT — a cut here is copied, not re-encoded",
59- false => "",
60- };
61- (
62- join_detail(
63- sync,
64- &join_detail(
65- &self.live_decode(position, state.is_playing()),
66- &format!(
67- "{} copy · {} paste · {} undo · {} redo · click the bar to seek · \
68- drop a file to import",
69- key(ActionId::Copy),
70- key(ActionId::Paste),
71- key(ActionId::Undo),
72- key(ActionId::Redo)
73- ),
74- ),
75- ),
76- filled,
77- )
78- };
79- // What the region got, and what is left inside it for the lanes: the
80- // number a scroll is measured against, and the one the affordance below
81- // counts with. The line it costs is taken off the box before the count,
82- // or the row that says "1 more" would be the row hiding it.
83- // What the lane count asks for against its share of the window -- or
84- // what a hand dragged the seam above to, which wins both
85- // ([`Player::split_px`]).
86- //
87- // The scrollbar's geometry comes off the very view the wheel and the
88- // zoom write: `settled` is what those paths clamp to, so the thumb
89- // never disagrees with where the panel actually is. And with the whole
90- // timeline on the bed there is no strip at all -- nor a row reserved
91- // for one: the region, this box and the seam's floor all carry the
92- // strip's pixels or none of them do ([`timeline_fixed_h`]), so the
93- // lanes keep exactly the room they had at either side of the zoom
94- // that crosses the line.
95- let view = self.view();
96- let scrollable = view.duration > view.span();
97- let kinds: Vec<LaneKind> = lanes.iter().map(|lane| lane.kind).collect();
98- let region_h = self.split_px(Split::Timeline, viewport);
99- let lanes_box = (region_h - timeline_fixed_h(scrollable)).max(LANE_H);
100- let overflows = lanes.len() > lanes_shown_mixed(&kinds, lanes_box);
101- let lanes_box = match overflows {
102- true => (lanes_box - LABEL_H - 8.).max(LANE_H),
103- false => lanes_box,
104- };
105- let (thumb_x, thumb_w) = scroll_thumb(
106- view.bed,
107- view.duration,
108- view.scale.start.max(0.),
109- view.span(),
110- );
111- // Live, not a count of the lanes: the column reports where it has been
112- // taken to, so the line empties itself as the last track comes up
113- // instead of insisting there is still something below. The stack's own
114- // strip below reads the same number, so a thumb dragged there and a
115- // count the affordance lets go of cannot disagree.
116- let scrolled = -f32::from(self.lanes_scroll.offset().y);
117- let below = rows_below_mixed(&kinds, lanes_box, scrolled);
118- // The stack's own scrollbar: the thumb is the visible share of the
119- // lane rows, read straight off the column's own scroll state -- the
120- // box, the fold and how far down it has been taken are all the
121- // handle's to know, so nothing here is a second truth about any of
122- // them.
123- let stack = self.lanes_scroll.bounds();
124- let track_h = f32::from(stack.size.height);
125- let stack_max = f32::from(self.lanes_scroll.max_offset().height);
126- let (stack_y, stack_thumb_h) = lanes_thumb(track_h, track_h + stack_max, track_h, scrolled);
127- div()
128- .flex_none()
129- // Never more than its share of a short window: the lane column
130- // scrolls inside whatever it gets, and a timeline that pushes the
131- // picture off the screen at the 640x360 floor is not a timeline.
132- .h(px(region_h))
133- .flex()
134- .flex_col()
135- .gap(px(8.))
136- .px(px(12.))
137- .py(px(8.))
138- .bg(rgb(BG_TIMELINE()))
139- .border_t_1()
140- .border_color(rgb(STROKE_DIVIDER()))
141- .child(
142- div()
143- .flex_none()
144- .flex()
145- .items_center()
146- .gap(px(12.))
147- // Fixed width and one line: changing digits must not push
148- // the row around, nor wrap and change its height.
149- // The timeline's own length, never the drawn one: a tail
150- // being dragged inflates the bed to the room that edge has
151- // ([`Player::drawn_duration`]), and for a still that room is
152- // ten minutes -- a total that jumped to 10:00:00 the moment
153- // a picture's edge was pressed, and back on release.
154- .child(div().flex_none().w(px(TIME_W)).truncate().child(format!(
155- "{} / {}",
156- timecode(position, self.fps),
157- timecode(
158- self.session
159- .as_ref()
160- .map_or(0., PlaybackSession::timeline_duration),
161- self.fps
162- )
163- )))
164- .child(
165- div()
166- .flex_1()
167- .min_w(px(0.))
168- .truncate()
169- .text_size(px(11.))
170- .text_color(rgb(FG_SECONDARY()))
171- .child(hint),
172- ),
173- )
174- // Press to seek, drag to scrub: the move and release halves live on
175- // the root, since the pointer leaves the bar immediately. The bar
176- // stays 6 px to look at; the strip that takes the click is 24, so
177- // it can be hit without aiming (WCAG 2.5.8).
178- .child(
179- div()
180- .flex_none()
181- .flex()
182- .gap(px(HEADER_GAP))
183- // The lanes' header column, empty here: the ruler's own bar
184- // has to start where their beds start, or the playhead
185- // would point at a different moment in each row.
186- .child(div().flex_none().w(px(HEADER_W)))
187- .child(
188- div()
189- .id("ruler")
190- .flex_1()
191- .min_w(px(0.))
192- .h(px(RULER_HIT_H))
193- .flex()
194- .flex_col()
195- .justify_center()
196- .rounded(px(3.))
197- .cursor_pointer()
198- .hover(|s| s.bg(rgb(BG_HOVER_DIM())))
199- // The strip carries no text, so the tooltip is the only
200- // place it can say what it is.
201- .tooltip(|_, cx| {
202- cx.new(|_| {
203- Tip("Seek — click or drag; wheel scrolls, ctrl+wheel zooms"
204- .into())
205- })
206- .into()
207- })
208- // Ctrl+wheel zooms about the pointer and a bare one
209- // scrolls the view along -- [`Player::timeline_wheel`],
210- // the same answer the lanes below give, because a
211- // hand does not aim at a strip to zoom a timeline.
212- .on_scroll_wheel(cx.listener(
213- |this, event: &ScrollWheelEvent, _, cx| {
214- this.timeline_wheel(event, cx);
215- },
216- ))
217- .on_mouse_down(
218- MouseButton::Left,
219- cx.listener(|this, event: &MouseDownEvent, _, cx| {
220- this.scrubbing = true;
221- this.scrub_to(event.position.x, true, cx);
222- }),
223- )
224- .child(
225- div()
226- .w_full()
227- .h(px(6.))
228- .rounded(px(3.))
229- .bg(rgb(BG_RAISED()))
230- .child(bounds_probe(self.ruler.clone()))
231- .child(
232- div()
233- .h_full()
234- .w(px(filled))
235- .rounded(px(3.))
236- .bg(rgb(ACCENT_PRIMARY())),
237- )
238- // The export's own mark, in and out: drawn
239- // over the played fill rather than under it,
240- // so a range that starts behind the playhead
241- // still shows -- translucent, the same wash
242- // the silence marks use, so the ruler under
243- // it stays readable.
244- .children(self.range.map(|(start, end)| {
245- let left = self.scale.px_at(f64::from(start) / self.fps);
246- let right = self.scale.px_at(f64::from(end) / self.fps);
247- // The wash alone is the played fill's own
248- // color at lower alpha, so once the
249- // playhead has passed the whole band the
250- // two blend to one flat color and the mark
251- // vanishes. A tick at each boundary, in
252- // the theme's foreground rather than its
253- // accent, reads over either background.
254- div()
255- .absolute()
256- .top_0()
257- .h_full()
258- .left(px(left))
259- .w(px((right - left).max(1.)))
260- .rounded(px(3.))
261- .bg(rgba(ACCENT_WASH()))
262- .border_l(px(2.))
263- .border_r(px(2.))
264- .border_color(rgb(FG_PRIMARY()))
265- })),
266- ),
267- ),
268- )
269- // Every lane the project has, in its own order -- and its own
270- // column, so a project with more lanes than the panel is tall
271- // scrolls its tracks instead of pushing the picture off the window.
272- // The gap is the panel's own, so two lanes lay out exactly as they
273- // did when they were two children of it. The column sits in a
274- // relative box so the stack's own scrollbar can lie *over* the
275- // beds' right edge: a gutter beside them would take its width off
276- // the bed, and the ruler above would stop pointing at the moment
277- // the lanes are drawn at.
278- .child(
279- div()
280- .flex_1()
281- .min_h(px(0.))
282- .max_h(px(lanes_h(LANES_MAX)))
283- .relative()
284- .flex()
285- .flex_col()
286- .child(
287- div()
288- .id("lanes")
289- // Takes whatever the region has left and scrolls
290- // inside it: at the 640x360 floor the region is
291- // capped ([`TIMELINE_SHARE`]) and a fixed column
292- // would be clipped by it rather than scrolled.
293- .flex_1()
294- .min_h(px(0.))
295- .w_full()
296- .flex()
297- .flex_col()
298- .gap(px(8.))
299- .overflow_y_scroll()
300- .track_scroll(&self.lanes_scroll)
301- .children(rows),
302- )
303- // The lane stack's own scrollbar, drawn only while the
304- // stack overflows -- the same state the affordance below
305- // announces -- and never while the whole stack is on
306- // screen, where a full-height thumb would say nothing the
307- // lanes themselves do not. It costs the lanes nothing,
308- // being over the bed rather than out of it, and it is its
309- // own mouse region: a press there never reaches a clip.
310- .when(overflows, |d| {
311- d.child(
312- div()
313- .id("lanes-scroll")
314- .absolute()
315- .top_0()
316- .right_0()
317- .bottom_0()
318- .w(px(SCROLL_HIT))
319- .rounded(px(3.))
320- .cursor_pointer()
321- .hover(|s| s.bg(rgb(BG_HOVER_DIM())))
322- .tooltip(|_, cx| {
323- cx.new(|_| {
324- Tip("Scroll the tracks — drag the thumb or click to \
325- jump; the wheel scrolls them"
326- .into())
327- })
328- .into()
329- })
330- // The strip is its own mouse region, and it
331- // says so with an occluder: gpui's hit test
332- // stops here, so the clip a press lands on
333- // top of -- and the column's own native
334- // scroll, and the bed's time wheel behind
335- // that -- never hear anything through it.
336- // Occluding is also why the two drag
337- // listeners ride here and not only on the
338- // root: an occluder deafens the root to
339- // everything under it ([`drag_scrim`]'s
340- // lesson), and this thumb's drag runs along
341- // the strip's own 14 px -- the pointer never
342- // leaves the one place the root cannot hear.
343- // A drag that does leave it is picked up by
344- // the root's own copies, without a seam.
345- .occlude()
346- .on_scroll_wheel(cx.listener(
347- |this, event: &ScrollWheelEvent, window, cx| {
348- cx.stop_propagation();
349- let line = window.line_height();
350- let dy = f32::from(event.delta.pixel_delta(line).y);
351- this.lanes_wheel(dy, cx);
352- },
353- ))
354- .on_mouse_down(
355- MouseButton::Left,
356- cx.listener(|this, event: &MouseDownEvent, _, cx| {
357- cx.stop_propagation();
358- this.lanes_press(event.position.y, cx);
359- }),
360- )
361- // A right press is a clip's menu anywhere
362- // else on the bed; over the strip it is
363- // nothing, and the clip beneath must not
364- // answer it through the strip.
365- .on_mouse_down(MouseButton::Right, |_: &MouseDownEvent, _, cx| {
366- cx.stop_propagation()
367- })
368- .on_mouse_move(cx.listener(Player::drag_move))
369- .on_mouse_up(MouseButton::Left, cx.listener(Player::drag_release))
370- .child(
371- div()
372- .absolute()
373- .top_0()
374- .bottom_0()
375- .left(px((SCROLL_HIT - 6.) / 2.))
376- .w(px(6.))
377- .rounded(px(3.))
378- .bg(rgb(BG_RAISED()))
379- .child(
380- div()
381- .absolute()
382- .top(px(stack_y))
383- .h(px(stack_thumb_h))
384- .w_full()
385- .rounded(px(3.))
386- .bg(rgb(ACCENT_PRIMARY())),
387- ),
388- ),
389- )
390- }),
391- )
392- // The timeline's own scrollbar: the time axis is the one dimension
393- // the panel scrolls with no bar of its own, and until f69ba33 only
394- // the wheel and the keys reached it. The thumb is the visible share
395- // of the drawn duration and sits where that share is -- read off
396- // the very `Scale` every box is drawn through, so a wheel notch, a
397- // zoom about the pointer and the follow of the playhead all move
398- // it, because they all move the one state. The row exists only
399- // while there is somewhere to scroll to: zoomed out to the whole
400- // timeline the strip is not drawn and no pixels are held for it
401- // ([`timeline_fixed_h`]) -- a bar for a view that cannot move is a
402- // bar teaching nothing.
403- .when(scrollable, |d| {
404- d.child(
405- div()
406- .flex_none()
407- .flex()
408- .gap(px(HEADER_GAP))
409- // Under the lane headers like the ruler is above them, so
410- // the thumb and the bed it stands for line up.
411- .child(div().flex_none().w(px(HEADER_W)))
412- .child(
413- div()
414- .id("timeline-scroll")
415- .flex_1()
416- .min_w(px(0.))
417- .h(px(SCROLL_HIT))
418- .flex()
419- .flex_col()
420- .justify_center()
421- .rounded(px(3.))
422- .cursor_pointer()
423- .hover(|s| s.bg(rgb(BG_HOVER_DIM())))
424- .tooltip(|_, cx| {
425- cx.new(|_| {
426- Tip("Scroll the timeline — drag the thumb or click to \
427- jump; wheel scrolls, ctrl+wheel zooms"
428- .into())
429- })
430- .into()
431- })
432- // Both consumed here for the vertical strip's
433- // reason: the row sits over nothing today, but
434- // a press or a notch that fell through it
435- // would be a gesture the strip drew and the
436- // panel answered.
437- .on_scroll_wheel(cx.listener(
438- |this, event: &ScrollWheelEvent, _, cx| {
439- cx.stop_propagation();
440- this.timeline_wheel(event, cx);
441- },
442- ))
443- .on_mouse_down(
444- MouseButton::Left,
445- cx.listener(|this, event: &MouseDownEvent, _, cx| {
446- cx.stop_propagation();
447- this.scroll_press(event.position.x, cx);
448- }),
449- )
450- .child(
451- div()
452- .w_full()
453- .h(px(6.))
454- .rounded(px(3.))
455- .bg(rgb(BG_RAISED()))
456- .child(bounds_probe(self.scroll_track.clone()))
457- .child(
458- div()
459- .h_full()
460- .rounded(px(3.))
461- .left(px(thumb_x))
462- .absolute()
463- .top_0()
464- .w(px(thumb_w))
465- .bg(rgb(ACCENT_PRIMARY())),
466- ),
467- ),
468- ),
469- )
470- })
471- // "It scrolls" is not "it can be found": when the region is too
472- // short for every track -- which is what the 640x360 floor does to a
473- // three-track project -- the lanes below the fold say so, in the one
474- // place the eye is already looking. Its own flex_none row under a
475- // flex_1 column, so the thing announcing the overflow cannot be the
476- // thing the overflow pushes off the window.
477- .when(overflows, |d| {
478- d.child(
479- div()
480- .flex_none()
481- .h(px(LABEL_H))
482- .flex()
483- .items_center()
484- .justify_end()
485- .text_size(px(10.))
486- .text_color(rgb(match below {
487- 0 => FG_SECONDARY(),
488- _ => ACCENT_PRIMARY(),
489- }))
490- .child(match below {
491- // Over the track names, not over the beds: a wheel
492- // on a bed moves the *view* along the timeline now,
493- // so the column names its own scroll surface.
494- 0 => "the last track — scroll the names for the rest".to_string(),
495- 1 => "1 more track below — scroll the track names".to_string(),
496- n => format!("{n} more tracks below — scroll the track names"),
497- }),
498- )
499- })
500- }
501-
502- /// The subtitle tracks this timeline holds, under the media list: one row
503- /// each, the picked one marked, and a click makes another one the picked one
504- /// -- which is the whole of choosing between the two tracks of a film. A row
505- /// per track and no cycle: three of them is an ordinary number for a remux,
506- /// and a key that steps through three is a key nobody can aim.
507- ///
508- /// A track that could not be read is *here*, greyed and saying why, exactly
509- /// as a media row the timeline cannot take is: PGS subtitles are pictures,
510- /// and a film carrying four of them says so instead of listing nothing.
511- ///
512- /// Every row names the file it came out of itself, in words and in the tint
513- /// that file's clips wear on the lanes -- but only where there is more than
514- /// one file to tell apart, the way [`row_name`] numbers audio streams only
515- /// where a file gave several. There, each file's block is headed by its
516- /// name as well, its swatch and its track count -- always, whatever the
517- /// window's height, since the list under it scrolls (`SUB_ROWS_H`) rather
518- /// than the header being the thing a short window drops. A click on a
519- /// header folds its rows shut (`Player::sub_folded`) and a second one opens
520- /// them back -- a fold and not a cycle, so what a click does never depends
521- /// on what the last one did.
522- ///
523- /// `None` when there are none -- an empty heading is a section about
524- /// nothing.
525- pub(crate) fn subtitle_section(
526- &self,
527- width: f32,
528- cx: &mut Context<Self>,
529- ) -> Option<impl IntoElement> {
530- let tracks = self.session.as_ref()?.subtitles();
531- if tracks.is_empty() {
532- return None;
533- }
534- let groups = subtitle_rows(tracks);
535- // What the row's × says the way back is, in the stroke this keymap
536- // actually binds: a file's subtitles go on without the file.
537- let add_key = self.keymap.display(ActionId::ImportSubtitles);
538- // One file's tracks need no prefix saying which file: it is the only
539- // one, and every row would carry the same word.
540- let several_files = groups.len() > 1;
541- let headed = several_files;
542- let text_w = row_text_w(width);
543- let rows: Vec<_> = groups
544- .into_iter()
545- .enumerate()
546- .map(|(group_ord, SubGroup { name, path, rows })| {
547- // The file's own colour, the one its media rows and its clips
548- // wear -- and none at all for a standalone `.srt`, which came
549- // off no file on this timeline.
550- let tint = file_tint(self.sources(), &path);
551- let track_count = rows.len();
552- let numbered = rows.len() > 1;
553- let folded = self.sub_folded.contains(&path);
554- let fold_path = path.clone();
555- // The name twice over: all of it the header can hold, and the
556- // share of a row a prefix may take in front of the label.
557- let head = clip_middle(&name, text_w);
558- let prefix = clip_middle(&name, text_w * SUB_STEM_SHARE);
559- let rows: Vec<_> = rows
560- .into_iter()
561- .map(|row| {
562- let track = row.track;
563- let picked = track == self.sub_track;
564- let usable = row.refused.is_none();
565- // Two tracks off one remux that both say "eng" are told
566- // apart by their number and by nothing else -- the same
567- // count [`sub_pick_name`] echoes.
568- let title = match numbered {
569- true => format!("{} {}", row.label, row.number),
570- false => row.label,
571- };
572- // A standalone `.srt` is named after its own file, so
573- // the file in front of it says the same word twice
574- // ("Legend.of.… · Legend.of.…"). [`sub_pick_name`]'s
575- // rule, on the row it is about.
576- let owned = several_files && !title.starts_with(name.as_str());
577- // The whole path, never clipped: the row says which
578- // file, and the tooltip says which one on disk.
579- let tip: SharedString = match &row.refused {
580- Some(why) => format!("{} — {why}", path.display()),
581- None => format!(
582- "{} — drag it onto a subtitle track to place it; nothing is over \
583- the picture until it is placed",
584- path.display()
585- ),
586- }
587- .into();
588- // What the pointer carries onto a lane: the row's own
589- // name, the ghost a library row makes.
590- let carried: SharedString = title.clone().into();
591- // Named, because a × is the same glyph on every row and
592- // the tooltip is what says which track it takes off.
593- let remove_tip: SharedString = format!(
594- "Remove {title} from the palette — {} puts a file's subtitles \
595- back in it",
596- add_key
597- )
598- .into();
599- div()
600- // The *flat* index into the session's add-order
601- // list, which is what a pick is and what a save
602- // writes: the grouping moved the row on screen and
603- // never the track it stands for.
604- .id(("subtitle-track", track))
605- .flex_none()
606- .h(px(ROW_H))
607- .flex()
608- .items_center()
609- .gap(px(6.))
610- .pr(px(6.))
611- .rounded(px(3.))
612- .when(!usable, |d| d.text_color(rgb(FG_SECONDARY())).opacity(0.55))
613- .when(usable, |d| {
614- d.cursor_pointer()
615- .hover(|s| s.bg(rgb(BG_HOVER())))
616- // Dragged, the whole track goes down on the
617- // subtitle lane it is let go over -- the
618- // gesture a media row already answers to,
619- // on the list beside it. A track that could
620- // not be read carries nothing: there is
621- // nothing of it to place.
622- .on_drag(SubPick(track), move |_, _, _, cx| {
623- cx.new(|_| Tip(carried.clone()))
624- })
625- // Selects the row and shows nothing: a
626- // subtitle track reaches the picture by
627- // being placed on a subtitle lane, the way
628- // a film reaches it by being placed on a
629- // video one. What the selection is for is
630- // the × and the mark on the row.
631- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
632- this.sub_track = track;
633- cx.notify();
634- }))
635- })
636- .when(picked, |d| d.bg(rgb(BG_SELECTED())))
637- .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into())
638- // The media rows' bar, same width and hard against
639- // the same edge: one association across the panel
640- // and the lanes. Kept as room rather than dropped
641- // where there is no tint, so a standalone `.srt`
642- // still lines its words up with the rest.
643- .child(
644- div()
645- .flex_none()
646- .w(px(SWATCH_W))
647- .h_full()
648- .rounded(px(2.))
649- .when_some(tint, |d, tint| d.bg(rgb(tint))),
650- )
651- .child(
652- div()
653- .flex_1()
654- .min_w(px(0.))
655- .flex()
656- .flex_col()
657- .child(
658- div()
659- .flex()
660- .text_size(px(11.))
661- // In front, because the column
662- // truncates from the right: an
663- // ownership word at the end is a
664- // word the floor never shows.
665- .when(owned, |d| {
666- d.child(
667- div()
668- .flex_none()
669- // Said twice where a
670- // header says it above:
671- // still there, out of
672- // the way.
673- .when(headed, |d| {
674- d.text_color(rgb(FG_SECONDARY()))
675- })
676- .child(format!("{prefix} · ")),
677- )
678- })
679- .child(
680- div()
681- .flex_1()
682- .min_w(px(0.))
683- .truncate()
684- .child(title),
685- ),
686- )
687- .child(
688- div()
689- .truncate()
690- .text_size(px(10.))
691- .text_color(rgb(FG_SECONDARY()))
692- .child(row.detail),
693- ),
694- )
695- // The way back off the timeline, on every row and on
696- // the last one too -- a list of subtitles is allowed
697- // to be empty, unlike a lane. A `HIT_MIN` target and
698- // never hidden, the lane header's ×, and it stops
699- // the click there: the row under it picks a track,
700- // and picking the track that has just gone would
701- // leave the pick naming nothing.
702- .child(
703- div()
704- .id(("subtitle-remove", track))
705- .flex_none()
706- .w(px(HIT_MIN))
707- .h_full()
708- .flex()
709- .items_center()
710- .justify_center()
711- .rounded(px(3.))
712- .cursor_pointer()
713- .hover(|s| s.bg(rgb(BG_HOVER())))
714- .tooltip(move |_, cx| {
715- cx.new(|_| Tip(remove_tip.clone())).into()
716- })
717- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
718- cx.stop_propagation();
719- this.remove_subtitle_track(track, cx);
720- }))
721- .child("×"),
722- )
723- })
724- .collect();
725- div()
726- .flex_none()
727- .flex()
728- .flex_col()
729- .gap(px(2.))
730- // The header: which film these came out of, in words and not
731- // in colour alone -- a click folds its rows shut and a
732- // second click opens them, so it is its own `HIT_MIN`
733- // target rather than a bare label.
734- .when(headed, |d| {
735- d.child(
736- div()
737- .id(("subtitle-group-head", group_ord))
738- .flex_none()
739- .h(px(SUB_HEAD_H))
740- .flex()
741- .items_center()
742- .gap(px(6.))
743- .text_size(px(10.))
744- .text_color(rgb(FG_SECONDARY()))
745- .rounded(px(3.))
746- .cursor_pointer()
747- .hover(|s| s.bg(rgb(BG_HOVER())))
748- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
749- match this.sub_folded.remove(&fold_path) {
750- true => {}
751- false => {
752- this.sub_folded.insert(fold_path.clone());
753- }
754- }
755- cx.notify();
756- }))
757- // Folded / open, in the same glyph a fold uses
758- // everywhere else on this row list.
759- .child(match folded {
760- true => "▸",
761- false => "▾",
762- })
763- .when_some(tint, |d, tint| {
764- d.child(
765- div()
766- .flex_none()
767- .w(px(SWATCH_W))
768- .h_full()
769- .rounded(px(2.))
770- .bg(rgb(tint)),
771- )
772- })
773- .child(div().flex_1().min_w(px(0.)).truncate().child(head))
774- .child(match track_count {
775- 1 => "1 track".to_string(),
776- n => format!("{n} tracks"),
777- }),
778- )
779- })
780- .when(!(headed && folded), |d| d.children(rows))
781- })
782- .collect();
783- Some(
784- div()
785- .flex_none()
786- .flex()
787- .flex_col()
788- .gap(px(2.))
789- .child(
790- div()
791- .truncate()
792- .text_size(px(11.))
793- .text_color(rgb(FG_SECONDARY()))
794- .child(match self.subs_on {
795- // A palette and not a picker: none of these rows is
796- // "the one on screen" any more, so the heading names
797- // no track. What is on screen is on the subtitle
798- // lanes, each with its own eye.
799- true => "Subtitles",
800- // The mute's state where the tracks are listed: with
801- // it off no lane draws, however many are placed.
802- false => "Subtitles — hidden",
803- }),
804- )
805- .child(
806- div()
807- .id("subtitle-rows")
808- .flex()
809- .flex_col()
810- .gap(px(2.))
811- .max_h(px(SUB_ROWS_H))
812- .overflow_y_scroll()
813- .children(rows),
814- ),
815- )
816- }
817-
818- /// One lane of the edit list made visible: a fixed header saying which lane
819- /// it is, then a bed with a box per clip, placed and sized by its share of
820- /// the timeline. A cut adds a box without moving anything, a delete closes
821- /// the hole, a lift leaves one. A clip too narrow for its name says what it
822- /// is by its tint, and the tooltip is where every box says what clicking it
823- /// does. Never focusable, so the root keeps focus and the play binding still
824- /// works after a click (ledger:182).
825- pub(crate) fn lane_row(
826- &self,
827- lane: Lane,
828- // Where the playhead is on the bed, in pixels: worked out once by the
829- // panel so the ruler's line and every lane's draw the same one.
830- filled: f32,
831- cx: &mut Context<Self>,
832- // Borrows nothing it was given (`use<>`): the rows are built one after
833- // another into a list, and a row still holding `cx` would be the only
834- // one that could be built.
835- ) -> impl IntoElement + use<> {
836- // The mapping, copied out once: every box in the row is placed through
837- // it, so all of them move together when it does. No bed width is needed
838- // to place them any more -- a second is so many pixels wherever it is.
839- let scale = self.scale;
840- // How much bed there is to be seen on, measured off the ruler's own
841- // probe like every other question about it: what a box draws *inside*
842- // itself is clipped to this ([`visible_slice`]), because a box at a deep
843- // zoom is far wider than the strip it is being watched through.
844- let bed = f32::from(self.ruler.get().size.width);
845- // Where the snap line stands, in the same pixels every box is placed
846- // through -- and only while a gesture is actually live: gpui drops a
847- // drag without telling anyone, so this asks whether one is in flight
848- // (`App::has_active_drag`) rather than remembering that one was.
849- let cue = self
850- .snap_cue
851- .filter(|_| self.trim.is_some() || cx.has_active_drag())
852- .map(|frame| scale.px_at(f64::from(frame) / self.fps));
853- // The shadow (or shadows, on a set-drag -- [`Player::preview_ghost`]),
854- // on the one lane each names -- and, like the line, only while the
855- // drag that asked for it is still in flight.
856- let ghost: Vec<Ghost> = self
857- .ghost
858- .iter()
859- .copied()
860- .filter(|g| g.lane == lane && cx.has_active_drag())
861- .collect();
862- let clips = self
863- .session
864- .as_ref()
865- .map_or(&[][..], |session| session.lane_clips(lane));
866- // The group ids some *other* lane carries: a clip whose id is in here
867- // has a half elsewhere, and one whose is not is a detached half however
868- // many lanes there are.
869- // The group ids some *other* lane carries, on either of its lists: a
870- // placement whose id is in here has a half elsewhere -- a clip on
871- // another track, or a caption pinned to this clip -- and one whose is
872- // not is detached however many lanes there are.
873- let others: Vec<u32> = self.session.as_ref().map_or_else(Vec::new, |session| {
874- session
875- .lanes()
876- .into_iter()
877- .filter(|&other| other != lane)
878- .flat_map(|other| {
879- let clips = session.lane_clips(other).iter().filter_map(|c| c.link);
880- let subs = session.sub_lane(other).iter().filter_map(|s| s.link);
881- clips.chain(subs)
882- })
883- .collect()
884- });
885- let name = lane.label();
886- let row_id: SharedString = format!("{name}-clip").into();
887- let remove_id: SharedString = format!("{name}-remove").into();
888- let header_id: SharedString = format!("{name}-header").into();
889- let header_tip: SharedString =
890- format!("{name} — drag this header onto another to reorder the tracks").into();
891- // The header ghost, the same shape a clip's is: the track's own name
892- // under the pointer, so what is in the hand is legible while it moves.
893- let header_ghost: SharedString = name.clone().into();
894- // The line this row draws between itself and its neighbour while a
895- // header is being carried -- and, like every other drag cue here, only
896- // while the gesture is still in flight.
897- let drop = self
898- .lane_drop
899- .filter(|d| d.lane == lane && cx.has_active_drag());
900- let remove_tip: SharedString = format!(
901- "Remove {name} — it must be empty first, and {} brings it back",
902- self.keymap.display(ActionId::Undo)
903- )
904- .into();
905- let sources = self
906- .session
907- .as_ref()
908- .map_or(&[][..], PlaybackSession::sources);
909- let (picks, pick_links) = self.marks();
910- let audio = lane.kind == LaneKind::Audio;
911- // A subtitle lane holds no `Clip` and every other lane holds no
912- // `SubClip`, so the two lists below are never both full and the bed
913- // draws whichever it was given -- one row, and no second kind of row to
914- // keep in step with this one.
915- let sub = lane.kind == LaneKind::Subtitle;
916- let shown = self.sub_lane_on(lane);
917- let subs: Vec<SubClip> = match (sub, &self.session) {
918- (true, Some(session)) => session.sub_lane(lane).to_vec(),
919- _ => Vec::new(),
920- };
921- // Where this lane's words actually are on this timeline
922- // ([`PlaybackSession::sub_lane_cues`], the same map an export and the
923- // plate over the picture go through): the marks inside the placements'
924- // boxes, so a caption's box says where in it anybody speaks.
925- let cues: Vec<(f32, f32)> = match (sub, &self.session) {
926- (true, Some(session)) => session
927- .sub_lane_cues(lane)
928- .iter()
929- .map(|cue| cue_box(scale, cue))
930- .collect(),
931- _ => Vec::new(),
932- };
933- // Thinner than a media lane's ([`SUB_LANE_H`]), so its header has room
934- // for one `HIT_MIN` target and not the two a stacked eye-and-remove
935- // pair would need -- the right button carries the remove instead, the
936- // same door a caption's own box already answers to (`sub_tip`), so a
937- // track that used to have its own × still has one, just not a second
938- // row to draw it in.
939- let eye_tip: SharedString = match shown {
940- true => format!(
941- "{name} is the track shown over the picture — the right button removes it, empty \
942- first, and {} brings it back",
943- self.keymap.display(ActionId::Undo)
944- ),
945- false => format!(
946- "Click to show {name} over the picture instead — one subtitle track is drawn at a \
947- time, and an export carries every one of them; the right button removes it, empty \
948- first, and {} brings it back",
949- self.keymap.display(ActionId::Undo)
950- ),
951- }
952- .into();
953- // What a caption's box says clicking it does; the media boxes' tooltip
954- // names edits a placement has none of (no group, no speed, no ripple).
955- let sub_tip: SharedString =
956- "Drag it along the lane or onto another subtitle track, an end to trim it, x or the \
957- right button takes it off"
958- .into();
959- // What this track plays at, on the header it belongs to: shown only
960- // when it is not unity, because a column 40 px wide has room for a
961- // number or for a name, and the name is what a header is for. The
962- // press opens the mix card on this very track.
963- let gain_db = self
964- .session
965- .as_ref()
966- .map_or(0., |session| session.lane_gain_db(lane));
967- let gain_tip: SharedString = format!(
968- "{name} plays at {gain_db:+.0} dB — opens the mix ({}); the whole track, every frequency, unlike the equalizer",
969- self.keymap.display(ActionId::Mix)
970- )
971- .into();
972- let tip: SharedString = format!(
973- "Select (or {} under the playhead, {}/{} along the lane) — drag it to move it, an end to trim, {} removes the take, {} leaves a gap, {} rejoins a cut",
974- self.keymap.display(ActionId::Select),
975- self.keymap.display(ActionId::SelectPrev),
976- self.keymap.display(ActionId::SelectNext),
977- self.keymap.display(ActionId::Delete),
978- self.keymap.display(ActionId::Lift),
979- self.keymap.display(ActionId::Regroup)
980- )
981- .into();
982- div()
983- .flex_none()
984- .h(px(lane_h(lane.kind)))
985- .flex()
986- .gap(px(HEADER_GAP))
987- // A header let go anywhere along this row lands the track in the
988- // hand in this row's place: the whole width is the target, not the
989- // 40 px column, because a slot is what is being aimed at. The bed's
990- // own drops carry other payloads and never see this one.
991- .relative()
992- .on_drop(cx.listener(move |this, drag: &LaneDrag, _, cx| {
993- this.reorder_lane(drag.0, lane, cx);
994- }))
995- .on_drag_move(
996- cx.listener(move |this, event: &DragMoveEvent<LaneDrag>, _, cx| {
997- // Carried off this row, the line it was promising goes with
998- // it: a cue left painted over a slot a release out here does
999- // not commit is the drag saying one thing and the drop
1000- // doing another. Its *own* promise only -- gpui runs this on
1001- // every painted row, not just the one under the pointer, so
1002- // a row that cleared the cue outright would rub out the line
1003- // the hovered row had just drawn.
1004- if !event.bounds.contains(&event.event.position) {
1005- return this.forget_lane_drop(lane, cx);
1006- }
1007- this.preview_lane_drop(event.drag(cx).0, lane, cx);
1008- }),
1009- )
1010- // The fixed column the ruler above is offset by as well. Full lane
1011- // height, so it reads as the bed continuing rather than as a chip.
1012- .child(
1013- div()
1014- // Dragged, the whole track moves in the stack -- the
1015- // gesture every editor reorders tracks with, and the reason
1016- // the column is a handle rather than a caption.
1017- .id(header_id)
1018- .cursor(CursorStyle::OpenHand)
1019- .tooltip(move |_, cx| cx.new(|_| Tip(header_tip.clone())).into())
1020- .on_drag(LaneDrag(lane), move |_, _, _, cx| {
1021- cx.new(|_| Tip(header_ghost.clone()))
1022- })
1023- .flex_none()
1024- .w(px(HEADER_W))
1025- .h_full()
1026- .flex()
1027- .flex_col()
1028- .items_center()
1029- .justify_center()
1030- .rounded(px(3.))
1031- .bg(rgb(BG_RAISED()))
1032- .text_size(px(11.))
1033- .text_color(rgb(FG_SECONDARY()))
1034- .child(match audio {
1035- // A button, not a label: the one setting a track has of
1036- // its own used to be reachable from nowhere.
1037- true => div()
1038- .id(("mix-lane", lane.ord))
1039- .flex_1()
1040- .w_full()
1041- .flex()
1042- .items_center()
1043- .justify_center()
1044- .rounded(px(3.))
1045- .cursor_pointer()
1046- .hover(|s| s.bg(rgb(BG_HOVER())))
1047- .tooltip(move |_, cx| cx.new(|_| Tip(gain_tip.clone())).into())
1048- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
1049- this.open_mix(Some(lane), cx)
1050- }))
1051- .child(match gain_db == 0. {
1052- true => name.clone(),
1053- false => format!("{name} {gain_db:+.0}"),
1054- })
1055- .into_any_element(),
1056- // A subtitle track's own one setting, in the same
1057- // place and for the same reason: whether *this* lane is
1058- // the one drawn over the picture. A radio and not an
1059- // eye -- one track shows at a time, so a click here
1060- // takes the picture off whichever lane had it -- and
1061- // `HIT_MIN` tall like the mix button it sits where.
1062- // The lit dot and the accent tell the shown lane from
1063- // the rest of a stack of them at a glance.
1064- // One line, not name-over-dot: at `SUB_LANE_H` the
1065- // whole header is one `HIT_MIN` target, and the
1066- // shown/hidden state is already the colour, the
1067- // background and the border below -- a second line
1068- // saying the same thing again is a line this row no
1069- // longer has the height to spare.
1070- false if sub => div()
1071- .id(("show-lane", lane.ord))
1072- .flex_1()
1073- .w_full()
1074- .flex()
1075- .items_center()
1076- .justify_center()
1077- .rounded(px(3.))
1078- .cursor_pointer()
1079- .hover(|s| s.bg(rgb(BG_HOVER())))
1080- .when(!shown, |d| d.text_color(rgb(FG_DISABLED())))
1081- .when(shown, |d| {
1082- d.text_color(rgb(ACCENT_PRIMARY()))
1083- .bg(rgb(BG_HOVER()))
1084- .border_1()
1085- .border_color(rgb(ACCENT_PRIMARY()))
1086- })
1087- .tooltip(move |_, cx| cx.new(|_| Tip(eye_tip.clone())).into())
1088- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
1089- this.show_sub_lane(lane, cx)
1090- }))
1091- // The remove door a stacked second row used to be,
1092- // on the same button now: the right button is
1093- // already how a caption's own box takes itself
1094- // off the lane (`sub_tip`), so the header answers
1095- // to it too rather than spending a second
1096- // `HIT_MIN` row on a thin lane that has none to
1097- // spare.
1098- .on_mouse_down(
1099- MouseButton::Right,
1100- cx.listener(move |this, _: &MouseDownEvent, _, cx| {
1101- this.remove_lane(lane, cx)
1102- }),
1103- )
1104- .child(name.clone())
1105- .into_any_element(),
1106- false => div()
1107- .flex_1()
1108- .flex()
1109- .items_center()
1110- .child(name.clone())
1111- .into_any_element(),
1112- })
1113- // The one thing a media header does: take this track away
1114- // again. A `HIT_MIN` target rather than a glyph-sized one,
1115- // and it stays put on a track holding clips instead of
1116- // hiding -- the refusal names them, and a control that
1117- // vanishes teaches nothing. A subtitle lane's remove lives
1118- // on the eye button instead ([`eye_tip`]) -- this row is
1119- // thin enough for one `HIT_MIN` target, not two.
1120- .when(!sub, |d| {
1121- d.child(
1122- div()
1123- .id(remove_id)
1124- .flex_none()
1125- .w_full()
1126- .h(px(HIT_MIN))
1127- .flex()
1128- .items_center()
1129- .justify_center()
1130- .rounded(px(3.))
1131- .cursor_pointer()
1132- .hover(|s| s.bg(rgb(BG_HOVER())))
1133- .tooltip(move |_, cx| cx.new(|_| Tip(remove_tip.clone())).into())
1134- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
1135- this.remove_lane(lane, cx)
1136- }))
1137- .child("×"),
1138- )
1139- }),
1140- )
1141- .child(
1142- // Clips are placed at their own start rather than queued edge
1143- // to edge: a lift leaves a hole in the lane, and the bare bed
1144- // showing through it *is* how a gap looks.
1145- div()
1146- .relative()
1147- .flex_1()
1148- .min_w(px(0.))
1149- .h_full()
1150- .rounded(px(3.))
1151- .bg(rgb(BG_TIMELINE()))
1152- .overflow_hidden()
1153- // The wheel over the clips themselves, which is where a
1154- // hand already is: ctrl zooms about the pointer, bare
1155- // scrolls the view along ([`Player::timeline_wheel`]).
1156- // Stopped here, because gpui runs the lane *column's* own
1157- // overflow scroll on the same notch (div.rs:2403) and a
1158- // gesture that slid the view sideways and the tracks upward
1159- // at once is two answers to one notch. The track headers
1160- // beside this bed are still the column's scroll surface.
1161- .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| {
1162- cx.stop_propagation();
1163- this.timeline_wheel(event, cx);
1164- }))
1165- // A library row let go over a lane is the same insert the
1166- // Add button makes, through the same call -- but where the
1167- // pointer let it go, not at the playhead: a hand that
1168- // carried a file to a place on the bed named that place.
1169- // gpui hands a drop no event, so the pointer is read off
1170- // the window, which took it from the release that fired
1171- // this (gpui window.rs:3602).
1172- .on_drop(cx.listener(move |this, drag: &AssetDrag, window, cx| {
1173- // Onto the edges near it, exactly as a clip carried by
1174- // hand lands: the line drawn while it was in flight is
1175- // the frame it goes down on.
1176- let at = this.place_frame(window.mouse_position().x).0;
1177- this.insert_source(&drag.0.clone(), drag.1, Some(lane), Some(at), cx)
1178- }))
1179- .drag_over::<AssetDrag>(|s, _, _, _| s.bg(rgb(BG_HOVER_DIM())))
1180- // The shadow of the row in flight, drawn by the lane the
1181- // pointer is inside: `on_drag_move` fires on every painted
1182- // element while a drag of its type is live, wherever the
1183- // pointer is, and hands each one its own box -- which is how
1184- // a lane knows the pointer is over *it* (gpui div.rs:282).
1185- // The root cleared it a moment ago, so exactly one lane
1186- // draws one.
1187- .on_drag_move(cx.listener(
1188- move |this, event: &DragMoveEvent<AssetDrag>, _, cx| {
1189- if !event.bounds.contains(&event.event.position) {
1190- return;
1191- }
1192- let path = event.drag(cx).0.clone();
1193- this.preview_ghost_asset(&path, lane, event.event.position.x, cx);
1194- },
1195- ))
1196- // ...and a clip let go over a lane lands the same way: on
1197- // the track it was dropped on, at the frame it was carried
1198- // to -- its own included, which is the drag that moves a
1199- // take along its track.
1200- .on_drop(cx.listener(move |this, drag: &ClipDrag, window, cx| {
1201- // Against the lane as it is *now* ([`Player::dragged`]),
1202- // and then snapped by `move_clip` like any other drop:
1203- // which clip is being moved and where it lands are two
1204- // questions, and this is the first one.
1205- let Some(idx) = this.dragged(drag) else {
1206- return;
1207- };
1208- this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx)
1209- }))
1210- .drag_over::<ClipDrag>(|s, _, _, _| s.bg(rgb(BG_HOVER_DIM())))
1211- // ...and the same shadow for the clip in the hand, seated on
1212- // this lane when the pointer is inside it.
1213- .on_drag_move(cx.listener(
1214- move |this, event: &DragMoveEvent<ClipDrag>, _, cx| {
1215- if !event.bounds.contains(&event.event.position) {
1216- return;
1217- }
1218- let drag = *event.drag(cx);
1219- this.preview_ghost(&drag, lane, event.event.position.x, cx);
1220- },
1221- ))
1222- // A palette row let go over a lane places that whole
1223- // subtitle track where the hand left it -- and over a lane
1224- // that is not a subtitle one, `place_sub` refuses it in
1225- // words, which is why the listener is on every bed rather
1226- // than on the subtitle beds alone.
1227- .on_drop(cx.listener(move |this, drag: &SubPick, window, cx| {
1228- this.place_sub(drag.0, lane, window.mouse_position().x, cx);
1229- }))
1230- .drag_over::<SubPick>(|s, _, _, _| s.bg(rgb(BG_HOVER_DIM())))
1231- .on_drag_move(cx.listener(
1232- move |this, event: &DragMoveEvent<SubPick>, _, cx| {
1233- if !event.bounds.contains(&event.event.position) {
1234- return;
1235- }
1236- let track = event.drag(cx).0;
1237- this.preview_ghost_pick(track, lane, event.event.position.x, cx);
1238- },
1239- ))
1240- // ...and a caption already on a lane moves along it, or onto
1241- // another subtitle track, exactly as a clip does.
1242- .on_drop(cx.listener(move |this, drag: &SubDrag, window, cx| {
1243- this.move_sub(drag, lane, window.mouse_position().x, cx);
1244- }))
1245- .drag_over::<SubDrag>(|s, _, _, _| s.bg(rgb(BG_HOVER_DIM())))
1246- .on_drag_move(cx.listener(
1247- move |this, event: &DragMoveEvent<SubDrag>, _, cx| {
1248- if !event.bounds.contains(&event.event.position) {
1249- return;
1250- }
1251- let drag = *event.drag(cx);
1252- this.preview_ghost_sub(&drag, lane, event.event.position.x, cx);
1253- },
1254- ))
1255- .children(clips.iter().enumerate().map(|(i, clip)| {
1256- // The clip as the lane holds it, for the drag payload:
1257- // what a drop looks itself up by has to be the placed
1258- // clip, never the preview an edge drag is drawing.
1259- let placed = *clip;
1260- // What a drag on an edge is showing, which is the clip
1261- // itself while nothing is being dragged.
1262- let clip = &self.trimmed(lane, i, *clip);
1263- // Its *timeline* length, which a speed halves or
1264- // quadruples: the box is as wide as the clip is long
1265- // where it sits, not as long as the source it reads.
1266- let (start, len) = (
1267- f64::from(clip.start) / self.fps,
1268- f64::from(clip.frames()) / self.fps,
1269- );
1270- let on = marked((lane, i), clip.link, &picks, &pick_links);
1271- // A group with a half in the other lane wears its tint;
1272- // one without is outlined, so a detached half is visible
1273- // as detached before anyone clicks it.
1274- let grouped = clip.link.is_some_and(|link| others.contains(&link));
1275- // Tinted by *file*, not by source entry: two audio
1276- // streams of one file are two sources, and the library
1277- // gives them one swatch because they are one file.
1278- let tint = self.clip_tint(clip.source);
1279- // ...and painted by *kind*, which is the one thing a
1280- // glance down a timeline has to answer: video blue,
1281- // audio green, a still teal, the cues purple, the way
1282- // every editor with more than one track colours them.
1283- // The source tint stays the identity of the file and is
1284- // the border and the library swatch.
1285- let kind = clip_kind(
1286- lane.kind,
1287- sources
1288- .get(clip.source)
1289- .is_some_and(|s| engine::is_image(&s.path)),
1290- );
1291- // What the clip is worth in pixels, and how wide its box
1292- // is drawn -- the two part company on a take too short
1293- // to be hit at this zoom ([`clip_width`]).
1294- let span = scale.width_px(len);
1295- let width = clip_width(span);
1296- let left = scale.px_at(start);
1297- // The slice of this box that is on the bed: where its
1298- // name, its badge and its waveform go, so none of the
1299- // three is drawn out at a zoomed-in box's own edges.
1300- let (vis_x, vis_w) = visible_slice(left, width, bed);
1301- let label = sources.get(clip.source).map(|s| file_name(&s.path));
1302- let wave = sources
1303- .get(clip.source)
1304- .and_then(|s| self.waves.get(&(s.path.clone(), s.audio_stream)))
1305- .cloned();
1306- // The source seconds that slice plays -- not the clip's
1307- // whole range: the envelope is drawn for the part of the
1308- // box that can be seen, at the resolution of the pixels
1309- // it actually has, and never one column per two pixels
1310- // of a box millions of pixels wide.
1311- let along = |x: f32| match width > 0. {
1312- true => {
1313- f64::from(clip.in_frame)
1314- + f64::from(clip.out_frame - clip.in_frame)
1315- * f64::from(x / width)
1316- }
1317- false => f64::from(clip.in_frame),
1318- };
1319- let (from, to) = (along(vis_x) / self.fps, along(vis_x + vis_w) / self.fps);
1320- let tip = tip.clone();
1321- // What the pointer carries on the way to another lane:
1322- // the file the box is showing, the same ghost a library
1323- // row makes. A box too narrow for its own label still
1324- // says what is moving.
1325- let ghost: SharedString =
1326- label.clone().unwrap_or_else(|| lane.label()).into();
1327- // Its head in frames, for the press below: the `start`
1328- // above is the same moment in seconds, which is what
1329- // the box is *drawn* from.
1330- let head = clip.start;
1331- div()
1332- // Named per lane: two rows numbering their clips
1333- // from zero would hand gpui the same id twice.
1334- .id((row_id.clone(), i))
1335- .absolute()
1336- .top_0()
1337- .h_full()
1338- // Negative once the clip's head has been scrolled
1339- // off the left edge: the bed clips what hangs out
1340- // of it, so a half-visible clip is drawn as the
1341- // half of itself that is on screen.
1342- .left(px(left))
1343- .w(px(width))
1344- .overflow_hidden()
1345- .rounded(px(3.))
1346- .border_1()
1347- .border_color(rgb(if on {
1348- STROKE_SELECTED()
1349- } else if grouped {
1350- tint
1351- } else {
1352- FG_SECONDARY()
1353- }))
1354- .bg(rgb(if on { BG_SELECTED() } else { kind }))
1355- .cursor_pointer()
1356- .hover(|s| s.border_color(rgb(ACCENT_PRIMARY())))
1357- .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into())
1358- // Dragged, it *moves*: to the frame it was let go on
1359- // and to the lane it was let go over. The click that
1360- // starts the drag still selects, so picking a clip
1361- // up and putting it back down where it was is
1362- // exactly a click.
1363- .on_drag(
1364- ClipDrag {
1365- lane,
1366- idx: i,
1367- clip: placed,
1368- },
1369- move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())),
1370- )
1371- .on_mouse_down(
1372- MouseButton::Left,
1373- cx.listener(move |this, event: &MouseDownEvent, _, cx| {
1374- // Where in the box the hand took hold of it,
1375- // for the drag this press may become: the
1376- // clip has to move with the pointer rather
1377- // than jump its head under it.
1378- this.grab =
1379- this.frame_under(event.position.x).saturating_sub(head);
1380- // Ctrl held, the pick joins the selection
1381- // instead of replacing it -- the toggle a
1382- // group is assembled by hand with.
1383- this.pick((lane, i), event.modifiers.control, cx);
1384- }),
1385- )
1386- // A plain click collapses a multi-pick to this one
1387- // clip -- `pick` above deliberately keeps the whole
1388- // set on the press so a set-drag has something to
1389- // move; gpui drops the pending click once a drag
1390- // starts, so this only fires on a press-release
1391- // with no drag between.
1392- .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
1393- if !press_modifiers(event).control {
1394- this.select((lane, i), cx);
1395- }
1396- }))
1397- // The right button selects exactly as the left one
1398- // does -- the menu acts on the clip it names, so
1399- // opening one has to pick it -- and then hangs the
1400- // menu at the pointer.
1401- .on_mouse_down(
1402- MouseButton::Right,
1403- cx.listener(move |this, event: &MouseDownEvent, _, cx| {
1404- this.open_menu(lane, i, event.position, cx);
1405- }),
1406- )
1407- // The two strips a drag *lengthens* the clip by,
1408- // one at each end. They occlude the box behind
1409- // them, which is what keeps one gesture one thing:
1410- // a press here trims, a press anywhere else on the
1411- // box still starts the move to another lane.
1412- //
1413- // Asked of the clip's own width and not of the box's
1414- // floor: a take drawn at `HIT_MIN` because it is
1415- // shorter than that has no *pixels* to trim by -- one
1416- // would move it by seconds -- so it keeps all of its
1417- // padded box as a body to select and drag by, and is
1418- // trimmed after zooming in, exactly as [`trims`] says.
1419- .children(
1420- [Edge::Start, Edge::End]
1421- .into_iter()
1422- .filter(|_| trims(span))
1423- .map(|edge| {
1424- let mut zone = div()
1425- .absolute()
1426- .top_0()
1427- .h_full()
1428- .w(px(EDGE_W))
1429- .occlude()
1430- .cursor(CursorStyle::ResizeLeftRight)
1431- .hover(|s| s.bg(rgb(ACCENT_PRIMARY())))
1432- .on_mouse_down(
1433- MouseButton::Left,
1434- cx.listener(
1435- move |this, event: &MouseDownEvent, _, cx| {
1436- this.start_trim(
1437- lane,
1438- i,
1439- edge,
1440- event.modifiers.control,
1441- cx,
1442- );
1443- },
1444- ),
1445- )
1446- // ...and occluding takes the *wheel* off
1447- // the lane's bed with it (gpui stops the
1448- // hit test at an occluder, ancestors
1449- // included), so a notch aimed at a cut --
1450- // the one place a hand aims when it wants
1451- // to see a cut closer -- would be a dead
1452- // strip. The same answer as the bed's.
1453- .on_scroll_wheel(cx.listener(
1454- |this, event: &ScrollWheelEvent, _, cx| {
1455- cx.stop_propagation();
1456- this.timeline_wheel(event, cx);
1457- },
1458- ))
1459- // Occluded, so the box's own right-button
1460- // listener never fires here: the menu is
1461- // the same menu, opened by the same call.
1462- .on_mouse_down(
1463- MouseButton::Right,
1464- cx.listener(
1465- move |this, event: &MouseDownEvent, _, cx| {
1466- this.open_menu(lane, i, event.position, cx);
1467- },
1468- ),
1469- );
1470- zone = match edge {
1471- Edge::Start => zone.left_0(),
1472- Edge::End => zone.right_0(),
1473- };
1474- zone
1475- }),
1476- )
1477- // Under the label row, never through it.
1478- .children(wave.filter(|_| audio && vis_w > 0.).and_then(|wave| {
1479- let inner: AnyElement = match wave {
1480- Wave::Peaks(peaks) => {
1481- waveform(peaks, from, to).into_any_element()
1482- }
1483- // A bed while the decode runs, and dimmer
1484- // than any waveform is drawn: a flat
1485- // `FG_SECONDARY` line here would be the shape a
1486- // silent file makes, which this file is not
1487- // known to be yet.
1488- Wave::Loading => div()
1489- .h_full()
1490- .flex()
1491- .items_center()
1492- .child(div().w_full().h(px(1.)).bg(rgb(BG_HOVER())))
1493- .into_any_element(),
1494- // No audio track: nothing, never a fake.
1495- Wave::Silent => return None,
1496- // Could not be read: a band that says so in
1497- // words, because the empty band a silent
1498- // file draws would claim this file has no
1499- // sound. The reason itself went to the log.
1500- Wave::Failed => div()
1501- .h_full()
1502- .flex()
1503- .items_center()
1504- .justify_center()
1505- .truncate()
1506- .text_size(px(9.))
1507- .text_color(rgb(FG_SECONDARY()))
1508- .child("audio unreadable")
1509- .into_any_element(),
1510- };
1511- Some(
1512- div()
1513- .absolute()
1514- .left(px(vis_x))
1515- .w(px(vis_w))
1516- .top(px(LABEL_H))
1517- .bottom_0()
1518- .child(inner),
1519- )
1520- }))
1521- // The fades: a translucent wedge at each end an
1522- // audio clip ramps, drawn over the waveform the way
1523- // every editor shades a fade. Width comes straight
1524- // off the clip's own frames, never off the visible
1525- // slice -- unlike the waveform a wedge that starts
1526- // off the left edge of the bed still shades the
1527- // clip's own corner once scrolled back into view,
1528- // because `overflow_hidden` on the box already
1529- // clips it, and clamped to the box's own width so a
1530- // fade longer than a zoomed-in clip never draws
1531- // past its neighbour.
1532- .when(audio, |d| {
1533- let fade_in = self.shown_fade_in(lane, i, clip);
1534- let fade_out = self.shown_fade_out(lane, i, clip);
1535- d.children(
1536- [
1537- (fade_in > 0).then(|| {
1538- div()
1539- .absolute()
1540- .left_0()
1541- .top_0()
1542- .h_full()
1543- .w(px(scale
1544- .width_px(f64::from(fade_in) / self.fps)
1545- .min(width)))
1546- .child(fade_wedge(true))
1547- }),
1548- (fade_out > 0).then(|| {
1549- div()
1550- .absolute()
1551- .right_0()
1552- .top_0()
1553- .h_full()
1554- .w(px(scale
1555- .width_px(f64::from(fade_out) / self.fps)
1556- .min(width)))
1557- .child(fade_wedge(false))
1558- }),
1559- ]
1560- .into_iter()
1561- .flatten(),
1562- )
1563- })
1564- // The dissolve: a small X astride the join, drawn
1565- // over the last `transition_out` frames of this
1566- // clip's own box, whenever the next clip on the
1567- // lane actually abuts it -- the engine already
1568- // refuses `transition_out` on anything else
1569- // ([`Project::set_transition_out`]), but a moved
1570- // neighbour can leave a stale value behind, so
1571- // this checks the join itself rather than trust
1572- // the field alone.
1573- .when(
1574- lane.kind == LaneKind::Video
1575- && clip.transition_out > 0
1576- && clips.get(i + 1).is_some_and(|n| n.start == clip.end()),
1577- |d| {
1578- d.child(
1579- div()
1580- .absolute()
1581- .right_0()
1582- .top_0()
1583- .h_full()
1584- .w(px(scale
1585- .width_px(f64::from(clip.transition_out) / self.fps)
1586- .min(width)))
1587- .child(dissolve_glyph()),
1588- )
1589- },
1590- )
1591- // The fade handles: a small grab corner at each
1592- // *top* of an audio clip's box, sitting just
1593- // inside the [`EDGE_W`] trim strip rather than on
1594- // top of it -- [`FADE_HANDLE_H`] never reaches
1595- // past the label row, so a trim's own strip (the
1596- // box's *full* height) is still the whole of what
1597- // a press below the label starts. Gated on
1598- // [`trims`] like the trim strips themselves: a box
1599- // too small for an edge to trim by is too small
1600- // for a fade handle either.
1601- .when(audio && trims(span), |d| {
1602- d.children([Edge::Start, Edge::End].into_iter().map(|edge| {
1603- let is_in = edge == Edge::Start;
1604- let mut handle = div()
1605- .absolute()
1606- .top_0()
1607- .w(px(FADE_HANDLE_W))
1608- .h(px(FADE_HANDLE_H))
1609- .occlude()
1610- .cursor(CursorStyle::ResizeLeftRight)
1611- .hover(|s| s.bg(rgb(ACCENT_PRIMARY())))
1612- .on_mouse_down(
1613- MouseButton::Left,
1614- cx.listener(
1615- move |this, event: &MouseDownEvent, _, cx| {
1616- this.start_fade_drag(
1617- lane,
1618- i,
1619- is_in,
1620- event.position.x,
1621- cx,
1622- );
1623- },
1624- ),
1625- );
1626- handle = match edge {
1627- Edge::Start => handle.left(px(EDGE_W)),
1628- Edge::End => handle.right(px(EDGE_W)),
1629- };
1630- handle
1631- }))
1632- })
1633- // A speeded clip says so on the box, in the corner
1634- // the label does not reach: the box's width alone
1635- // cannot say whether a short clip is a trim or a
1636- // clip at 4x, and that is the difference between a
1637- // cut and a re-time.
1638- // Against the right edge of what is *visible* of the
1639- // box, not of the box: zoomed in, the box's own
1640- // right edge is off the screen and the badge with
1641- // it, which is a clip that stops saying it is
1642- // speeded exactly when it is being looked at
1643- // closely.
1644- .when(!clip.speed.is_normal() && vis_w > 0., |d| {
1645- d.child(
1646- div()
1647- .absolute()
1648- .top_0()
1649- .left(px(vis_x))
1650- .w(px(vis_w))
1651- .flex()
1652- .justify_end()
1653- .overflow_hidden()
1654- .child(
1655- div()
1656- .flex_none()
1657- .px(px(3.))
1658- .rounded(px(3.))
1659- .bg(rgb(ACCENT_PRIMARY()))
1660- .text_size(px(9.))
1661- .text_color(rgb(BG_RAISED()))
1662- .child(format!("{}", clip.speed)),
1663- ),
1664- )
1665- })
1666- // ...and the name sits at the left edge of the same
1667- // slice, for the same reason: a box scrolled half
1668- // off names itself on the half that is on screen.
1669- .when_some(label.filter(|_| show_label(vis_w)), |d, label| {
1670- d.child(
1671- div()
1672- .absolute()
1673- .top_0()
1674- .left(px(vis_x))
1675- .w(px(vis_w))
1676- .h(px(LABEL_H))
1677- .px(px(4.))
1678- .truncate()
1679- .text_size(px(10.))
1680- .child(label),
1681- )
1682- })
1683- }))
1684- // The same bed's other kind of box: a stretch of a palette
1685- // track placed on this lane, dragged along it, dragged onto
1686- // another subtitle lane, trimmed at either end, marked by a
1687- // click and lifted off by the Delete row of its own menu or
1688- // the stroke that row names -- the doors every other box on
1689- // the bed has. Empty on every lane that is not a
1690- // subtitle one, which is why there is one row and not two.
1691- .children(subs.iter().enumerate().map(|(i, placed)| {
1692- // What the drag payload names, and what an edge drag is
1693- // *showing* -- the box moves under the pointer and the
1694- // engine hears once, at the release.
1695- let (placed, shown_sub) = (*placed, self.trimmed_sub(lane, i, *placed));
1696- let (start, len) = (
1697- f64::from(shown_sub.start) / self.fps,
1698- f64::from(shown_sub.frames) / self.fps,
1699- );
1700- let span = scale.width_px(len);
1701- let width = clip_width(span);
1702- let left = scale.px_at(start);
1703- let (vis_x, vis_w) = visible_slice(left, width, bed);
1704- // Which track's words these are, film and all: two
1705- // "eng" tracks off two files read alike otherwise.
1706- let label = self
1707- .session
1708- .as_ref()
1709- .and_then(|session| sub_pick_name(session.subtitles(), placed.track));
1710- let ghost: SharedString =
1711- label.clone().unwrap_or_else(|| lane.label()).into();
1712- let tip = sub_tip.clone();
1713- let head = shown_sub.start;
1714- // Marked the way every other box on this bed is marked,
1715- // in this lane's own index space -- and a caption in a
1716- // group lights with the clips it was pinned to, exactly
1717- // as a clip lights with its halves.
1718- let on = marked((lane, i), placed.link, &picks, &pick_links);
1719- // ...and wears the group's border rather than a lone
1720- // box's, so what travels together reads together.
1721- let grouped = placed.link.is_some_and(|link| others.contains(&link));
1722- div()
1723- .id((row_id.clone(), i))
1724- .absolute()
1725- .top_0()
1726- .h_full()
1727- .left(px(left))
1728- .w(px(width))
1729- .overflow_hidden()
1730- .rounded(px(3.))
1731- .border_1()
1732- .border_color(rgb(if on {
1733- STROKE_SELECTED()
1734- } else if grouped {
1735- ACCENT_PRIMARY()
1736- } else {
1737- FG_SECONDARY()
1738- }))
1739- // A letterbox ground rather than the captions' own
1740- // colour: the box itself is where a sentence starts
1741- // and ends on the bed, and that is drawn by the cue
1742- // blocks below, not by the box's own fill. Marked,
1743- // it still takes the selection's colour, the same
1744- // pair a marked clip takes -- what Delete will act
1745- // on has one look on this bed and not two.
1746- .bg(rgb(if on { BG_SELECTED() } else { BG_PANEL() }))
1747- .when(!shown, |d| d.opacity(0.55))
1748- .cursor_pointer()
1749- .hover(|s| s.border_color(rgb(ACCENT_PRIMARY())))
1750- .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into())
1751- .on_drag(
1752- SubDrag {
1753- lane,
1754- idx: i,
1755- sub: placed,
1756- },
1757- move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())),
1758- )
1759- .on_mouse_down(
1760- MouseButton::Left,
1761- cx.listener(move |this, event: &MouseDownEvent, _, cx| {
1762- // Where in the box the hand took hold, so
1763- // the caption moves with the pointer rather
1764- // than jumping its head under it.
1765- this.grab =
1766- this.frame_under(event.position.x).saturating_sub(head);
1767- // ...and it marks the caption, exactly as
1768- // the press that may become a clip's drag
1769- // marks the clip: picking a caption up and
1770- // putting it back down is a click. Ctrl
1771- // toggles it into the selection like a clip.
1772- this.pick((lane, i), event.modifiers.control, cx);
1773- }),
1774- )
1775- // A plain click collapses a multi-pick to this one
1776- // caption, exactly as a clip's own box does above.
1777- .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
1778- if !press_modifiers(event).control {
1779- this.select((lane, i), cx);
1780- }
1781- }))
1782- // The right button marks it and hangs the menu at
1783- // the pointer, the clip menu opened on the clip
1784- // box's own rule -- the Delete row of it is this
1785- // caption's, and the rows a caption has no use for
1786- // are not drawn ([`oracle::enable`]).
1787- .on_mouse_down(
1788- MouseButton::Right,
1789- cx.listener(move |this, event: &MouseDownEvent, _, cx| {
1790- this.open_menu(lane, i, event.position, cx);
1791- }),
1792- )
1793- // The rate the caption's own window plays at, off
1794- // the placement itself: a re-timed group leaves it
1795- // on the box even after the group comes apart, and
1796- // the badge is the clip's badge -- same place, same
1797- // look -- on the visible slice, for the clip's
1798- // reason (zoomed in, the box's own edge is off the
1799- // screen and a badge at it with it).
1800- .when_some(
1801- caption_rate(shown_sub, self.fps).filter(|_| vis_w > 0.),
1802- |d, rate| {
1803- d.child(
1804- div()
1805- .absolute()
1806- .top_0()
1807- .left(px(vis_x))
1808- .w(px(vis_w))
1809- .flex()
1810- .justify_end()
1811- .overflow_hidden()
1812- .child(
1813- div()
1814- .flex_none()
1815- .px(px(3.))
1816- .rounded(px(3.))
1817- .bg(rgb(ACCENT_PRIMARY()))
1818- .text_size(px(9.))
1819- .text_color(rgb(BG_RAISED()))
1820- .child(format!("{rate}")),
1821- ),
1822- )
1823- },
1824- )
1825- // The two strips a drag lengthens it by, on the same
1826- // rule a clip's are drawn by ([`trims`]).
1827- .children(
1828- [Edge::Start, Edge::End]
1829- .into_iter()
1830- .filter(|_| trims(span))
1831- .map(|edge| {
1832- let mut zone = div()
1833- .absolute()
1834- .top_0()
1835- .h_full()
1836- .w(px(EDGE_W))
1837- .occlude()
1838- .cursor(CursorStyle::ResizeLeftRight)
1839- .hover(|s| s.bg(rgb(ACCENT_PRIMARY())))
1840- .on_mouse_down(
1841- MouseButton::Left,
1842- cx.listener(
1843- move |this, event: &MouseDownEvent, _, cx| {
1844- this.start_trim(
1845- lane,
1846- i,
1847- edge,
1848- event.modifiers.control,
1849- cx,
1850- );
1851- },
1852- ),
1853- )
1854- .on_scroll_wheel(cx.listener(
1855- |this, event: &ScrollWheelEvent, _, cx| {
1856- cx.stop_propagation();
1857- this.timeline_wheel(event, cx);
1858- },
1859- ))
1860- // Occluded, so the box's own
1861- // right-button listener never fires
1862- // here: the same menu, opened by the
1863- // same call, exactly as a clip's
1864- // edge strip does it.
1865- .on_mouse_down(
1866- MouseButton::Right,
1867- cx.listener(
1868- move |this, event: &MouseDownEvent, _, cx| {
1869- this.open_menu(lane, i, event.position, cx);
1870- },
1871- ),
1872- );
1873- zone = match edge {
1874- Edge::Start => zone.left_0(),
1875- Edge::End => zone.right_0(),
1876- };
1877- zone
1878- }),
1879- )
1880- // No name drawn on the box itself: the cue blocks
1881- // now fill its full height, and a label sitting
1882- // over them fights the very thing this box exists
1883- // to show. The tooltip still carries the words
1884- // (`sub_tip`), and the ghost while dragging still
1885- // names the track (`ghost`, above).
1886- // The way back off the lane is the way every other
1887- // box takes: the Delete stroke on the marked caption
1888- // and the Delete row of its own menu
1889- // ([`Player::lift_sub`]). The × that used to sit
1890- // here is gone with them -- it was drawn only where
1891- // the box was wide enough to hold it, so the one
1892- // removal a caption had was the one a zoomed-out
1893- // caption did not have.
1894- }))
1895- // ...and where the words actually are inside those boxes:
1896- // the cues this lane shows on *this* timeline, each its own
1897- // full-height block over the letterbox ground, inset a
1898- // pixel so the gap between two sentences is visible even
1899- // when they sit back to back. A placement is a window of a
1900- // track, so a box is not full of speech -- and a lane whose
1901- // marks are all in its first half is a caption dragged too
1902- // far, which is exactly what this shows.
1903- .children(cues.into_iter().map(|(left, width)| {
1904- div()
1905- .absolute()
1906- .top(px(1.))
1907- .bottom(px(1.))
1908- .left(px(left))
1909- .w(px(width))
1910- .rounded(px(2.))
1911- .bg(rgb(CLIP_TEXT()))
1912- }))
1913- // What the silence card found, over the clips it found them
1914- // in and over the waveform band that shows why: on the lane
1915- // the scan ran on and no other, because that is the only
1916- // lane whose sound was read. Drawn before anything is cut,
1917- // and replaced -- never stacked -- by every re-run.
1918- .children(
1919- self.silence_marks
1920- .iter()
1921- .filter(|_| self.silence_open.is_some_and(|(on, _)| on == lane))
1922- .map(|&(at, len)| {
1923- div()
1924- .absolute()
1925- .top_0()
1926- .h_full()
1927- .left(px(scale.px_at(f64::from(at) / self.fps)))
1928- // Floored like a cue's mark and for the same
1929- // reason: a half-second silence on a zoomed-
1930- // out bed rounds to nothing, and a preview
1931- // that draws nothing reads as a scan that
1932- // found nothing.
1933- .w(px(scale
1934- .width_px(f64::from(len) / self.fps)
1935- .max(SUB_CUE_MIN_W)))
1936- .bg(rgba(ACCENT_WASH()))
1937- }),
1938- )
1939- // Where the thing in the hand would come to rest, at the size
1940- // it would come to rest at: the shadow a proper editor draws
1941- // under a drag. Over the clips (it is translucent, so what
1942- // it would cover shows through) and under the line, which
1943- // marks the frame this box merely fills.
1944- .children(ghost.into_iter().map(|g| {
1945- div()
1946- .absolute()
1947- .top_0()
1948- .h_full()
1949- .left(px(scale.px_at(f64::from(g.start) / self.fps)))
1950- // A row whose length the engine has not measured
1951- // draws a head marker rather than nothing: where it
1952- // lands is known, how long it is is not.
1953- .w(px(scale
1954- .width_px(f64::from(g.frames) / self.fps)
1955- .max(GHOST_MIN)))
1956- .rounded(px(3.))
1957- .border_1()
1958- .border_color(rgb(if g.refused {
1959- DROP_REFUSE()
1960- } else {
1961- FG_PRIMARY()
1962- }))
1963- // The file's own swatch at a third of its weight, so
1964- // the box beneath is still legible through it -- and
1965- // the refusal red instead, for a lane that will not
1966- // take this drop at all.
1967- .bg(rgba(
1968- ((if g.refused { DROP_REFUSE() } else { g.tint }) << 8)
1969- | GHOST_ALPHA,
1970- ))
1971- }))
1972- // What the gesture in flight is about to land on, drawn on
1973- // every lane so a clip lining up with a take one track over
1974- // can be seen to line up with it. Under the playhead's line
1975- // and in another colour, since the two mean different
1976- // things and often stand on the same pixel.
1977- .children(cue.map(|x| {
1978- div()
1979- .absolute()
1980- .top_0()
1981- .h_full()
1982- .left(px(x))
1983- .w(px(1.))
1984- .bg(rgb(FG_PRIMARY()))
1985- }))
1986- // Last, so it is over the clips: the same fraction in both
1987- // lanes, which is the playhead being one line.
1988- .child(
1989- div()
1990- .absolute()
1991- .top_0()
1992- .h_full()
1993- .left(px(filled))
1994- .w(px(2.))
1995- .bg(rgb(ACCENT_PLAYHEAD())),
1996- ),
1997- )
1998- // The drop indicator, last of all so it is over the header and the
1999- // bed both: a line along the edge the track in the hand comes in
2000- // at, which is the slot the release commits to. *Inside* the row
crates/app/src/ui/toolbar.rsdeleted+0 -539
@@ -1,539 +0,0 @@
1-//! The three rows of chrome: the top bar over everything, the transport strip
2-//! under the picture, and the edit toolbar directly above the timeline.
3-//!
4-//! Every button in all three comes out of [`Player::action_control`], which
5-//! asks the one availability oracle whether the action can happen at all. That
6-//! is the whole point of this module existing: the toolbar used to decide with
7-//! ad-hoc booleans (`live && self.selected.is_some()`) while the keyboard asked
8-//! nobody, so with no file open Snap and `+ V` were dimmed *and dead* to the
9-//! pointer while the very same actions still fired from the keys. One oracle,
10-//! two doors -- if the key fires, the button fires.
11-
12-use crate::ui::widgets::*;
13-use crate::*;
14-
15-impl Player {
16- /// A toolbar button for `action`: enabled exactly when [`enable`] says the
17- /// action can happen, dimmed with the oracle's own reason in its tooltip
18- /// when it cannot, and firing the same call the key fires when it can.
19- ///
20- /// `w` is the rect the label lives in. It is reserved once and never
21- /// changes with state, so Play/Pause, Snap/No snap and Export/Cancel swap
22- /// their words and their colour inside a box that does not move -- the
23- /// complaint that started this redesign ("even button positions are
24- /// changing according to its state").
25- pub(crate) fn action_control(
26- &self,
27- id: &'static str,
28- w: f32,
29- bg: u32,
30- glyph: Option<AnyElement>,
31- label: impl Into<SharedString>,
32- hint: &str,
33- action: ActionId,
34- on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
35- ) -> impl IntoElement {
36- let enabled = self.enable(action, None);
37- let key = self.keymap.display(action);
38- // The dimmed button says *why* in the oracle's own words -- the same
39- // string the key answers with, so the tooltip and the notice cannot
40- // come to differ.
41- let say = match enabled.why() {
42- Some(why) => format!("{key} — {why}"),
43- None => format!("{key} — {hint}"),
44- };
45- control(id, w, bg, glyph, label, say, enabled.yes(), on_click)
46- }
47-
48- /// The bar over everything: what is open on the left, the two actions that
49- /// write a file on the right. Export is the one accented button in the
50- /// window -- the primary action of an editor, where every consumer editor
51- /// puts it -- and it keeps its rect while it is a Cancel.
52- pub(crate) fn topbar(&self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
53- let exporting = self.exporting().is_some();
54- // This button's own row is part of the chrome player fullscreen
55- // hides, so once it reads true the button is already off screen --
56- // F11 or Escape is what a person actually leaves by, which is why the
57- // hint below names both.
58- let fullscreen = self.player_fullscreen;
59- div()
60- .flex_none()
61- .h(px(TOPBAR_H))
62- .flex()
63- .items_center()
64- .gap(px(8.))
65- .px(px(12.))
66- .bg(rgb(BG_PANEL()))
67- .border_b_1()
68- .border_color(rgb(STROKE_DIVIDER()))
69- .child(
70- div()
71- .flex_none()
72- .w(px(10.))
73- .h(px(10.))
74- .rounded(px(2.))
75- .bg(rgb(ACCENT_PRIMARY())),
76- )
77- .child(
78- div()
79- .flex_1()
80- .min_w(px(0.))
81- .truncate()
82- .child(self.name.clone()),
83- )
84- // The window's own control, in the fixed rect the mute button uses
85- // for the same reason (toolbar.rs:194-203): fullscreen swaps the
86- // word and the colour, never the box.
87- .child(self.action_control(
88- "fullscreen",
89- 0.,
90- BG_RAISED(),
91- None,
92- match fullscreen {
93- true => "Exit fullscreen",
94- false => "Fullscreen",
95- },
96- "fills the screen with the picture; F11 or Escape gives it back",
97- ActionId::Fullscreen,
98- cx.listener(|this, _: &ClickEvent, window, cx| {
99- this.act(ActionId::Fullscreen, window, cx)
100- }),
101- ))
102- .child(self.action_control(
103- "save",
104- 0.,
105- BG_RAISED(),
106- None,
107- "Save",
108- "writes the project file",
109- ActionId::Save,
110- cx.listener(|this, _: &ClickEvent, _, cx| this.save_project(cx)),
111- ))
112- // One rect, two states: exporting swaps the word and the colour,
113- // never the box. `the_export_button_never_moves` is the guard.
114- .child(
115- div()
116- .flex_none()
117- .w(px(EXPORT_SLOT_W))
118- .child(self.action_control(
119- "export",
120- EXPORT_SLOT_W,
121- // The one accented button in the window: the primary
122- // action of an editor, where every consumer editor puts
123- // it. Cancel keeps the rect and the accent both.
124- ACCENT_PRIMARY(),
125- None,
126- if exporting { "Cancel" } else { "Export" },
127- if exporting {
128- "stops the export; the part-written file goes"
129- } else {
130- "quality and destination, then writes the timeline out"
131- },
132- if exporting {
133- ActionId::CancelExport
134- } else {
135- ActionId::Export
136- },
137- cx.listener(|this, _: &ClickEvent, _, cx| {
138- if this.exporting().is_some() {
139- this.cancel_export();
140- cx.notify();
141- } else {
142- this.open_export(cx);
143- }
144- }),
145- )),
146- )
147- }
148-
149- /// The player's own strip, under the picture and over the timeline: the
150- /// transport, the clock, and the level. Where a consumer editor puts them,
151- /// and the reason the edit toolbar below is nothing but edit tools.
152- pub(crate) fn transport_bar(
153- &self,
154- state: Transport,
155- viewport: Size<Pixels>,
156- cx: &mut Context<Self>,
157- ) -> impl IntoElement {
158- let muted = self.volume.muted;
159- // The room this strip actually has: the window less the two side
160- // panels. At the 640 px floor that is ~300 px, which the clock and the
161- // level together do not fit -- so the level's *bar* stands down (its
162- // button, its keys and its row on the actions card all remain), and
163- // the clock keeps a narrower rect rather than being pushed off.
164- // The two panels as they are *now*, dividers and all: a room worked out
165- // from the window's own shares would go stale the moment a seam moved,
166- // and the clock would be sized for a column that is no longer there.
167- let room = f32::from(viewport.width)
168- - self.split_px(Split::Library, viewport)
169- - self.split_px(Split::Inspector, viewport)
170- - 2. * SPLIT_W;
171- let clock_w = TIME_W.min(room - 140.).max(96.);
172- let slider = room >= TRANSPORT_ROOMY;
173- // Which window the loop button actually restarts, in the same
174- // priority [`active_loop_window`] picks it in: the marked i/o range
175- // once something is armed, the subject-cut trim next, the whole
176- // timeline last.
177- let armed = self.loop_on || self.loop_trim.is_some();
178- let loop_hint = if armed && self.range.is_some() {
179- "restarts from the marked in point on reaching the marked out point, instead of stopping"
180- } else if self.loop_trim.is_some() {
181- "restarts from the subject cut's own start on reaching its end, instead of stopping"
182- } else {
183- "restarts from the top on reaching the end, instead of stopping"
184- };
185- div()
186- .flex_none()
187- .h(px(TRANSPORT_H))
188- .flex()
189- .items_center()
190- .gap(px(8.))
191- .px(px(12.))
192- .bg(rgb(BG_PANEL()))
193- .border_t_1()
194- .border_color(rgb(STROKE_DIVIDER()))
195- .child(self.action_control(
196- "screenshot",
197- 0.,
198- BG_RAISED(),
199- None,
200- "Shot",
201- "saves the frame on screen as a PNG in ~/Pictures/edith",
202- ActionId::Screenshot,
203- cx.listener(|this, _: &ClickEvent, _, cx| this.take_screenshot(cx)),
204- ))
205- .child(self.action_control(
206- "transport",
207- 40.,
208- BG_RAISED(),
209- Some(transport_glyph(state).into_any_element()),
210- "",
211- "plays and pauses the timeline",
212- ActionId::Play,
213- cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_or_restart(cx)),
214- ))
215- // Accented while on, the box the export button and the mute glyph
216- // both use for a state rather than a click: the pump reads
217- // `loop_on` itself at the one place it already knows the end was
218- // reached ([`Player::pump`]).
219- .child(self.action_control(
220- "loop",
221- 0.,
222- match self.loop_on {
223- true => ACCENT_PRIMARY(),
224- false => BG_RAISED(),
225- },
226- None,
227- "Loop",
228- loop_hint,
229- ActionId::Loop,
230- cx.listener(|this, _: &ClickEvent, window, cx| {
231- this.act(ActionId::Loop, window, cx)
232- }),
233- ))
234- // One line, one fixed width: changing digits must not push the
235- // strip around, and the clock is the one number that changes
236- // sixty times a second.
237- .child(
238- div()
239- .flex_none()
240- .w(px(clock_w))
241- .truncate()
242- .text_color(rgb(FG_PRIMARY()))
243- .child(format!(
244- "{} / {}",
245- timecode(
246- self.active_session().map_or(0., PlaybackSession::now),
247- self.active_fps()
248- ),
249- timecode(
250- self.active_session()
251- .map_or(0., PlaybackSession::timeline_duration),
252- self.active_fps()
253- )
254- )),
255- )
256- .child(div().flex_1().min_w(px(0.)))
257- // The level as a number in its own rect, so muting swaps a glyph
258- // and a colour rather than relabelling the button "Muted 80%" and
259- // shoving the slider beside it along.
260- .child(self.action_control(
261- "volume",
262- VOLUME_SLOT_W,
263- BG_RAISED(),
264- None,
265- // The level is the label either way and it lives in a fixed
266- // rect: muting adds a mark and changes the colour, where it
267- // used to relabel the button "Muted 80%" and shove the slider
268- // beside it along the row.
269- match muted {
270- true => format!("× {}%", self.volume.percent()),
271- false => format!("{}%", self.volume.percent()),
272- },
273- "mutes and unmutes; the level is what it comes back to",
274- ActionId::ToggleMute,
275- cx.listener(|this, _: &ClickEvent, _, cx| {
276- this.set_volume(|volume| volume.muted = !volume.muted, cx)
277- }),
278- ))
279- .text_color(rgb(match muted {
280- true => STATUS_WARNING(),
281- false => FG_PRIMARY(),
282- }))
283- .when(slider, |d| {
284- d.child(volume_slider(
285- self.volume,
286- self.volume_bar.clone(),
287- self.enable(ActionId::ToggleMute, None).yes(),
288- cx,
289- ))
290- })
291- }
292-
293- /// The edit toolbar, directly above the timeline it acts on: split, delete,
294- /// undo, the tracks, the magnet and the zoom -- the arrangement Movavi and
295- /// CapCut share, and nothing in it that is not an edit or a way of looking
296- /// at one.
297- ///
298- /// The row scrolls rather than losing its tail at the 640 px floor, and the
299- /// door to everything scrolled off it is pinned outside the scrolling box:
300- /// "it scrolls" is not "it can be found" (`toolbar_fits_the_smallest_window`).
301- pub(crate) fn toolbar(&self, cx: &mut Context<Self>) -> impl IntoElement {
302- let exporting = self.exporting().is_some();
303- div()
304- .flex_none()
305- .h(px(TOOLBAR_H))
306- .flex()
307- .items_center()
308- .gap(px(8.))
309- .px(px(12.))
310- .bg(rgb(BG_PANEL()))
311- .border_t_1()
312- .border_color(rgb(STROKE_DIVIDER()))
313- .child(
314- div()
315- .id("controls")
316- .flex_1()
317- .min_w(px(0.))
318- .flex()
319- .items_center()
320- .gap(px(8.))
321- .overflow_x_scroll()
322- .child(group_label("Edit"))
323- .child(self.action_control(
324- "cut",
325- 0.,
326- BG_RAISED(),
327- Some(cut_glyph().into_any_element()),
328- "Split",
329- "splits the clip under the playhead",
330- ActionId::Cut,
331- cx.listener(|this, _: &ClickEvent, _, cx| this.cut(cx)),
332- ))
333- .child(self.action_control(
334- "delete",
335- 0.,
336- BG_RAISED(),
337- Some(delete_glyph().into_any_element()),
338- "Delete",
339- "takes the marked clip off the timeline",
340- ActionId::Delete,
341- cx.listener(|this, _: &ClickEvent, _, cx| this.delete_selected(cx)),
342- ))
343- .child(self.action_control(
344- "undo",
345- 0.,
346- BG_RAISED(),
347- None,
348- "Undo",
349- "takes the last edit back",
350- ActionId::Undo,
351- cx.listener(|this, _: &ClickEvent, _, cx| this.undo(cx)),
352- ))
353- .child(self.action_control(
354- "redo",
355- 0.,
356- BG_RAISED(),
357- None,
358- "Redo",
359- "brings the undone edit back",
360- ActionId::Redo,
361- cx.listener(|this, _: &ClickEvent, _, cx| this.redo(cx)),
362- ))
363- .child(separator())
364- .child(group_label("Track"))
365- .child(self.action_control(
366- "add-video-lane",
367- 0.,
368- BG_RAISED(),
369- None,
370- "+ V",
371- "adds a video track under the ones there",
372- ActionId::AddVideoLane,
373- cx.listener(|this, _: &ClickEvent, _, cx| {
374- this.add_lane(LaneKind::Video, cx)
375- }),
376- ))
377- .child(self.action_control(
378- "add-audio-lane",
379- 0.,
380- BG_RAISED(),
381- None,
382- "+ A",
383- "adds an audio track under the ones there",
384- ActionId::AddAudioLane,
385- cx.listener(|this, _: &ClickEvent, _, cx| {
386- this.add_lane(LaneKind::Audio, cx)
387- }),
388- ))
389- .child(self.action_control(
390- "add-subtitle-lane",
391- 0.,
392- BG_RAISED(),
393- None,
394- "+ C",
395- "adds a subtitle track under the ones there",
396- ActionId::AddSubtitleLane,
397- cx.listener(|this, _: &ClickEvent, _, cx| {
398- this.add_lane(LaneKind::Subtitle, cx)
399- }),
400- ))
401- .child(separator())
402- .child(group_label("View"))
403- // Both toggles keep a rect of their own: the label is the
404- // state, and a state that resized its own button is what
405- // made the row shuffle every time it was pressed.
406- .child(self.action_control(
407- "snap",
408- SNAP_SLOT_W,
409- BG_RAISED(),
410- None,
411- if self.snap { "Snap on" } else { "Snap off" },
412- match self.snap {
413- true => {
414- "drags and trims land on clip edges, the playhead and the start"
415- }
416- false => "drags and trims land exactly where the hand leaves them",
417- },
418- ActionId::ToggleSnap,
419- cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_snap(cx)),
420- ))
421- .child(self.action_control(
422- "subs",
423- SNAP_SLOT_W,
424- BG_RAISED(),
425- None,
426- match (self.placed_captions() > 0, self.subs_on) {
427- (false, _) => "No subs",
428- (true, true) => "Subs on",
429- (true, false) => "Subs off",
430- },
431- "draws the cue under the playhead over the picture",
432- ActionId::ToggleSubtitles,
433- cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_subtitles(cx)),
434- ))
435- .child(self.action_control(
436- "theme",
437- THEME_SLOT_W,
438- BG_RAISED(),
439- None,
440- format!("Theme: {}", crate::ui::theme::active().label()),
441- "the colours this window is painted in; kept in ~/.config/edith/theme",
442- ActionId::Theme,
443- cx.listener(|this, event: &ClickEvent, _, cx| {
444- this.open_picker(Pick::Theme, event.position(), cx)
445- }),
446- ))
447- .child(separator())
448- .child(self.action_control(
449- "zoom-out",
450- CONTROL_H,
451- BG_RAISED(),
452- None,
453- "−",
454- "show more of the timeline; stops with all of it on the bed",
455- ActionId::ZoomOut,
456- cx.listener(|this, _: &ClickEvent, _, cx| {
457- this.zoom(1. / ZOOM_STEP, None, cx)
458- }),
459- ))
460- .child(self.action_control(
461- "zoom-fit",
462- ZOOM_SLOT_W,
463- BG_RAISED(),
464- None,
465- span_label(self.view().span()),
466- "fit the whole timeline on the bed",
467- ActionId::ZoomFit,
468- cx.listener(|this, _: &ClickEvent, _, cx| this.zoom_fit(cx)),
469- ))
470- .child(self.action_control(
471- "zoom-in",
472- CONTROL_H,
473- BG_RAISED(),
474- None,
475- "+",
476- "magnify around the playhead; ctrl+wheel over the timeline zooms at the \
477- pointer, and a bare wheel scrolls it",
478- ActionId::ZoomIn,
479- cx.listener(|this, _: &ClickEvent, _, cx| this.zoom(ZOOM_STEP, None, cx)),
480- ))
481- .child(self.action_control(
482- "keys",
483- 0.,
484- BG_RAISED(),
485- None,
486- "Actions",
487- "do any action, or change the key that does it",
488- ActionId::ShowActions,
489- cx.listener(|this, _: &ClickEvent, _, cx| match this.keys_open {
490- true => {
491- this.keys_open = false;
492- this.rebinding = None;
493- cx.notify();
494- }
495- false => this.show_actions(cx),
496- }),
497- )),
498- )
499- // The door to everything the row cannot show at this window, pinned
500- // where a scroll cannot take it.
501- .child(control(
502- "controls-more",
503- CONTROL_H,
504- BG_RAISED(),
505- None,
506- "⋯",
507- format!(
508- "{} — every action, including the ones scrolled off this row",
509- self.keymap.display(ActionId::ShowActions)
510- ),
511- !exporting,
512- cx.listener(|this, _: &ClickEvent, _, cx| match this.keys_open {
513- true => {
514- this.keys_open = false;
515- this.rebinding = None;
516- cx.notify();
517- }
518- false => this.show_actions(cx),
519- }),
520- ))
521- }
522-}
523-
524-/// The rects the stateful buttons live in. Wide enough for the longest word
525-/// each of them can say, so the swap happens inside the box.
526-pub(crate) const EXPORT_SLOT_W: f32 = 76.;
527-pub(crate) const SNAP_SLOT_W: f32 = 76.;
528-pub(crate) const ZOOM_SLOT_W: f32 = 76.;
529-pub(crate) const VOLUME_SLOT_W: f32 = 76.;
530-/// The HDR rendition's names are the longest words on any button here.
531-pub(crate) const TONE_SLOT_W: f32 = 148.;
532-/// "Theme: " and the longest palette name: a fixed rect like the two toggles
533-/// beside it, so picking a palette repaints the button without moving the ones
534-/// after it.
535-pub(crate) const THEME_SLOT_W: f32 = 96.;
536-
537-/// The width the transport strip needs before the level's bar fits beside the
538-/// clock: play + clock + the mute button + the bar, in their gaps.
539-pub(crate) const TRANSPORT_ROOMY: f32 = 460.;
crates/app/src/ui/widgets.rsmodified+0 -149
@@ -2,13 +2,6 @@
2 2
3 use crate::*;3 use crate::*;
4 4
5-/// One clip's audio, drawn as a filled min/max envelope inside whatever box it
6-/// is given. Peaks are the source's whole envelope; `from`/`to` are the source
7-/// seconds this clip plays, so a cut clip shows its own stretch of the file.
8-pub(crate) fn waveform(peaks: Arc<Vec<(f32, f32)>>, from: f64, to: f64) -> impl IntoElement {
9- waveform_ink(peaks, from, to, FG_SECONDARY())
10-}
11-
12 /// `ClickEvent::modifiers()` answers the mouse-*up* modifiers (gpui-0.2.25 /// `ClickEvent::modifiers()` answers the mouse-*up* modifiers (gpui-0.2.2
13 /// `interactive.rs`), so releasing ctrl before the button lands undoes a6 /// `interactive.rs`), so releasing ctrl before the button lands undoes a
14 /// ctrl-held toggle decided on mouse-down. This reads the *press* modifiers7 /// ctrl-held toggle decided on mouse-down. This reads the *press* modifiers
@@ -203,79 +196,6 @@ pub(crate) fn control(
203 /// colour sliders both make. Only the level -- mute is the button beside it, so196 /// colour sliders both make. Only the level -- mute is the button beside it, so
204 /// a muted slider still shows what unmuting comes back to, drawn dim.197 /// a muted slider still shows what unmuting comes back to, drawn dim.
205 ///198 ///
206-/// Dimmed and inert without a timeline, like every other control that would
207-/// have nothing to act on.
208-pub(crate) fn volume_slider(
209- volume: Volume,
210- bar: Rc<Cell<Bounds<Pixels>>>,
211- enabled: bool,
212- cx: &mut Context<Player>,
213-) -> impl IntoElement {
214- div()
215- .id("volume-bar")
216- .relative()
217- .flex_none()
218- .w(px(VOLUME_W))
219- .h(px(CONTROL_H))
220- .flex()
221- .items_center()
222- .tooltip(|_, cx| {
223- cx.new(|_| Tip("Volume — drag to set the level; the button mutes".into()))
224- .into()
225- })
226- .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed())
227- .when(enabled, |d| {
228- d.cursor_pointer()
229- .on_mouse_down(
230- MouseButton::Left,
231- cx.listener(|this, event: &MouseDownEvent, _, cx| {
232- this.volume_dragging = true;
233- this.drag_volume(event.position.x, cx);
234- }),
235- )
236- .child(bounds_probe(bar))
237- })
238- .child(
239- div()
240- .w_full()
241- .h(px(4.))
242- .rounded(px(2.))
243- .bg(rgb(BG_RAISED()))
244- .child(
245- div()
246- .h_full()
247- .w(relative(volume.along()))
248- .rounded(px(2.))
249- .bg(rgb(if volume.muted {
250- FG_SECONDARY()
251- } else {
252- ACCENT_PRIMARY()
253- })),
254- ),
255- )
256-}
257-
258-/// The line between two groups of buttons.
259-/// What a group of buttons is *for*, printed in front of it. A toolbar of
260-/// twelve unlabelled boxes is a toolbar nobody reads twice; three named groups
261-/// are three things to skip.
262-pub(crate) fn group_label(name: &'static str) -> impl IntoElement {
263- div()
264- .flex_none()
265- .text_size(px(10.))
266- .text_color(rgb(FG_SECONDARY()))
267- .child(name)
268-}
269-
270-pub(crate) fn separator() -> impl IntoElement {
271- div()
272- .flex_none()
273- .mx(px(4.))
274- .w(px(1.))
275- .h(px(18.))
276- .bg(rgb(BG_HOVER()))
277-}
278-
279 /// Whether a card or a menu is drawn over the window, as the hover labels see199 /// Whether a card or a menu is drawn over the window, as the hover labels see
280 /// it: written once a frame by [`Player::render`], read by every [`Tip`] before200 /// it: written once a frame by [`Player::render`], read by every [`Tip`] before
281 /// it paints.201 /// it paints.
@@ -352,39 +272,6 @@ impl Render for OverlayTip {
352 }272 }
353 }273 }
354 274
355-/// Scissors: two blades crossed. Drawn this way and not as a split clip because
356-/// two bars is what the transport wears when it is playing -- the one glyph a
357-/// cut must never be mistaken for.
358-pub(crate) fn cut_glyph() -> impl IntoElement {
359- canvas(
360- |_, _, _| (),
361- |bounds, _, window, _| {
362- let (o, s) = (bounds.origin, bounds.size);
363- let mut path = PathBuilder::stroke(px(1.5));
364- path.move_to(point(o.x + s.width * 0.15, o.y + s.height));
365- path.line_to(point(o.x + s.width * 0.9, o.y + s.height * 0.1));
366- path.move_to(point(o.x + s.width * 0.85, o.y + s.height));
367- path.line_to(point(o.x + s.width * 0.1, o.y + s.height * 0.1));
368- if let Ok(path) = path.build() {
369- window.paint_path(path, rgb(FG_PRIMARY()));
370- }
371- },
372- )
373- .w(px(13.))
374- .h(px(13.))
375-}
376-
377-/// A lid over a bin.
378-pub(crate) fn delete_glyph() -> impl IntoElement {
379- div()
380- .flex()
381- .flex_col()
382- .items_center()
383- .gap(px(2.))
384- .child(div().w(px(13.)).h(px(2.)).bg(rgb(FG_PRIMARY())))
385- .child(div().w(px(9.)).h(px(9.)).bg(rgb(FG_PRIMARY())))
386-}
387-
388 /// What a window with no file open is waiting for. Both ways in are already275 /// What a window with no file open is waiting for. Both ways in are already
389 /// built -- the whole window is the drop target and the Import chooser takes a276 /// built -- the whole window is the drop target and the Import chooser takes a
390 /// project as readily as media -- so this only has to say so.277 /// project as readily as media -- so this only has to say so.
@@ -402,39 +289,3 @@ pub(crate) fn empty_hint() -> impl IntoElement {
402 .child("or click Import in the media list"),289 .child("or click Import in the media list"),
403 )290 )
404 }291 }
405-
406-/// Two bars while playing, a triangle in every other state -- paused, nothing
407-/// open, and played out, where the button's next act is to start over rather
408-/// than to stop something. Drawn, so there is no icon font and no glyph
409-/// coverage to depend on.
410-pub(crate) fn transport_glyph(state: Transport) -> impl IntoElement {
411- let playing = state.is_playing();
412- div()
413- .flex()
414- .items_center()
415- .gap(px(4.))
416- .when(playing, |d| {
417- d.child(div().w(px(3.)).h(px(12.)).bg(rgb(FG_PRIMARY())))
418- .child(div().w(px(3.)).h(px(12.)).bg(rgb(FG_PRIMARY())))
419- })
420- .when(!playing, |d| {
421- d.child(
422- canvas(
423- |_, _, _| (),
424- |bounds, _, window, _| {
425- let (o, s) = (bounds.origin, bounds.size);
426- let mut path = PathBuilder::fill();
427- path.move_to(o);
428- path.line_to(point(o.x + s.width, o.y + s.height / 2.));
429- path.line_to(point(o.x, o.y + s.height));
430- path.close();
431- if let Ok(path) = path.build() {
432- window.paint_path(path, rgb(FG_PRIMARY()));
433- }
434- },
435- )
436- .w(px(11.))
437- .h(px(13.)),
438- )
439- })
440-}
crates/app/src/viewport.rsmodified+0 -15
@@ -2,21 +2,6 @@
2 2
3 use crate::*;3 use crate::*;
4 4
5-/// What the zoom button says it is showing: how much timeline fits on the bed,
6-/// in the coarsest unit that still tells two zooms apart.
7-pub(crate) fn span_label(span: f64) -> String {
8- match span {
9- s if !s.is_finite() || s <= 0. => "—".to_string(),
10- // Hours once a timeline is long enough to be measured in them: the far
11- // stop follows the content now, so "315m" is a span a user can be sat
12- // at, and no one reads a pill in minutes past sixty.
13- s if s >= 3600. => format!("{:.1}h", s / 3600.),
14- s if s >= 600. => format!("{:.0}m", s / 60.),
15- s if s >= 60. => format!("{:.1}m", s / 60.),
16- s if s >= 10. => format!("{s:.0}s"),
17- s => secs_label(s),
18- }
19-}
20 5
21 /// A span of seconds as a person reads it: one decimal above a second, two6 /// A span of seconds as a person reads it: one decimal above a second, two
22 /// below -- [`scaled`]'s rule, for its reason. The tightest zoom is7 /// below -- [`scaled`]'s rule, for its reason. The tightest zoom is