diff --git a/crates/app/src/oracle.rs b/crates/app/src/oracle.rs index 75816d5..3bb489c 100644 --- a/crates/app/src/oracle.rs +++ b/crates/app/src/oracle.rs @@ -315,6 +315,19 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { } } +/// Whether a lane-header verb applies to this particular lane as well as to +/// the editor state. The shared action oracle still owns timeline/export +/// refusal; this narrow gate prevents a header from borrowing a type-level +/// chord for the wrong kind of lane. +pub(crate) fn enable_lane(action: ActionId, lane: Lane, ctx: Ctx) -> Enable { + match (action, lane.kind) { + (ActionId::Mix, LaneKind::Audio) + | (ActionId::RemoveVideoLane, LaneKind::Video) + | (ActionId::RemoveAudioLane, LaneKind::Audio) => enable(action, ctx), + _ => Enable::Hidden("this verb does not apply to this lane"), + } +} + /// The rows a clip menu draws, for the clip it was opened on: the registry /// filtered by the one availability oracle, and the *only* way that menu is /// built. An action that means nothing for what was right-clicked -- a grade on diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index 7de72ad..c54d0df 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -184,6 +184,29 @@ impl Player { } } + /// Dispatches a type-level keyboard verb from its concrete lane header. + /// The key still acts on the last lane of its kind; a header click must + /// keep the lane the hand named, so it enters through this targeted door. + pub(crate) fn act_lane(&mut self, action: ActionId, lane: Lane, cx: &mut Context) { + match enable_lane(action, lane, self.ctx(None)) { + Enable::Yes => {} + Enable::No(why) => { + self.notify_user(format!("{} — {why}", action.label()).into()); + cx.notify(); + return; + } + Enable::Hidden(_) => return, + } + match action { + ActionId::Mix => self.open_mix(Some(lane), cx), + ActionId::RemoveVideoLane | ActionId::RemoveAudioLane => { + self.mark_dirty(); + self.remove_lane(lane, cx); + } + _ => unreachable!("only lane-header actions reach act_lane"), + } + } + /// Says something to the user. The one door: every message in this editor /// comes through here, so "queued rather than overwritten" is a property of /// the field and not of seventy call sites remembering to be polite. diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index 49e98f4..237319d 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -2,6 +2,7 @@ //! colour and speed bars, the silence scan, the choices and the export. use super::*; +use crate::audio_cards::EQ_GRAPH_MAX_H; use std::sync::atomic::Ordering; /// FAULT 2's general shape (not just the source dot's menu): `overlaid()` diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index 5a7737e..b7e3542 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -1672,6 +1672,50 @@ fn the_volume_slider_lands_where_it_paints() { } } +/// Darkroom lane heads dispatch only verbs that apply to the lane under the +/// pointer; source checks pin the visible pointer doors to that guarded path. +#[test] +fn darkroom_lane_header_verbs_are_targeted_and_visible() { + let live = Ctx { + timeline: true, + ..Ctx::default() + }; + assert_eq!(enable_lane(ActionId::Mix, Lane::A1, live), Enable::Yes); + assert_eq!( + enable_lane(ActionId::RemoveVideoLane, Lane::V1, live), + Enable::Yes + ); + assert_eq!( + enable_lane(ActionId::RemoveAudioLane, Lane::A1, live), + Enable::Yes + ); + assert!(matches!( + enable_lane(ActionId::Mix, Lane::V1, live), + Enable::Hidden(_) + )); + + let bench = src_text("ui/bench_stance.rs"); + for door in [ + "\"bench-mix-lane\"", + "\"bench-show-sub-lane\"", + "\"bench-remove-lane\"", + "this.act_lane(ActionId::Mix, lane, cx)", + "this.show_sub_lane(lane, cx)", + "this.act_lane(action, lane, cx)", + ] { + assert!(bench.contains(door), "lane header lost {door}"); + } + let time_band = src_text("ui/timeband_stance.rs"); + for door in [ + "fn volume_slider(", + "\"stance-tb-volume-bar\"", + "this.drag_volume(event.position.x, cx)", + ".child(volume_slider(player, cx))", + ] { + assert!(time_band.contains(door), "time band lost {door}"); + } +} + /// The three seams a hand may move, and the two ends neither of them may be /// dragged past: a panel dragged to nothing is a panel nobody can get back, and /// a picture squeezed out by its two neighbours is that same loss from the diff --git a/crates/app/src/tests/mod.rs b/crates/app/src/tests/mod.rs index 43f5a51..906abb0 100644 --- a/crates/app/src/tests/mod.rs +++ b/crates/app/src/tests/mod.rs @@ -24,8 +24,7 @@ use super::{ Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL, WAVE_COLS_MAX, Wave, band_label, bitrate_detail, bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, commit_mbps, containers, - enable, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, - EQ_GRAPH_MAX_H, + enable, enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, escape_leaves_player_fullscreen, estimated_bytes, export_path, export_settings, format_key, format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at, @@ -43,7 +42,7 @@ use super::{ }; use super::{ - Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, LaneKind, SubClip, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, + ActionId, Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, LaneKind, SubClip, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, Scale, View, ZOOM_MIN_FRAMES, ZOOM_OUT_MARGIN, ZOOM_STEP, audio_rate_choices, av1_hw_warning, clock, encoder_choices, encoder_label, eta_secs, file_name, file_uri, diff --git a/crates/app/src/ui/bench_stance.rs b/crates/app/src/ui/bench_stance.rs index ceb3185..670242d 100644 --- a/crates/app/src/ui/bench_stance.rs +++ b/crates/app/src/ui/bench_stance.rs @@ -62,10 +62,9 @@ const TICK_MIN_PX: f64 = 64.; const PLATE_W: f32 = 11. * crate::layout::LIST_CHAR_W / type_scale::CHORD_METADATA_MIN_PX * type_scale::CHORD_METADATA_MAX_PX + 9.; -/// The pinned track-head column, DESIGN §5's "track heads" -- narrower than -/// the legacy timeline's `HEADER_W` since a darkroom lane carries no mix/eye -/// button yet (deferred with the rest of the header's verbs). -const HEAD_W: f32 = 28.; +/// The pinned track-head column: wide enough for its lane-specific ghost +/// verbs and their compact chords without shrinking their pointer targets. +const HEAD_W: f32 = 72.; pub(crate) const ROW_GAP: f32 = 2.; /// DESIGN §7: lanes compress evenly up to this many rows before the column /// scrolls behind the pinned ruler and heads instead of compressing further. @@ -634,6 +633,15 @@ fn lane_row( .first() .map_or_else(INK4, |clip| source_tint(clip.source)); let head_ghost: SharedString = lane.label().into(); + let gain_db = player + .session + .as_ref() + .map_or(0., |session| session.lane_gain_db(lane)); + let shown = player.sub_lane_on(lane); + let chord_style = type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + ); div() .id(("bench-lane", lane.ord * 10 + lane.kind as usize)) .flex_none() @@ -649,7 +657,9 @@ fn lane_row( this.reorder_lane(drag.0, lane, cx); })) .child( - // Pinned track head. + // Pinned track head: its drag handle remains the lane label; verbs + // stay separate pointer targets so a mix/remove click never starts + // a reorder drag. div() .id(("bench-lane-head", lane.ord * 10 + lane.kind as usize)) .flex_none() @@ -665,13 +675,122 @@ fn lane_row( .on_drag(LaneDrag(lane), move |_, _, _, cx| { cx.new(|_| Tip(head_ghost.clone())) }) - // MOCK-SPEC.md "Bench": "V1, A1 in mono". - .type_style(type_scale::mono( - type_scale::CHORD_METADATA_MIN_PX, - gpui::FontWeight::MEDIUM, - )) - .text_color(rgb(INK2())) - .child(lane.label()) + .child( + div() + .flex() + .items_center() + .gap(px(2.)) + // MOCK-SPEC.md "Bench": "V1, A1 in mono". + .type_style(type_scale::mono( + type_scale::CHORD_METADATA_MIN_PX, + gpui::FontWeight::MEDIUM, + )) + .text_color(rgb(INK2())) + .child(lane.label()) + .when(lane.kind == LaneKind::Audio, |d| { + d.child( + div() + .id(("bench-mix-lane", lane.ord)) + .flex() + .items_center() + .gap(px(1.)) + .rounded(px(3.)) + .px(px(2.)) + .cursor_pointer() + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) + .tooltip(move |_, cx| { + cx.new(|_| { + Tip( + format!( + "{} {gain_db:+.0} dB — mix this lane", + lane.label() + ) + .into(), + ) + }) + .into() + }) + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + this.act_lane(ActionId::Mix, lane, cx); + })) + .child("≋") + .child( + div() + .type_style(chord_style.clone()) + .text_color(rgb(INK3())) + .child(player.keymap.chord(ActionId::Mix)), + ), + ) + }) + .when(lane.kind == LaneKind::Subtitle, |d| { + d.child( + div() + .id(("bench-show-sub-lane", lane.ord)) + .rounded(px(3.)) + .px(px(2.)) + .cursor_pointer() + .text_color(rgb(if shown { INK1() } else { INK3() })) + .when(shown, |s| s.bg(rgb(DARK_RAISED()))) + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) + .tooltip(move |_, cx| { + cx.new(|_| { + Tip( + format!( + "{} — click to show this subtitle lane", + lane.label() + ) + .into(), + ) + }) + .into() + }) + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + this.show_sub_lane(lane, cx); + })) + .child("◉"), + ) + }) + .when(lane.kind != LaneKind::Subtitle, |d| { + let action = match lane.kind { + LaneKind::Video => ActionId::RemoveVideoLane, + LaneKind::Audio => ActionId::RemoveAudioLane, + LaneKind::Subtitle => unreachable!(), + }; + d.child( + div() + .id(("bench-remove-lane", lane.ord * 10 + lane.kind as usize)) + .flex() + .items_center() + .gap(px(1.)) + .rounded(px(3.)) + .px(px(2.)) + .cursor_pointer() + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) + .tooltip(move |_, cx| { + cx.new(|_| { + Tip( + format!( + "Remove {} — it must be empty first", + lane.label() + ) + .into(), + ) + }) + .into() + }) + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + this.act_lane(action, lane, cx); + })) + .child("×") + .child( + div() + .type_style(chord_style) + .text_color(rgb(INK3())) + .child(player.keymap.chord(action)), + ), + ) + }), + ) .child( div() .flex_none() diff --git a/crates/app/src/ui/timeband_stance.rs b/crates/app/src/ui/timeband_stance.rs index 3687c9e..e579b9e 100644 --- a/crates/app/src/ui/timeband_stance.rs +++ b/crates/app/src/ui/timeband_stance.rs @@ -466,6 +466,51 @@ fn export_chip(player: &Player, cx: &mut Context) -> impl IntoElement { ) } +/// The monitoring level's continuous pointer door. It shares the Player's +/// measured bar and root drag plumbing with the legacy slider, but keeps the +/// Darkroom's achromatic track and ink ladder. +fn volume_slider(player: &Player, cx: &mut Context) -> impl IntoElement { + let volume = player.volume; + let enabled = player.enable(ActionId::ToggleMute, None).yes(); + div() + .id("stance-tb-volume-bar") + .relative() + .flex_none() + .w(px(VOLUME_W)) + .h(px(CONTROL_H)) + .flex() + .items_center() + .tooltip(|_, cx| { + cx.new(|_| Tip("Volume — drag to set the level; the button mutes".into())).into() + }) + .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed()) + .when(enabled, |d| { + d.cursor_pointer() + .on_mouse_down( + MouseButton::Left, + cx.listener(|this, event: &MouseDownEvent, _, cx| { + this.volume_dragging = true; + this.drag_volume(event.position.x, cx); + }), + ) + .child(bounds_probe(player.volume_bar.clone())) + }) + .child( + div() + .w_full() + .h(px(4.)) + .rounded(px(2.)) + .bg(rgb(DARK_RAISED())) + .child( + div() + .h_full() + .w(relative(volume.along())) + .rounded(px(2.)) + .bg(rgb(if volume.muted { INK3() } else { INK2() })), + ), + ) +} + /// The whole band, left to right per MOCK-SPEC: hero timecode, ghost /// transport, cut readout, the contact strip filling the rest, the Export /// chip at the end. @@ -576,6 +621,7 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context