From 726f956aa0e45749b25b05c0a87810a77fccb900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 27 Aug 2026 07:22:28 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(app):=20dock=20clip=20verbs?= =?UTF-8?q?=20hide=20(not=20grey)=20for=20the=20wrong=20media=20kind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mix now refuses by the same class rule as Silence/Equalizer (still or no-sound clip); the dock's ghost_verb reads Enable::listed() and leaves a Hidden verb out of the row entirely instead of always drawing it dimmed. DESIGN.md §8 amended: state refusals grey out, media-kind refusals hide. --- DESIGN.md | 6 +- crates/app/src/oracle.rs | 11 ++- crates/app/src/tests/editing.rs | 139 +++++++++++++++++++++---------- crates/app/src/ui/dock_stance.rs | 114 +++++++++++++------------ 4 files changed, 166 insertions(+), 104 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index b5ee0e9..8ad0e29 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -173,8 +173,10 @@ one at a time; severity is a **3px left spine**, not a color flood: Every failure names its remedy, and the wound stays visible where it lives (dark clips in the lane). **A refusal string is a claim:** shipping "cannot be decoded" requires a test proving the -capability is genuinely absent — otherwise it is a bug, not a message. A verb the state refuses -(in menus) greys out with its reason on hover; it never disappears. +capability is genuinely absent — otherwise it is a bug, not a message. A verb the current *state* +refuses (in menus) greys out with its reason on hover; it never disappears. A verb the selected +clip's *media kind* can never use (a grade on sound, an equalizer on a picture) is hidden outright +instead — a class refusal, not a moment's answer the next click could change (user 2026-08-27). **No instructional copy (rejected pattern, user 2026-08-27).** The room never explains itself in prose: no "pick a verb above", no "type to filter — name, codec, unused…", no "Import, or drop a diff --git a/crates/app/src/oracle.rs b/crates/app/src/oracle.rs index 5f02969..372001a 100644 --- a/crates/app/src/oracle.rs +++ b/crates/app/src/oracle.rs @@ -225,9 +225,13 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { // The scan reads samples, and a still has none -- ever, unlike a video // clip whose sound may be one lane down or simply silent. Exactly what // `unscannable` says after the fact, said before the row is drawn so - // there is no row left to click. - ActionId::Silence if ctx.image => Enable::Hidden("this clip is a still"), - ActionId::Silence if ctx.no_sound => Enable::Hidden("this clip has no sound"), + // there is no row left to click. The mixer's track volumes are the + // same class refusal over the same clip: nothing to mix for a picture + // with no sound at all. + ActionId::Silence | ActionId::Mix if ctx.image => Enable::Hidden("this clip is a still"), + ActionId::Silence | ActionId::Mix if ctx.no_sound => { + Enable::Hidden("this clip has no sound") + } // -- state: true of this clip now, and the next playhead click or the // next selection changes the answer. Splits this clip only from inside // it: at either edge there is nothing to split off -- and, on a speeded @@ -464,4 +468,3 @@ pub(crate) fn menu_at(at: Point, viewport: Size, height: f32) -> fit(f32::from(at.y), height, f32::from(viewport.height)), ) } - diff --git a/crates/app/src/tests/editing.rs b/crates/app/src/tests/editing.rs index 7b4f415..d56b980 100644 --- a/crates/app/src/tests/editing.rs +++ b/crates/app/src/tests/editing.rs @@ -771,6 +771,30 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { assert!(still.contains(&ActionId::Color)); assert!(still.contains(&ActionId::Fit)); assert!(still.contains(&ActionId::Speed)); + // Mix is not in the clip menu, but it wears the same class refusal the + // dock's verb row hides it by (`ui::dock_stance::ghost_verb`): nothing to + // mix for a picture with no sound at all, live everywhere else. + let mix_ctx = |lane, image| Ctx { + clip: Some((clip, lane)), + image, + playhead: 60, + timeline: true, + ..Ctx::default() + }; + assert!(!enable(ActionId::Mix, mix_ctx(v1, true)).listed()); + assert!(enable(ActionId::Mix, mix_ctx(v1, false)).listed()); + assert!(enable(ActionId::Mix, mix_ctx(a1, false)).listed()); + // A silent video (no still, but its source's stream table is empty) + // refuses Mix and Silence the same way, by `no_sound` rather than `image`. + let mute_video = Ctx { + clip: Some((clip, v1)), + no_sound: true, + playhead: 60, + timeline: true, + ..Ctx::default() + }; + assert!(!enable(ActionId::Mix, mute_video).listed()); + assert!(!enable(ActionId::Silence, mute_video).listed()); // ...and the state refusals are on all three, dimmed rather than gone: // at 30 the playhead is on this clip's head, where a cut has nothing to // split off -- a row the next click of the playhead lights. @@ -1730,12 +1754,12 @@ fn a_copied_clip_is_renumbered_or_dropped_when_a_row_leaves_the_library() { assert!(clipboard_after_remove(Vec::new(), 0).is_empty()); // A set with one member's file gone loses only that member -- the rest // of the set survives to be pasted, gaps and lanes intact. - let trimmed = clipboard_after_remove( - vec![(Lane::V1, clip(1)), (Lane::A1, clip(2))], - 1, - ); + let trimmed = clipboard_after_remove(vec![(Lane::V1, clip(1)), (Lane::A1, clip(2))], 1); assert_eq!( - trimmed.into_iter().map(|(_, c)| c.source).collect::>(), + trimmed + .into_iter() + .map(|(_, c)| c.source) + .collect::>(), vec![1] ); } @@ -2042,18 +2066,22 @@ fn a_selection_drag_moves_every_pick_by_the_same_delta() { // clip0 on V1 at the fixture's own start; clip1 on V1 ten seconds in, // appended to the open bed and rippling nothing. - assert!(session - .place_stream_at(10.0, &second, 0, None) - .expect("av2 is on this timeline")); + assert!( + session + .place_stream_at(10.0, &second, 0, None) + .expect("av2 is on this timeline") + ); let clip0 = session.lane_clips(Lane::V1)[0]; let clip1 = session.lane_clips(Lane::V1)[1]; assert_eq!((clip0.start, clip1.start), (0, 300)); // clipC on a second video row, well past both of the above. let v2 = session.add_lane(LaneKind::Video); - assert!(session - .place_stream_at(20.0, &path, 0, Some(v2)) - .expect("test_av.mp4 is on this timeline")); + assert!( + session + .place_stream_at(20.0, &path, 0, Some(v2)) + .expect("test_av.mp4 is on this timeline") + ); let clip_c = session.lane_clips(v2)[0]; assert_eq!(clip_c.start, 600); @@ -2071,11 +2099,17 @@ fn a_selection_drag_moves_every_pick_by_the_same_delta() { // rather than clearing it. assert_eq!( session.lane_clips(Lane::V1)[0], - Clip { start: clip0.start + 50, ..clip0 } + Clip { + start: clip0.start + 50, + ..clip0 + } ); assert_eq!( session.lane_clips(v2)[0], - Clip { start: clip_c.start + 50, ..clip_c } + Clip { + start: clip_c.start + 50, + ..clip_c + } ); assert!(session.undo(), "one step for the whole set-move"); @@ -2100,35 +2134,35 @@ fn a_selection_drag_refuses_as_one_set_when_any_pick_cannot_land() { session.import(&asset("test_av2.mp4")).expect("av2 matches"); let second = session.sources()[1].path.clone(); - assert!(session - .place_stream_at(10.0, &second, 0, None) - .expect("av2 is on this timeline")); + assert!( + session + .place_stream_at(10.0, &second, 0, None) + .expect("av2 is on this timeline") + ); let clip0 = session.lane_clips(Lane::V1)[0]; let clip1 = session.lane_clips(Lane::V1)[1]; let v2 = session.add_lane(LaneKind::Video); - assert!(session - .place_stream_at(0.0, &path, 0, Some(v2)) - .expect("test_av.mp4 is on this timeline")); + assert!( + session + .place_stream_at(0.0, &path, 0, Some(v2)) + .expect("test_av.mp4 is on this timeline") + ); let clip_c = session.lane_clips(v2)[0]; // A clip clip1 is not picked, blocking the road on V2 the drag is about // to try: clip1 dragged onto V2 lands its head inside this one. - assert!(session - .place_stream_at(10.0, &second, 0, Some(v2)) - .expect("av2 is on this timeline")); + assert!( + session + .place_stream_at(10.0, &second, 0, Some(v2)) + .expect("av2 is on this timeline") + ); let blocker = session.lane_clips(v2)[1]; assert_eq!(blocker.start, 300); let picks = [(Lane::V1, 0), (Lane::V1, 1), (v2, 0)]; // Dragged onto V2 at a frame inside the blocker: refused outright, the // way a lone drag onto another clip already is. - assert!(!session.move_selection_to( - &picks, - Lane::V1, - 1, - v2, - blocker.start + 10 - )); + assert!(!session.move_selection_to(&picks, Lane::V1, 1, v2, blocker.start + 10)); // Nothing moved -- not clip1 clamped short of the blocker, and not the // two picks that had all the room to spare. assert_eq!(session.lane_clips(Lane::V1)[0], clip0); @@ -2176,23 +2210,30 @@ fn a_three_pick_copy_paste_preserves_gaps_and_lane_assignment() { session.import(&asset("test_av2.mp4")).expect("av2 matches"); let second = session.sources()[1].path.clone(); - assert!(session - .place_stream_at(10.0, &second, 0, None) - .expect("av2 is on this timeline")); + assert!( + session + .place_stream_at(10.0, &second, 0, None) + .expect("av2 is on this timeline") + ); let clip0 = session.lane_clips(Lane::V1)[0]; let clip1 = session.lane_clips(Lane::V1)[1]; let v2 = session.add_lane(LaneKind::Video); - assert!(session - .place_stream_at(20.0, &path, 0, Some(v2)) - .expect("test_av.mp4 is on this timeline")); + assert!( + session + .place_stream_at(20.0, &path, 0, Some(v2)) + .expect("test_av.mp4 is on this timeline") + ); let clip_c = session.lane_clips(v2)[0]; // Copied in click order, out of the lanes each was clicked in -- exactly // what `Player::copy_selected` builds. let items = [(Lane::V1, clip0), (Lane::V1, clip1), (v2, clip_c)]; let at = session.timeline_duration(); - assert!(session.paste_set_at(at, &items), "a free spot takes the set"); + assert!( + session.paste_set_at(at, &items), + "a free spot takes the set" + ); let new0 = session.lane_clips(Lane::V1)[2]; let new1 = session.lane_clips(Lane::V1)[3]; @@ -2230,16 +2271,20 @@ fn a_colliding_set_paste_refuses_whole() { session.import(&asset("test_av2.mp4")).expect("av2 matches"); let second = session.sources()[1].path.clone(); - assert!(session - .place_stream_at(10.0, &second, 0, None) - .expect("av2 is on this timeline")); + assert!( + session + .place_stream_at(10.0, &second, 0, None) + .expect("av2 is on this timeline") + ); let clip0 = session.lane_clips(Lane::V1)[0]; let clip1 = session.lane_clips(Lane::V1)[1]; let v2 = session.add_lane(LaneKind::Video); - assert!(session - .place_stream_at(20.0, &path, 0, Some(v2)) - .expect("test_av.mp4 is on this timeline")); + assert!( + session + .place_stream_at(20.0, &path, 0, Some(v2)) + .expect("test_av.mp4 is on this timeline") + ); let clip_c = session.lane_clips(v2)[0]; let items = [(Lane::V1, clip0), (Lane::V1, clip1), (v2, clip_c)]; @@ -2570,8 +2615,14 @@ fn escape_closes_a_card_before_it_can_ever_reach_deselect() { "if this.param_card_key(key, event.keystroke.modifiers.shift, cx) {", "a param card", ), - ("if this.card_open()", "a card (keys overlay/export/eq/color/...)"), - ("|| this.context_menu.is_some()", "the clip/row menu or a list"), + ( + "if this.card_open()", + "a card (keys overlay/export/eq/color/...)", + ), + ( + "|| this.context_menu.is_some()", + "the clip/row menu or a list", + ), ( "if key == ESCAPE && !ctrl && this.preview_session.is_some() {", "an open preview", diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index 2b8fb29..881c9c9 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -109,8 +109,10 @@ impl DockSort { /// A ghost verb (DESIGN §4): borderless glyph/label in `ink2`, its chord in /// `ink3` beside it, read live off the keymap so it can never drift from the /// key that does the same thing. Hover is one fill step and an ink brighten; -/// held open (`active`) keeps both. A refused verb dims and says why on -/// hover instead of disappearing (§8). +/// held open (`active`) keeps both. A verb the current *state* refuses dims +/// and says why on hover; a verb the clip's *media kind* can never use +/// ([`Enable::Hidden`]) is left out of the row entirely instead (§8) -- the +/// same `listed()`/`Hidden` split the clip menu already reads. fn ghost_verb( id: &'static str, verb_label: &'static str, @@ -119,8 +121,11 @@ fn ghost_verb( hint: &str, player: &Player, on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, -) -> impl IntoElement { +) -> Option { let enabled = player.enable(action, None); + if !enabled.listed() { + return None; + } let key = player.keymap.chord(action); let say: SharedString = match enabled.why() { Some(why) => format!("{key} — {why}"), @@ -130,39 +135,41 @@ fn ghost_verb( let on = enabled.yes(); let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); - div() - .id(id) - .flex_none() - .flex() - .items_center() - .justify_between() - .h(px(CONTROL_H)) - .px(px(8.)) - .rounded(px(3.)) - .when(active, |d| d.bg(rgb(DARK_RAISED()))) - .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into()) - .when(!on, |d| d.opacity(0.4).cursor_not_allowed()) - .when(on, |d| { - d.cursor_pointer() - .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) - .on_click(on_click) - }) - .children(hitmap::action(action, on)) - .child( - div() - .font(label_style.font) - .text_size(label_style.size) - .text_color(rgb(if active { INK1() } else { INK2() })) - .child(verb_label), - ) - .child( - div() - .flex_none() - .font(chord_style.font) - .text_size(chord_style.size) - .text_color(rgb(if active { INK1() } else { INK3() })) - .child(key), - ) + Some( + div() + .id(id) + .flex_none() + .flex() + .items_center() + .justify_between() + .h(px(CONTROL_H)) + .px(px(8.)) + .rounded(px(3.)) + .when(active, |d| d.bg(rgb(DARK_RAISED()))) + .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into()) + .when(!on, |d| d.opacity(0.4).cursor_not_allowed()) + .when(on, |d| { + d.cursor_pointer() + .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) + .on_click(on_click) + }) + .children(hitmap::action(action, on)) + .child( + div() + .font(label_style.font) + .text_size(label_style.size) + .text_color(rgb(if active { INK1() } else { INK2() })) + .child(verb_label), + ) + .child( + div() + .flex_none() + .font(chord_style.font) + .text_size(chord_style.size) + .text_color(rgb(if active { INK1() } else { INK3() })) + .child(key), + ), + ) } /// One tab of the Src/Clip pair (MOCK-SPEC "Dock": no pill, no fill, no @@ -827,11 +834,7 @@ fn subtitle_palette(player: &Player, cx: &mut Context) -> Option, -) -> impl IntoElement { +fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context) -> impl IntoElement { let focused = player.focus_dock.is_focused(window); let sources = player .session @@ -1033,7 +1036,7 @@ fn sources_tab( .flex_none() .flex() .flex_col() - .child(ghost_verb( + .children(ghost_verb( "dock-import-files", "Add files", ActionId::AddFiles, @@ -1042,7 +1045,7 @@ fn sources_tab( player, cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_import(cx)), )) - .child(ghost_verb( + .children(ghost_verb( "dock-paste-path", "Paste path", ActionId::PasteFilePath, @@ -1057,7 +1060,7 @@ fn sources_tab( // that no longer had the height for it (user 2026-08-21: // "the spine menu is too crowded"), and an import belongs // beside the other two imports, not beside the lane verbs. - .child(ghost_verb( + .children(ghost_verb( "dock-import-subtitles", "Import subtitles", ActionId::ImportSubtitles, @@ -1117,11 +1120,14 @@ fn transition_row(player: &Player, cx: &mut Context) -> Option| { + let step = |id: &'static str, + label: &'static str, + glyph: &'static str, + by: i32, + cx: &mut Context| { div() .id(id) .flex() @@ -1220,7 +1226,7 @@ fn clip_tab( .flex_col() .gap(px(2.)) .p(px(8.)) - .child(ghost_verb( + .children(ghost_verb( "dock-verb-speed", "Speed", ActionId::Speed, @@ -1229,7 +1235,7 @@ fn clip_tab( player, cx.listener(|this, _: &ClickEvent, _, cx| this.open_speed(cx)), )) - .child(ghost_verb( + .children(ghost_verb( "dock-verb-color", "Colour", ActionId::Color, @@ -1238,7 +1244,7 @@ fn clip_tab( player, cx.listener(|this, _: &ClickEvent, _, cx| this.open_color(cx)), )) - .child(ghost_verb( + .children(ghost_verb( "dock-verb-transform", "Transform", ActionId::Transform, @@ -1247,7 +1253,7 @@ fn clip_tab( player, cx.listener(|this, _: &ClickEvent, _, cx| this.open_transform(cx)), )) - .child(ghost_verb( + .children(ghost_verb( "dock-verb-eq", "EQ", ActionId::Equalizer, @@ -1264,7 +1270,7 @@ fn clip_tab( // (`bench_stance.rs`, another builder's file this session); // it stays reachable by its chord until that lane grows a // header to hang a verb on. - .child(ghost_verb( + .children(ghost_verb( "dock-verb-silence", "Silence", ActionId::Silence, @@ -1273,7 +1279,7 @@ fn clip_tab( player, cx.listener(|this, _: &ClickEvent, _, cx| this.open_silence(cx)), )) - .child(ghost_verb( + .children(ghost_verb( "dock-verb-mix", "Mix", ActionId::Mix, @@ -1290,7 +1296,7 @@ fn clip_tab( // right-click menu (`overlays.rs`'s `Pick::Fit`); this is its // direct button, beside the other per-clip verbs it keeps // company with. - .child(ghost_verb( + .children(ghost_verb( "dock-verb-fit", "Fit", ActionId::Fit,