diff --git a/crates/app/src/library_meta.rs b/crates/app/src/library_meta.rs index ddbe126..07fc572 100644 --- a/crates/app/src/library_meta.rs +++ b/crates/app/src/library_meta.rs @@ -64,7 +64,7 @@ pub(crate) struct Row { pub(crate) fn library_rows( sources: &[Source], streams: &HashMap>, - decoders: &HashMap, Backend)>>, + decoders: &HashMap, timeline_audio: Option<(u32, u16)>, frames: impl Fn(&Path) -> u32, ) -> Vec { @@ -89,9 +89,7 @@ pub(crate) fn library_rows( detail: join_detail( &decoders .get(&source.path) - .copied() - .flatten() - .map_or_else(String::new, |(codec, backend)| decode_label(codec, backend)), + .map_or_else(|| Decoder::Pending.detail(), Decoder::detail), &info .filter(|_| of_file.len() > 1) .map_or_else(String::new, stream_detail), @@ -196,6 +194,49 @@ pub(crate) fn decode_label(codec: Option, backend: Backend) -> String { } } +/// What the one-shot probe said about a file: the seat it will open on, or -- +/// when the decoder itself refused -- the refusal, in the decoder's own words. +/// +/// Three answers, not two, because "asked" and "refused" are not the same +/// answer. Both used to be a missing entry, and a missing entry drew an empty +/// second line -- the same line a song draws -- so a file this machine cannot +/// decode was indistinguishable from one that needs no word at all. +#[derive(Debug, Clone, PartialEq)] +pub(crate) enum Decoder { + /// Asked and not yet answered: the probe is still walking the file. A + /// real wait, and one that claims nothing while it lasts. + Pending, + /// The codec (`None` for a still, which has no coded stream) and the seat + /// the engine picked for it. + Seat(Option, Backend), + /// The decoder refused this file, and these are its words. Not a message + /// of this program's own making: the probe is `engine::decode::probe`, + /// and the refusal is the one opening the file would give. + Refused(String), +} + +impl From, Backend)>> for Decoder { + fn from(probed: engine::Result<(Option, Backend)>) -> Self { + match probed { + Ok((codec, backend)) => Self::Seat(codec, backend), + Err(why) => Self::Refused(why.to_string()), + } + } +} + +impl Decoder { + /// What the row's second line says about the file's decoder: the seat for + /// a file that opens, the refusal for one that does not, and nothing for a + /// probe still running. + pub(crate) fn detail(&self) -> String { + match self { + Self::Pending => String::new(), + Self::Seat(codec, backend) => decode_label(*codec, *backend), + Self::Refused(why) => why.clone(), + } + } +} + /// How a row names its file: the file alone when it has one audio stream or /// none, and the file plus which stream this row is when it has several -- /// counted from 1, the way a player numbers tracks. diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 0656641..7d91cb8 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -68,11 +68,11 @@ use engine::transform::TransformParams; use engine::{Clip, Codec, ExportHandle, Frame, MediaBitrate, PlaybackSession}; use gpui::{ AnyElement, App, Application, Bounds, ClickEvent, Context, Corners, CursorStyle, Div, - DragMoveEvent, FocusHandle, KeyDownEvent, MouseButton, MouseDownEvent, - MouseExitEvent, MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, Point, RenderImage, - ScrollDelta, ScrollHandle, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign, - TitlebarOptions, Window, WindowBounds, WindowOptions, canvas, div, point, prelude::*, px, - relative, rgb, rgba, size, + DragMoveEvent, FocusHandle, KeyDownEvent, MouseButton, MouseDownEvent, MouseExitEvent, + MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, Point, RenderImage, ScrollDelta, + ScrollHandle, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign, TitlebarOptions, + Window, WindowBounds, WindowOptions, canvas, div, point, prelude::*, px, relative, rgb, rgba, + size, }; struct Player { @@ -278,13 +278,14 @@ struct Player { /// must stay in the map or every repaint would ask again. syncs: HashMap>, /// Which decoder each source will run on, probed once at import and kept: - /// the codec (`None` for a still) and the seat the engine picked for it. + /// the codec (`None` for a still) and the seat the engine picked for it -- + /// or, where the decoder refused the file, the refusal in its own words. /// What a library row says *before* anything plays; the running answer is /// the session's own (`PlaybackSession::decode_backend`), which follows a /// fallback this cannot. Filled like `sizes`: presence means "asked", and - /// `None` is a source with no decoder to name -- a song, or one the probe - /// refused -- which must stay in the map or every repaint would ask again. - decoders: HashMap, Backend)>>, + /// `Decoder::Pending` is that asked-but-unanswered window -- which must + /// stay in the map or every repaint would ask again. + decoders: HashMap, /// What an export of the picked settings would open -- the picture's seat /// or the copy that means it opens none, and the sound's -- and what it was /// asked about: the settings, the canvas and the *cuts*, since where they diff --git a/crates/app/src/player/export.rs b/crates/app/src/player/export.rs index 75423f3..c9983ed 100644 --- a/crates/app/src/player/export.rs +++ b/crates/app/src/player/export.rs @@ -180,13 +180,15 @@ impl Player { // a frame of it plays. Off the render thread like the streams above: a // stream the plugin takes costs one VA-API init (~90 ms) to answer. for path in unseen_paths(session.sources(), &self.decoders) { - self.decoders.insert(path.clone(), None); + self.decoders.insert(path.clone(), Decoder::Pending); let probed = cx.background_executor().spawn({ let path = path.clone(); - // A song and a source no decoder here takes are both `None`: - // the row says nothing about them rather than guessing, and - // import refused the second at the door anyway. - async move { engine::decode::probe(&path).ok() } + // A refusal is kept in the decoder's own words, and the row + // shows them: a file this machine cannot decode is the one + // whose second line has to say so. A song is a different + // answer entirely -- it has no coded stream, and the probe + // says so by naming the still seat. + async move { Decoder::from(engine::decode::probe(&path)) } }); cx.spawn(async move |this, cx| { let probed = probed.await; @@ -644,7 +646,12 @@ impl Player { /// /// Escape retreats one step at a time (DESIGN.md:146): the field first, /// the moment second. - pub(crate) fn export_moment_key(&mut self, key: &str, shift: bool, cx: &mut Context) -> bool { + pub(crate) fn export_moment_key( + &mut self, + key: &str, + shift: bool, + cx: &mut Context, + ) -> bool { if !self.export_open { return false; } diff --git a/crates/app/src/tests/editing.rs b/crates/app/src/tests/editing.rs index ce1ecf6..ba71a0c 100644 --- a/crates/app/src/tests/editing.rs +++ b/crates/app/src/tests/editing.rs @@ -109,9 +109,11 @@ fn a_song_opens_the_window_by_itself() { // ...and it places, on the audio lane, through the door `insert_source` // uses: a second copy of the song at the playhead. session.seek(1.0); - assert!(session - .place_stream_at(1.0, &path, 0, Some(Lane::A1)) - .expect("its own file is on this timeline")); + assert!( + session + .place_stream_at(1.0, &path, 0, Some(Lane::A1)) + .expect("its own file is on this timeline") + ); assert_eq!(session.lane_clips(Lane::A1).len(), 2); assert!(session.lane_clips(Lane::V1).is_empty(), "still no picture"); @@ -256,6 +258,63 @@ fn every_audio_stream_of_a_file_is_a_row_usable_or_not() { assert_eq!(rows[1].tint, 1, "the other file is the other tint"); } +/// A file the decoder refuses says so on its own row, in the decoder's own +/// words. The refusal is the only thing a person can act on for a file that +/// will not play, and before this the row drew an empty second line -- the +/// same line a song draws, which claims nothing and means nothing. +/// +/// Dumped through the real [`engine::decode::probe`], not a hand-written +/// `Err`: a `.mkv` that is not a container is refused by the demuxer, with no +/// plugin and no hardware involved, so the words under test are the ones the +/// engine really produces. +#[test] +fn a_refused_file_names_the_refusal_on_its_row() { + let junk = std::env::temp_dir().join("edith-lane-j-refused.mkv"); + std::fs::write(&junk, b"not a container, and never will be").expect("write the junk file"); + let words = engine::decode::probe(&junk) + .expect_err("a file that is not a stream is refused") + .to_string(); + assert!( + !words.is_empty(), + "a refusal that says nothing says nothing" + ); + + let mut decoders = HashMap::new(); + decoders.insert(junk.clone(), Decoder::from(engine::decode::probe(&junk))); + let rows = library_rows( + &[Source { + path: junk.clone(), + audio_stream: 0, + }], + &HashMap::new(), + &decoders, + None, + |_| 0, + ); + assert_eq!( + rows[0].detail, words, + "the row carries the refusal verbatim" + ); + + // A probe still running says nothing, and must keep saying nothing: an + // empty second line is a real answer here, not a missing one. + let mut pending = HashMap::new(); + pending.insert(junk.clone(), Decoder::Pending); + let rows = library_rows( + &[Source { + path: junk.clone(), + audio_stream: 0, + }], + &HashMap::new(), + &pending, + None, + |_| 0, + ); + assert_eq!(rows[0].detail, "", "an unasked decoder claims nothing"); + + std::fs::remove_file(&junk).ok(); +} + /// What the clip menu offers, and where it hangs. The two items that act on /// the playhead rather than on the clicked clip are the ones that can be /// inapplicable, and a menu at the edge of the window has to come back inside @@ -343,11 +402,13 @@ fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() { ); // ...and the same reading with a clip under it is the clip menu, untouched: // the flag is off wherever a `Clip` was clicked. - assert!(menu_items(Ctx { - timeline: true, - ..Ctx::default() - }) - .contains(&ActionId::Cut)); + assert!( + menu_items(Ctx { + timeline: true, + ..Ctx::default() + }) + .contains(&ActionId::Cut) + ); } /// A timeline with a subtitle palette and an empty subtitle lane: what a @@ -949,14 +1010,16 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { } assert!(!whole(ActionId::Delete, live).yes()); assert!(!whole(ActionId::Paste, live).yes()); - assert!(whole( - ActionId::Paste, - Ctx { - clipboard: true, - ..live - } - ) - .yes()); + assert!( + whole( + ActionId::Paste, + Ctx { + clipboard: true, + ..live + } + ) + .yes() + ); assert!(!whole(ActionId::CancelExport, live).yes()); let busy = Ctx { exporting: true, @@ -1176,14 +1239,16 @@ fn a_menu_offers_only_what_applies_and_is_drawn_inside_the_window() { assert!(row_enable(RowItem::RemoveWithClips, placed).yes()); let unplaced = row_items(live); assert!(unplaced.contains(&RowItem::Remove) && !unplaced.contains(&RowItem::RemoveWithClips)); - assert!(!row_enable( - RowItem::RemoveWithClips, - RowCtx { - exporting: true, - ..placed - } - ) - .yes()); + assert!( + !row_enable( + RowItem::RemoveWithClips, + RowCtx { + exporting: true, + ..placed + } + ) + .yes() + ); assert!(!row_enable(RowItem::Add, RowCtx::default()).yes()); // Every refusal is short enough to sit in the hint column beside its // label, the clip menu's rule. @@ -1617,9 +1682,11 @@ fn adding_a_row_drops_the_whole_source_in_at_the_playhead() { let frames = session.file_frames(&second); // Through the engine door `insert_source` uses, with the row's own // stream: the button, the drop and this are one call. - assert!(session - .place_stream_at(2.0, &second, 0, None) - .expect("av2 is already on the timeline")); + assert!( + session + .place_stream_at(2.0, &second, 0, None) + .expect("av2 is already on the timeline") + ); // The whole of source 1 went in and nothing was painted over: the // timeline is longer by exactly that file. assert_eq!(session.timeline_duration(), 9.0); @@ -1646,9 +1713,11 @@ fn adding_a_row_drops_the_whole_source_in_at_the_playhead() { let path = session.sources()[0].path.clone(); let frames = session.file_frames(&path); let end = session.timeline_duration(); - assert!(session - .place_stream_at(end, &path, 1, None) - .expect("the French track shares the timeline's parameters")); + assert!( + session + .place_stream_at(end, &path, 1, None) + .expect("the French track shares the timeline's parameters") + ); assert_eq!(session.sources()[1].audio_stream, 1); assert_eq!(session.timeline_duration(), end * 2.0); // Both rows are the same file, so both rows are that file's length -- @@ -1698,9 +1767,11 @@ fn a_row_dropped_on_the_open_bed_lands_under_the_pointer() { // ...and what the release does with it: the frame back through the same // rate every box is drawn at, into the door the Add button uses too. - assert!(session - .place_stream_at(f64::from(at) / fps, &second, 0, None) - .expect("av2 is already on this timeline")); + assert!( + session + .place_stream_at(f64::from(at) / fps, &second, 0, None) + .expect("av2 is already on this timeline") + ); let head = |lane| { session .lane_clips(lane) @@ -1734,9 +1805,11 @@ fn removing_a_row_is_refused_while_it_plays_and_takes_the_row_away() { session.import(&asset("test_av2.mp4")).expect("av2 matches"); let second = session.sources()[1].path.clone(); let end = session.timeline_duration(); - assert!(session - .place_stream_at(end, &second, 0, None) - .expect("a file just imported is on this timeline")); + assert!( + session + .place_stream_at(end, &second, 0, None) + .expect("a file just imported is on this timeline") + ); let streams = HashMap::new(); let rows = |session: &PlaybackSession| { library_rows(session.sources(), &streams, &HashMap::new(), None, |_| 0).len() @@ -1957,7 +2030,7 @@ fn trim_to_playhead_moves_the_selected_clips_edge_and_undoes_in_one_step() { /// it makes. #[test] fn the_windows_settings_caches_follow_the_session_across_undo_and_redo() { - use crate::player::actions::{history_step, HistoryBefore, SessionCaches}; + use crate::player::actions::{HistoryBefore, SessionCaches, history_step}; let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture"); session.set_gain(0.0); @@ -2037,7 +2110,7 @@ fn the_windows_settings_caches_follow_the_session_across_undo_and_redo() { /// keyed by where a cue sits -- but because the step moves the cues under it. #[test] fn the_subtitle_pick_follows_its_track_across_an_undo_of_a_removal() { - use crate::player::actions::{history_step, HistoryBefore, SessionCaches}; + use crate::player::actions::{HistoryBefore, SessionCaches, history_step}; let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture"); session.set_gain(0.0); @@ -2268,9 +2341,11 @@ fn a_track_can_be_added_dropped_on_edited_and_taken_back() { // A library row let go over that row: the same door the Add button // uses, told which lane it was let go over. let path = session.sources()[0].path.clone(); - assert!(session - .place_stream_at(1.0, &path, 0, Some(v2)) - .expect("its own file is on this timeline")); + assert!( + session + .place_stream_at(1.0, &path, 0, Some(v2)) + .expect("its own file is on this timeline") + ); assert_eq!(session.lane_clips(v2).len(), 1, "the drop landed on V2"); assert_eq!(session.lane_clips(v2)[0].start, 30, "at the playhead"); // ...with the sound it came with, on the row of its own the drop added: @@ -2357,18 +2432,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); @@ -2421,22 +2500,28 @@ 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); @@ -2491,16 +2576,20 @@ 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 @@ -2548,16 +2637,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)]; @@ -2612,9 +2705,11 @@ fn a_grouped_clip_on_an_added_lane_closes_its_hole_with_its_caption() { let (mut session, sub_lane) = with_subtitle_lane(); let v2 = session.add_lane(LaneKind::Video); let path = session.sources()[0].path.clone(); - assert!(session - .place_stream_at(0.0, &path, 0, Some(v2)) - .expect("its own file is on this timeline")); + assert!( + session + .place_stream_at(0.0, &path, 0, Some(v2)) + .expect("its own file is on this timeline") + ); session .place_sub(sub_lane, 0, one_second(0)) .expect("the caption goes down"); diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index 3620196..ebe162a 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -351,7 +351,7 @@ fn a_lane_row_is_a_fixed_header_and_a_bed_that_can_be_hit() { /// strip's row at the zoom boundary without the strip to show for it. #[test] fn the_scroll_strip_row_comes_and_goes_with_the_zoom() { - use crate::{lanes_h, split_size, timeline_fixed_h, timeline_h, Split, SCROLL_HIT}; + use crate::{SCROLL_HIT, Split, lanes_h, split_size, timeline_fixed_h, timeline_h}; use gpui::{px, size}; // The strip's row, and only the strip's row, is what the two faces differ @@ -398,8 +398,8 @@ fn the_scroll_strip_row_comes_and_goes_with_the_zoom() { /// on the track, the time axis's own thumb turned through a right angle. #[test] fn the_lane_thumb_is_the_visible_share_of_the_stack() { - use crate::lanes_thumb; use crate::SCROLL_THUMB_MIN; + use crate::lanes_thumb; // Whole stack on screen: the track fills and there is nothing to scroll. assert_eq!(lanes_thumb(200., 104., 200., 0.), (0., 200.)); @@ -1301,7 +1301,7 @@ fn the_darkroom_subtitle_palette_drags_tracks_to_subtitle_lanes() { /// arrival order, at the end. #[test] fn a_file_subtitle_group_follows_its_own_row() { - use crate::ui::dock_stance::{source_list_order, Slot}; + use crate::ui::dock_stance::{Slot, source_list_order}; let film = PathBuf::from("/films/a.mkv"); let other = PathBuf::from("/rec/b.mp4"); let loose = PathBuf::from("/subs/late.srt"); @@ -1798,8 +1798,8 @@ fn darkroom_lane_header_verbs_are_targeted_and_visible() { fn a_dragged_divider_stops_before_either_panel_disappears() { use crate::ui::theme::INSPECTOR_MIN_W; use crate::{ - inspector_w, library_w, split_drag_size, split_size, timeline_fixed_h, timeline_h, Split, - SIDE_MAX_FRAC, SPLIT_W, TIMELINE_MAX_SHARE, TOOLBAR_H, + SIDE_MAX_FRAC, SPLIT_W, Split, TIMELINE_MAX_SHARE, TOOLBAR_H, inspector_w, library_w, + split_drag_size, split_size, timeline_fixed_h, timeline_h, }; use gpui::{point, px, size}; @@ -1919,7 +1919,7 @@ fn a_dragged_divider_stops_before_either_panel_disappears() { fn the_darkroom_seams_stop_before_either_side_disappears() { use crate::ui::theme::INSPECTOR_MIN_W; use crate::{ - split_bounds, split_drag_size, split_size, Split, BENCH_MIN_H, SIDE_MAX_FRAC, SPLIT_W, + BENCH_MIN_H, SIDE_MAX_FRAC, SPLIT_W, Split, split_bounds, split_drag_size, split_size, }; use gpui::{point, px, size}; @@ -1978,9 +1978,9 @@ fn the_darkroom_seams_stop_before_either_side_disappears() { /// ~2px at the old `BENCH_MIN_H = 80.`). #[test] fn both_default_lanes_fit_the_bench_at_its_floor() { - use crate::ui::bench_stance::{row_h, LANE_MIN_H, ROW_GAP, RULER_H}; - use crate::ui::stance::BENCH_CHROME_H; use crate::BENCH_MIN_H; + use crate::ui::bench_stance::{LANE_MIN_H, ROW_GAP, RULER_H, row_h}; + use crate::ui::stance::BENCH_CHROME_H; let box_h = BENCH_MIN_H - BENCH_CHROME_H; let avail = box_h - RULER_H - ROW_GAP; @@ -2020,9 +2020,9 @@ fn both_default_lanes_fit_the_bench_at_its_floor() { /// painted bounds back, so it stays geometry-only, same as its neighbours. #[test] fn the_whole_bench_stack_fits_its_own_floor_with_the_ledger_seam_clear() { + use crate::BENCH_MIN_H; use crate::ui::bench_stance::{LANE_MIN_H, ROW_GAP, RULER_H}; use crate::ui::stance::BENCH_CHROME_H; - use crate::BENCH_MIN_H; const BENCH_BORDER_T: f32 = 1.; const BENCH_PY_TOP: f32 = 4.; @@ -2092,9 +2092,9 @@ fn a_lane_row_fits_what_its_own_head_draws() { #[test] fn a_saved_seam_survives_a_reload() { use crate::{ - load_stance_splits_from, save_stance_splits_to, Split, Splits, BENCH_MIN_H, SIDE_MAX_FRAC, + BENCH_MIN_H, SIDE_MAX_FRAC, Split, Splits, load_stance_splits_from, save_stance_splits_to, }; - use gpui::{px, size, Pixels, Size}; + use gpui::{Pixels, Size, px, size}; let dir = engine::scratch::Scratch::dir("edith-stance-splits"); let path = dir.join("stance-splits"); @@ -2137,7 +2137,7 @@ fn a_saved_seam_survives_a_reload() { /// drag that never started (`None`) owes nothing. #[test] fn only_the_persisted_seams_owe_a_save_when_a_drag_loses_the_window() { - use crate::{player::timeline_edit::split_drag_owes_save, Split}; + use crate::{Split, player::timeline_edit::split_drag_owes_save}; assert!(split_drag_owes_save(Some(Split::Dock))); assert!(split_drag_owes_save(Some(Split::Bench))); @@ -2151,8 +2151,8 @@ fn only_the_persisted_seams_owe_a_save_when_a_drag_loses_the_window() { /// `load_stance_splits`'s doc comment promises. #[test] fn a_missing_stance_splits_file_leaves_every_region_at_its_default() { - use crate::{load_stance_splits_from, Split}; - use gpui::{px, size, Pixels, Size}; + use crate::{Split, load_stance_splits_from}; + use gpui::{Pixels, Size, px, size}; let dir = engine::scratch::Scratch::dir("edith-stance-splits-missing"); let window: Size = size(px(1280.), px(720.)); @@ -2993,7 +2993,7 @@ fn the_bench_answers_a_wheel_notch_anywhere_over_it() { /// kept beside the first ([`Splits::clear`]). #[test] fn a_double_pressed_divider_forgets_the_size_it_was_dragged_to() { - use crate::layout::{split_size, Split, Splits}; + use crate::layout::{Split, Splits, split_size}; use gpui::{px, size}; let window = size(px(1280.), px(720.)); @@ -3083,7 +3083,7 @@ fn the_bench_seam_reaches_no_further_than_every_other_seam() { /// `bench=105` at the floor, `bench=1164` at the ceiling. #[test] fn the_bench_seam_stops_at_its_floor_and_its_ceiling() { - use crate::{split_bounds, split_size, Split, BENCH_MIN_H}; + use crate::{BENCH_MIN_H, Split, split_bounds, split_size}; use gpui::{px, size}; let window = size(px(2560.), px(1440.)); @@ -3197,6 +3197,41 @@ fn a_source_row_shows_its_name_before_anything_else() { ); } +/// The dock's metadata line drops the decoder *seat* and nothing else. A file +/// the decoder refused has no seat to drop: its detail is the refusal, and it +/// is the only thing the line has to say. +#[test] +fn the_dock_keeps_a_refusal_where_it_drops_a_seat() { + use crate::ui::dock_stance::without_seats; + use engine::decode::Backend; + + let seats = [ + Backend::Opening, + Backend::Hardware, + Backend::Software, + Backend::Still, + Backend::Gap, + ] + .map(Backend::label); + assert_eq!( + without_seats("h264 · HW", &seats), + "h264", + "the seat is how this machine reads it, and the row says what the file is" + ); + let refusal = "no Segment element: not a Matroska file"; + assert_eq!( + without_seats(refusal, &seats), + refusal, + "a refusal is not a seat, and reaches the row whole" + ); + // The halves keep their separator either way: a stream detail beside a + // refusal is still two things said in order. + assert_eq!( + without_seats(&format!("{refusal} · stereo · 48 kHz"), &seats), + format!("{refusal} · stereo · 48 kHz") + ); +} + /// A room key pressed while the ring sits in the dock has to reach the room. /// Two ways it did not: the dock's own handler could stop a key it does not /// answer, and the body the dock mounts could leave the focused @@ -3400,8 +3435,8 @@ fn the_ledger_carries_the_rooms_four_verbs_and_no_rail_remains() { /// deletion. #[test] fn select_all_left_the_ruler_for_the_rulers_own_menu() { - use crate::menus::BENCH_ITEMS; use crate::ActionId; + use crate::menus::BENCH_ITEMS; let bench = src_text("ui/bench_stance.rs"); for gone in ["bench-select-all", "select_all_band", "SELECT_ALL_PAD"] { assert!(!bench.contains(gone), "the ruler still carries {gone}"); @@ -3873,7 +3908,7 @@ fn the_export_section_is_four_rows_and_no_fifth() { /// cannot write, because [`Player::set_format`] would only refuse it back. #[test] fn the_picture_row_cycles_codec_and_container_together_and_skips_a_refusal() { - use crate::ui::settings_stance::{next_picture, picture_label, PICTURE_CYCLE}; + use crate::ui::settings_stance::{PICTURE_CYCLE, next_picture, picture_label}; assert_eq!( PICTURE_CYCLE, [ diff --git a/crates/app/src/tests/mod.rs b/crates/app/src/tests/mod.rs index ce51f9e..8661872 100644 --- a/crates/app/src/tests/mod.rs +++ b/crates/app/src/tests/mod.rs @@ -10,55 +10,56 @@ mod media; mod view; use super::{ - active_lane, auto_bps, band_label, bitrate_detail, clipboard_after_remove, color_snap, - containers, destructive, enable, enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label, - eq_graph_h, eq_spectrum, eq_x, eq_y, estimated_bytes, export_path, export_settings, - format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at, frame_rate_ladder, - histogram, inserted_band, is_project, keymap, keys_rows, keys_rows_matching, lane_items, - lanes_h, marked, menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play, - notice_tone, panel_h, parse_budget, project_path, proxies_to_start, push_notice, px_below, - range_word, rate_label, retarget, row_enable, row_items, scrub_due, secs_label, should_resync, + ACCENT_PRIMARY, AUDIO_KBPS, BENCH_ITEMS, BG_RAISED, BPS_COARSE, BPS_FINE, BPS_MAX, BPS_MIN, + COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, CONTROL_H, Clip, ColorEdit, Ctx, + DEFAULT_AUDIO_KBPS, Decoder, EQ_BANDS_MAX, EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, EQ_FREQ_LOW, + EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, EQ_Q_STEP, + EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, EXPORT_DONE, EXPORT_MOMENT_H, Enable, EncoderSeat, + FORMATS, Format, HEADER_H, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, KEYS_ROW_H, KEYS_W, + KeyRow, LABEL_H, LANE_H, LANES_MAX, LATE_RESYNC, LIBRARY_MAX_W, LIBRARY_MIN_W, Lane, MB_FLOOR, + MENU_ITEMS, MENU_PAD, MENU_ROW_H, MENU_W, NO_FILE, NOTICES_MAX, NumberEdit, OVERLAID, PANEL_H, + RESYNC_GAP, ROW_ITEMS, RULER_HIT_H, RowCtx, RowItem, SCROLL_NOTCH_SHARE, SILENCE_ROWS, + SOURCE_TINTS, SPEED_PRESETS, SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, + SUB_PLAN_CHARS, Source, Speed, StreamInfo, SubPickKey, TIMELINE_SHARE, Transport, VOLUME_W, + VizSlot, Volume, WAVE_BPS, WAVE_COL, WAVE_COLS_MAX, Wave, ZOOM_MIN_FRAMES, active_lane, + auto_bps, band_label, bitrate_detail, clipboard_after_remove, color_snap, containers, + destructive, enable, enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h, + eq_spectrum, eq_x, eq_y, estimated_bytes, export_path, export_settings, format_refusal, + fps_choices, fps_label, frac_along, frac_down, frame_at, frame_rate_ladder, histogram, + inserted_band, is_project, keymap, keys_rows, keys_rows_matching, lane_items, lanes_h, marked, + menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play, notice_tone, + panel_h, parse_budget, project_path, proxies_to_start, push_notice, px_below, range_word, + rate_label, retarget, row_enable, row_items, scrub_due, secs_label, should_resync, silence_rate, size_label, snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at, sub_pick_after_removal, sub_pick_after_restore, subtitle_plan, timecode, timeline_fixed_h, tip_may_paint, transport, typed, unseen_paths, unseen_sources, viz_held_paint, whole_take, - window_title, Clip, ColorEdit, Ctx, Enable, EncoderSeat, Format, KeyRow, Lane, NumberEdit, - RowCtx, RowItem, Source, Speed, StreamInfo, SubPickKey, Transport, VizSlot, Volume, Wave, - ACCENT_PRIMARY, AUDIO_KBPS, BENCH_ITEMS, BG_RAISED, BPS_COARSE, BPS_FINE, BPS_MAX, BPS_MIN, - COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, CONTROL_H, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, - EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, - EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, - EXPORT_DONE, EXPORT_MOMENT_H, FORMATS, HEADER_H, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, - KEYS_ROW_H, KEYS_W, LABEL_H, LANES_MAX, LANE_H, LATE_RESYNC, LIBRARY_MAX_W, LIBRARY_MIN_W, - MB_FLOOR, MENU_ITEMS, MENU_PAD, MENU_ROW_H, MENU_W, NOTICES_MAX, NO_FILE, OVERLAID, PANEL_H, - RESYNC_GAP, ROW_ITEMS, RULER_HIT_H, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS, - SPEED_PRESETS, SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_PLAN_CHARS, - TIMELINE_SHARE, VOLUME_W, WAVE_BPS, WAVE_COL, WAVE_COLS_MAX, ZOOM_MIN_FRAMES, + window_title, }; use super::{ - arrival, audio_rate_choices, av1_hw_warning, clip_width, clock, encoder_choices, encoder_label, + ActionId, Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, IMPORT_STALL, Import, ImportStage, + Landing, LaneKind, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, SAMPLE_RATES, SEEK_STALL, + Scale, ScanKey, ScanPlan, SilenceScan, SubClip, View, ZOOM_OUT_MARGIN, ZOOM_STEP, arrival, + audio_rate_choices, av1_hw_warning, clip_width, clock, encoder_choices, encoder_label, eta_secs, file_name, file_uri, fit_choices, frames_of_us, full_scan_key, import_line, landing, lane_refuses, launch_queue, library_rows, live_idx, next_fit, next_resolution, note_progress, pending_fps_choices, pending_resolution_choices, px_along, read_ahead, repeats, resolution_choices, resolution_ladder, sample_rate_choices, scan_plan, seek_line, silence_cached, silence_line, slice_whole_levels, source_secs, stash_or_write, tone_choices, - tone_label, trimmed_clip, trimmed_sub, trims, unscannable, unusable, ActionId, Choice, Edge, - Import, ImportStage, Landing, LaneKind, Preset, Repeat, Scale, ScanKey, ScanPlan, SilenceScan, - SubClip, View, EDGE_W, ETA_SPAN, FITS, FRAME_RATES, IMPORT_STALL, PPS_DEFAULT, PPS_MIN, - RESOLUTIONS, SAMPLE_RATES, SEEK_STALL, ZOOM_OUT_MARGIN, ZOOM_STEP, + tone_label, trimmed_clip, trimmed_sub, trims, unscannable, unusable, }; use super::{ - carries_subtitles, cue_box, cues_at, file_tint, is_subtitle, lang_human, sub_bottom, - sub_pick_name, subtitle_detail, subtitle_notice, subtitle_rows, subtitle_tail, - subtitle_toggle_notice, walk_subtitles, Subs, SUB_BOTTOM, SUB_CUE_MIN_W, SUB_LINE_H, SUB_TEXT, + SUB_BOTTOM, SUB_CUE_MIN_W, SUB_LINE_H, SUB_TEXT, Subs, carries_subtitles, cue_box, cues_at, + file_tint, is_subtitle, lang_human, sub_bottom, sub_pick_name, subtitle_detail, + subtitle_notice, subtitle_rows, subtitle_tail, subtitle_toggle_notice, walk_subtitles, }; use engine::PlaybackSession; use engine::scale::FitPolicy; -use gpui::{point, px, size, Bounds, Pixels}; +use gpui::{Bounds, Pixels, point, px, size}; use std::collections::HashMap; diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index 4a0e869..0be77ad 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -185,7 +185,11 @@ fn dock_tab( } cx.notify(); })) - .tooltip(crate::ui::widgets::tip_hover(&format!("Show {}", label_text.to_lowercase()), "", None)) + .tooltip(crate::ui::widgets::tip_hover( + &format!("Show {}", label_text.to_lowercase()), + "", + None, + )) .children(hitmap::control(id, label_text, true)) .child( div() @@ -232,6 +236,25 @@ fn usage_line(player: &Player, source_idx: usize, placed: usize) -> String { lanes.join(" ") } +/// A row's detail line with the decoder seats taken out of it, which is what +/// the dock draws: the seat is how this machine happens to read the file and +/// the transport line and the Properties side both still say it, so the row +/// says what the file *is* instead. +/// +/// Only a whole part is dropped, and a part is a seat only when it is exactly +/// a seat's word. That is what keeps a refusal: the row's detail for a file +/// the decoder would not take is the refusal itself +/// ([`crate::Decoder::Refused`]), and no seat is ever named by a sentence -- +/// so the one line that has to say why the file will not play reaches the +/// dock whole. +pub(crate) fn without_seats(detail: &str, seats: &[&str]) -> String { + detail + .split(" · ") + .filter(|part| !seats.contains(part)) + .collect::>() + .join(" · ") +} + /// The file's name without its extension -- what the editor calls the film, /// not what the filesystem calls the bytes (cleanse round 2). A row that /// names several streams of one file keeps the stream half it was given @@ -281,12 +304,7 @@ fn source_row( Backend::Gap, ] .map(Backend::label); - let detail = row - .detail - .split(" · ") - .filter(|part| !seats.contains(part)) - .collect::>() - .join(" · "); + let detail = without_seats(&row.detail, &seats); let under: String = match &row.unusable { Some(why) => why.clone(), None => join_detail( @@ -690,15 +708,15 @@ fn subtitle_tab_rows( .on_drag(SubPick(track), { let me = cx.entity(); move |_, _, _, cx| { - // A fresh gesture inherits nothing: `Player::drag_lane` - // and `Player::drag_x` are the *last live sample* of the - // drag being made, and a drag whose first sample lands - // outside every row would otherwise be let go onto the - // lane the previous one ended over. - me.update(cx, |this, _| { - this.drag_lane = None; - this.drag_x = None; - }); + // A fresh gesture inherits nothing: `Player::drag_lane` + // and `Player::drag_x` are the *last live sample* of the + // drag being made, and a drag whose first sample lands + // outside every row would otherwise be let go onto the + // lane the previous one ended over. + me.update(cx, |this, _| { + this.drag_lane = None; + this.drag_x = None; + }); cx.new(|_| Tip(ghost.clone())) } }) @@ -707,7 +725,11 @@ fn subtitle_tab_rows( cx.notify(); })) }) - .tooltip(crate::ui::widgets::tip_hover("Subtitle track", "drag to a lane", None)) + .tooltip(crate::ui::widgets::tip_hover( + "Subtitle track", + "drag to a lane", + None, + )) .children(hitmap::dynamic( move || { ( @@ -777,7 +799,11 @@ fn subtitle_tab_rows( cx.stop_propagation(); this.remove_subtitle_track(track, cx); })) - .tooltip(crate::ui::widgets::tip_hover("Remove subtitle track", "", None)) + .tooltip(crate::ui::widgets::tip_hover( + "Remove subtitle track", + "", + None, + )) .children(hitmap::dynamic( move || { ( @@ -794,78 +820,79 @@ fn subtitle_tab_rows( let has_header = !nested || track_count > 3; let folded = has_header && (nested != player.sub_folded.contains(&group_path)); let header = div() - .id(("dock-subtitle-group", group_ord)) - .flex_none() - .flex() - .items_center() - .gap(px(6.)) - .px(px(8.)) - // Stepped in under its parent when it has one, the - // same outline the track rows below it read as. - .when(nested, |d| d.pl(px(22.))) - .py(px(4.)) - .rounded(px(3.)) - .cursor_pointer() - .hover(|s| s.bg(rgb(DARK_RAISED()))) - .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { - if !this.sub_folded.remove(&fold_path) { - this.sub_folded.insert(fold_path.clone()); - } - cx.notify(); - })) - .tooltip(crate::ui::widgets::tip_hover("Fold this source", "click", None)) - .children(hitmap::dynamic( - move || { - ( - format!("subtitle-group.{group_ord}.fold"), - "Toggle subtitle group".into(), - ) - }, - true, - )) - // Bare, the glyph inherited the panel's dim ink and - // vanished ("the little arrow on left side is hard - // to see", user 2026-08-27) -- it reads at the same - // ink as the name it folds. - .child( - div() - .flex_none() - .w(px(10.)) - .text_color(rgb(INK1())) - .child(if folded { "▸" } else { "▾" }), - ) - .when_some(tint, |d, tint| { - d.child( - div() - .flex_none() - .w(px(8.)) - .h(px(8.)) - .rounded(px(4.)) - .bg(rgb(tint)), - ) - }) - .child( - div() - .flex_1() - .min_w(px(0.)) - .truncate() - .type_style(mono(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM)) - .text_color(rgb(INK1())) - .child(group.name), + .id(("dock-subtitle-group", group_ord)) + .flex_none() + .flex() + .items_center() + .gap(px(6.)) + .px(px(8.)) + // Stepped in under its parent when it has one, the + // same outline the track rows below it read as. + .when(nested, |d| d.pl(px(22.))) + .py(px(4.)) + .rounded(px(3.)) + .cursor_pointer() + .hover(|s| s.bg(rgb(DARK_RAISED()))) + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + if !this.sub_folded.remove(&fold_path) { + this.sub_folded.insert(fold_path.clone()); + } + cx.notify(); + })) + .tooltip(crate::ui::widgets::tip_hover( + "Fold this source", + "click", + None, + )) + .children(hitmap::dynamic( + move || { + ( + format!("subtitle-group.{group_ord}.fold"), + "Toggle subtitle group".into(), ) - .child( - div() - .flex_none() - .type_style(mono( - type_scale::CHORD_METADATA_MIN_PX, - FontWeight::MEDIUM, - )) - .text_color(rgb(INK3())) - .child(format!( - "{track_count} track{}", - if track_count == 1 { "" } else { "s" } - )), - ); + }, + true, + )) + // Bare, the glyph inherited the panel's dim ink and + // vanished ("the little arrow on left side is hard + // to see", user 2026-08-27) -- it reads at the same + // ink as the name it folds. + .child( + div() + .flex_none() + .w(px(10.)) + .text_color(rgb(INK1())) + .child(if folded { "▸" } else { "▾" }), + ) + .when_some(tint, |d, tint| { + d.child( + div() + .flex_none() + .w(px(8.)) + .h(px(8.)) + .rounded(px(4.)) + .bg(rgb(tint)), + ) + }) + .child( + div() + .flex_1() + .min_w(px(0.)) + .truncate() + .type_style(mono(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM)) + .text_color(rgb(INK1())) + .child(group.name), + ) + .child( + div() + .flex_none() + .type_style(mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM)) + .text_color(rgb(INK3())) + .child(format!( + "{track_count} track{}", + if track_count == 1 { "" } else { "s" } + )), + ); ( group_path, track_count, @@ -1033,7 +1060,11 @@ fn sources_tab( this.dock_filter_edit = true; cx.notify(); })) - .tooltip(crate::ui::widgets::tip_hover("Filter sources", "type to narrow", None)) + .tooltip(crate::ui::widgets::tip_hover( + "Filter sources", + "type to narrow", + None, + )) .children(hitmap::control("dock.filter", "Filter sources", true)) // The glass alone at rest: the word "filter" beside it was // the box telling the editor what a filter box is (DESIGN §8). @@ -1160,7 +1191,11 @@ fn transition_row(player: &Player, cx: &mut Context) -> Option) -> impl .flex() .items_center() .child(chip("dock-viz-colour", "Colour", VizSlot::Main, true)) - .child(chip("dock-viz-strand", "Strand", VizSlot::Strand, strand_live)) + .child(chip( + "dock-viz-strand", + "Strand", + VizSlot::Strand, + strand_live, + )) } /// The picked slot's colour as text, and the way in: a click opens the type-in @@ -1395,7 +1435,11 @@ fn viz_hex_row(player: &Player, paint: u64, cx: &mut Context) -> impl In .text_size(row.size) .text_color(rgb(INK2())) .cursor_pointer() - .tooltip(crate::ui::widgets::tip_hover("Colour", "click to type", None)) + .tooltip(crate::ui::widgets::tip_hover( + "Colour", + "click to type", + None, + )) .children(hitmap::control( "dock-viz-hex-field", "Colour hex, type-in", @@ -1424,7 +1468,11 @@ fn viz_color_wheel(player: &Player, paint: u64, cx: &mut Context) -> imp .h(px(112.)) .relative() .cursor_pointer() - .tooltip(crate::ui::widgets::tip_hover("Colour wheel", "drag to pick", None)) + .tooltip(crate::ui::widgets::tip_hover( + "Colour wheel", + "drag to pick", + None, + )) .children(hitmap::control("dock-viz-hs", "Colour wheel", true)) .child(bounds_probe(player.viz_wheel.clone())) .child( @@ -1448,10 +1496,22 @@ fn viz_color_wheel(player: &Player, paint: u64, cx: &mut Context) -> imp let hue = i as f32 / wedges as f32 * 360.; let (r, g, b) = engine::decode::viz_hsv_rgb(hue, sat, 0.84); let color = (u32::from(r) << 16) | (u32::from(g) << 8) | u32::from(b); - let p00 = point(px(cx + radius * s0 * a0.sin()), px(cy - radius * s0 * a0.cos())); - let p01 = point(px(cx + radius * s0 * a1.sin()), px(cy - radius * s0 * a1.cos())); - let p11 = point(px(cx + radius * s1 * a1.sin()), px(cy - radius * s1 * a1.cos())); - let p10 = point(px(cx + radius * s1 * a0.sin()), px(cy - radius * s1 * a0.cos())); + let p00 = point( + px(cx + radius * s0 * a0.sin()), + px(cy - radius * s0 * a0.cos()), + ); + let p01 = point( + px(cx + radius * s0 * a1.sin()), + px(cy - radius * s0 * a1.cos()), + ); + let p11 = point( + px(cx + radius * s1 * a1.sin()), + px(cy - radius * s1 * a1.cos()), + ); + let p10 = point( + px(cx + radius * s1 * a0.sin()), + px(cy - radius * s1 * a0.cos()), + ); let mut path = PathBuilder::fill(); path.add_polygon(&[p00, p01, p11, p10], false); if let Ok(path) = path.build() { @@ -1523,9 +1583,20 @@ fn viz_paint_knobs(player: &Player, paint: u64, cx: &mut Context) -> imp .text_color(rgb(INK2())) .child("Strands"), ) - .child(viz_step("dock-viz-strands-minus", "Fewer strands", "−", cx, |this, cx| { - this.set_viz_strands(engine::decode::viz_strands_of(this.viz_paint()).saturating_sub(1).max(1), cx); - })) + .child(viz_step( + "dock-viz-strands-minus", + "Fewer strands", + "−", + cx, + |this, cx| { + this.set_viz_strands( + engine::decode::viz_strands_of(this.viz_paint()) + .saturating_sub(1) + .max(1), + cx, + ); + }, + )) .child( div() .font(style.font.clone()) @@ -1533,9 +1604,20 @@ fn viz_paint_knobs(player: &Player, paint: u64, cx: &mut Context) -> imp .text_color(rgb(INK1())) .child(format!("{strands}")), ) - .child(viz_step("dock-viz-strands-plus", "More strands", "+", cx, |this, cx| { - this.set_viz_strands(engine::decode::viz_strands_of(this.viz_paint()).saturating_add(1).min(32), cx); - })), + .child(viz_step( + "dock-viz-strands-plus", + "More strands", + "+", + cx, + |this, cx| { + this.set_viz_strands( + engine::decode::viz_strands_of(this.viz_paint()) + .saturating_add(1) + .min(32), + cx, + ); + }, + )), ) .child( div() @@ -1550,9 +1632,18 @@ fn viz_paint_knobs(player: &Player, paint: u64, cx: &mut Context) -> imp .text_color(rgb(INK2())) .child("Glow"), ) - .child(viz_step("dock-viz-glow-minus", "Less glow", "−", cx, |this, cx| { - this.set_viz_glow(engine::decode::viz_glow_of(this.viz_paint()).saturating_sub(1), cx); - })) + .child(viz_step( + "dock-viz-glow-minus", + "Less glow", + "−", + cx, + |this, cx| { + this.set_viz_glow( + engine::decode::viz_glow_of(this.viz_paint()).saturating_sub(1), + cx, + ); + }, + )) .child( div() .font(style.font.clone()) @@ -1560,9 +1651,20 @@ fn viz_paint_knobs(player: &Player, paint: u64, cx: &mut Context) -> imp .text_color(rgb(INK1())) .child(format!("{glow}")), ) - .child(viz_step("dock-viz-glow-plus", "More glow", "+", cx, |this, cx| { - this.set_viz_glow(engine::decode::viz_glow_of(this.viz_paint()).saturating_add(1).min(16), cx); - })), + .child(viz_step( + "dock-viz-glow-plus", + "More glow", + "+", + cx, + |this, cx| { + this.set_viz_glow( + engine::decode::viz_glow_of(this.viz_paint()) + .saturating_add(1) + .min(16), + cx, + ); + }, + )), ) } @@ -1806,36 +1908,44 @@ fn keys_tab(player: &Player, cx: &mut Context) -> impl IntoElement { .font(style.font.clone()) .text_size(style.size) .text_color(rgb(INK1())) - .tooltip(crate::ui::widgets::tip_hover("Filter keys", "click to type", None)) + .tooltip(crate::ui::widgets::tip_hover( + "Filter keys", + "click to type", + None, + )) .children(hitmap::control("dock.keys-filter", "Filter keys", true)) .child(match player.keys_filter.is_empty() { true => "⌕".to_string(), false => format!("⌕ {filter_text}"), }) }) - .children(keys_rows_matching(&player.keys_filter, &player.keymap).into_iter().map(|row| match row { - KeyRow::Head(category) => div() - .flex_none() - .pt(px(4.)) - .child(section_head(category.label().to_uppercase())) - .into_any_element(), - // The full-truth surface: every chord the action answers to - // (`display`), not the badge's primary-only compact form. - KeyRow::Act(action) => pair( - action.label().to_string(), - player.keymap.display(action), - match player.enable(action, None) { - Enable::Yes => INK2(), - _ => INK4(), - }, - ), - // A fixed stroke is the window's, not an action the room can - // refuse, so it never greys. - KeyRow::Fixed(i) => { - let f = &keymap::FIXED[i]; - pair(f.label.to_string(), f.chord.to_string(), INK2()) - } - })) + .children( + keys_rows_matching(&player.keys_filter, &player.keymap) + .into_iter() + .map(|row| match row { + KeyRow::Head(category) => div() + .flex_none() + .pt(px(4.)) + .child(section_head(category.label().to_uppercase())) + .into_any_element(), + // The full-truth surface: every chord the action answers to + // (`display`), not the badge's primary-only compact form. + KeyRow::Act(action) => pair( + action.label().to_string(), + player.keymap.display(action), + match player.enable(action, None) { + Enable::Yes => INK2(), + _ => INK4(), + }, + ), + // A fixed stroke is the window's, not an action the room can + // refuse, so it never greys. + KeyRow::Fixed(i) => { + let f = &keymap::FIXED[i]; + pair(f.label.to_string(), f.chord.to_string(), INK2()) + } + }), + ) } /// The dock's content, under `stance.rs::dock()`'s tab-bar-and-body frame: