Add Darkroom lane verbs
Browse files at this commit2806b15b9068a2e28e10f0cfeedb33ef893f7286Parent: 3e04aeb- feat
- add Darkroom lane verbs
7 changed files +260 -15
- crates/app/src/oracle.rs +13 -0
- crates/app/src/player/actions.rs +23 -0
- crates/app/src/tests/cards.rs +1 -0
- crates/app/src/tests/layout.rs +44 -0
- crates/app/src/tests/mod.rs +2 -3
- crates/app/src/ui/bench_stance.rs +131 -12
- crates/app/src/ui/timeband_stance.rs +46 -0
crates/app/src/oracle.rsmodified+13 -0
| @@ -315,6 +315,19 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { | ||
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | +/// Whether a lane-header verb applies to this particular lane as well as to | |
| 319 | +/// the editor state. The shared action oracle still owns timeline/export | |
| 320 | +/// refusal; this narrow gate prevents a header from borrowing a type-level | |
| 321 | +/// chord for the wrong kind of lane. | |
| 322 | +pub(crate) fn enable_lane(action: ActionId, lane: Lane, ctx: Ctx) -> Enable { | |
| 323 | + match (action, lane.kind) { | |
| 324 | + (ActionId::Mix, LaneKind::Audio) | |
| 325 | + | (ActionId::RemoveVideoLane, LaneKind::Video) | |
| 326 | + | (ActionId::RemoveAudioLane, LaneKind::Audio) => enable(action, ctx), | |
| 327 | + _ => Enable::Hidden("this verb does not apply to this lane"), | |
| 328 | + } | |
| 329 | +} | |
| 330 | + | |
| 318 | 331 | /// The rows a clip menu draws, for the clip it was opened on: the registry |
| 319 | 332 | /// filtered by the one availability oracle, and the *only* way that menu is |
| 320 | 333 | /// built. An action that means nothing for what was right-clicked -- a grade on |
crates/app/src/player/actions.rsmodified+23 -0
| @@ -184,6 +184,29 @@ impl Player { | ||
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | + /// Dispatches a type-level keyboard verb from its concrete lane header. | |
| 188 | + /// The key still acts on the last lane of its kind; a header click must | |
| 189 | + /// keep the lane the hand named, so it enters through this targeted door. | |
| 190 | + pub(crate) fn act_lane(&mut self, action: ActionId, lane: Lane, cx: &mut Context<Self>) { | |
| 191 | + match enable_lane(action, lane, self.ctx(None)) { | |
| 192 | + Enable::Yes => {} | |
| 193 | + Enable::No(why) => { | |
| 194 | + self.notify_user(format!("{} — {why}", action.label()).into()); | |
| 195 | + cx.notify(); | |
| 196 | + return; | |
| 197 | + } | |
| 198 | + Enable::Hidden(_) => return, | |
| 199 | + } | |
| 200 | + match action { | |
| 201 | + ActionId::Mix => self.open_mix(Some(lane), cx), | |
| 202 | + ActionId::RemoveVideoLane | ActionId::RemoveAudioLane => { | |
| 203 | + self.mark_dirty(); | |
| 204 | + self.remove_lane(lane, cx); | |
| 205 | + } | |
| 206 | + _ => unreachable!("only lane-header actions reach act_lane"), | |
| 207 | + } | |
| 208 | + } | |
| 209 | + | |
| 187 | 210 | /// Says something to the user. The one door: every message in this editor |
| 188 | 211 | /// comes through here, so "queued rather than overwritten" is a property of |
| 189 | 212 | /// the field and not of seventy call sites remembering to be polite. |
crates/app/src/tests/cards.rsmodified+1 -0
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | //! colour and speed bars, the silence scan, the choices and the export. |
| 3 | 3 | |
| 4 | 4 | use super::*; |
| 5 | +use crate::audio_cards::EQ_GRAPH_MAX_H; | |
| 5 | 6 | use std::sync::atomic::Ordering; |
| 6 | 7 | |
| 7 | 8 | /// FAULT 2's general shape (not just the source dot's menu): `overlaid()` |
crates/app/src/tests/layout.rsmodified+44 -0
| @@ -1672,6 +1672,50 @@ fn the_volume_slider_lands_where_it_paints() { | ||
| 1672 | 1672 | } |
| 1673 | 1673 | } |
| 1674 | 1674 | |
| 1675 | +/// Darkroom lane heads dispatch only verbs that apply to the lane under the | |
| 1676 | +/// pointer; source checks pin the visible pointer doors to that guarded path. | |
| 1677 | +#[test] | |
| 1678 | +fn darkroom_lane_header_verbs_are_targeted_and_visible() { | |
| 1679 | + let live = Ctx { | |
| 1680 | + timeline: true, | |
| 1681 | + ..Ctx::default() | |
| 1682 | + }; | |
| 1683 | + assert_eq!(enable_lane(ActionId::Mix, Lane::A1, live), Enable::Yes); | |
| 1684 | + assert_eq!( | |
| 1685 | + enable_lane(ActionId::RemoveVideoLane, Lane::V1, live), | |
| 1686 | + Enable::Yes | |
| 1687 | + ); | |
| 1688 | + assert_eq!( | |
| 1689 | + enable_lane(ActionId::RemoveAudioLane, Lane::A1, live), | |
| 1690 | + Enable::Yes | |
| 1691 | + ); | |
| 1692 | + assert!(matches!( | |
| 1693 | + enable_lane(ActionId::Mix, Lane::V1, live), | |
| 1694 | + Enable::Hidden(_) | |
| 1695 | + )); | |
| 1696 | + | |
| 1697 | + let bench = src_text("ui/bench_stance.rs"); | |
| 1698 | + for door in [ | |
| 1699 | + "\"bench-mix-lane\"", | |
| 1700 | + "\"bench-show-sub-lane\"", | |
| 1701 | + "\"bench-remove-lane\"", | |
| 1702 | + "this.act_lane(ActionId::Mix, lane, cx)", | |
| 1703 | + "this.show_sub_lane(lane, cx)", | |
| 1704 | + "this.act_lane(action, lane, cx)", | |
| 1705 | + ] { | |
| 1706 | + assert!(bench.contains(door), "lane header lost {door}"); | |
| 1707 | + } | |
| 1708 | + let time_band = src_text("ui/timeband_stance.rs"); | |
| 1709 | + for door in [ | |
| 1710 | + "fn volume_slider(", | |
| 1711 | + "\"stance-tb-volume-bar\"", | |
| 1712 | + "this.drag_volume(event.position.x, cx)", | |
| 1713 | + ".child(volume_slider(player, cx))", | |
| 1714 | + ] { | |
| 1715 | + assert!(time_band.contains(door), "time band lost {door}"); | |
| 1716 | + } | |
| 1717 | +} | |
| 1718 | + | |
| 1675 | 1719 | /// The three seams a hand may move, and the two ends neither of them may be |
| 1676 | 1720 | /// dragged past: a panel dragged to nothing is a panel nobody can get back, and |
| 1677 | 1721 | /// a picture squeezed out by its two neighbours is that same loss from the |
crates/app/src/tests/mod.rsmodified+2 -3
| @@ -24,8 +24,7 @@ use super::{ | ||
| 24 | 24 | Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL, WAVE_COLS_MAX, Wave, band_label, |
| 25 | 25 | bitrate_detail, bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, commit_mbps, |
| 26 | 26 | containers, |
| 27 | - enable, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, | |
| 28 | - EQ_GRAPH_MAX_H, | |
| 27 | + enable, enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, | |
| 29 | 28 | escape_leaves_player_fullscreen, |
| 30 | 29 | estimated_bytes, export_path, export_settings, format_key, |
| 31 | 30 | format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at, |
| @@ -43,7 +42,7 @@ use super::{ | ||
| 43 | 42 | }; |
| 44 | 43 | |
| 45 | 44 | use super::{ |
| 46 | - Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, LaneKind, SubClip, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, | |
| 45 | + ActionId, Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, LaneKind, SubClip, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, | |
| 47 | 46 | Scale, View, |
| 48 | 47 | ZOOM_MIN_FRAMES, ZOOM_OUT_MARGIN, ZOOM_STEP, audio_rate_choices, av1_hw_warning, clock, |
| 49 | 48 | encoder_choices, encoder_label, eta_secs, file_name, file_uri, |
crates/app/src/ui/bench_stance.rsmodified+131 -12
| @@ -62,10 +62,9 @@ const TICK_MIN_PX: f64 = 64.; | ||
| 62 | 62 | const PLATE_W: f32 = 11. * crate::layout::LIST_CHAR_W / type_scale::CHORD_METADATA_MIN_PX |
| 63 | 63 | * type_scale::CHORD_METADATA_MAX_PX |
| 64 | 64 | + 9.; |
| 65 | -/// The pinned track-head column, DESIGN §5's "track heads" -- narrower than | |
| 66 | -/// the legacy timeline's `HEADER_W` since a darkroom lane carries no mix/eye | |
| 67 | -/// button yet (deferred with the rest of the header's verbs). | |
| 68 | -const HEAD_W: f32 = 28.; | |
| 65 | +/// The pinned track-head column: wide enough for its lane-specific ghost | |
| 66 | +/// verbs and their compact chords without shrinking their pointer targets. | |
| 67 | +const HEAD_W: f32 = 72.; | |
| 69 | 68 | pub(crate) const ROW_GAP: f32 = 2.; |
| 70 | 69 | /// DESIGN §7: lanes compress evenly up to this many rows before the column |
| 71 | 70 | /// scrolls behind the pinned ruler and heads instead of compressing further. |
| @@ -634,6 +633,15 @@ fn lane_row( | ||
| 634 | 633 | .first() |
| 635 | 634 | .map_or_else(INK4, |clip| source_tint(clip.source)); |
| 636 | 635 | let head_ghost: SharedString = lane.label().into(); |
| 636 | + let gain_db = player | |
| 637 | + .session | |
| 638 | + .as_ref() | |
| 639 | + .map_or(0., |session| session.lane_gain_db(lane)); | |
| 640 | + let shown = player.sub_lane_on(lane); | |
| 641 | + let chord_style = type_scale::mono( | |
| 642 | + type_scale::CHORD_METADATA_MIN_PX, | |
| 643 | + gpui::FontWeight::MEDIUM, | |
| 644 | + ); | |
| 637 | 645 | div() |
| 638 | 646 | .id(("bench-lane", lane.ord * 10 + lane.kind as usize)) |
| 639 | 647 | .flex_none() |
| @@ -649,7 +657,9 @@ fn lane_row( | ||
| 649 | 657 | this.reorder_lane(drag.0, lane, cx); |
| 650 | 658 | })) |
| 651 | 659 | .child( |
| 652 | - // Pinned track head. | |
| 660 | + // Pinned track head: its drag handle remains the lane label; verbs | |
| 661 | + // stay separate pointer targets so a mix/remove click never starts | |
| 662 | + // a reorder drag. | |
| 653 | 663 | div() |
| 654 | 664 | .id(("bench-lane-head", lane.ord * 10 + lane.kind as usize)) |
| 655 | 665 | .flex_none() |
| @@ -665,13 +675,122 @@ fn lane_row( | ||
| 665 | 675 | .on_drag(LaneDrag(lane), move |_, _, _, cx| { |
| 666 | 676 | cx.new(|_| Tip(head_ghost.clone())) |
| 667 | 677 | }) |
| 668 | - // MOCK-SPEC.md "Bench": "V1, A1 in mono". | |
| 669 | - .type_style(type_scale::mono( | |
| 670 | - type_scale::CHORD_METADATA_MIN_PX, | |
| 671 | - gpui::FontWeight::MEDIUM, | |
| 672 | - )) | |
| 673 | - .text_color(rgb(INK2())) | |
| 674 | - .child(lane.label()) | |
| 678 | + .child( | |
| 679 | + div() | |
| 680 | + .flex() | |
| 681 | + .items_center() | |
| 682 | + .gap(px(2.)) | |
| 683 | + // MOCK-SPEC.md "Bench": "V1, A1 in mono". | |
| 684 | + .type_style(type_scale::mono( | |
| 685 | + type_scale::CHORD_METADATA_MIN_PX, | |
| 686 | + gpui::FontWeight::MEDIUM, | |
| 687 | + )) | |
| 688 | + .text_color(rgb(INK2())) | |
| 689 | + .child(lane.label()) | |
| 690 | + .when(lane.kind == LaneKind::Audio, |d| { | |
| 691 | + d.child( | |
| 692 | + div() | |
| 693 | + .id(("bench-mix-lane", lane.ord)) | |
| 694 | + .flex() | |
| 695 | + .items_center() | |
| 696 | + .gap(px(1.)) | |
| 697 | + .rounded(px(3.)) | |
| 698 | + .px(px(2.)) | |
| 699 | + .cursor_pointer() | |
| 700 | + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) | |
| 701 | + .tooltip(move |_, cx| { | |
| 702 | + cx.new(|_| { | |
| 703 | + Tip( | |
| 704 | + format!( | |
| 705 | + "{} {gain_db:+.0} dB — mix this lane", | |
| 706 | + lane.label() | |
| 707 | + ) | |
| 708 | + .into(), | |
| 709 | + ) | |
| 710 | + }) | |
| 711 | + .into() | |
| 712 | + }) | |
| 713 | + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 714 | + this.act_lane(ActionId::Mix, lane, cx); | |
| 715 | + })) | |
| 716 | + .child("≋") | |
| 717 | + .child( | |
| 718 | + div() | |
| 719 | + .type_style(chord_style.clone()) | |
| 720 | + .text_color(rgb(INK3())) | |
| 721 | + .child(player.keymap.chord(ActionId::Mix)), | |
| 722 | + ), | |
| 723 | + ) | |
| 724 | + }) | |
| 725 | + .when(lane.kind == LaneKind::Subtitle, |d| { | |
| 726 | + d.child( | |
| 727 | + div() | |
| 728 | + .id(("bench-show-sub-lane", lane.ord)) | |
| 729 | + .rounded(px(3.)) | |
| 730 | + .px(px(2.)) | |
| 731 | + .cursor_pointer() | |
| 732 | + .text_color(rgb(if shown { INK1() } else { INK3() })) | |
| 733 | + .when(shown, |s| s.bg(rgb(DARK_RAISED()))) | |
| 734 | + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) | |
| 735 | + .tooltip(move |_, cx| { | |
| 736 | + cx.new(|_| { | |
| 737 | + Tip( | |
| 738 | + format!( | |
| 739 | + "{} — click to show this subtitle lane", | |
| 740 | + lane.label() | |
| 741 | + ) | |
| 742 | + .into(), | |
| 743 | + ) | |
| 744 | + }) | |
| 745 | + .into() | |
| 746 | + }) | |
| 747 | + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 748 | + this.show_sub_lane(lane, cx); | |
| 749 | + })) | |
| 750 | + .child("◉"), | |
| 751 | + ) | |
| 752 | + }) | |
| 753 | + .when(lane.kind != LaneKind::Subtitle, |d| { | |
| 754 | + let action = match lane.kind { | |
| 755 | + LaneKind::Video => ActionId::RemoveVideoLane, | |
| 756 | + LaneKind::Audio => ActionId::RemoveAudioLane, | |
| 757 | + LaneKind::Subtitle => unreachable!(), | |
| 758 | + }; | |
| 759 | + d.child( | |
| 760 | + div() | |
| 761 | + .id(("bench-remove-lane", lane.ord * 10 + lane.kind as usize)) | |
| 762 | + .flex() | |
| 763 | + .items_center() | |
| 764 | + .gap(px(1.)) | |
| 765 | + .rounded(px(3.)) | |
| 766 | + .px(px(2.)) | |
| 767 | + .cursor_pointer() | |
| 768 | + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) | |
| 769 | + .tooltip(move |_, cx| { | |
| 770 | + cx.new(|_| { | |
| 771 | + Tip( | |
| 772 | + format!( | |
| 773 | + "Remove {} — it must be empty first", | |
| 774 | + lane.label() | |
| 775 | + ) | |
| 776 | + .into(), | |
| 777 | + ) | |
| 778 | + }) | |
| 779 | + .into() | |
| 780 | + }) | |
| 781 | + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 782 | + this.act_lane(action, lane, cx); | |
| 783 | + })) | |
| 784 | + .child("×") | |
| 785 | + .child( | |
| 786 | + div() | |
| 787 | + .type_style(chord_style) | |
| 788 | + .text_color(rgb(INK3())) | |
| 789 | + .child(player.keymap.chord(action)), | |
| 790 | + ), | |
| 791 | + ) | |
| 792 | + }), | |
| 793 | + ) | |
| 675 | 794 | .child( |
| 676 | 795 | div() |
| 677 | 796 | .flex_none() |
crates/app/src/ui/timeband_stance.rsmodified+46 -0
| @@ -466,6 +466,51 @@ fn export_chip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 466 | 466 | ) |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | +/// The monitoring level's continuous pointer door. It shares the Player's | |
| 470 | +/// measured bar and root drag plumbing with the legacy slider, but keeps the | |
| 471 | +/// Darkroom's achromatic track and ink ladder. | |
| 472 | +fn volume_slider(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | |
| 473 | + let volume = player.volume; | |
| 474 | + let enabled = player.enable(ActionId::ToggleMute, None).yes(); | |
| 475 | + div() | |
| 476 | + .id("stance-tb-volume-bar") | |
| 477 | + .relative() | |
| 478 | + .flex_none() | |
| 479 | + .w(px(VOLUME_W)) | |
| 480 | + .h(px(CONTROL_H)) | |
| 481 | + .flex() | |
| 482 | + .items_center() | |
| 483 | + .tooltip(|_, cx| { | |
| 484 | + cx.new(|_| Tip("Volume — drag to set the level; the button mutes".into())).into() | |
| 485 | + }) | |
| 486 | + .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed()) | |
| 487 | + .when(enabled, |d| { | |
| 488 | + d.cursor_pointer() | |
| 489 | + .on_mouse_down( | |
| 490 | + MouseButton::Left, | |
| 491 | + cx.listener(|this, event: &MouseDownEvent, _, cx| { | |
| 492 | + this.volume_dragging = true; | |
| 493 | + this.drag_volume(event.position.x, cx); | |
| 494 | + }), | |
| 495 | + ) | |
| 496 | + .child(bounds_probe(player.volume_bar.clone())) | |
| 497 | + }) | |
| 498 | + .child( | |
| 499 | + div() | |
| 500 | + .w_full() | |
| 501 | + .h(px(4.)) | |
| 502 | + .rounded(px(2.)) | |
| 503 | + .bg(rgb(DARK_RAISED())) | |
| 504 | + .child( | |
| 505 | + div() | |
| 506 | + .h_full() | |
| 507 | + .w(relative(volume.along())) | |
| 508 | + .rounded(px(2.)) | |
| 509 | + .bg(rgb(if volume.muted { INK3() } else { INK2() })), | |
| 510 | + ), | |
| 511 | + ) | |
| 512 | +} | |
| 513 | + | |
| 469 | 514 | /// The whole band, left to right per MOCK-SPEC: hero timecode, ghost |
| 470 | 515 | /// transport, cut readout, the contact strip filling the rest, the Export |
| 471 | 516 | /// chip at the end. |
| @@ -576,6 +621,7 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player | ||
| 576 | 621 | player.volume.muted, |
| 577 | 622 | cx, |
| 578 | 623 | )) |
| 624 | + .child(volume_slider(player, cx)) | |
| 579 | 625 | .child(ghost("stance-tb-vol-up", player, "+", ActionId::VolumeUp, false, cx)), |
| 580 | 626 | ) |
| 581 | 627 | .child(cut_readout(player)) |