Four defect classes made impossible instead of tested
Browse files at this commit5909fc91e48dce0664793f9c152e578fe58c8a6dParent: 00fea7e- fix
- four defect classes made impossible instead of tested
2 changed files +827 -580
- crates/app/src/keymap.rs +289 -213
- crates/app/src/main.rs +538 -367
crates/app/src/keymap.rsmodified+289 -213
| @@ -36,10 +36,31 @@ use std::path::{Path, PathBuf}; | |||
| 36 | /// First line, exactly. The version is part of it, as in the project file. | 36 | /// First line, exactly. The version is part of it, as in the project file. |
| 37 | const MAGIC: &str = "edith-keys 1"; | 37 | const MAGIC: &str = "edith-keys 1"; |
| 38 | 38 | ||
| 39 | -/// Everything a stroke can ask for. Not the mouse's actions: only what a key | 39 | +/// The action list, written once: the enum and the display-order array come out |
| 40 | -/// can reach is bindable. | 40 | +/// of the same names, so an action added here is in [`ActionId::ALL`] by |
| 41 | -#[derive(Clone, Copy, PartialEq, Eq, Debug)] | 41 | +/// construction. It used to be two lists, and a variant added to one of them |
| 42 | -pub enum ActionId { | 42 | +/// compiled, passed every test, and was simply missing from the keys card -- |
| 43 | +/// the pointer-unreachable action this editor opened with. | ||
| 44 | +macro_rules! actions { | ||
| 45 | + ($($(#[$note:meta])* $variant:ident),+ $(,)?) => { | ||
| 46 | + /// Everything a stroke can ask for. Not the mouse's actions: only what a | ||
| 47 | + /// key can reach is bindable. | ||
| 48 | + #[derive(Clone, Copy, PartialEq, Eq, Debug)] | ||
| 49 | + pub enum ActionId { | ||
| 50 | + $($(#[$note])* $variant,)+ | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + impl ActionId { | ||
| 54 | + /// Display order everywhere -- the editor lists them in it and | ||
| 55 | + /// [`Keymap::defaults`] binds them in it. Derived from the list | ||
| 56 | + /// above, so there is no second place to forget. | ||
| 57 | + pub const ALL: [ActionId; [$(stringify!($variant)),+].len()] = | ||
| 58 | + [$(ActionId::$variant),+]; | ||
| 59 | + } | ||
| 60 | + }; | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +actions! { | ||
| 43 | Play, | 64 | Play, |
| 44 | StepBack, | 65 | StepBack, |
| 45 | StepForward, | 66 | StepForward, |
| @@ -88,53 +109,6 @@ pub enum ActionId { | |||
| 88 | } | 109 | } |
| 89 | 110 | ||
| 90 | impl ActionId { | 111 | impl ActionId { |
| 91 | - /// Display order everywhere -- the editor lists them in it and | ||
| 92 | - /// [`Keymap::defaults`] binds them in it. | ||
| 93 | - pub const ALL: [ActionId; 42] = [ | ||
| 94 | - ActionId::Play, | ||
| 95 | - ActionId::StepBack, | ||
| 96 | - ActionId::StepForward, | ||
| 97 | - ActionId::JumpBack, | ||
| 98 | - ActionId::JumpForward, | ||
| 99 | - ActionId::GoStart, | ||
| 100 | - ActionId::GoEnd, | ||
| 101 | - ActionId::Export, | ||
| 102 | - ActionId::Save, | ||
| 103 | - ActionId::Copy, | ||
| 104 | - ActionId::Paste, | ||
| 105 | - ActionId::Cut, | ||
| 106 | - ActionId::Regroup, | ||
| 107 | - ActionId::Detach, | ||
| 108 | - ActionId::Group, | ||
| 109 | - ActionId::Select, | ||
| 110 | - ActionId::SelectNext, | ||
| 111 | - ActionId::SelectPrev, | ||
| 112 | - ActionId::Delete, | ||
| 113 | - ActionId::Lift, | ||
| 114 | - ActionId::Color, | ||
| 115 | - ActionId::Fit, | ||
| 116 | - ActionId::Resolution, | ||
| 117 | - ActionId::ZoomIn, | ||
| 118 | - ActionId::ZoomOut, | ||
| 119 | - ActionId::ZoomFit, | ||
| 120 | - ActionId::Undo, | ||
| 121 | - ActionId::AddVideoLane, | ||
| 122 | - ActionId::AddAudioLane, | ||
| 123 | - ActionId::RemoveVideoLane, | ||
| 124 | - ActionId::RemoveAudioLane, | ||
| 125 | - ActionId::ToggleMute, | ||
| 126 | - ActionId::VolumeUp, | ||
| 127 | - ActionId::VolumeDown, | ||
| 128 | - ActionId::Equalizer, | ||
| 129 | - ActionId::Speed, | ||
| 130 | - ActionId::Silence, | ||
| 131 | - ActionId::Mix, | ||
| 132 | - ActionId::ToggleSnap, | ||
| 133 | - ActionId::ToggleSubtitles, | ||
| 134 | - ActionId::CancelExport, | ||
| 135 | - ActionId::ShowActions, | ||
| 136 | - ]; | ||
| 137 | - | ||
| 138 | /// What a person calls it. | 112 | /// What a person calls it. |
| 139 | pub fn label(self) -> &'static str { | 113 | pub fn label(self) -> &'static str { |
| 140 | match self { | 114 | match self { |
| @@ -347,171 +321,234 @@ impl Category { | |||
| 347 | /// and fails on any key that reaches neither this table nor a binding. | 321 | /// and fails on any key that reaches neither this table nor a binding. |
| 348 | pub struct Fixed { | 322 | pub struct Fixed { |
| 349 | /// As a person reads it, which for a single key is [`Chord::pretty`]'s | 323 | /// As a person reads it, which for a single key is [`Chord::pretty`]'s |
| 350 | - /// spelling and for a family of keys is the family (`0–9`). | 324 | + /// spelling and for a family of keys is the family (`0–9`). A `String` |
| 351 | - pub chord: &'static str, | 325 | + /// because one of them is generated: the codec row's keys are the export |
| 326 | + /// card's own table, not a line typed a second time here. | ||
| 327 | + pub chord: String, | ||
| 352 | pub label: &'static str, | 328 | pub label: &'static str, |
| 353 | pub category: Category, | 329 | pub category: Category, |
| 330 | + /// What a hand with only a mouse does instead. Every stroke here is | ||
| 331 | + /// card-local, and a card whose rows only a keyboard can reach is half this | ||
| 332 | + /// editor's users locked out of it, so each row names the thing on its card | ||
| 333 | + /// -- `every_action_is_reachable_without_the_keyboard` looks each id up in | ||
| 334 | + /// the render's own source. | ||
| 335 | + pub reach: Reach, | ||
| 336 | +} | ||
| 337 | + | ||
| 338 | +/// The pointer's answer to a fixed stroke. | ||
| 339 | +#[derive(Clone, Copy, PartialEq, Eq, Debug)] | ||
| 340 | +pub enum Reach { | ||
| 341 | + /// The id of the element on the card that does the same thing by click or | ||
| 342 | + /// by drag. | ||
| 343 | + Click(&'static str), | ||
| 344 | + /// Not an action a pointer takes: the way *out* of a card, and the hold | ||
| 345 | + /// that only repeats what a drag already does continuously. A variant | ||
| 346 | + /// rather than an omission, so a row with nothing to click is a decision | ||
| 347 | + /// somebody wrote down instead of a line missing from a list. | ||
| 348 | + Gesture, | ||
| 349 | +} | ||
| 350 | + | ||
| 351 | +/// The codec row's keys, from the export card's own table. Typed out here once, | ||
| 352 | +/// it named six of the seven codecs the same row's label advertised -- OGG had | ||
| 353 | +/// a key (`o`) that this card never said. | ||
| 354 | +fn codec_chord() -> String { | ||
| 355 | + crate::FORMATS | ||
| 356 | + .iter() | ||
| 357 | + .map(|(_, stroke, ..)| *stroke) | ||
| 358 | + .filter(|stroke| !stroke.is_empty()) | ||
| 359 | + .collect::<Vec<_>>() | ||
| 360 | + .join(" / ") | ||
| 354 | } | 361 | } |
| 355 | 362 | ||
| 356 | -pub const FIXED: [Fixed; 28] = [ | 363 | +pub static FIXED: std::sync::LazyLock<[Fixed; 28]> = std::sync::LazyLock::new(|| { |
| 357 | - // Not a chord at all but a way of pressing one, and the only place the | 364 | + [ |
| 358 | - // editor can say so: holding a key that moves a *value* runs it, and | 365 | + // Not a chord at all but a way of pressing one, and the only place the |
| 359 | - // holding anything else still does what one press did. | 366 | + // editor can say so: holding a key that moves a *value* runs it, and |
| 360 | - Fixed { | 367 | + // holding anything else still does what one press did. |
| 361 | - chord: "hold ← → ↑ ↓", | 368 | + Fixed { |
| 362 | - label: "Run a card's slider, or the volume and zoom keys, while held", | 369 | + chord: "hold ← → ↑ ↓".into(), |
| 363 | - category: Category::View, | 370 | + label: "Run a card's slider, or the volume and zoom keys, while held", |
| 364 | - }, | 371 | + category: Category::View, |
| 365 | - Fixed { | 372 | + reach: Reach::Gesture, |
| 366 | - chord: "esc", | 373 | + }, |
| 367 | - label: "Close this card or menu, or cancel a capture", | 374 | + Fixed { |
| 368 | - category: Category::View, | 375 | + chord: "esc".into(), |
| 369 | - }, | 376 | + label: "Close this card or menu, or cancel a capture", |
| 370 | - Fixed { | 377 | + category: Category::View, |
| 371 | - chord: "n", | 378 | + reach: Reach::Gesture, |
| 372 | - label: "Open the custom export bitrate field — ↑↓ step it", | 379 | + }, |
| 373 | - category: Category::File, | 380 | + Fixed { |
| 374 | - }, | 381 | + chord: "n".into(), |
| 375 | - Fixed { | 382 | + label: "Open the custom export bitrate field — ↑↓ step it", |
| 376 | - chord: "0–9", | 383 | + category: Category::File, |
| 377 | - label: "Type into that field — nothing outside it", | 384 | + reach: Reach::Click("quality"), |
| 378 | - category: Category::File, | 385 | + }, |
| 379 | - }, | 386 | + Fixed { |
| 380 | - Fixed { | 387 | + chord: "0–9".into(), |
| 381 | - chord: "m / a / h / w / f / p", | 388 | + label: "Type into that field — nothing outside it", |
| 382 | - label: "Pick the export codec: H.264, AV1, HEVC, WAV, FLAC, MP3 or OGG", | 389 | + category: Category::File, |
| 383 | - category: Category::File, | 390 | + reach: Reach::Click("mbps-up"), |
| 384 | - }, | 391 | + }, |
| 385 | - // The rest of the export card's own rows, each on the letter its row is | 392 | + Fixed { |
| 386 | - // named after. They shadow the clip keys of the same letter while the card | 393 | + chord: codec_chord(), |
| 387 | - // is up, exactly as its digits shadow nothing and its arrows would: a modal | 394 | + label: "Pick the export codec: H.264, AV1, HEVC, WAV, FLAC, MP3 or OGG", |
| 388 | - // card owns the keyboard, and cutting a clip under it is not a thing that | 395 | + category: Category::File, |
| 389 | - // can happen anyway. | 396 | + reach: Reach::Click("format"), |
| 390 | - Fixed { | 397 | + }, |
| 391 | - chord: "c", | 398 | + // The rest of the export card's own rows, each on the letter its row is |
| 392 | - label: "Switch the export container: Matroska or MP4", | 399 | + // named after. They shadow the clip keys of the same letter while the card |
| 393 | - category: Category::File, | 400 | + // is up, exactly as its digits shadow nothing and its arrows would: a modal |
| 394 | - }, | 401 | + // card owns the keyboard, and cutting a clip under it is not a thing that |
| 395 | - Fixed { | 402 | + // can happen anyway. |
| 396 | - chord: "q", | 403 | + Fixed { |
| 397 | - label: "Step through the export quality rows", | 404 | + chord: "c".into(), |
| 398 | - category: Category::File, | 405 | + label: "Switch the export container: Matroska or MP4", |
| 399 | - }, | 406 | + category: Category::File, |
| 400 | - Fixed { | 407 | + reach: Reach::Click("container"), |
| 401 | - chord: "b", | 408 | + }, |
| 402 | - label: "Step through the export sound bitrates", | 409 | + Fixed { |
| 403 | - category: Category::File, | 410 | + chord: "q".into(), |
| 404 | - }, | 411 | + label: "Step through the export quality rows", |
| 405 | - Fixed { | 412 | + category: Category::File, |
| 406 | - chord: "d", | 413 | + reach: Reach::Click("quality"), |
| 407 | - label: "Choose where the export is written", | 414 | + }, |
| 408 | - category: Category::File, | 415 | + Fixed { |
| 409 | - }, | 416 | + chord: "b".into(), |
| 410 | - Fixed { | 417 | + label: "Step through the export sound bitrates", |
| 411 | - chord: "g", | 418 | + category: Category::File, |
| 412 | - label: "Export card: sections or one flat list", | 419 | + reach: Reach::Click("sound"), |
| 413 | - category: Category::File, | 420 | + }, |
| 414 | - }, | 421 | + Fixed { |
| 415 | - Fixed { | 422 | + chord: "d".into(), |
| 416 | - chord: "r", | 423 | + label: "Choose where the export is written", |
| 417 | - label: "Export card: the formats with no encoder as rows or as one line", | 424 | + category: Category::File, |
| 418 | - category: Category::File, | 425 | + reach: Reach::Click("destination"), |
| 419 | - }, | 426 | + }, |
| 420 | - Fixed { | 427 | + Fixed { |
| 421 | - chord: "enter", | 428 | + chord: "g".into(), |
| 422 | - label: "Start the export — or commit the bitrate field", | 429 | + label: "Export card: sections or one flat list", |
| 423 | - category: Category::File, | 430 | + category: Category::File, |
| 424 | - }, | 431 | + reach: Reach::Click("export-layout"), |
| 425 | - Fixed { | 432 | + }, |
| 426 | - chord: "backspace", | 433 | + Fixed { |
| 427 | - label: "Erase a digit in the bitrate field", | 434 | + chord: "r".into(), |
| 428 | - category: Category::File, | 435 | + label: "Export card: the formats with no encoder as rows or as one line", |
| 429 | - }, | 436 | + category: Category::File, |
| 430 | - // The equalizer card's own input, for the same reason the export card has | 437 | + reach: Reach::Click("export-refusals"), |
| 431 | - // its own: a band nothing but a drag can reach is a band half the users of | 438 | + }, |
| 432 | - // this editor cannot move at all. Card-local, so none of them is bindable. | 439 | + Fixed { |
| 433 | - Fixed { | 440 | + chord: "enter".into(), |
| 434 | - chord: "1–9, 0", | 441 | + label: "Start the export — or commit the bitrate field", |
| 435 | - label: "Pick an equalizer band", | 442 | + category: Category::File, |
| 436 | - category: Category::Audio, | 443 | + reach: Reach::Click("export-confirm"), |
| 437 | - }, | 444 | + }, |
| 438 | - Fixed { | 445 | + Fixed { |
| 439 | - chord: "up", | 446 | + chord: "backspace".into(), |
| 440 | - label: "Raise the picked band 1 dB", | 447 | + label: "Erase a digit in the bitrate field", |
| 441 | - category: Category::Audio, | 448 | + category: Category::File, |
| 442 | - }, | 449 | + reach: Reach::Click("mbps-down"), |
| 443 | - Fixed { | 450 | + }, |
| 444 | - chord: "down", | 451 | + // The equalizer card's own input, for the same reason the export card has |
| 445 | - label: "Lower the picked band 1 dB", | 452 | + // its own: a band nothing but a drag can reach is a band half the users of |
| 446 | - category: Category::Audio, | 453 | + // this editor cannot move at all. Card-local, so none of them is bindable. |
| 447 | - }, | 454 | + Fixed { |
| 448 | - Fixed { | 455 | + chord: "1–9, 0".into(), |
| 449 | - chord: "← / →", | 456 | + label: "Pick an equalizer band", |
| 450 | - label: "Move the picked band down or up in frequency", | 457 | + category: Category::Audio, |
| 451 | - category: Category::Audio, | 458 | + reach: Reach::Click("eq-graph"), |
| 452 | - }, | 459 | + }, |
| 453 | - Fixed { | 460 | + Fixed { |
| 454 | - chord: "shift ← / →", | 461 | + chord: "up".into(), |
| 455 | - label: "Widen or narrow the picked band (its Q)", | 462 | + label: "Raise the picked band 1 dB", |
| 456 | - category: Category::Audio, | 463 | + category: Category::Audio, |
| 457 | - }, | 464 | + reach: Reach::Click("eq-gain-up"), |
| 458 | - Fixed { | 465 | + }, |
| 459 | - chord: "a", | 466 | + Fixed { |
| 460 | - label: "Add an equalizer band beside the picked one", | 467 | + chord: "down".into(), |
| 461 | - category: Category::Audio, | 468 | + label: "Lower the picked band 1 dB", |
| 462 | - }, | 469 | + category: Category::Audio, |
| 463 | - Fixed { | 470 | + reach: Reach::Click("eq-gain-down"), |
| 464 | - chord: "x", | 471 | + }, |
| 465 | - label: "Remove the picked equalizer band", | 472 | + Fixed { |
| 466 | - category: Category::Audio, | 473 | + chord: "← / →".into(), |
| 467 | - }, | 474 | + label: "Move the picked band down or up in frequency", |
| 468 | - Fixed { | 475 | + category: Category::Audio, |
| 469 | - chord: "f", | 476 | + reach: Reach::Click("eq-freq-up"), |
| 470 | - label: "Flatten the picked band (double-click does the same)", | 477 | + }, |
| 471 | - category: Category::Audio, | 478 | + Fixed { |
| 472 | - }, | 479 | + chord: "shift ← / →".into(), |
| 473 | - Fixed { | 480 | + label: "Widen or narrow the picked band (its Q)", |
| 474 | - chord: "r", | 481 | + category: Category::Audio, |
| 475 | - label: "Flatten every band", | 482 | + reach: Reach::Click("eq-q-wider"), |
| 476 | - category: Category::Audio, | 483 | + }, |
| 477 | - }, | 484 | + Fixed { |
| 478 | - Fixed { | 485 | + chord: "a".into(), |
| 479 | - chord: "s", | 486 | + label: "Add an equalizer band beside the picked one", |
| 480 | - label: "Show or hide the spectrum behind the curve", | 487 | + category: Category::Audio, |
| 481 | - category: Category::Audio, | 488 | + reach: Reach::Click("eq-add"), |
| 482 | - }, | 489 | + }, |
| 483 | - // The colour card's own three, which mean nothing outside it -- the same | 490 | + Fixed { |
| 484 | - // card-local input the export card's digits are. | 491 | + chord: "x".into(), |
| 485 | - Fixed { | 492 | + label: "Remove the picked equalizer band", |
| 486 | - chord: "↑ / ↓", | 493 | + category: Category::Audio, |
| 487 | - label: "Pick a colour slider", | 494 | + reach: Reach::Click("eq-remove"), |
| 488 | - category: Category::Clips, | 495 | + }, |
| 489 | - }, | 496 | + Fixed { |
| 490 | - Fixed { | 497 | + chord: "f".into(), |
| 491 | - chord: "← / →", | 498 | + label: "Flatten the picked band (double-click does the same)", |
| 492 | - label: "Move the picked colour slider", | 499 | + category: Category::Audio, |
| 493 | - category: Category::Clips, | 500 | + reach: Reach::Click("eq-flat-band"), |
| 494 | - }, | 501 | + }, |
| 495 | - Fixed { | 502 | + Fixed { |
| 496 | - chord: "r", | 503 | + chord: "r".into(), |
| 497 | - label: "Take the colour grade off the clip", | 504 | + label: "Flatten every band", |
| 498 | - category: Category::Clips, | 505 | + category: Category::Audio, |
| 499 | - }, | 506 | + reach: Reach::Click("eq-reset"), |
| 500 | - // The silence card's two apply keys. Card-local like every stroke above -- | 507 | + }, |
| 501 | - // they mean nothing while it is closed -- but the card is the one place in | 508 | + Fixed { |
| 502 | - // this editor where a key rewrites forty places at once, so both of them | 509 | + chord: "s".into(), |
| 503 | - // are listed rather than hidden in the card's own hint line. | 510 | + label: "Show or hide the spectrum behind the curve", |
| 504 | - Fixed { | 511 | + category: Category::Audio, |
| 505 | - chord: "enter", | 512 | + reach: Reach::Click("eq-spectrum"), |
| 506 | - label: "Cut every silence the card found", | 513 | + }, |
| 507 | - category: Category::Clips, | 514 | + // The colour card's own three, which mean nothing outside it -- the same |
| 508 | - }, | 515 | + // card-local input the export card's digits are. |
| 509 | - Fixed { | 516 | + Fixed { |
| 510 | - chord: "f", | 517 | + chord: "↑ / ↓".into(), |
| 511 | - label: "Speed the silences up instead of cutting them", | 518 | + label: "Pick a colour slider", |
| 512 | - category: Category::Clips, | 519 | + category: Category::Clips, |
| 513 | - }, | 520 | + reach: Reach::Click("color-row"), |
| 514 | -]; | 521 | + }, |
| 522 | + Fixed { | ||
| 523 | + chord: "← / →".into(), | ||
| 524 | + label: "Move the picked colour slider", | ||
| 525 | + category: Category::Clips, | ||
| 526 | + reach: Reach::Click("color-bar"), | ||
| 527 | + }, | ||
| 528 | + Fixed { | ||
| 529 | + chord: "r".into(), | ||
| 530 | + label: "Take the colour grade off the clip", | ||
| 531 | + category: Category::Clips, | ||
| 532 | + reach: Reach::Click("color-reset"), | ||
| 533 | + }, | ||
| 534 | + // The silence card's two apply keys. Card-local like every stroke above -- | ||
| 535 | + // they mean nothing while it is closed -- but the card is the one place in | ||
| 536 | + // this editor where a key rewrites forty places at once, so both of them | ||
| 537 | + // are listed rather than hidden in the card's own hint line. | ||
| 538 | + Fixed { | ||
| 539 | + chord: "enter".into(), | ||
| 540 | + label: "Cut every silence the card found", | ||
| 541 | + category: Category::Clips, | ||
| 542 | + reach: Reach::Click("silence-apply"), | ||
| 543 | + }, | ||
| 544 | + Fixed { | ||
| 545 | + chord: "f".into(), | ||
| 546 | + label: "Speed the silences up instead of cutting them", | ||
| 547 | + category: Category::Clips, | ||
| 548 | + reach: Reach::Click("silence-apply"), | ||
| 549 | + }, | ||
| 550 | + ] | ||
| 551 | +}); | ||
| 515 | 552 | ||
| 516 | /// A stroke as the key handler sees it: gpui's key name plus the one modifier | 553 | /// A stroke as the key handler sees it: gpui's key name plus the one modifier |
| 517 | /// this editor binds. Nothing else is a chord here -- shift and alt are part of | 554 | /// this editor binds. Nothing else is a chord here -- shift and alt are part of |
| @@ -1222,13 +1259,52 @@ mod tests { | |||
| 1222 | assert_eq!(whole("edith-keys 1\n").display(ActionId::Cut), "unbound"); | 1259 | assert_eq!(whole("edith-keys 1\n").display(ActionId::Cut), "unbound"); |
| 1223 | // The label is the editor's column, and never the file's word for it. | 1260 | // The label is the editor's column, and never the file's word for it. |
| 1224 | assert_eq!(ActionId::CancelExport.label(), "Cancel export"); | 1261 | assert_eq!(ActionId::CancelExport.label(), "Cancel export"); |
| 1225 | - assert_eq!(ActionId::ALL.len(), 42); | ||
| 1226 | assert_eq!(k.display(ActionId::ToggleSnap), "n"); | 1262 | assert_eq!(k.display(ActionId::ToggleSnap), "n"); |
| 1227 | assert_eq!(k.display(ActionId::ShowActions), "f1"); | 1263 | assert_eq!(k.display(ActionId::ShowActions), "f1"); |
| 1228 | assert_eq!(k.display(ActionId::ToggleSubtitles), "t"); | 1264 | assert_eq!(k.display(ActionId::ToggleSubtitles), "t"); |
| 1229 | assert_eq!(k.display(ActionId::ZoomIn), "ctrl+="); | 1265 | assert_eq!(k.display(ActionId::ZoomIn), "ctrl+="); |
| 1230 | } | 1266 | } |
| 1231 | 1267 | ||
| 1268 | + /// The one row of [`FIXED`] that speaks for a whole table elsewhere: it | ||
| 1269 | + /// named six keys for seven codecs, and OGG's `o` was a stroke the card | ||
| 1270 | + /// never mentioned. The chord is generated from `FORMATS` now, and this | ||
| 1271 | + /// holds the *label* to the same table -- a codec added there with no name | ||
| 1272 | + /// in this row fails here rather than in a user's hands. | ||
| 1273 | + #[test] | ||
| 1274 | + fn the_codec_row_says_every_codec_the_export_card_offers() { | ||
| 1275 | + let row = super::FIXED | ||
| 1276 | + .iter() | ||
| 1277 | + .find(|f| f.label.starts_with("Pick the export codec")) | ||
| 1278 | + .expect("the codec row"); | ||
| 1279 | + let keys: Vec<&str> = row.chord.split(" / ").collect(); | ||
| 1280 | + for (boxes, stroke, label, _) in crate::FORMATS { | ||
| 1281 | + if stroke.is_empty() { | ||
| 1282 | + // A codec this program cannot write at all has no key and no | ||
| 1283 | + // business in this row. | ||
| 1284 | + assert!(boxes.is_empty(), "{label} has a box but no stroke"); | ||
| 1285 | + assert!(!keys.contains(&stroke)); | ||
| 1286 | + continue; | ||
| 1287 | + } | ||
| 1288 | + assert!( | ||
| 1289 | + keys.contains(&stroke), | ||
| 1290 | + "{label}'s key {stroke:?} is not in {:?}", | ||
| 1291 | + row.chord | ||
| 1292 | + ); | ||
| 1293 | + assert!( | ||
| 1294 | + row.label.contains(label), | ||
| 1295 | + "{label} is not named in {:?}", | ||
| 1296 | + row.label | ||
| 1297 | + ); | ||
| 1298 | + } | ||
| 1299 | + assert_eq!( | ||
| 1300 | + keys.len(), | ||
| 1301 | + crate::FORMATS | ||
| 1302 | + .iter() | ||
| 1303 | + .filter(|(_, s, ..)| !s.is_empty()) | ||
| 1304 | + .count() | ||
| 1305 | + ); | ||
| 1306 | + } | ||
| 1307 | + | ||
| 1232 | #[test] | 1308 | #[test] |
| 1233 | fn a_saved_keymap_comes_back_off_the_disk() { | 1309 | fn a_saved_keymap_comes_back_off_the_disk() { |
| 1234 | // Its own directory, never the real config one: this test writes. | 1310 | // Its own directory, never the real config one: this test writes. |
crates/app/src/main.rsmodified+538 -367
| @@ -473,6 +473,18 @@ struct Trim { | |||
| 473 | /// still the body. | 473 | /// still the body. |
| 474 | const EDGE_W: f32 = 6.; | 474 | const EDGE_W: f32 = 6.; |
| 475 | 475 | ||
| 476 | +/// Whether a clip box this wide gets its two trim strips at all. Below three | ||
| 477 | +/// handles wide the pair would occlude the whole box: every press on it would | ||
| 478 | +/// trim, and the clip could not be selected, dragged to another lane or picked | ||
| 479 | +/// up by its middle -- which is exactly what a jumpcut leaves behind | ||
| 480 | +/// ([`Player::cut_silences`] manufactures a great many short clips). Above it, | ||
| 481 | +/// what is left between the two strips is a handle's width of body in its own | ||
| 482 | +/// right. A clip too short for its handles is trimmed by zooming in first: the | ||
| 483 | +/// bed is a magnifier, and the strip grows with the box. | ||
| 484 | +fn trims(width: f32) -> bool { | ||
| 485 | + width >= 3. * EDGE_W | ||
| 486 | +} | ||
| 487 | + | ||
| 476 | /// How close to an edge a dragged clip has to be let go for it to land *on* it: | 488 | /// How close to an edge a dragged clip has to be let go for it to land *on* it: |
| 477 | /// the snap every timeline has, in pixels rather than frames so that it feels | 489 | /// the snap every timeline has, in pixels rather than frames so that it feels |
| 478 | /// the same at every zoom. Narrower than [`EDGE_W`] -- a hand aiming between two | 490 | /// the same at every zoom. Narrower than [`EDGE_W`] -- a hand aiming between two |
| @@ -693,7 +705,7 @@ fn keys_filter(needle: &str, keymap: &Keymap) -> Vec<(usize, KeyRow)> { | |||
| 693 | } | 705 | } |
| 694 | KeyRow::Fixed(f) => { | 706 | KeyRow::Fixed(f) => { |
| 695 | let fixed = &keymap::FIXED[*f]; | 707 | let fixed = &keymap::FIXED[*f]; |
| 696 | - if hit(fixed.label, fixed.chord) { | 708 | + if hit(fixed.label, &fixed.chord) { |
| 697 | out.extend(pending.take()); | 709 | out.extend(pending.take()); |
| 698 | out.push((i, row)); | 710 | out.push((i, row)); |
| 699 | } | 711 | } |
| @@ -6196,347 +6208,382 @@ impl Player { | |||
| 6196 | // off the right edge is a button a pointer cannot press. A plain | 6208 | // off the right edge is a button a pointer cannot press. A plain |
| 6197 | // wheel moves it -- gpui puts a vertical delta on the x axis when | 6209 | // wheel moves it -- gpui puts a vertical delta on the x axis when |
| 6198 | // that is the only one scrolling (div.rs:2424). | 6210 | // that is the only one scrolling (div.rs:2424). |
| 6211 | + // | ||
| 6212 | + // ...and "it scrolls" is not "it can be found": the button beside | ||
| 6213 | + // the row is pinned outside it and never scrolls away, so Export, | ||
| 6214 | + // Save and the rest are one press from the smallest window even | ||
| 6215 | + // when the row's tail is off the edge. | ||
| 6216 | + // `toolbar_fits_the_smallest_window` is the guard. | ||
| 6199 | .child( | 6217 | .child( |
| 6200 | div() | 6218 | div() |
| 6201 | - .id("controls") | ||
| 6202 | .flex_none() | 6219 | .flex_none() |
| 6203 | .flex() | 6220 | .flex() |
| 6204 | .items_center() | 6221 | .items_center() |
| 6205 | .gap(px(8.)) | 6222 | .gap(px(8.)) |
| 6206 | - .overflow_x_scroll() | 6223 | + .child( |
| 6207 | - .child(control( | 6224 | + div() |
| 6208 | - "transport", | 6225 | + .id("controls") |
| 6209 | - Some(transport_glyph(state).into_any_element()), | 6226 | + .flex_1() |
| 6210 | - if state.is_playing() { "Pause" } else { "Play" }, | 6227 | + .min_w(px(0.)) |
| 6211 | - if nothing_to_play(self.session.as_ref()) && !state.is_playing() { | 6228 | + .flex() |
| 6212 | - format!("{} — put a clip on a lane first", key(ActionId::Play)) | 6229 | + .items_center() |
| 6213 | - } else { | 6230 | + .gap(px(8.)) |
| 6214 | - key(ActionId::Play) | 6231 | + .overflow_x_scroll() |
| 6215 | - }, | 6232 | + .child(control( |
| 6216 | - // An empty timeline has nothing to play, so the button | 6233 | + "transport", |
| 6217 | - // says so by being dim rather than by starting a clock | 6234 | + Some(transport_glyph(state).into_any_element()), |
| 6218 | - // against nothing (the key press answers with the | 6235 | + if state.is_playing() { "Pause" } else { "Play" }, |
| 6219 | - // notice). Still live while it *is* playing: a delete | 6236 | + if nothing_to_play(self.session.as_ref()) && !state.is_playing() { |
| 6220 | - // can empty the timeline mid-play and that has to stop. | 6237 | + format!("{} — put a clip on a lane first", key(ActionId::Play)) |
| 6221 | - live && (state.is_playing() || !nothing_to_play(self.session.as_ref())), | 6238 | + } else { |
| 6222 | - cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_or_restart(cx)), | 6239 | + key(ActionId::Play) |
| 6223 | - )) | 6240 | + }, |
| 6224 | - .child(separator()) | 6241 | + // An empty timeline has nothing to play, so the button |
| 6225 | - .child(control( | 6242 | + // says so by being dim rather than by starting a clock |
| 6226 | - "cut", | 6243 | + // against nothing (the key press answers with the |
| 6227 | - Some(cut_glyph().into_any_element()), | 6244 | + // notice). Still live while it *is* playing: a delete |
| 6228 | - "Cut", | 6245 | + // can empty the timeline mid-play and that has to stop. |
| 6229 | - format!( | 6246 | + live && (state.is_playing() || !nothing_to_play(self.session.as_ref())), |
| 6230 | - "{} — splits the clip under the playhead", | 6247 | + cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_or_restart(cx)), |
| 6231 | - key(ActionId::Cut) | 6248 | + )) |
| 6232 | - ), | 6249 | + .child(separator()) |
| 6233 | - live, | 6250 | + .child(control( |
| 6234 | - cx.listener(|this, _: &ClickEvent, _, cx| this.cut(cx)), | 6251 | + "cut", |
| 6235 | - )) | 6252 | + Some(cut_glyph().into_any_element()), |
| 6236 | - .child(control( | 6253 | + "Cut", |
| 6237 | - "delete", | 6254 | + format!( |
| 6238 | - Some(delete_glyph().into_any_element()), | 6255 | + "{} — splits the clip under the playhead", |
| 6239 | - "Delete", | 6256 | + key(ActionId::Cut) |
| 6240 | - if self.selected.is_some() { | 6257 | + ), |
| 6241 | - key(ActionId::Delete) | 6258 | + live, |
| 6242 | - } else { | 6259 | + cx.listener(|this, _: &ClickEvent, _, cx| this.cut(cx)), |
| 6243 | - format!("{} — click a clip below first", key(ActionId::Delete)) | 6260 | + )) |
| 6244 | - }, | 6261 | + .child(control( |
| 6245 | - live && self.selected.is_some(), | 6262 | + "delete", |
| 6246 | - cx.listener(|this, _: &ClickEvent, _, cx| this.delete_selected(cx)), | 6263 | + Some(delete_glyph().into_any_element()), |
| 6247 | - )) | 6264 | + "Delete", |
| 6248 | - // The way back from every one of them. It was a stroke and | 6265 | + if self.selected.is_some() { |
| 6249 | - // nothing else, which made the whole edit group a one-way | 6266 | + key(ActionId::Delete) |
| 6250 | - // door for anyone working with a pointer. | 6267 | + } else { |
| 6251 | - .child(control( | 6268 | + format!("{} — click a clip below first", key(ActionId::Delete)) |
| 6252 | - "undo", | 6269 | + }, |
| 6253 | - None, | 6270 | + live && self.selected.is_some(), |
| 6254 | - "Undo", | 6271 | + cx.listener(|this, _: &ClickEvent, _, cx| this.delete_selected(cx)), |
| 6255 | - format!("{} — takes the last edit back", key(ActionId::Undo)), | 6272 | + )) |
| 6256 | - live, | 6273 | + // The way back from every one of them. It was a stroke and |
| 6257 | - cx.listener(|this, _: &ClickEvent, _, cx| this.undo(cx)), | 6274 | + // nothing else, which made the whole edit group a one-way |
| 6258 | - )) | 6275 | + // door for anyone working with a pointer. |
| 6259 | - // With the edit group, beside the buttons that change the | 6276 | + .child(control( |
| 6260 | - // edit list: a track is a row of it, and adding one is an | 6277 | + "undo", |
| 6261 | - // undoable edit like the rest. Two buttons rather than one | 6278 | + None, |
| 6262 | - // with a choice, because the choice is the whole action. | 6279 | + "Undo", |
| 6263 | - .child(control( | 6280 | + format!("{} — takes the last edit back", key(ActionId::Undo)), |
| 6264 | - "add-video-lane", | 6281 | + live, |
| 6265 | - None, | 6282 | + cx.listener(|this, _: &ClickEvent, _, cx| this.undo(cx)), |
| 6266 | - "+ V", | 6283 | + )) |
| 6267 | - format!( | 6284 | + // With the edit group, beside the buttons that change the |
| 6268 | - "{} — adds a video track under the ones there", | 6285 | + // edit list: a track is a row of it, and adding one is an |
| 6269 | - key(ActionId::AddVideoLane) | 6286 | + // undoable edit like the rest. Two buttons rather than one |
| 6270 | - ), | 6287 | + // with a choice, because the choice is the whole action. |
| 6271 | - live, | 6288 | + .child(control( |
| 6272 | - cx.listener(|this, _: &ClickEvent, _, cx| { | 6289 | + "add-video-lane", |
| 6273 | - this.add_lane(LaneKind::Video, cx) | 6290 | + None, |
| 6274 | - }), | 6291 | + "+ V", |
| 6275 | - )) | 6292 | + format!( |
| 6276 | - .child(control( | 6293 | + "{} — adds a video track under the ones there", |
| 6277 | - "add-audio-lane", | 6294 | + key(ActionId::AddVideoLane) |
| 6278 | - None, | 6295 | + ), |
| 6279 | - "+ A", | 6296 | + live, |
| 6280 | - format!( | 6297 | + cx.listener(|this, _: &ClickEvent, _, cx| { |
| 6281 | - "{} — adds an audio track under the ones there", | 6298 | + this.add_lane(LaneKind::Video, cx) |
| 6282 | - key(ActionId::AddAudioLane) | 6299 | + }), |
| 6283 | - ), | 6300 | + )) |
| 6284 | - live, | 6301 | + .child(control( |
| 6285 | - cx.listener(|this, _: &ClickEvent, _, cx| { | 6302 | + "add-audio-lane", |
| 6286 | - this.add_lane(LaneKind::Audio, cx) | 6303 | + None, |
| 6287 | - }), | 6304 | + "+ A", |
| 6288 | - )) | 6305 | + format!( |
| 6289 | - // With the transport, not the edit group: it changes what | 6306 | + "{} — adds an audio track under the ones there", |
| 6290 | - // the file sounds like, never what it is. Reads as its own | 6307 | + key(ActionId::AddAudioLane) |
| 6291 | - // state, so muted is legible without a tooltip. | 6308 | + ), |
| 6292 | - .child(control( | 6309 | + live, |
| 6293 | - "volume", | 6310 | + cx.listener(|this, _: &ClickEvent, _, cx| { |
| 6294 | - None, | 6311 | + this.add_lane(LaneKind::Audio, cx) |
| 6295 | - self.volume.label(), | 6312 | + }), |
| 6296 | - format!( | 6313 | + )) |
| 6297 | - "{} mutes · {} louder · {} quieter", | 6314 | + // With the transport, not the edit group: it changes what |
| 6298 | - key(ActionId::ToggleMute), | 6315 | + // the file sounds like, never what it is. Reads as its own |
| 6299 | - key(ActionId::VolumeUp), | 6316 | + // state, so muted is legible without a tooltip. |
| 6300 | - key(ActionId::VolumeDown) | 6317 | + .child(control( |
| 6301 | - ), | 6318 | + "volume", |
| 6302 | - live, | 6319 | + None, |
| 6303 | - cx.listener(|this, _: &ClickEvent, _, cx| { | 6320 | + self.volume.label(), |
| 6304 | - this.set_volume(|volume| volume.muted = !volume.muted, cx) | 6321 | + format!( |
| 6305 | - }), | 6322 | + "{} mutes · {} louder · {} quieter", |
| 6306 | - )) | 6323 | + key(ActionId::ToggleMute), |
| 6307 | - // The level itself, to drag. The button beside it stays the | 6324 | + key(ActionId::VolumeUp), |
| 6308 | - // mute -- one gesture each -- and the label above is what | 6325 | + key(ActionId::VolumeDown) |
| 6309 | - // this writes, live, so the number follows the hand. | 6326 | + ), |
| 6310 | - .child(volume_slider( | 6327 | + live, |
| 6311 | - self.volume, | 6328 | + cx.listener(|this, _: &ClickEvent, _, cx| { |
| 6312 | - self.volume_bar.clone(), | 6329 | + this.set_volume(|volume| volume.muted = !volume.muted, cx) |
| 6313 | - live, | 6330 | + }), |
| 6314 | - cx, | 6331 | + )) |
| 6315 | - )) | 6332 | + // The level itself, to drag. The button beside it stays the |
| 6316 | - .child(separator()) | 6333 | + // mute -- one gesture each -- and the label above is what |
| 6317 | - // The size every clip is composed onto, which is also the | 6334 | + // this writes, live, so the number follows the hand. |
| 6318 | - // size the export comes out at. Five sizes, so a click opens | 6335 | + .child(volume_slider( |
| 6319 | - // the list of them with this one marked and picks whichever | 6336 | + self.volume, |
| 6320 | - // was meant: a button that stepped one on per press made the | 6337 | + self.volume_bar.clone(), |
| 6321 | - // user click round the ladder to get back to where they | 6338 | + live, |
| 6322 | - // were. The stroke still steps, for the hand already on it. | 6339 | + cx, |
| 6323 | - .child(control( | 6340 | + )) |
| 6324 | - "resolution", | 6341 | + .child(separator()) |
| 6325 | - None, | 6342 | + // The size every clip is composed onto, which is also the |
| 6326 | - resolution.map_or_else(|| "Size".to_string(), |(_, h)| format!("{h}p")), | 6343 | + // size the export comes out at. Five sizes, so a click opens |
| 6327 | - match resolution { | 6344 | + // the list of them with this one marked and picks whichever |
| 6328 | - Some((w, h)) => format!( | 6345 | + // was meant: a button that stepped one on per press made the |
| 6329 | - "click to pick a size — the project is {w}x{h}; {} steps to the next", | 6346 | + // user click round the ladder to get back to where they |
| 6330 | - key(ActionId::Resolution) | 6347 | + // were. The stroke still steps, for the hand already on it. |
| 6331 | - ), | 6348 | + .child(control( |
| 6332 | - None => format!("{} — open a file first", key(ActionId::Resolution)), | 6349 | + "resolution", |
| 6333 | - }, | 6350 | + None, |
| 6334 | - live, | 6351 | + resolution.map_or_else(|| "Size".to_string(), |(_, h)| format!("{h}p")), |
| 6335 | - cx.listener(|this, event: &ClickEvent, _, cx| { | 6352 | + match resolution { |
| 6336 | - this.open_picker(Pick::Resolution, event.position(), cx) | 6353 | + Some((w, h)) => format!( |
| 6337 | - }), | 6354 | + "click to pick a size — the project is {w}x{h}; {} steps to the next", |
| 6338 | - )) | 6355 | + key(ActionId::Resolution) |
| 6339 | - // The rate every clip is counted in, which is also the rate | 6356 | + ), |
| 6340 | - // the export is written at -- the other half of "the project | 6357 | + None => format!("{} — open a file first", key(ActionId::Resolution)), |
| 6341 | - // is not the media", and the one the panel could only ever | 6358 | + }, |
| 6342 | - // read out before. A click opens the rates with this one | 6359 | + live, |
| 6343 | - // marked; picking one conforms the whole timeline to it. | 6360 | + cx.listener(|this, event: &ClickEvent, _, cx| { |
| 6344 | - .child(control( | 6361 | + this.open_picker(Pick::Resolution, event.position(), cx) |
| 6345 | - "fps", | 6362 | + }), |
| 6346 | - None, | 6363 | + )) |
| 6347 | - match self.session.is_some() { | 6364 | + // The rate every clip is counted in, which is also the rate |
| 6348 | - true => format!("{} fps", fps_label(self.fps)), | 6365 | + // the export is written at -- the other half of "the project |
| 6349 | - false => "Rate".to_string(), | 6366 | + // is not the media", and the one the panel could only ever |
| 6350 | - }, | 6367 | + // read out before. A click opens the rates with this one |
| 6351 | - match self.session.is_some() { | 6368 | + // marked; picking one conforms the whole timeline to it. |
| 6352 | - true => format!( | 6369 | + .child(control( |
| 6353 | - "click to pick a frame rate — the project is cut at {} fps", | 6370 | + "fps", |
| 6354 | - fps_label(self.fps) | 6371 | + None, |
| 6355 | - ), | 6372 | + match self.session.is_some() { |
| 6356 | - false => "the project's frame rate — open a file first".to_string(), | 6373 | + true => format!("{} fps", fps_label(self.fps)), |
| 6357 | - }, | 6374 | + false => "Rate".to_string(), |
| 6358 | - live, | 6375 | + }, |
| 6359 | - cx.listener(|this, event: &ClickEvent, _, cx| { | 6376 | + match self.session.is_some() { |
| 6360 | - this.open_picker(Pick::Fps, event.position(), cx) | 6377 | + true => format!( |
| 6361 | - }), | 6378 | + "click to pick a frame rate — the project is cut at {} fps", |
| 6362 | - )) | 6379 | + fps_label(self.fps) |
| 6363 | - // ...and which rendition its HDR media is watched in, the | 6380 | + ), |
| 6364 | - // third thing that is the project's rather than the media's. | 6381 | + false => "the project's frame rate — open a file first".to_string(), |
| 6365 | - // Listed whatever is on the timeline, and the tooltip says | 6382 | + }, |
| 6366 | - // who it acts on: a control that came and went with the | 6383 | + live, |
| 6367 | - // media would be one nobody could find when they wanted it. | 6384 | + cx.listener(|this, event: &ClickEvent, _, cx| { |
| 6368 | - .child(control( | 6385 | + this.open_picker(Pick::Fps, event.position(), cx) |
| 6369 | - "tonemap", | 6386 | + }), |
| 6370 | - None, | 6387 | + )) |
| 6371 | - match &self.session { | 6388 | + // ...and which rendition its HDR media is watched in, the |
| 6372 | - Some(session) => format!("HDR {}", tone_label(session.tone())), | 6389 | + // third thing that is the project's rather than the media's. |
| 6373 | - None => "HDR".to_string(), | 6390 | + // Listed whatever is on the timeline, and the tooltip says |
| 6374 | - }, | 6391 | + // who it acts on: a control that came and went with the |
| 6375 | - match &self.session { | 6392 | + // media would be one nobody could find when they wanted it. |
| 6376 | - Some(session) => format!( | 6393 | + .child(control( |
| 6377 | - "click to pick the HDR rendition — the project is {}; SDR media is untouched", | 6394 | + "tonemap", |
| 6378 | - tone_label(session.tone()) | 6395 | + None, |
| 6379 | - ), | 6396 | + match &self.session { |
| 6380 | - None => "the HDR rendition — open a file first".to_string(), | 6397 | + Some(session) => format!("HDR {}", tone_label(session.tone())), |
| 6381 | - }, | 6398 | + None => "HDR".to_string(), |
| 6382 | - live, | 6399 | + }, |
| 6383 | - cx.listener(|this, event: &ClickEvent, _, cx| { | 6400 | + match &self.session { |
| 6384 | - this.open_picker(Pick::Tone, event.position(), cx) | 6401 | + Some(session) => format!( |
| 6385 | - }), | 6402 | + "click to pick the HDR rendition — the project is {}; SDR media is untouched", |
| 6386 | - )) | 6403 | + tone_label(session.tone()) |
| 6387 | - // How much of the timeline the panel below is showing -- | 6404 | + ), |
| 6388 | - // beside the resolution, since neither of them edits | 6405 | + None => "the HDR rendition — open a file first".to_string(), |
| 6389 | - // anything: they are both what is being looked at. The | 6406 | + }, |
| 6390 | - // middle one says how much of it is on the bed, and is the | 6407 | + live, |
| 6391 | - // way back to the whole of it. | 6408 | + cx.listener(|this, event: &ClickEvent, _, cx| { |
| 6392 | - .child(control( | 6409 | + this.open_picker(Pick::Tone, event.position(), cx) |
| 6393 | - "zoom-out", | 6410 | + }), |
| 6394 | - None, | 6411 | + )) |
| 6395 | - "−", | 6412 | + // How much of the timeline the panel below is showing -- |
| 6396 | - format!( | 6413 | + // beside the resolution, since neither of them edits |
| 6397 | - "{} — show more of the timeline; stops with all of it on the bed", | 6414 | + // anything: they are both what is being looked at. The |
| 6398 | - key(ActionId::ZoomOut) | 6415 | + // middle one says how much of it is on the bed, and is the |
| 6399 | - ), | 6416 | + // way back to the whole of it. |
| 6400 | - live, | 6417 | + .child(control( |
| 6401 | - cx.listener(|this, _: &ClickEvent, _, cx| { | 6418 | + "zoom-out", |
| 6402 | - this.zoom(1. / ZOOM_STEP, None, cx) | 6419 | + None, |
| 6403 | - }), | 6420 | + "−", |
| 6404 | - )) | 6421 | + format!( |
| 6405 | - .child(control( | 6422 | + "{} — show more of the timeline; stops with all of it on the bed", |
| 6406 | - "zoom-fit", | 6423 | + key(ActionId::ZoomOut) |
| 6407 | - None, | 6424 | + ), |
| 6408 | - // How much timeline is on the bed, not a multiple of | 6425 | + live, |
| 6409 | - // "the whole of it": the scale no longer knows what the | 6426 | + cx.listener(|this, _: &ClickEvent, _, cx| { |
| 6410 | - // whole of it is, and a number that changed on every | 6427 | + this.zoom(1. / ZOOM_STEP, None, cx) |
| 6411 | - // import was a number that lied. | 6428 | + }), |
| 6412 | - span_label(self.view().span()), | 6429 | + )) |
| 6413 | - format!( | 6430 | + .child(control( |
| 6414 | - "{} — fit the whole timeline; showing {} to {}", | 6431 | + "zoom-fit", |
| 6415 | - key(ActionId::ZoomFit), | 6432 | + None, |
| 6416 | - timecode(self.scale.start, self.fps), | 6433 | + // How much timeline is on the bed, not a multiple of |
| 6417 | - timecode( | 6434 | + // "the whole of it": the scale no longer knows what the |
| 6418 | - (self.scale.start + self.view().span()).min(duration), | 6435 | + // whole of it is, and a number that changed on every |
| 6419 | - self.fps | 6436 | + // import was a number that lied. |
| 6420 | - ) | 6437 | + span_label(self.view().span()), |
| 6421 | - ), | 6438 | + format!( |
| 6422 | - live, | 6439 | + "{} — fit the whole timeline; showing {} to {}", |
| 6423 | - cx.listener(|this, _: &ClickEvent, _, cx| this.zoom_fit(cx)), | 6440 | + key(ActionId::ZoomFit), |
| 6424 | - )) | 6441 | + timecode(self.scale.start, self.fps), |
| 6425 | - .child(control( | 6442 | + timecode( |
| 6426 | - "zoom-in", | 6443 | + (self.scale.start + self.view().span()).min(duration), |
| 6427 | - None, | 6444 | + self.fps |
| 6428 | - "+", | 6445 | + ) |
| 6429 | - format!( | 6446 | + ), |
| 6430 | - "{} — magnify around the playhead; ctrl+wheel on the bar zooms at the pointer", | 6447 | + live, |
| 6431 | - key(ActionId::ZoomIn) | 6448 | + cx.listener(|this, _: &ClickEvent, _, cx| this.zoom_fit(cx)), |
| 6432 | - ), | 6449 | + )) |
| 6433 | - live, | 6450 | + .child(control( |
| 6434 | - cx.listener(|this, _: &ClickEvent, _, cx| this.zoom(ZOOM_STEP, None, cx)), | 6451 | + "zoom-in", |
| 6435 | - )) | 6452 | + None, |
| 6436 | - // The magnet, beside the zoom for the zoom's own reason: it | 6453 | + "+", |
| 6437 | - // changes nothing on the timeline, it changes how the hand | 6454 | + format!( |
| 6438 | - // meets it. The label is the state, as the volume's is -- | 6455 | + "{} — magnify around the playhead; ctrl+wheel on the bar zooms at the pointer", |
| 6439 | - // a toggle that looks the same either way says nothing. | 6456 | + key(ActionId::ZoomIn) |
| 6440 | - .child(control( | 6457 | + ), |
| 6441 | - "snap", | 6458 | + live, |
| 6442 | - None, | 6459 | + cx.listener(|this, _: &ClickEvent, _, cx| this.zoom(ZOOM_STEP, None, cx)), |
| 6443 | - if self.snap { "Snap" } else { "No snap" }, | 6460 | + )) |
| 6444 | - format!( | 6461 | + // The magnet, beside the zoom for the zoom's own reason: it |
| 6445 | - "{} — {}", | 6462 | + // changes nothing on the timeline, it changes how the hand |
| 6446 | - key(ActionId::ToggleSnap), | 6463 | + // meets it. The label is the state, as the volume's is -- |
| 6447 | - match self.snap { | 6464 | + // a toggle that looks the same either way says nothing. |
| 6448 | - true => "drags and trims land on clip edges, the playhead and the start", | 6465 | + .child(control( |
| 6449 | - false => "drags and trims land exactly where the hand leaves them", | 6466 | + "snap", |
| 6450 | - } | 6467 | + None, |
| 6451 | - ), | 6468 | + if self.snap { "Snap" } else { "No snap" }, |
| 6452 | - live, | 6469 | + format!( |
| 6453 | - cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_snap(cx)), | 6470 | + "{} — {}", |
| 6454 | - )) | 6471 | + key(ActionId::ToggleSnap), |
| 6455 | - // The cues over the picture, off and on -- beside the zoom | 6472 | + match self.snap { |
| 6456 | - // and the snap, since like both of them it changes what is | 6473 | + true => "drags and trims land on clip edges, the playhead and the start", |
| 6457 | - // being looked at and nothing about the edit. The label is | 6474 | + false => "drags and trims land exactly where the hand leaves them", |
| 6458 | - // the state, as the snap's is, and it says what there is to | 6475 | + } |
| 6459 | - // toggle when there is nothing. | 6476 | + ), |
| 6460 | - .child(control( | 6477 | + live, |
| 6461 | - "subs", | 6478 | + cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_snap(cx)), |
| 6462 | - None, | 6479 | + )) |
| 6463 | - match (self.subtitle_track().is_some(), self.subs_on) { | 6480 | + // The cues over the picture, off and on -- beside the zoom |
| 6464 | - (false, _) => "No subs", | 6481 | + // and the snap, since like both of them it changes what is |
| 6465 | - (true, true) => "Subs", | 6482 | + // being looked at and nothing about the edit. The label is |
| 6466 | - (true, false) => "Subs off", | 6483 | + // the state, as the snap's is, and it says what there is to |
| 6467 | - }, | 6484 | + // toggle when there is nothing. |
| 6468 | - match self.enable(ActionId::ToggleSubtitles, None).why() { | 6485 | + .child(control( |
| 6469 | - Some(why) => format!( | 6486 | + "subs", |
| 6470 | - "{} — {why}; drop a .srt on the window, or open an mkv that carries them", | 6487 | + None, |
| 6471 | - key(ActionId::ToggleSubtitles) | 6488 | + match (self.subtitle_track().is_some(), self.subs_on) { |
| 6472 | - ), | 6489 | + (false, _) => "No subs", |
| 6473 | - None => format!( | 6490 | + (true, true) => "Subs", |
| 6474 | - "{} — {}", | 6491 | + (true, false) => "Subs off", |
| 6475 | - key(ActionId::ToggleSubtitles), | 6492 | + }, |
| 6476 | - match self.subs_on { | 6493 | + match self.enable(ActionId::ToggleSubtitles, None).why() { |
| 6477 | - true => "the cue under the playhead is drawn over the picture", | 6494 | + Some(why) => format!( |
| 6478 | - false => "the cues are on the timeline and off the picture", | 6495 | + "{} — {why}; drop a .srt on the window, or open an mkv that carries them", |
| 6479 | - } | 6496 | + key(ActionId::ToggleSubtitles) |
| 6480 | - ), | 6497 | + ), |
| 6481 | - }, | 6498 | + None => format!( |
| 6482 | - live && self.enable(ActionId::ToggleSubtitles, None).yes(), | 6499 | + "{} — {}", |
| 6483 | - cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_subtitles(cx)), | 6500 | + key(ActionId::ToggleSubtitles), |
| 6484 | - )) | 6501 | + match self.subs_on { |
| 6485 | - // Import is not here: it belongs to the media list it adds | 6502 | + true => "the cue under the playhead is drawn over the picture", |
| 6486 | - // to, and two doors into one action is a question about | 6503 | + false => "the cues are on the timeline and off the picture", |
| 6487 | - // which one is the real one. | 6504 | + } |
| 6488 | - // | 6505 | + ), |
| 6489 | - // While one runs, this button is the way out of it: the | 6506 | + }, |
| 6490 | - // progress line promised esc and nothing else, which left a | 6507 | + live && self.enable(ActionId::ToggleSubtitles, None).yes(), |
| 6491 | - // pointer no way to stop an export it had started. | 6508 | + cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_subtitles(cx)), |
| 6492 | - .child(control( | 6509 | + )) |
| 6493 | - "export", | 6510 | + // Import is not here: it belongs to the media list it adds |
| 6494 | - None, | 6511 | + // to, and two doors into one action is a question about |
| 6495 | - if exporting { "Cancel" } else { "Export" }, | 6512 | + // which one is the real one. |
| 6496 | - if exporting { | 6513 | + // |
| 6497 | - format!( | 6514 | + // While one runs, this button is the way out of it: the |
| 6498 | - "{} — stops the export; the part-written file goes", | 6515 | + // progress line promised esc and nothing else, which left a |
| 6499 | - key(ActionId::CancelExport) | 6516 | + // pointer no way to stop an export it had started. |
| 6500 | - ) | 6517 | + .child(control( |
| 6501 | - } else { | 6518 | + "export", |
| 6502 | - format!( | 6519 | + None, |
| 6503 | - "{} — quality and destination, then writes the timeline out", | 6520 | + if exporting { "Cancel" } else { "Export" }, |
| 6504 | - key(ActionId::Export) | 6521 | + if exporting { |
| 6505 | - ) | 6522 | + format!( |
| 6506 | - }, | 6523 | + "{} — stops the export; the part-written file goes", |
| 6507 | - if exporting { | 6524 | + key(ActionId::CancelExport) |
| 6508 | - true | 6525 | + ) |
| 6509 | - } else { | 6526 | + } else { |
| 6510 | - live && self.export.is_none() | 6527 | + format!( |
| 6511 | - }, | 6528 | + "{} — quality and destination, then writes the timeline out", |
| 6512 | - cx.listener(|this, _: &ClickEvent, _, cx| { | 6529 | + key(ActionId::Export) |
| 6513 | - if this.exporting().is_some() { | 6530 | + ) |
| 6514 | - this.cancel_export(); | 6531 | + }, |
| 6515 | - cx.notify(); | 6532 | + if exporting { |
| 6516 | - } else { | 6533 | + true |
| 6517 | - this.open_export(cx); | 6534 | + } else { |
| 6518 | - } | 6535 | + live && self.export.is_none() |
| 6519 | - }), | 6536 | + }, |
| 6520 | - )) | 6537 | + cx.listener(|this, _: &ClickEvent, _, cx| { |
| 6521 | - .child(control( | 6538 | + if this.exporting().is_some() { |
| 6522 | - "save", | 6539 | + this.cancel_export(); |
| 6523 | - None, | 6540 | + cx.notify(); |
| 6524 | - "Save", | 6541 | + } else { |
| 6525 | - format!("{} — writes the project file", key(ActionId::Save)), | 6542 | + this.open_export(cx); |
| 6526 | - live, | 6543 | + } |
| 6527 | - cx.listener(|this, _: &ClickEvent, _, cx| this.save_project(cx)), | 6544 | + }), |
| 6528 | - )) | 6545 | + )) |
| 6529 | - // Closed while an export runs, which is what keeps a waiting | 6546 | + .child(control( |
| 6530 | - // row from swallowing the escape the progress line promises | 6547 | + "save", |
| 6531 | - // cancels the export. | 6548 | + None, |
| 6549 | + "Save", | ||
| 6550 | + format!("{} — writes the project file", key(ActionId::Save)), | ||
| 6551 | + live, | ||
| 6552 | + cx.listener(|this, _: &ClickEvent, _, cx| this.save_project(cx)), | ||
| 6553 | + )) | ||
| 6554 | + // Closed while an export runs, which is what keeps a waiting | ||
| 6555 | + // row from swallowing the escape the progress line promises | ||
| 6556 | + // cancels the export. | ||
| 6557 | + .child(control( | ||
| 6558 | + "keys", | ||
| 6559 | + None, | ||
| 6560 | + "Actions", | ||
| 6561 | + // The pointer's way to every action there is, including | ||
| 6562 | + // the ones no button here has room for. | ||
| 6563 | + format!( | ||
| 6564 | + "{} — do any action, or change the key that does it", | ||
| 6565 | + key(ActionId::ShowActions) | ||
| 6566 | + ), | ||
| 6567 | + !exporting, | ||
| 6568 | + cx.listener(|this, _: &ClickEvent, _, cx| match this.keys_open { | ||
| 6569 | + true => { | ||
| 6570 | + this.keys_open = false; | ||
| 6571 | + this.rebinding = None; | ||
| 6572 | + cx.notify(); | ||
| 6573 | + } | ||
| 6574 | + false => this.show_actions(cx), | ||
| 6575 | + }), | ||
| 6576 | + )) | ||
| 6577 | + ) | ||
| 6578 | + // The door to everything the row cannot show at this | ||
| 6579 | + // window: the same card the Actions button opens, by the | ||
| 6580 | + // same call, pinned where a scroll cannot take it. | ||
| 6532 | .child(control( | 6581 | .child(control( |
| 6533 | - "keys", | 6582 | + "controls-more", |
| 6534 | None, | 6583 | None, |
| 6535 | - "Actions", | 6584 | + "⋯", |
| 6536 | - // The pointer's way to every action there is, including | ||
| 6537 | - // the ones no button here has room for. | ||
| 6538 | format!( | 6585 | format!( |
| 6539 | - "{} — do any action, or change the key that does it", | 6586 | + "{} — every action, including the ones scrolled off this row", |
| 6540 | key(ActionId::ShowActions) | 6587 | key(ActionId::ShowActions) |
| 6541 | ), | 6588 | ), |
| 6542 | !exporting, | 6589 | !exporting, |
| @@ -6962,7 +7009,7 @@ impl Player { | |||
| 6962 | row() | 7009 | row() |
| 6963 | .child(f.label) | 7010 | .child(f.label) |
| 6964 | // Dim, and no hover: this one is not a row you can click. | 7011 | // Dim, and no hover: this one is not a row you can click. |
| 6965 | - .child(div().text_color(rgb(INK_DIM)).child(f.chord)) | 7012 | + .child(div().text_color(rgb(INK_DIM)).child(f.chord.clone())) |
| 6966 | .into_any_element() | 7013 | .into_any_element() |
| 6967 | } | 7014 | } |
| 6968 | }); | 7015 | }); |
| @@ -7343,6 +7390,45 @@ impl Player { | |||
| 7343 | ) | 7390 | ) |
| 7344 | .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.pick_destination(cx))) | 7391 | .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.pick_destination(cx))) |
| 7345 | .into_any_element(); | 7392 | .into_any_element(); |
| 7393 | + // The card's own two layout switches. They were `g` and `r` and nothing | ||
| 7394 | + // else, while the status line under the title advertised both of them: | ||
| 7395 | + // a hand on the mouse read what they do and had nothing to press. | ||
| 7396 | + list.push( | ||
| 7397 | + entry( | ||
| 7398 | + ("export-layout", 0), | ||
| 7399 | + "g", | ||
| 7400 | + "Layout".into(), | ||
| 7401 | + match self.export_grouped { | ||
| 7402 | + true => "sections — g for one flat list".into(), | ||
| 7403 | + false => "one flat list — g for sections".into(), | ||
| 7404 | + }, | ||
| 7405 | + self.export_grouped, | ||
| 7406 | + true, | ||
| 7407 | + ) | ||
| 7408 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 7409 | + this.export_grouped = !this.export_grouped; | ||
| 7410 | + cx.notify(); | ||
| 7411 | + })) | ||
| 7412 | + .into_any_element(), | ||
| 7413 | + ); | ||
| 7414 | + list.push( | ||
| 7415 | + entry( | ||
| 7416 | + ("export-refusals", 0), | ||
| 7417 | + "r", | ||
| 7418 | + "Codecs with no encoder".into(), | ||
| 7419 | + match self.export_refusals_inline { | ||
| 7420 | + true => "a dimmed row each — r collapses them".into(), | ||
| 7421 | + false => "one line at the foot — r shows a row each".into(), | ||
| 7422 | + }, | ||
| 7423 | + self.export_refusals_inline, | ||
| 7424 | + true, | ||
| 7425 | + ) | ||
| 7426 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 7427 | + this.export_refusals_inline = !this.export_refusals_inline; | ||
| 7428 | + cx.notify(); | ||
| 7429 | + })) | ||
| 7430 | + .into_any_element(), | ||
| 7431 | + ); | ||
| 7346 | match self.export_grouped { | 7432 | match self.export_grouped { |
| 7347 | true => list.push(destination), | 7433 | true => list.push(destination), |
| 7348 | // Flat: the same rows with no headers over them, and the | 7434 | // Flat: the same rows with no headers over them, and the |
| @@ -9634,36 +9720,45 @@ impl Player { | |||
| 9634 | // them, which is what keeps one gesture one thing: | 9720 | // them, which is what keeps one gesture one thing: |
| 9635 | // a press here trims, a press anywhere else on the | 9721 | // a press here trims, a press anywhere else on the |
| 9636 | // box still starts the move to another lane. | 9722 | // box still starts the move to another lane. |
| 9637 | - .children([Edge::Start, Edge::End].map(|edge| { | 9723 | + .children( |
| 9638 | - let mut zone = div() | 9724 | + [Edge::Start, Edge::End] |
| 9639 | - .absolute() | 9725 | + .into_iter() |
| 9640 | - .top_0() | 9726 | + .filter(|_| trims(width)) |
| 9641 | - .h_full() | 9727 | + .map(|edge| { |
| 9642 | - .w(px(EDGE_W)) | 9728 | + let mut zone = div() |
| 9643 | - .occlude() | 9729 | + .absolute() |
| 9644 | - .cursor(CursorStyle::ResizeLeftRight) | 9730 | + .top_0() |
| 9645 | - .hover(|s| s.bg(rgb(ACCENT))) | 9731 | + .h_full() |
| 9646 | - .on_mouse_down( | 9732 | + .w(px(EDGE_W)) |
| 9647 | - MouseButton::Left, | 9733 | + .occlude() |
| 9648 | - cx.listener(move |this, _: &MouseDownEvent, _, cx| { | 9734 | + .cursor(CursorStyle::ResizeLeftRight) |
| 9649 | - this.start_trim(lane, i, edge, cx); | 9735 | + .hover(|s| s.bg(rgb(ACCENT))) |
| 9650 | - }), | 9736 | + .on_mouse_down( |
| 9651 | - ) | 9737 | + MouseButton::Left, |
| 9652 | - // Occluded, so the box's own right-button | 9738 | + cx.listener( |
| 9653 | - // listener never fires here: the menu is | 9739 | + move |this, _: &MouseDownEvent, _, cx| { |
| 9654 | - // the same menu, opened by the same call. | 9740 | + this.start_trim(lane, i, edge, cx); |
| 9655 | - .on_mouse_down( | 9741 | + }, |
| 9656 | - MouseButton::Right, | 9742 | + ), |
| 9657 | - cx.listener(move |this, event: &MouseDownEvent, _, cx| { | 9743 | + ) |
| 9658 | - this.open_menu(lane, i, event.position, cx); | 9744 | + // Occluded, so the box's own right-button |
| 9659 | - }), | 9745 | + // listener never fires here: the menu is |
| 9660 | - ); | 9746 | + // the same menu, opened by the same call. |
| 9661 | - zone = match edge { | 9747 | + .on_mouse_down( |
| 9662 | - Edge::Start => zone.left_0(), | 9748 | + MouseButton::Right, |
| 9663 | - Edge::End => zone.right_0(), | 9749 | + cx.listener( |
| 9664 | - }; | 9750 | + move |this, event: &MouseDownEvent, _, cx| { |
| 9665 | - zone | 9751 | + this.open_menu(lane, i, event.position, cx); |
| 9666 | - })) | 9752 | + }, |
| 9753 | + ), | ||
| 9754 | + ); | ||
| 9755 | + zone = match edge { | ||
| 9756 | + Edge::Start => zone.left_0(), | ||
| 9757 | + Edge::End => zone.right_0(), | ||
| 9758 | + }; | ||
| 9759 | + zone | ||
| 9760 | + }), | ||
| 9761 | + ) | ||
| 9667 | // Under the label row, never through it. | 9762 | // Under the label row, never through it. |
| 9668 | .children(wave.filter(|_| audio && vis_w > 0.).and_then(|wave| { | 9763 | .children(wave.filter(|_| audio && vis_w > 0.).and_then(|wave| { |
| 9669 | let inner: AnyElement = match wave { | 9764 | let inner: AnyElement = match wave { |
| @@ -13179,7 +13274,7 @@ mod tests { | |||
| 13179 | whole_take, window_title, | 13274 | whole_take, window_title, |
| 13180 | }; | 13275 | }; |
| 13181 | use super::{ | 13276 | use super::{ |
| 13182 | - Choice, ETA_SPAN, Edge, FITS, FRAME_RATES, LaneKind, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, | 13277 | + Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, LaneKind, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, |
| 13183 | Scale, View, | 13278 | Scale, View, |
| 13184 | ZOOM_MIN_FRAMES, ZOOM_OUT_MARGIN, ZOOM_STEP, audio_rate_choices, clock, eta_secs, file_name, file_uri, | 13279 | ZOOM_MIN_FRAMES, ZOOM_OUT_MARGIN, ZOOM_STEP, audio_rate_choices, clock, eta_secs, file_name, file_uri, |
| 13185 | fit_choices, landing, lane_refuses, library_rows, live_idx, next_fit, next_resolution, | 13280 | fit_choices, landing, lane_refuses, library_rows, live_idx, next_fit, next_resolution, |
| @@ -13188,7 +13283,7 @@ mod tests { | |||
| 13188 | Landing, arrival, launch_queue, | 13283 | Landing, arrival, launch_queue, |
| 13189 | read_ahead, scan_plan, seek_line, silence_line, stash_or_write, | 13284 | read_ahead, scan_plan, seek_line, silence_line, stash_or_write, |
| 13190 | repeats, resolution_choices, resolution_ladder, span_label, tone_choices, tone_label, | 13285 | repeats, resolution_choices, resolution_ladder, span_label, tone_choices, tone_label, |
| 13191 | - trimmed_clip, unscannable, | 13286 | + trimmed_clip, trims, unscannable, |
| 13192 | visible_slice, | 13287 | visible_slice, |
| 13193 | }; | 13288 | }; |
| 13194 | use super::{ | 13289 | use super::{ |
| @@ -13806,6 +13901,25 @@ mod tests { | |||
| 13806 | ] { | 13901 | ] { |
| 13807 | assert!(element(id), "{id} is not on any card"); | 13902 | assert!(element(id), "{id} is not on any card"); |
| 13808 | } | 13903 | } |
| 13904 | + // ...and each one is named by the row that carries its stroke, so a | ||
| 13905 | + // card-local key added to `FIXED` with nothing to click fails here | ||
| 13906 | + // instead of being noticed by whoever tries to use the card without a | ||
| 13907 | + // keyboard. `KeyRow::Fixed` is "shown and never offered", which used to | ||
| 13908 | + // mean the twenty-eight rows below were the one part of this editor no | ||
| 13909 | + // reachability test read. | ||
| 13910 | + for fixed in keymap::FIXED.iter() { | ||
| 13911 | + match fixed.reach { | ||
| 13912 | + keymap::Reach::Click(id) => assert!( | ||
| 13913 | + element(id), | ||
| 13914 | + "{:?} ({}) points at {id}, which is on no card", | ||
| 13915 | + fixed.chord, | ||
| 13916 | + fixed.label | ||
| 13917 | + ), | ||
| 13918 | + // Nothing to click by decision, not by omission: getting out of | ||
| 13919 | + // a card, and the hold that repeats what a drag already does. | ||
| 13920 | + keymap::Reach::Gesture => {} | ||
| 13921 | + } | ||
| 13922 | + } | ||
| 13809 | } | 13923 | } |
| 13810 | 13924 | ||
| 13811 | /// What the Detach and Group items do to a real timeline: a music video's | 13925 | /// What the Detach and Group items do to a real timeline: a music video's |
| @@ -14772,7 +14886,7 @@ mod tests { | |||
| 14772 | for action in ActionId::ALL { | 14886 | for action in ActionId::ALL { |
| 14773 | assert!(keymap::Category::ALL.contains(&action.category())); | 14887 | assert!(keymap::Category::ALL.contains(&action.category())); |
| 14774 | } | 14888 | } |
| 14775 | - for fixed in &keymap::FIXED { | 14889 | + for fixed in keymap::FIXED.iter() { |
| 14776 | assert!(keymap::Category::ALL.contains(&fixed.category)); | 14890 | assert!(keymap::Category::ALL.contains(&fixed.category)); |
| 14777 | } | 14891 | } |
| 14778 | } | 14892 | } |
| @@ -17303,6 +17417,45 @@ mod tests { | |||
| 17303 | assert_eq!(cue_box(scale, &mapped[1]), (80., 40.)); | 17417 | assert_eq!(cue_box(scale, &mapped[1]), (80., 40.)); |
| 17304 | } | 17418 | } |
| 17305 | 17419 | ||
| 17420 | + /// The panel's button row against the 640x360 floor the whole editor is | ||
| 17421 | + /// measured at. It does not fit and cannot be made to -- so what it may | ||
| 17422 | + /// never do is *hide* the tail: the row scrolls, and the door to everything | ||
| 17423 | + /// scrolled off it is pinned outside the scrolling box. | ||
| 17424 | + #[test] | ||
| 17425 | + fn toolbar_fits_the_smallest_window() { | ||
| 17426 | + let source = include_str!("main.rs") | ||
| 17427 | + .split("#[cfg(test)]") | ||
| 17428 | + .next() | ||
| 17429 | + .unwrap(); | ||
| 17430 | + let panel = &source[source.find(" fn panel(").expect("the panel") | ||
| 17431 | + ..source.find(" fn import_bar(").expect("the panel's end")]; | ||
| 17432 | + // Every button in the row is a hit target, so none of them is narrower | ||
| 17433 | + // than `HIT_MIN`, and they sit in 8 px gaps inside the panel's own | ||
| 17434 | + // 12 px padding. The level slider is the one fixed width among them. | ||
| 17435 | + let buttons = panel.matches("control(").count(); | ||
| 17436 | + assert!(buttons >= 15, "the row's buttons moved; this scan is blind"); | ||
| 17437 | + let row_w = buttons as f32 * (HIT_MIN + 8.) + VOLUME_W + 24.; | ||
| 17438 | + assert!( | ||
| 17439 | + row_w > 640., | ||
| 17440 | + "{row_w} px of buttons now fits the floor -- the pinned door may go" | ||
| 17441 | + ); | ||
| 17442 | + // So Export, Save and Actions are off the right edge at that width, and | ||
| 17443 | + // "it scrolls" is not "it can be found": this is the button that never | ||
| 17444 | + // scrolls, and the card it opens carries every action there is | ||
| 17445 | + // (`every_action_is_on_the_actions_card`). | ||
| 17446 | + assert!( | ||
| 17447 | + panel.contains("\"controls-more\""), | ||
| 17448 | + "nothing pinned beside the scrolling row: the tail is unreachable at 640 px" | ||
| 17449 | + ); | ||
| 17450 | + // ...and it is outside the scrolling box, which is the whole point of | ||
| 17451 | + // it: one `overflow_x_scroll`, and the door is written after it closes. | ||
| 17452 | + assert_eq!(panel.matches("overflow_x_scroll").count(), 1); | ||
| 17453 | + assert!( | ||
| 17454 | + panel.find("\"controls-more\"") > panel.find("overflow_x_scroll"), | ||
| 17455 | + "the pinned door is inside the row it is meant to outlive" | ||
| 17456 | + ); | ||
| 17457 | + } | ||
| 17458 | + | ||
| 17306 | #[test] | 17459 | #[test] |
| 17307 | fn nothing_clickable_is_smaller_than_the_wcag_minimum() { | 17460 | fn nothing_clickable_is_smaller_than_the_wcag_minimum() { |
| 17308 | // Every hit target in the panel, including the scrub strip -- whose bar | 17461 | // Every hit target in the panel, including the scrub strip -- whose bar |
| @@ -17310,6 +17463,24 @@ mod tests { | |||
| 17310 | assert!(CONTROL_H >= HIT_MIN); | 17463 | assert!(CONTROL_H >= HIT_MIN); |
| 17311 | assert!(RULER_HIT_H >= HIT_MIN); | 17464 | assert!(RULER_HIT_H >= HIT_MIN); |
| 17312 | assert!(LANE_H >= HIT_MIN); | 17465 | assert!(LANE_H >= HIT_MIN); |
| 17466 | + // A clip box is a hit target too, and its two trim strips occlude it: | ||
| 17467 | + // on a box narrower than the pair there is no body left to press, so | ||
| 17468 | + // the clip cannot be selected, dragged or menued at all -- which is | ||
| 17469 | + // every clip a jumpcut leaves at a normal zoom. Below three handles | ||
| 17470 | + // there are no strips. | ||
| 17471 | + assert!(!trims(0.)); | ||
| 17472 | + assert!(!trims(EDGE_W)); | ||
| 17473 | + assert!(!trims(2. * EDGE_W), "a box that is all handle and no clip"); | ||
| 17474 | + assert!(!trims(3. * EDGE_W - 0.1)); | ||
| 17475 | + // And where they are drawn, what is left between them is a hit target | ||
| 17476 | + // in its own right -- a whole handle's width of clip. | ||
| 17477 | + for width in [3. * EDGE_W, 24., 100., 4000.] { | ||
| 17478 | + assert!(trims(width)); | ||
| 17479 | + assert!( | ||
| 17480 | + width - 2. * EDGE_W >= EDGE_W, | ||
| 17481 | + "{width} px of box leaves no middle" | ||
| 17482 | + ); | ||
| 17483 | + } | ||
| 17313 | } | 17484 | } |
| 17314 | 17485 | ||
| 17315 | /// WCAG 2.1 relative luminance of a packed `0xRRGGBB`. | 17486 | /// WCAG 2.1 relative luminance of a packed `0xRRGGBB`. |