Every command finds a home in the room
Browse files at this commitb97144e02c1eafb49729129c4503746d96ea1332Parent: aaf986f- feat
- every command finds a home in the room
8 changed files +661 -218
- crates/app/src/player/cards.rs +196 -0
- crates/app/src/render.rs +5 -201
- crates/app/src/tests/cards.rs +58 -0
- crates/app/src/ui/bench_stance.rs +167 -1
- crates/app/src/ui/dock_stance.rs +39 -1
- crates/app/src/ui/spine_stance.rs +81 -12
- crates/app/src/ui/stance.rs +12 -0
- crates/app/src/ui/timeband_stance.rs +103 -3
crates/app/src/player/cards.rsmodified+196 -0
| @@ -1464,4 +1464,200 @@ impl Player { | |||
| 1464 | }) | 1464 | }) |
| 1465 | .map_or(0, |(i, _)| i) | 1465 | .map_or(0, |(i, _)| i) |
| 1466 | } | 1466 | } |
| 1467 | + | ||
| 1468 | + /// Every param card's own key branch (EQ, Colour, Transform, Speed, | ||
| 1469 | + /// Silence, Mix, Subtitle style), factored out of the legacy tree's | ||
| 1470 | + /// `render.rs` handler so a second stance (`ui/stance.rs`) can drive the | ||
| 1471 | + /// same cards without a second, divergent copy of this logic -- the | ||
| 1472 | + /// defect class DESIGN §6's "drag while playing... `r` resets" was | ||
| 1473 | + /// missing from the darkroom for. Returns `true` when a card was open | ||
| 1474 | + /// and ate the key, the caller's cue to `cx.notify()` and stop exactly | ||
| 1475 | + /// where each of these branches used to `return` inline. | ||
| 1476 | + pub(crate) fn param_card_key(&mut self, key: &str, shift: bool, cx: &mut Context<Self>) -> bool { | ||
| 1477 | + if self.eq_open.is_some() { | ||
| 1478 | + if key == ESCAPE { | ||
| 1479 | + // Nothing to undo: every change is already at the clip, and | ||
| 1480 | + // undo is undo's own key. | ||
| 1481 | + self.eq_open = None; | ||
| 1482 | + self.eq_dragging = false; | ||
| 1483 | + } else if key == "up" { | ||
| 1484 | + self.nudge_band(|b| b.gain_db += EQ_STEP, cx); | ||
| 1485 | + } else if key == "down" { | ||
| 1486 | + self.nudge_band(|b| b.gain_db -= EQ_STEP, cx); | ||
| 1487 | + } else if key == "left" && shift { | ||
| 1488 | + self.nudge_band(|b| b.q /= EQ_Q_STEP, cx); | ||
| 1489 | + } else if key == "right" && shift { | ||
| 1490 | + self.nudge_band(|b| b.q *= EQ_Q_STEP, cx); | ||
| 1491 | + } else if key == "left" { | ||
| 1492 | + self.nudge_band(|b| b.freq_hz /= EQ_FREQ_STEP, cx); | ||
| 1493 | + } else if key == "right" { | ||
| 1494 | + self.nudge_band(|b| b.freq_hz *= EQ_FREQ_STEP, cx); | ||
| 1495 | + } else if key == "r" { | ||
| 1496 | + for band in &mut self.eq_params.bands { | ||
| 1497 | + band.gain_db = 0.; | ||
| 1498 | + } | ||
| 1499 | + self.commit_eq(cx); | ||
| 1500 | + } else if key == "f" { | ||
| 1501 | + // This one band back to flat, which is the undo of one hand | ||
| 1502 | + // movement -- `r` is the undo of the whole card. | ||
| 1503 | + self.nudge_band(|b| b.gain_db = 0., cx); | ||
| 1504 | + } else if key == "a" { | ||
| 1505 | + self.add_band(cx); | ||
| 1506 | + } else if key == "x" { | ||
| 1507 | + self.remove_band(cx); | ||
| 1508 | + } else if key == "s" { | ||
| 1509 | + // The analyser off and on. Nothing is committed: it is what | ||
| 1510 | + // the card *shows*, so it survives no further than this | ||
| 1511 | + // window. | ||
| 1512 | + self.eq_spectrum = !self.eq_spectrum; | ||
| 1513 | + } else if let Ok(digit) = key.parse::<usize>() { | ||
| 1514 | + // As the keys are laid out: 1-9 then 0 for the tenth, which | ||
| 1515 | + // is the cap ([`EQ_BANDS_MAX`]). A digit past the last band | ||
| 1516 | + // picks nothing rather than panics. | ||
| 1517 | + let band = match digit { | ||
| 1518 | + 0 => EQ_BANDS_MAX - 1, | ||
| 1519 | + n => n - 1, | ||
| 1520 | + }; | ||
| 1521 | + if band < self.eq_params.bands.len() { | ||
| 1522 | + self.eq_band = band; | ||
| 1523 | + } | ||
| 1524 | + } | ||
| 1525 | + return true; | ||
| 1526 | + } | ||
| 1527 | + // The colour card owns the keyboard the same way the export card | ||
| 1528 | + // does, and its keys mean nothing outside it: the arrows pick a | ||
| 1529 | + // slider and move it, and `r` takes the grade off. Not keymap | ||
| 1530 | + // bindings for exactly that reason -- see `FIXED`, where the keys | ||
| 1531 | + // menu still lists them. | ||
| 1532 | + if self.color_open.is_some() { | ||
| 1533 | + match color_key(key) { | ||
| 1534 | + Some(ColorKey::Close) => { | ||
| 1535 | + self.color_open = None; | ||
| 1536 | + self.color_dragging = false; | ||
| 1537 | + } | ||
| 1538 | + Some(ColorKey::Band(step)) => { | ||
| 1539 | + self.color_band = (self.color_band + step) % COLOR_BANDS.len(); | ||
| 1540 | + } | ||
| 1541 | + Some(ColorKey::Nudge(steps)) => self.nudge_color(steps, cx), | ||
| 1542 | + Some(ColorKey::Reset) => { | ||
| 1543 | + self.set_color(ColorParams::default(), cx); | ||
| 1544 | + } | ||
| 1545 | + None => {} | ||
| 1546 | + } | ||
| 1547 | + return true; | ||
| 1548 | + } | ||
| 1549 | + // The transform card, the same way again: the arrows pick a slider | ||
| 1550 | + // and move it, and `r` puts the placement back to identity. | ||
| 1551 | + // Card-local, [`ActionId::Color`]'s own reason (see `FIXED`, where | ||
| 1552 | + // the keys menu still lists them). | ||
| 1553 | + if self.transform_open.is_some() { | ||
| 1554 | + let n = TRANSFORM_BANDS.len(); | ||
| 1555 | + if key == ESCAPE { | ||
| 1556 | + self.transform_open = None; | ||
| 1557 | + self.transform_dragging = false; | ||
| 1558 | + } else if key == "down" { | ||
| 1559 | + self.transform_band = (self.transform_band + 1) % n; | ||
| 1560 | + } else if key == "up" { | ||
| 1561 | + self.transform_band = (self.transform_band + n - 1) % n; | ||
| 1562 | + } else if key == "right" { | ||
| 1563 | + self.nudge_transform(1., cx); | ||
| 1564 | + } else if key == "left" { | ||
| 1565 | + self.nudge_transform(-1., cx); | ||
| 1566 | + } else if key == "r" { | ||
| 1567 | + self.set_transform(TransformParams::default(), cx); | ||
| 1568 | + } | ||
| 1569 | + return true; | ||
| 1570 | + } | ||
| 1571 | + // The speed card, the same way again: its arrows move the rate and | ||
| 1572 | + // `r` puts it back to real time, and neither means anything outside | ||
| 1573 | + // the card -- so neither is a binding (see `FIXED`, where the keys | ||
| 1574 | + // menu still lists them). | ||
| 1575 | + if self.speed_open.is_some() { | ||
| 1576 | + match color_key(key) { | ||
| 1577 | + Some(ColorKey::Close) => { | ||
| 1578 | + self.speed_open = None; | ||
| 1579 | + self.speed_dragging = false; | ||
| 1580 | + } | ||
| 1581 | + // The card has one value, so the pair that picks a slider on | ||
| 1582 | + // the colour card moves this one by a whole preset's worth | ||
| 1583 | + // instead of a step. | ||
| 1584 | + Some(ColorKey::Band(step)) => self.nudge_speed(if step == 1 { -2 } else { 2 }, cx), | ||
| 1585 | + Some(ColorKey::Nudge(steps)) => self.nudge_speed(steps as i32, cx), | ||
| 1586 | + Some(ColorKey::Reset) => self.set_speed(Speed::NORMAL, cx), | ||
| 1587 | + None => {} | ||
| 1588 | + } | ||
| 1589 | + return true; | ||
| 1590 | + } | ||
| 1591 | + // The silence card, the same way again: the arrows pick one of its | ||
| 1592 | + // rows and move it, and its two apply keys are the two things it can | ||
| 1593 | + // do to the timeline. Card-local, every one of them -- and listed in | ||
| 1594 | + // the keys menu (keymap.rs `FIXED`), because a key that cuts forty | ||
| 1595 | + // places at once is not a secret. | ||
| 1596 | + if self.silence_open.is_some() { | ||
| 1597 | + if key == ESCAPE { | ||
| 1598 | + // Nothing to undo: a preview is not an edit. | ||
| 1599 | + self.close_silence(); | ||
| 1600 | + } else if key == "down" { | ||
| 1601 | + self.silence_field = (self.silence_field + 1) % SILENCE_ROWS; | ||
| 1602 | + } else if key == "up" { | ||
| 1603 | + self.silence_field = (self.silence_field + SILENCE_ROWS - 1) % SILENCE_ROWS; | ||
| 1604 | + } else if key == "right" { | ||
| 1605 | + self.nudge_silence(1); | ||
| 1606 | + } else if key == "left" { | ||
| 1607 | + self.nudge_silence(-1); | ||
| 1608 | + } else if key == "enter" { | ||
| 1609 | + self.cut_silences(cx); | ||
| 1610 | + } else if key == "f" { | ||
| 1611 | + self.speed_silences(cx); | ||
| 1612 | + } | ||
| 1613 | + return true; | ||
| 1614 | + } | ||
| 1615 | + // The mix card, the same way again: up/down pick a row -- a track's | ||
| 1616 | + // fader, the limiter's ceiling or its switch -- and left/right move | ||
| 1617 | + // it, held or pressed. Card-local like the four above it. | ||
| 1618 | + if self.mix_open { | ||
| 1619 | + let rows = self.mix_lanes().len() + MIX_MASTER_ROWS; | ||
| 1620 | + if key == ESCAPE { | ||
| 1621 | + self.mix_open = false; | ||
| 1622 | + } else if key == "down" { | ||
| 1623 | + self.mix_field = (self.mix_field + 1) % rows; | ||
| 1624 | + } else if key == "up" { | ||
| 1625 | + self.mix_field = (self.mix_field + rows - 1) % rows; | ||
| 1626 | + } else if key == "right" { | ||
| 1627 | + self.nudge_mix(1, cx); | ||
| 1628 | + } else if key == "left" { | ||
| 1629 | + self.nudge_mix(-1, cx); | ||
| 1630 | + } | ||
| 1631 | + return true; | ||
| 1632 | + } | ||
| 1633 | + // The subtitle style card, the same way again: row 0 is the size | ||
| 1634 | + // stepper (left/right moves it, held or pressed, the mix card's | ||
| 1635 | + // rule) and every row after it a family in `subtitle_fonts` -- | ||
| 1636 | + // up/down walk the whole list and `enter` picks the one the arrows | ||
| 1637 | + // are on, since a hand with no mouse still has to be able to leave | ||
| 1638 | + // the platform default. | ||
| 1639 | + if self.subtitle_style_open { | ||
| 1640 | + // Row 0 is the size stepper, row 1 the platform default, and | ||
| 1641 | + // every row after it a family in `subtitle_fonts`. | ||
| 1642 | + let rows = 2 + self.subtitle_fonts.len(); | ||
| 1643 | + if key == ESCAPE { | ||
| 1644 | + self.subtitle_style_open = false; | ||
| 1645 | + } else if key == "down" { | ||
| 1646 | + self.subtitle_style_field = (self.subtitle_style_field + 1) % rows; | ||
| 1647 | + } else if key == "up" { | ||
| 1648 | + self.subtitle_style_field = (self.subtitle_style_field + rows - 1) % rows; | ||
| 1649 | + } else if key == "right" { | ||
| 1650 | + self.nudge_sub_size(1, cx); | ||
| 1651 | + } else if key == "left" { | ||
| 1652 | + self.nudge_sub_size(-1, cx); | ||
| 1653 | + } else if key == "enter" && self.subtitle_style_field == 1 { | ||
| 1654 | + self.set_sub_family(None, cx); | ||
| 1655 | + } else if key == "enter" && self.subtitle_style_field > 1 { | ||
| 1656 | + let family = self.subtitle_fonts[self.subtitle_style_field - 2].clone(); | ||
| 1657 | + self.set_sub_family(Some(family), cx); | ||
| 1658 | + } | ||
| 1659 | + return true; | ||
| 1660 | + } | ||
| 1661 | + false | ||
| 1662 | + } | ||
| 1467 | } | 1663 | } |
crates/app/src/render.rsmodified+5 -201
| @@ -484,207 +484,11 @@ impl Render for Player { | |||
| 484 | cx.notify(); | 484 | cx.notify(); |
| 485 | return; | 485 | return; |
| 486 | } | 486 | } |
| 487 | - // And the equalizer card, the same way again. Its own strokes | 487 | + // Every param card's own key branch, factored into |
| 488 | - // are the card's input, exactly as the export card's digits | 488 | + // `Player::param_card_key` (`player/cards.rs`) so this tree and |
| 489 | - // are: a band reachable only by dragging is a band a keyboard | 489 | + // the darkroom stance drive the same logic rather than a |
| 490 | - // cannot move at all, and every one of them is listed in the | 490 | + // second, divergent copy. |
| 491 | - // keys menu (keymap.rs `FIXED`) rather than being a secret. | 491 | + if this.param_card_key(key, event.keystroke.modifiers.shift, cx) { |
| 492 | - if this.eq_open.is_some() { | ||
| 493 | - // Shift makes the two horizontal keys Q instead of | ||
| 494 | - // frequency: both are the *width* of the same hump, so they | ||
| 495 | - // sit on the same axis rather than on two keys nobody would | ||
| 496 | - // guess. Wider is a lower Q, which is why left widens. | ||
| 497 | - let shift = event.keystroke.modifiers.shift; | ||
| 498 | - if key == ESCAPE { | ||
| 499 | - // Nothing to undo: every change is already at the clip, | ||
| 500 | - // and undo is undo's own key. | ||
| 501 | - this.eq_open = None; | ||
| 502 | - this.eq_dragging = false; | ||
| 503 | - } else if key == "up" { | ||
| 504 | - this.nudge_band(|b| b.gain_db += EQ_STEP, cx); | ||
| 505 | - } else if key == "down" { | ||
| 506 | - this.nudge_band(|b| b.gain_db -= EQ_STEP, cx); | ||
| 507 | - } else if key == "left" && shift { | ||
| 508 | - this.nudge_band(|b| b.q /= EQ_Q_STEP, cx); | ||
| 509 | - } else if key == "right" && shift { | ||
| 510 | - this.nudge_band(|b| b.q *= EQ_Q_STEP, cx); | ||
| 511 | - } else if key == "left" { | ||
| 512 | - this.nudge_band(|b| b.freq_hz /= EQ_FREQ_STEP, cx); | ||
| 513 | - } else if key == "right" { | ||
| 514 | - this.nudge_band(|b| b.freq_hz *= EQ_FREQ_STEP, cx); | ||
| 515 | - } else if key == "r" { | ||
| 516 | - for band in &mut this.eq_params.bands { | ||
| 517 | - band.gain_db = 0.; | ||
| 518 | - } | ||
| 519 | - this.commit_eq(cx); | ||
| 520 | - } else if key == "f" { | ||
| 521 | - // This one band back to flat, which is the undo of one | ||
| 522 | - // hand movement -- `r` is the undo of the whole card. | ||
| 523 | - this.nudge_band(|b| b.gain_db = 0., cx); | ||
| 524 | - } else if key == "a" { | ||
| 525 | - this.add_band(cx); | ||
| 526 | - } else if key == "x" { | ||
| 527 | - this.remove_band(cx); | ||
| 528 | - } else if key == "s" { | ||
| 529 | - // The analyser off and on. Nothing is committed: it is | ||
| 530 | - // what the card *shows*, so it survives no further than | ||
| 531 | - // this window. | ||
| 532 | - this.eq_spectrum = !this.eq_spectrum; | ||
| 533 | - } else if let Ok(digit) = key.parse::<usize>() { | ||
| 534 | - // As the keys are laid out: 1-9 then 0 for the tenth, | ||
| 535 | - // which is the cap ([`EQ_BANDS_MAX`]). A digit past the | ||
| 536 | - // last band picks nothing rather than panics. | ||
| 537 | - let band = match digit { | ||
| 538 | - 0 => EQ_BANDS_MAX - 1, | ||
| 539 | - n => n - 1, | ||
| 540 | - }; | ||
| 541 | - if band < this.eq_params.bands.len() { | ||
| 542 | - this.eq_band = band; | ||
| 543 | - } | ||
| 544 | - } | ||
| 545 | - cx.notify(); | ||
| 546 | - return; | ||
| 547 | - } | ||
| 548 | - // The colour card owns the keyboard the same way the export | ||
| 549 | - // card does, and its keys mean nothing outside it: the arrows | ||
| 550 | - // pick a slider and move it, and `r` takes the grade off. Not | ||
| 551 | - // keymap bindings for exactly that reason -- see `FIXED`, where | ||
| 552 | - // the keys menu still lists them. | ||
| 553 | - if this.color_open.is_some() { | ||
| 554 | - match color_key(key) { | ||
| 555 | - Some(ColorKey::Close) => { | ||
| 556 | - this.color_open = None; | ||
| 557 | - this.color_dragging = false; | ||
| 558 | - } | ||
| 559 | - Some(ColorKey::Band(step)) => { | ||
| 560 | - this.color_band = (this.color_band + step) % COLOR_BANDS.len(); | ||
| 561 | - } | ||
| 562 | - Some(ColorKey::Nudge(steps)) => this.nudge_color(steps, cx), | ||
| 563 | - Some(ColorKey::Reset) => { | ||
| 564 | - this.set_color(ColorParams::default(), cx); | ||
| 565 | - } | ||
| 566 | - None => {} | ||
| 567 | - } | ||
| 568 | - cx.notify(); | ||
| 569 | - return; | ||
| 570 | - } | ||
| 571 | - // The transform card, the same way again: the arrows pick a | ||
| 572 | - // slider and move it, and `r` puts the placement back to | ||
| 573 | - // identity. Card-local, [`ActionId::Color`]'s own reason (see | ||
| 574 | - // `FIXED`, where the keys menu still lists them). | ||
| 575 | - if this.transform_open.is_some() { | ||
| 576 | - let n = TRANSFORM_BANDS.len(); | ||
| 577 | - if key == ESCAPE { | ||
| 578 | - this.transform_open = None; | ||
| 579 | - this.transform_dragging = false; | ||
| 580 | - } else if key == "down" { | ||
| 581 | - this.transform_band = (this.transform_band + 1) % n; | ||
| 582 | - } else if key == "up" { | ||
| 583 | - this.transform_band = (this.transform_band + n - 1) % n; | ||
| 584 | - } else if key == "right" { | ||
| 585 | - this.nudge_transform(1., cx); | ||
| 586 | - } else if key == "left" { | ||
| 587 | - this.nudge_transform(-1., cx); | ||
| 588 | - } else if key == "r" { | ||
| 589 | - this.set_transform(TransformParams::default(), cx); | ||
| 590 | - } | ||
| 591 | - cx.notify(); | ||
| 592 | - return; | ||
| 593 | - } | ||
| 594 | - // The speed card, the same way again: its arrows move the rate | ||
| 595 | - // and `r` puts it back to real time, and neither means anything | ||
| 596 | - // outside the card -- so neither is a binding (see `FIXED`, | ||
| 597 | - // where the keys menu still lists them). | ||
| 598 | - if this.speed_open.is_some() { | ||
| 599 | - match color_key(key) { | ||
| 600 | - Some(ColorKey::Close) => { | ||
| 601 | - this.speed_open = None; | ||
| 602 | - this.speed_dragging = false; | ||
| 603 | - } | ||
| 604 | - // The card has one value, so the pair that picks a | ||
| 605 | - // slider on the colour card moves this one by a whole | ||
| 606 | - // preset's worth instead of a step. | ||
| 607 | - Some(ColorKey::Band(step)) => { | ||
| 608 | - this.nudge_speed(if step == 1 { -2 } else { 2 }, cx) | ||
| 609 | - } | ||
| 610 | - Some(ColorKey::Nudge(steps)) => this.nudge_speed(steps as i32, cx), | ||
| 611 | - Some(ColorKey::Reset) => this.set_speed(Speed::NORMAL, cx), | ||
| 612 | - None => {} | ||
| 613 | - } | ||
| 614 | - cx.notify(); | ||
| 615 | - return; | ||
| 616 | - } | ||
| 617 | - // The silence card, the same way again: the arrows pick one of | ||
| 618 | - // its rows and move it, and its two apply keys are the two | ||
| 619 | - // things it can do to the timeline. Card-local, every one of | ||
| 620 | - // them -- and listed in the keys menu (keymap.rs `FIXED`), | ||
| 621 | - // because a key that cuts forty places at once is not a secret. | ||
| 622 | - if this.silence_open.is_some() { | ||
| 623 | - if key == ESCAPE { | ||
| 624 | - // Nothing to undo: a preview is not an edit. | ||
| 625 | - this.close_silence(); | ||
| 626 | - } else if key == "down" { | ||
| 627 | - this.silence_field = (this.silence_field + 1) % SILENCE_ROWS; | ||
| 628 | - } else if key == "up" { | ||
| 629 | - this.silence_field = (this.silence_field + SILENCE_ROWS - 1) % SILENCE_ROWS; | ||
| 630 | - } else if key == "right" { | ||
| 631 | - this.nudge_silence(1); | ||
| 632 | - } else if key == "left" { | ||
| 633 | - this.nudge_silence(-1); | ||
| 634 | - } else if key == "enter" { | ||
| 635 | - this.cut_silences(cx); | ||
| 636 | - } else if key == "f" { | ||
| 637 | - this.speed_silences(cx); | ||
| 638 | - } | ||
| 639 | - cx.notify(); | ||
| 640 | - return; | ||
| 641 | - } | ||
| 642 | - // The mix card, the same way again: ↑↓ pick a row -- a track's | ||
| 643 | - // fader, the limiter's ceiling or its switch -- and ←→ move it, | ||
| 644 | - // held or pressed. Card-local like the four above it. | ||
| 645 | - if this.mix_open { | ||
| 646 | - let rows = this.mix_lanes().len() + MIX_MASTER_ROWS; | ||
| 647 | - if key == ESCAPE { | ||
| 648 | - this.mix_open = false; | ||
| 649 | - } else if key == "down" { | ||
| 650 | - this.mix_field = (this.mix_field + 1) % rows; | ||
| 651 | - } else if key == "up" { | ||
| 652 | - this.mix_field = (this.mix_field + rows - 1) % rows; | ||
| 653 | - } else if key == "right" { | ||
| 654 | - this.nudge_mix(1, cx); | ||
| 655 | - } else if key == "left" { | ||
| 656 | - this.nudge_mix(-1, cx); | ||
| 657 | - } | ||
| 658 | - cx.notify(); | ||
| 659 | - return; | ||
| 660 | - } | ||
| 661 | - // The subtitle style card, the same way again: row 0 is the | ||
| 662 | - // size stepper (←→ moves it, held or pressed, the mix card's | ||
| 663 | - // rule) and every row after it a family in | ||
| 664 | - // `subtitle_fonts` -- ↑↓ walk the whole list and `enter` | ||
| 665 | - // picks the one the arrows are on, since a hand with no | ||
| 666 | - // mouse still has to be able to leave the platform default. | ||
| 667 | - if this.subtitle_style_open { | ||
| 668 | - // Row 0 is the size stepper, row 1 the platform default, | ||
| 669 | - // and every row after it a family in `subtitle_fonts`. | ||
| 670 | - let rows = 2 + this.subtitle_fonts.len(); | ||
| 671 | - if key == ESCAPE { | ||
| 672 | - this.subtitle_style_open = false; | ||
| 673 | - } else if key == "down" { | ||
| 674 | - this.subtitle_style_field = (this.subtitle_style_field + 1) % rows; | ||
| 675 | - } else if key == "up" { | ||
| 676 | - this.subtitle_style_field = | ||
| 677 | - (this.subtitle_style_field + rows - 1) % rows; | ||
| 678 | - } else if key == "right" { | ||
| 679 | - this.nudge_sub_size(1, cx); | ||
| 680 | - } else if key == "left" { | ||
| 681 | - this.nudge_sub_size(-1, cx); | ||
| 682 | - } else if key == "enter" && this.subtitle_style_field == 1 { | ||
| 683 | - this.set_sub_family(None, cx); | ||
| 684 | - } else if key == "enter" && this.subtitle_style_field > 1 { | ||
| 685 | - let family = this.subtitle_fonts[this.subtitle_style_field - 2].clone(); | ||
| 686 | - this.set_sub_family(Some(family), cx); | ||
| 687 | - } | ||
| 688 | cx.notify(); | 492 | cx.notify(); |
| 689 | return; | 493 | return; |
| 690 | } | 494 | } |
crates/app/src/tests/cards.rsmodified+58 -0
| @@ -36,6 +36,64 @@ fn no_overlaid_state_in_the_stance_goes_modal_without_painting_something() { | |||
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | +#[test] | ||
| 40 | +fn every_modal_field_has_a_mounted_surface_somewhere_in_the_darkroom() { | ||
| 41 | + // Every field/method `Player::modal()` reads, pulled from its own body | ||
| 42 | + // rather than hand-copied -- a hand-copied list is exactly the shape | ||
| 43 | + // that let three cards go modal with nothing mounted (GAP 2): the field | ||
| 44 | + // was in `modal()` and nowhere in this test. | ||
| 45 | + let modal_body = fn_body("modal"); | ||
| 46 | + let mut fields = Vec::new(); | ||
| 47 | + for chunk in modal_body.split("self.").skip(1) { | ||
| 48 | + let name: String = chunk | ||
| 49 | + .chars() | ||
| 50 | + .take_while(|c| c.is_alphanumeric() || *c == '_') | ||
| 51 | + .collect(); | ||
| 52 | + if !name.is_empty() && !fields.contains(&name) { | ||
| 53 | + fields.push(name); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + assert!(fields.len() >= 9, "modal()'s own field list looks too short to have been parsed: {fields:?}"); | ||
| 57 | + // The mounted-surface function each field's own card draws, by the | ||
| 58 | + // convention the param cards already follow (`x_open` -> `x_card(` -- | ||
| 59 | + // `Player::eq_card`/`color_card`/... in `ui/cards.rs`). `keys_open` and | ||
| 60 | + // `export_open`/`exporting` don't follow that convention (the keys | ||
| 61 | + // overlay isn't a "card", export pairs with the running-export sheet), | ||
| 62 | + // so they're named explicitly. Anything else unmapped panics loudly -- | ||
| 63 | + // the point is that a ninth card has to earn a line here, not just a | ||
| 64 | + // mount, or this test cannot see it. | ||
| 65 | + let mount_for = |field: &str| -> &'static str { | ||
| 66 | + match field { | ||
| 67 | + "keys_open" => "keys_overlay(", | ||
| 68 | + "export_open" => "export_card(", | ||
| 69 | + "exporting" => "export_progress_card(", | ||
| 70 | + "eq_open" => "eq_card(", | ||
| 71 | + "color_open" => "color_card(", | ||
| 72 | + "transform_open" => "transform_card(", | ||
| 73 | + "speed_open" => "speed_card(", | ||
| 74 | + "silence_open" => "silence_card(", | ||
| 75 | + "mix_open" => "mix_card(", | ||
| 76 | + "subtitle_style_open" => "subtitle_style_card(", | ||
| 77 | + other => panic!( | ||
| 78 | + "Player::modal() now reads `self.{other}` with no entry in this test's \ | ||
| 79 | + mount_for map -- add one naming the function that mounts its surface in \ | ||
| 80 | + the darkroom (ui/stance.rs or ui/dock_stance.rs), or the room can go modal \ | ||
| 81 | + over it with nothing drawn (the silence/mix/subtitle-style bug, GAP 2)." | ||
| 82 | + ), | ||
| 83 | + } | ||
| 84 | + }; | ||
| 85 | + let haystack = format!("{}\n{}", src_text("ui/stance.rs"), src_text("ui/dock_stance.rs")); | ||
| 86 | + for field in &fields { | ||
| 87 | + let mount = mount_for(field); | ||
| 88 | + assert!( | ||
| 89 | + haystack.contains(mount), | ||
| 90 | + "Player::modal()'s `self.{field}` makes overlaid() true, but the darkroom never \ | ||
| 91 | + mounts `{mount}` in ui/stance.rs or ui/dock_stance.rs -- pressing its key opens \ | ||
| 92 | + an invisible modal (GAP 2)." | ||
| 93 | + ); | ||
| 94 | + } | ||
| 95 | +} | ||
| 96 | + | ||
| 39 | #[test] | 97 | #[test] |
| 40 | fn a_bare_escape_leaves_player_fullscreen_before_anything_under_it() { | 98 | fn a_bare_escape_leaves_player_fullscreen_before_anything_under_it() { |
| 41 | // Fires while the picture-only layout is up, on the same bare escape | 99 | // Fires while the picture-only layout is up, on the same bare escape |
crates/app/src/ui/bench_stance.rsmodified+167 -1
| @@ -233,6 +233,18 @@ fn clip_box( | |||
| 233 | this.pick((lane, idx), event.modifiers.control, cx); | 233 | this.pick((lane, idx), event.modifiers.control, cx); |
| 234 | }), | 234 | }), |
| 235 | ) | 235 | ) |
| 236 | + // The right button selects exactly as the left one does -- the menu | ||
| 237 | + // acts on the clip it names -- then hangs the clip menu at the | ||
| 238 | + // pointer (DESIGN §9's "verbs of the thing under the cursor"). Same | ||
| 239 | + // call and same surface the legacy timeline's clip box opens | ||
| 240 | + // (`ui/timeline.rs`'s `Player::open_menu`; the card itself is | ||
| 241 | + // `context_card`, already mounted at `stance.rs:695`). | ||
| 242 | + .on_mouse_down( | ||
| 243 | + MouseButton::Right, | ||
| 244 | + cx.listener(move |this, event: &MouseDownEvent, _, cx| { | ||
| 245 | + this.open_menu(lane, idx, event.position, cx); | ||
| 246 | + }), | ||
| 247 | + ) | ||
| 236 | // Dragged, it moves: to the frame and the lane it is let go over | 248 | // Dragged, it moves: to the frame and the lane it is let go over |
| 237 | // (`Player::move_clip`, `ClipDrag`) -- the same payload and the same | 249 | // (`Player::move_clip`, `ClipDrag`) -- the same payload and the same |
| 238 | // ghost tooltip `ui/timeline.rs`'s own clip box drags. | 250 | // ghost tooltip `ui/timeline.rs`'s own clip box drags. |
| @@ -263,6 +275,15 @@ fn clip_box( | |||
| 263 | cx.listener(move |this, event: &MouseDownEvent, _, cx| { | 275 | cx.listener(move |this, event: &MouseDownEvent, _, cx| { |
| 264 | this.start_trim(lane, idx, edge, event.modifiers.control, cx); | 276 | this.start_trim(lane, idx, edge, event.modifiers.control, cx); |
| 265 | }), | 277 | }), |
| 278 | + ) | ||
| 279 | + // Occluded, so the box's own right-button listener | ||
| 280 | + // never fires here: the same menu, opened by the same | ||
| 281 | + // call, exactly as the legacy clip's edge strip does. | ||
| 282 | + .on_mouse_down( | ||
| 283 | + MouseButton::Right, | ||
| 284 | + cx.listener(move |this, event: &MouseDownEvent, _, cx| { | ||
| 285 | + this.open_menu(lane, idx, event.position, cx); | ||
| 286 | + }), | ||
| 266 | ); | 287 | ); |
| 267 | zone = match edge { | 288 | zone = match edge { |
| 268 | Edge::Start => zone.left_0(), | 289 | Edge::Start => zone.left_0(), |
| @@ -385,6 +406,129 @@ fn clip_box( | |||
| 385 | ) | 406 | ) |
| 386 | } | 407 | } |
| 387 | 408 | ||
| 409 | +/// A placed caption's box, on a subtitle lane: [`clip_box`]'s twin, minus the | ||
| 410 | +/// thumbnail/waveform trace a caption has none of (DESIGN §6 -- "the subtitle | ||
| 411 | +/// cue edge IS a cut", so the same selection ring, drag, edge-trim and | ||
| 412 | +/// right-click menu a clip gets apply here too). Reused rather than | ||
| 413 | +/// reimplemented: `Player::trimmed_sub`/`SubDrag`/`sub_pick_name`/`cue_box`, | ||
| 414 | +/// the same plumbing `ui/timeline.rs`'s own caption box already drives. | ||
| 415 | +fn sub_box( | ||
| 416 | + player: &Player, | ||
| 417 | + lane: Lane, | ||
| 418 | + idx: usize, | ||
| 419 | + sub: &SubClip, | ||
| 420 | + scale: Scale, | ||
| 421 | + picks: &[(Lane, usize)], | ||
| 422 | + pick_links: &[Option<u32>], | ||
| 423 | + cx: &mut Context<Player>, | ||
| 424 | +) -> impl IntoElement + use<> { | ||
| 425 | + let placed = *sub; | ||
| 426 | + let shown = player.trimmed_sub(lane, idx, placed); | ||
| 427 | + let (start, len) = ( | ||
| 428 | + f64::from(shown.start) / player.fps, | ||
| 429 | + f64::from(shown.frames) / player.fps, | ||
| 430 | + ); | ||
| 431 | + let span = scale.width_px(len); | ||
| 432 | + let width = clip_width(span); | ||
| 433 | + let left = scale.px_at(start); | ||
| 434 | + let on = marked((lane, idx), placed.link, picks, pick_links); | ||
| 435 | + // Where in this window the track's own cues actually fall | ||
| 436 | + // (`PlaybackSession::sub_lane_cues`, the same map the export and the | ||
| 437 | + // picture's own plate go through). | ||
| 438 | + let cues: Vec<(f32, f32)> = player.session.as_ref().map_or_else(Vec::new, |s| { | ||
| 439 | + s.sub_lane_cues(lane).iter().map(|cue| cue_box(scale, cue)).collect() | ||
| 440 | + }); | ||
| 441 | + let label = player | ||
| 442 | + .session | ||
| 443 | + .as_ref() | ||
| 444 | + .and_then(|s| sub_pick_name(s.subtitles(), placed.track)); | ||
| 445 | + let ghost: SharedString = label.unwrap_or_else(|| lane.label()).into(); | ||
| 446 | + div() | ||
| 447 | + .id(("bench-sub", lane.ord * 1000 + idx)) | ||
| 448 | + .absolute() | ||
| 449 | + .top_0() | ||
| 450 | + .h_full() | ||
| 451 | + .left(px(left)) | ||
| 452 | + .w(px(width)) | ||
| 453 | + .overflow_hidden() | ||
| 454 | + .rounded(px(0.)) | ||
| 455 | + .bg(rgb(DARK_PANEL())) | ||
| 456 | + .when(on, |d| d.border_1().border_color(rgb(INK1()))) | ||
| 457 | + .cursor_pointer() | ||
| 458 | + .on_mouse_down( | ||
| 459 | + MouseButton::Left, | ||
| 460 | + cx.listener(move |this, event: &MouseDownEvent, _, cx| { | ||
| 461 | + this.pick((lane, idx), event.modifiers.control, cx); | ||
| 462 | + }), | ||
| 463 | + ) | ||
| 464 | + // Same door a clip's box opens its menu by (DESIGN §9). | ||
| 465 | + .on_mouse_down( | ||
| 466 | + MouseButton::Right, | ||
| 467 | + cx.listener(move |this, event: &MouseDownEvent, _, cx| { | ||
| 468 | + this.open_menu(lane, idx, event.position, cx); | ||
| 469 | + }), | ||
| 470 | + ) | ||
| 471 | + .on_drag(SubDrag { lane, idx, sub: placed }, { | ||
| 472 | + let ghost = ghost.clone(); | ||
| 473 | + move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) | ||
| 474 | + }) | ||
| 475 | + // The same edge-trim strips a clip gets, on the same [`trims`] floor. | ||
| 476 | + .children( | ||
| 477 | + [Edge::Start, Edge::End] | ||
| 478 | + .into_iter() | ||
| 479 | + .filter(|_| trims(span)) | ||
| 480 | + .map(|edge| { | ||
| 481 | + let mut zone = div() | ||
| 482 | + .absolute() | ||
| 483 | + .top_0() | ||
| 484 | + .h_full() | ||
| 485 | + .w(px(EDGE_W)) | ||
| 486 | + .occlude() | ||
| 487 | + .cursor(CursorStyle::ResizeLeftRight) | ||
| 488 | + .hover(|s| s.bg(rgb(INK1()))) | ||
| 489 | + .on_mouse_down( | ||
| 490 | + MouseButton::Left, | ||
| 491 | + cx.listener(move |this, event: &MouseDownEvent, _, cx| { | ||
| 492 | + this.start_trim(lane, idx, edge, event.modifiers.control, cx); | ||
| 493 | + }), | ||
| 494 | + ) | ||
| 495 | + .on_mouse_down( | ||
| 496 | + MouseButton::Right, | ||
| 497 | + cx.listener(move |this, event: &MouseDownEvent, _, cx| { | ||
| 498 | + this.open_menu(lane, idx, event.position, cx); | ||
| 499 | + }), | ||
| 500 | + ); | ||
| 501 | + zone = match edge { | ||
| 502 | + Edge::Start => zone.left_0(), | ||
| 503 | + Edge::End => zone.right_0(), | ||
| 504 | + }; | ||
| 505 | + zone | ||
| 506 | + }), | ||
| 507 | + ) | ||
| 508 | + // The cues themselves: where in this window the track's words fall, | ||
| 509 | + // each its own full-height block over the letterbox ground -- a | ||
| 510 | + // placement is a window of a track, not full of speech. | ||
| 511 | + .children(cues.into_iter().map(|(cl, cw)| { | ||
| 512 | + div() | ||
| 513 | + .absolute() | ||
| 514 | + .top(px(1.)) | ||
| 515 | + .bottom(px(1.)) | ||
| 516 | + .left(px(cl)) | ||
| 517 | + .w(px(cw)) | ||
| 518 | + .rounded(px(0.)) | ||
| 519 | + .bg(rgb(CLIP_TEXT())) | ||
| 520 | + })) | ||
| 521 | + .child( | ||
| 522 | + div() | ||
| 523 | + .absolute() | ||
| 524 | + .top_0() | ||
| 525 | + .right_0() | ||
| 526 | + .h_full() | ||
| 527 | + .w(px(1.)) | ||
| 528 | + .bg(rgb(LAMP_WHITE())), | ||
| 529 | + ) | ||
| 530 | +} | ||
| 531 | + | ||
| 388 | /// One lane row: pinned head + bed of clips, DESIGN §5's "lanes V/A/S", drawn | 532 | /// One lane row: pinned head + bed of clips, DESIGN §5's "lanes V/A/S", drawn |
| 389 | /// at the compressed height [`row_h`] gives it. | 533 | /// at the compressed height [`row_h`] gives it. |
| 390 | fn lane_row( | 534 | fn lane_row( |
| @@ -406,6 +550,20 @@ fn lane_row( | |||
| 406 | .enumerate() | 550 | .enumerate() |
| 407 | .map(|(idx, clip)| clip_box(player, lane, idx, clip, scale, picks, pick_links, cx)) | 551 | .map(|(idx, clip)| clip_box(player, lane, idx, clip, scale, picks, pick_links, cx)) |
| 408 | .collect(); | 552 | .collect(); |
| 553 | + // The bed's other kind of box: a subtitle lane holds no `Clip` at all | ||
| 554 | + // (`LaneKind::Subtitle`'s own doc), so this is empty everywhere but S1.. | ||
| 555 | + // and `boxes` above is empty on a subtitle lane -- one row draws whichever | ||
| 556 | + // list it was given. | ||
| 557 | + let subs: Vec<SubClip> = player | ||
| 558 | + .session | ||
| 559 | + .as_ref() | ||
| 560 | + .map_or(&[][..], |s| s.sub_lane(lane)) | ||
| 561 | + .to_vec(); | ||
| 562 | + let sub_boxes: Vec<_> = subs | ||
| 563 | + .iter() | ||
| 564 | + .enumerate() | ||
| 565 | + .map(|(idx, sub)| sub_box(player, lane, idx, sub, scale, picks, pick_links, cx)) | ||
| 566 | + .collect(); | ||
| 409 | // DESIGN §5's lane heads: "a small ink dot under each head, coloured by | 567 | // DESIGN §5's lane heads: "a small ink dot under each head, coloured by |
| 410 | // the lane's source ink" -- the first clip's source stands for the lane, | 568 | // the lane's source ink" -- the first clip's source stands for the lane, |
| 411 | // since a lane with several sources still needs one dot, not a legend. | 569 | // since a lane with several sources still needs one dot, not a legend. |
| @@ -478,6 +636,13 @@ fn lane_row( | |||
| 478 | }; | 636 | }; |
| 479 | this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx) | 637 | this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx) |
| 480 | })) | 638 | })) |
| 639 | + // A caption already on a lane moves along it, or onto another | ||
| 640 | + // subtitle track, exactly as a clip does (`Player::move_sub`, | ||
| 641 | + // the same call `ui/timeline.rs`'s own bed makes). | ||
| 642 | + .drag_over::<SubDrag>(|d, _, _, _| d.bg(rgb(DARK_RAISED()))) | ||
| 643 | + .on_drop(cx.listener(move |this, drag: &SubDrag, window, cx| { | ||
| 644 | + this.move_sub(drag, lane, window.mouse_position().x, cx); | ||
| 645 | + })) | ||
| 481 | // The wheel, matched to the legacy timeline's own mapping: | 646 | // The wheel, matched to the legacy timeline's own mapping: |
| 482 | // ctrl+wheel zooms about the pointer, a bare wheel scrolls | 647 | // ctrl+wheel zooms about the pointer, a bare wheel scrolls |
| 483 | // the bed along the film (`Player::timeline_wheel`). Stopped | 648 | // the bed along the film (`Player::timeline_wheel`). Stopped |
| @@ -487,7 +652,8 @@ fn lane_row( | |||
| 487 | cx.stop_propagation(); | 652 | cx.stop_propagation(); |
| 488 | this.timeline_wheel(event, cx); | 653 | this.timeline_wheel(event, cx); |
| 489 | })) | 654 | })) |
| 490 | - .children(boxes), | 655 | + .children(boxes) |
| 656 | + .children(sub_boxes), | ||
| 491 | ) | 657 | ) |
| 492 | } | 658 | } |
| 493 | 659 | ||
crates/app/src/ui/dock_stance.rsmodified+39 -1
| @@ -510,7 +510,10 @@ fn clip_tab(player: &Player, width: f32, window_h: Pixels, cx: &mut Context<Play | |||
| 510 | let none_open = player.eq_open.is_none() | 510 | let none_open = player.eq_open.is_none() |
| 511 | && player.color_open.is_none() | 511 | && player.color_open.is_none() |
| 512 | && player.transform_open.is_none() | 512 | && player.transform_open.is_none() |
| 513 | - && player.speed_open.is_none(); | 513 | + && player.speed_open.is_none() |
| 514 | + && player.silence_open.is_none() | ||
| 515 | + && !player.mix_open | ||
| 516 | + && !player.subtitle_style_open; | ||
| 514 | div() | 517 | div() |
| 515 | .id("dock-clip") | 518 | .id("dock-clip") |
| 516 | .flex_1() | 519 | .flex_1() |
| @@ -561,6 +564,32 @@ fn clip_tab(player: &Player, width: f32, window_h: Pixels, cx: &mut Context<Play | |||
| 561 | "the bands this clip's sound is filtered through", | 564 | "the bands this clip's sound is filtered through", |
| 562 | player, | 565 | player, |
| 563 | cx.listener(|this, _: &ClickEvent, _, cx| this.open_eq(cx)), | 566 | cx.listener(|this, _: &ClickEvent, _, cx| this.open_eq(cx)), |
| 567 | + )) | ||
| 568 | + // Silence and Mix: two more verbs over param rows, GAP 2's | ||
| 569 | + // fix for "the card had a key but no way in" -- the same | ||
| 570 | + // ghost-verb-over-inline-card anatomy the four above already | ||
| 571 | + // use, not a new pattern. Subtitle style is *not* here: its | ||
| 572 | + // natural home is beside the subtitle lane it edits | ||
| 573 | + // (`bench_stance.rs`, another builder's file this session); | ||
| 574 | + // it stays reachable by its chord until that lane grows a | ||
| 575 | + // header to hang a verb on. | ||
| 576 | + .child(ghost_verb( | ||
| 577 | + "dock-verb-silence", | ||
| 578 | + "Silence", | ||
| 579 | + ActionId::Silence, | ||
| 580 | + player.silence_open.is_some(), | ||
| 581 | + "scans for quiet stretches to cut or speed up", | ||
| 582 | + player, | ||
| 583 | + cx.listener(|this, _: &ClickEvent, _, cx| this.open_silence(cx)), | ||
| 584 | + )) | ||
| 585 | + .child(ghost_verb( | ||
| 586 | + "dock-verb-mix", | ||
| 587 | + "Mix", | ||
| 588 | + ActionId::Mix, | ||
| 589 | + player.mix_open, | ||
| 590 | + "track volumes and the limiter", | ||
| 591 | + player, | ||
| 592 | + cx.listener(|this, _: &ClickEvent, _, cx| this.open_mix(None, cx)), | ||
| 564 | )), | 593 | )), |
| 565 | ) | 594 | ) |
| 566 | .child( | 595 | .child( |
| @@ -574,6 +603,15 @@ fn clip_tab(player: &Player, width: f32, window_h: Pixels, cx: &mut Context<Play | |||
| 574 | .children(player.color_card(cx)) | 603 | .children(player.color_card(cx)) |
| 575 | .children(player.transform_card(cx)) | 604 | .children(player.transform_card(cx)) |
| 576 | .children(player.speed_card(cx)) | 605 | .children(player.speed_card(cx)) |
| 606 | + .children(player.silence_card(cx)) | ||
| 607 | + .children(player.mix_card(cx)) | ||
| 608 | + // Subtitle style has no verb row of its own here (see the | ||
| 609 | + // comment above the ghost verbs) but its card still has to | ||
| 610 | + // be mounted somewhere in the darkroom or its chord (`y`) | ||
| 611 | + // opens an invisible modal (GAP 2) -- this is that mount, | ||
| 612 | + // painted in the Clip tab like the six cards beside it until | ||
| 613 | + // the subtitle lane grows the header that is its real home. | ||
| 614 | + .children(player.subtitle_style_card(cx)) | ||
| 577 | // A plate, not bare space: DESIGN §11's "states" checklist -- | 615 | // A plate, not bare space: DESIGN §11's "states" checklist -- |
| 578 | // nothing picked reads as a hint, not as a hole in the panel. | 616 | // nothing picked reads as a hint, not as a hole in the panel. |
| 579 | .when(none_open, |d| { | 617 | .when(none_open, |d| { |
crates/app/src/ui/spine_stance.rsmodified+81 -12
| @@ -35,11 +35,18 @@ fn group_head(label: &str) -> impl IntoElement { | |||
| 35 | /// §4): borderless, hover is one fill step, active is `ink1` + fill, and a | 35 | /// §4): borderless, hover is one fill step, active is `ink1` + fill, and a |
| 36 | /// refused verb greys with its reason on hover rather than disappearing | 36 | /// refused verb greys with its reason on hover rather than disappearing |
| 37 | /// (DESIGN §8) -- the same oracle door `dock_stance::ghost_verb` opens. | 37 | /// (DESIGN §8) -- the same oracle door `dock_stance::ghost_verb` opens. |
| 38 | +/// `quiet` demotes a row a whole ink step (DESIGN §2's ink-demotion rule, | ||
| 39 | +/// applied per this task's charter to the once-a-session/once-a-project | ||
| 40 | +/// acts -- theme, proxies, screenshot, fullscreen -- rather than to a | ||
| 41 | +/// re-inking gesture): glyph reads `ink3` instead of `ink2`, its chord | ||
| 42 | +/// `ink4` instead of `ink3`, so the ROOM group sits visibly quieter than | ||
| 43 | +/// the burst-use groups above it without a second widget shape. | ||
| 38 | fn glyph( | 44 | fn glyph( |
| 39 | id: &'static str, | 45 | id: &'static str, |
| 40 | glyph: &'static str, | 46 | glyph: &'static str, |
| 41 | action: ActionId, | 47 | action: ActionId, |
| 42 | active: bool, | 48 | active: bool, |
| 49 | + quiet: bool, | ||
| 43 | player: &Player, | 50 | player: &Player, |
| 44 | cx: &mut Context<Player>, | 51 | cx: &mut Context<Player>, |
| 45 | ) -> impl IntoElement + use<> { | 52 | ) -> impl IntoElement + use<> { |
| @@ -82,7 +89,13 @@ fn glyph( | |||
| 82 | // FAULT 1: the glyph is the loudest thing in its row -- BOLD, | 89 | // FAULT 1: the glyph is the loudest thing in its row -- BOLD, |
| 83 | // not the MEDIUM weight the chord beneath it also wears. | 90 | // not the MEDIUM weight the chord beneath it also wears. |
| 84 | .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::BOLD)) | 91 | .type_style(type_scale::label(GLYPH_SIZE, gpui::FontWeight::BOLD)) |
| 85 | - .text_color(rgb(if active { INK1() } else { INK2() })) | 92 | + .text_color(rgb(if active { |
| 93 | + INK1() | ||
| 94 | + } else if quiet { | ||
| 95 | + INK3() | ||
| 96 | + } else { | ||
| 97 | + INK2() | ||
| 98 | + })) | ||
| 86 | .child(glyph), | 99 | .child(glyph), |
| 87 | ) | 100 | ) |
| 88 | .child( | 101 | .child( |
| @@ -92,7 +105,7 @@ fn glyph( | |||
| 92 | type_scale::CHORD_METADATA_MIN_PX, | 105 | type_scale::CHORD_METADATA_MIN_PX, |
| 93 | gpui::FontWeight::MEDIUM, | 106 | gpui::FontWeight::MEDIUM, |
| 94 | )) | 107 | )) |
| 95 | - .text_color(rgb(INK3())) | 108 | + .text_color(rgb(if quiet { INK4() } else { INK3() })) |
| 96 | .child(compact), | 109 | .child(compact), |
| 97 | ) | 110 | ) |
| 98 | } | 111 | } |
| @@ -209,13 +222,13 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem | |||
| 209 | .gap(px(1.)) | 222 | .gap(px(1.)) |
| 210 | .overflow_y_scroll() | 223 | .overflow_y_scroll() |
| 211 | .child(group_head("edit")) | 224 | .child(group_head("edit")) |
| 212 | - .child(glyph("spine-split", "||", ActionId::Cut, false, player, cx)) | 225 | + .child(glyph("spine-split", "||", ActionId::Cut, false, false, player, cx)) |
| 213 | - .child(glyph("spine-delete", "⊂⊃", ActionId::Delete, false, player, cx)) | 226 | + .child(glyph("spine-delete", "⊂⊃", ActionId::Delete, false, false, player, cx)) |
| 214 | - .child(glyph("spine-undo", "↺", ActionId::Undo, false, player, cx)) | 227 | + .child(glyph("spine-undo", "↺", ActionId::Undo, false, false, player, cx)) |
| 215 | .child(group_head("cut")) | 228 | .child(group_head("cut")) |
| 216 | .child(pair( | 229 | .child(pair( |
| 217 | - glyph("spine-cut-prev", "‹", ActionId::WalkCutPrev, false, player, cx), | 230 | + glyph("spine-cut-prev", "‹", ActionId::WalkCutPrev, false, false, player, cx), |
| 218 | - glyph("spine-cut-next", "›", ActionId::WalkCutNext, false, player, cx), | 231 | + glyph("spine-cut-next", "›", ActionId::WalkCutNext, false, false, player, cx), |
| 219 | )) | 232 | )) |
| 220 | .child(trim_control(player.loop_trim.is_some(), player, cx)) | 233 | .child(trim_control(player.loop_trim.is_some(), player, cx)) |
| 221 | .child(glyph( | 234 | .child(glyph( |
| @@ -223,6 +236,21 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem | |||
| 223 | "↻", | 236 | "↻", |
| 224 | ActionId::LoopTrim, | 237 | ActionId::LoopTrim, |
| 225 | player.loop_trim.is_some(), | 238 | player.loop_trim.is_some(), |
| 239 | + false, | ||
| 240 | + player, | ||
| 241 | + cx, | ||
| 242 | + )) | ||
| 243 | + // ToggleSnap (homeless per this task's audit): editing-adjacent -- | ||
| 244 | + // it decides where a drag lands (keymap.rs's own category puts it | ||
| 245 | + // under Editing, not View) -- so it earns the CUT group beside the | ||
| 246 | + // trim/loop-trim it changes the feel of, not the quiet ROOM cluster | ||
| 247 | + // below. Active fill mirrors loop-trim's own on/off convention. | ||
| 248 | + .child(glyph( | ||
| 249 | + "spine-toggle-snap", | ||
| 250 | + "Sn", | ||
| 251 | + ActionId::ToggleSnap, | ||
| 252 | + player.snap, | ||
| 253 | + false, | ||
| 226 | player, | 254 | player, |
| 227 | cx, | 255 | cx, |
| 228 | )) | 256 | )) |
| @@ -236,12 +264,53 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem | |||
| 236 | // less than walking/trimming cuts above it. | 264 | // less than walking/trimming cuts above it. |
| 237 | .child(group_head("view")) | 265 | .child(group_head("view")) |
| 238 | .child(pair( | 266 | .child(pair( |
| 239 | - glyph("spine-zoom-out", "−", ActionId::ZoomOut, false, player, cx), | 267 | + glyph("spine-zoom-out", "−", ActionId::ZoomOut, false, false, player, cx), |
| 240 | - glyph("spine-zoom-in", "+", ActionId::ZoomIn, false, player, cx), | 268 | + glyph("spine-zoom-in", "+", ActionId::ZoomIn, false, false, player, cx), |
| 241 | )) | 269 | )) |
| 242 | - .child(glyph("spine-zoom-fit", "⊡", ActionId::ZoomFit, false, player, cx)) | 270 | + .child(glyph("spine-zoom-fit", "⊡", ActionId::ZoomFit, false, false, player, cx)) |
| 243 | .child(group_head("track")) | 271 | .child(group_head("track")) |
| 244 | - .child(glyph("spine-add-video", "+V", ActionId::AddVideoLane, false, player, cx)) | 272 | + .child(glyph("spine-add-video", "+V", ActionId::AddVideoLane, false, false, player, cx)) |
| 245 | - .child(glyph("spine-add-audio", "+A", ActionId::AddAudioLane, false, player, cx)) | 273 | + .child(glyph("spine-add-audio", "+A", ActionId::AddAudioLane, false, false, player, cx)) |
| 274 | + // The subtitle trio (homeless per this task's audit): AddSubtitleLane | ||
| 275 | + // joins +V/+A on the same "+letter" grammar per this task's own | ||
| 276 | + // instruction ("+S joins +V/+A in TRACK"); remove/import are "the | ||
| 277 | + // subtitle work" the instruction says to place them beside, so they | ||
| 278 | + // share the row underneath rather than each eating a full row (the | ||
| 279 | + // same space-saving `pair` the walk-cuts and zoom in/out already | ||
| 280 | + // use). ToggleSubtitles (whether the cues draw over the picture at | ||
| 281 | + // all) is the fourth subtitle-lane command with no home anywhere in | ||
| 282 | + // the darkroom -- filed here too, "CC" being the glyph every player | ||
| 283 | + // already uses for exactly this toggle, rather than in the quiet | ||
| 284 | + // ROOM cluster below: cue visibility is judged shot to shot, closer | ||
| 285 | + // in frequency to a view toggle used often than to a once-a-session | ||
| 286 | + // preference. | ||
| 287 | + .child(glyph("spine-add-subtitle", "+S", ActionId::AddSubtitleLane, false, false, player, cx)) | ||
| 288 | + .child(pair( | ||
| 289 | + glyph("spine-remove-subtitle", "−S", ActionId::RemoveSubtitleLane, false, false, player, cx), | ||
| 290 | + glyph("spine-import-subtitles", "↓S", ActionId::ImportSubtitles, false, false, player, cx), | ||
| 291 | + )) | ||
| 292 | + .child(glyph("spine-toggle-subtitles", "CC", ActionId::ToggleSubtitles, player.subs_on, false, player, cx)) | ||
| 293 | + // ROOM: the once-a-session/once-a-project acts this task's charter | ||
| 294 | + // names explicitly (theme, proxies, screenshot, fullscreen) -- ink- | ||
| 295 | + // demoted (`quiet: true`) and paired two-to-a-row to keep the group | ||
| 296 | + // cheap, the same "rare acts live out of the way" pattern DESIGN §2 | ||
| 297 | + // names for re-inking, applied here to the spine's own bottom | ||
| 298 | + // instead of a right-click menu (these four are toggled/fired by a | ||
| 299 | + // click, not by picking a source dot, so a context menu is not | ||
| 300 | + // their shape). Left off this list: Save, which sits beside Export | ||
| 301 | + // in the time band instead (see timeband_stance.rs) because the | ||
| 302 | + // ledger already gives the saved/unsaved state a home there, and | ||
| 303 | + // keymap.rs's own `Category::File` files Save beside Export and | ||
| 304 | + // Screenshot on the strength of what each one writes. | ||
| 305 | + .child(group_head("room")) | ||
| 306 | + .child(pair( | ||
| 307 | + glyph("spine-theme", "H", ActionId::Theme, false, true, player, cx), | ||
| 308 | + glyph("spine-proxies", "P", ActionId::ToggleProxies, player.proxies_on, true, player, cx), | ||
| 309 | + )) | ||
| 310 | + .child(pair( | ||
| 311 | + glyph("spine-auto-proxies", "AP", ActionId::ToggleAutoProxies, player.auto_proxies_on, true, player, cx), | ||
| 312 | + glyph("spine-fullscreen", "FS", ActionId::Fullscreen, false, true, player, cx), | ||
| 313 | + )) | ||
| 314 | + .child(glyph("spine-screenshot", "Sh", ActionId::Screenshot, false, true, player, cx)) | ||
| 246 | .child(div().flex_1()) | 315 | .child(div().flex_1()) |
| 247 | } | 316 | } |
crates/app/src/ui/stance.rsmodified+12 -0
| @@ -600,6 +600,18 @@ pub(crate) fn render( | |||
| 600 | cx.notify(); | 600 | cx.notify(); |
| 601 | return; | 601 | return; |
| 602 | } | 602 | } |
| 603 | + // The param cards' own key branches (arrows nudge the focused | ||
| 604 | + // slider, digits pick an EQ band, `r` resets, card verbs) -- | ||
| 605 | + // `Player::param_card_key` (`player/cards.rs`), the same | ||
| 606 | + // function `render.rs`'s legacy handler now calls too, so this | ||
| 607 | + // is not a second copy of that logic (DESIGN §6: "drag while | ||
| 608 | + // playing... `r` resets"). Asked before the generic modal guard | ||
| 609 | + // below so a card open in the darkroom is not just a key-eating | ||
| 610 | + // black box the way the old uniform guard made it. | ||
| 611 | + if this.param_card_key(key, event.keystroke.modifiers.shift, cx) { | ||
| 612 | + cx.notify(); | ||
| 613 | + return; | ||
| 614 | + } | ||
| 603 | // Same modal guard the legacy handler's rebinding/keys_open/ | 615 | // Same modal guard the legacy handler's rebinding/keys_open/ |
| 604 | // export_open/exporting/colour/transform/speed/EQ/silence/mix/ | 616 | // export_open/exporting/colour/transform/speed/EQ/silence/mix/ |
| 605 | // subtitle-style/menu chain (`render.rs`) amounts to, read as | 617 | // subtitle-style/menu chain (`render.rs`) amounts to, read as |
crates/app/src/ui/timeband_stance.rsmodified+103 -3
| @@ -45,7 +45,19 @@ thread_local! { | |||
| 45 | /// `action` through [`Player::act`] the same way `stance::ghost` (spine) and | 45 | /// `action` through [`Player::act`] the same way `stance::ghost` (spine) and |
| 46 | /// `spine_stance`'s own ghost already do, `id` making the three transport | 46 | /// `spine_stance`'s own ghost already do, `id` making the three transport |
| 47 | /// ghosts distinct elements gpui can track. | 47 | /// ghosts distinct elements gpui can track. |
| 48 | -fn ghost(id: &'static str, player: &Player, glyph: &str, action: ActionId, cx: &mut Context<Player>) -> impl IntoElement { | 48 | +/// `active` (added alongside the volume/loop cluster this task adds) tints |
| 49 | +/// the glyph `ink1` instead of `ink2` -- the same on/off convention | ||
| 50 | +/// `spine_stance::glyph` already uses for loop-trim -- so a toggle sitting | ||
| 51 | +/// in this band (`Loop`, `ToggleMute`) can show its own state without a | ||
| 52 | +/// second widget shape. | ||
| 53 | +fn ghost( | ||
| 54 | + id: &'static str, | ||
| 55 | + player: &Player, | ||
| 56 | + glyph: impl Into<SharedString>, | ||
| 57 | + action: ActionId, | ||
| 58 | + active: bool, | ||
| 59 | + cx: &mut Context<Player>, | ||
| 60 | +) -> impl IntoElement { | ||
| 49 | let glyph_style = label(type_scale::HERO_TIMECODE_PX, FontWeight::MEDIUM); | 61 | let glyph_style = label(type_scale::HERO_TIMECODE_PX, FontWeight::MEDIUM); |
| 50 | // The chord names a key, so DESIGN §3's mono rule ("if a string is about | 62 | // The chord names a key, so DESIGN §3's mono rule ("if a string is about |
| 51 | // ... a key, it is mono") applies here same as everywhere else in the band. | 63 | // ... a key, it is mono") applies here same as everywhere else in the band. |
| @@ -63,8 +75,8 @@ fn ghost(id: &'static str, player: &Player, glyph: &str, action: ActionId, cx: & | |||
| 63 | })) | 75 | })) |
| 64 | .font(glyph_style.font) | 76 | .font(glyph_style.font) |
| 65 | .text_size(glyph_style.size) | 77 | .text_size(glyph_style.size) |
| 66 | - .text_color(rgb(INK2())) | 78 | + .text_color(rgb(if active { INK1() } else { INK2() })) |
| 67 | - .child(glyph.to_string()) | 79 | + .child(glyph.into()) |
| 68 | .child( | 80 | .child( |
| 69 | div() | 81 | div() |
| 70 | .font(chord_style.font) | 82 | .font(chord_style.font) |
| @@ -504,6 +516,7 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player | |||
| 504 | player, | 516 | player, |
| 505 | "◀◀", | 517 | "◀◀", |
| 506 | ActionId::JumpBack, | 518 | ActionId::JumpBack, |
| 519 | + false, | ||
| 507 | cx, | 520 | cx, |
| 508 | )) | 521 | )) |
| 509 | .child(ghost( | 522 | .child(ghost( |
| @@ -511,6 +524,7 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player | |||
| 511 | player, | 524 | player, |
| 512 | if player.transport().is_playing() { "❚❚" } else { "▶" }, | 525 | if player.transport().is_playing() { "❚❚" } else { "▶" }, |
| 513 | ActionId::Play, | 526 | ActionId::Play, |
| 527 | + false, | ||
| 514 | cx, | 528 | cx, |
| 515 | )) | 529 | )) |
| 516 | .child(ghost( | 530 | .child(ghost( |
| @@ -518,10 +532,96 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player | |||
| 518 | player, | 532 | player, |
| 519 | "▶▶", | 533 | "▶▶", |
| 520 | ActionId::JumpForward, | 534 | ActionId::JumpForward, |
| 535 | + false, | ||
| 536 | + cx, | ||
| 537 | + )) | ||
| 538 | + // Loop (homeless per this task's audit): the playback-loop | ||
| 539 | + // toggle -- burst-use during editing per the charter's own | ||
| 540 | + // classification -- earns the transport cluster it plays | ||
| 541 | + // alongside, not the CUT group's `LoopTrim` two files over | ||
| 542 | + // (a different verb already drawn on the spine, "↻" taken). | ||
| 543 | + // "∞" reads as "keeps going" without borrowing that glyph. | ||
| 544 | + .child(ghost( | ||
| 545 | + "stance-tb-loop", | ||
| 546 | + player, | ||
| 547 | + "∞", | ||
| 548 | + ActionId::Loop, | ||
| 549 | + player.loop_on, | ||
| 521 | cx, | 550 | cx, |
| 522 | )), | 551 | )), |
| 523 | ) | 552 | ) |
| 553 | + // The audio-monitoring cluster (homeless per this task's audit): | ||
| 554 | + // ToggleMute/VolumeUp/VolumeDown, burst-use per the charter, placed | ||
| 555 | + // beside the transport it plays with rather than the spine (the | ||
| 556 | + // rail is already tightened, and this is a play-time concern, same | ||
| 557 | + // land as J/spc/L above it). The level itself is the mute button's | ||
| 558 | + // own label (legacy `toolbar.rs`'s own convention: an "×" prefix | ||
| 559 | + // marks muted rather than a second colour), so one click toggles | ||
| 560 | + // mute and the two ghosts flanking it nudge the level -- three | ||
| 561 | + // homeless actions sharing one cluster rather than three unrelated | ||
| 562 | + // rows. | ||
| 563 | + .child( | ||
| 564 | + div() | ||
| 565 | + .flex_none() | ||
| 566 | + .flex() | ||
| 567 | + .items_center() | ||
| 568 | + .gap(px(6.)) | ||
| 569 | + .child(ghost("stance-tb-vol-down", player, "−", ActionId::VolumeDown, false, cx)) | ||
| 570 | + .child(ghost( | ||
| 571 | + "stance-tb-mute", | ||
| 572 | + player, | ||
| 573 | + if player.volume.muted { | ||
| 574 | + format!("× {}%", player.volume.percent()) | ||
| 575 | + } else { | ||
| 576 | + format!("{}%", player.volume.percent()) | ||
| 577 | + }, | ||
| 578 | + ActionId::ToggleMute, | ||
| 579 | + player.volume.muted, | ||
| 580 | + cx, | ||
| 581 | + )) | ||
| 582 | + .child(ghost("stance-tb-vol-up", player, "+", ActionId::VolumeUp, false, cx)), | ||
| 583 | + ) | ||
| 524 | .child(cut_readout(player)) | 584 | .child(cut_readout(player)) |
| 525 | .child(contact_strip(player, position, cx)) | 585 | .child(contact_strip(player, position, cx)) |
| 586 | + .child(save_verb(player, cx)) | ||
| 526 | .child(export_chip(player, cx)) | 587 | .child(export_chip(player, cx)) |
| 527 | } | 588 | } |
| 589 | + | ||
| 590 | +/// `Save` (homeless per this task's audit): not boxed -- DESIGN §4 reserves | ||
| 591 | +/// the room's one border for the commit-class Export beside it -- but filed | ||
| 592 | +/// right next to it anyway. `keymap.rs`'s own `Category::File` already | ||
| 593 | +/// files Save beside Export and Screenshot on the strength of what each one | ||
| 594 | +/// writes, and the ledger this task named as Save's natural home | ||
| 595 | +/// (`name.edith · saved`/`unsaved`) lives in `stance.rs`, a concurrent | ||
| 596 | +/// builder's file this task does not touch -- so the verb lands here | ||
| 597 | +/// instead, a ghost sharing the export chip's own end-of-band land rather | ||
| 598 | +/// than competing with the ledger strip below it for the same state. | ||
| 599 | +fn save_verb(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 600 | + let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); | ||
| 601 | + let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); | ||
| 602 | + div() | ||
| 603 | + .id("stance-tb-save") | ||
| 604 | + .flex_none() | ||
| 605 | + .flex() | ||
| 606 | + .items_center() | ||
| 607 | + .gap(px(4.)) | ||
| 608 | + .cursor_pointer() | ||
| 609 | + .hover(|s| s.text_color(rgb(INK1()))) | ||
| 610 | + .text_color(rgb(INK2())) | ||
| 611 | + .on_click(cx.listener(|this, _: &ClickEvent, window, cx| { | ||
| 612 | + this.act(ActionId::Save, window, cx); | ||
| 613 | + })) | ||
| 614 | + .child( | ||
| 615 | + div() | ||
| 616 | + .font(label_style.font) | ||
| 617 | + .text_size(label_style.size) | ||
| 618 | + .child("Save"), | ||
| 619 | + ) | ||
| 620 | + .child( | ||
| 621 | + div() | ||
| 622 | + .font(chord_style.font) | ||
| 623 | + .text_size(chord_style.size) | ||
| 624 | + .text_color(rgb(INK3())) | ||
| 625 | + .child(player.keymap.chord(ActionId::Save)), | ||
| 626 | + ) | ||
| 627 | +} | ||