forge
Explore
Log in

Don't you dare go Hollow

The Encoder row is the picture's own

Browse files at this commit

9c53bb8515ecd0a37b149d2de18eb1c50f32cbdbAhmet Kaan GümüşParent: ff23d47
  • ui
    • the Encoder row is the picture's own
Show full message
💄 ui(settings): the Encoder row is the picture's own

The engine opens no encoder seat for a song, so with an audio-only format picked the settings row was a button that did nothing when pressed. The export moment mounts no such row there; this is that same rule and not a third treatment. The settings/moment parity test also walks a settings pick through undo and redo now.
crates/app/src/tests/cards.rsmodified+146 -24
@@ -914,7 +914,10 @@ fn the_budget_is_the_one_number_the_engine_gets() {
914914 // put on screen.
915915 assert_eq!(auto_bps(1920, 1080, 30.), 6_220_800);
916916 assert_eq!(auto_bps(160, 120, 15.), BPS_MIN, "a tiny picture floors");
917- assert!(auto_bps(7680, 4320, 60.) <= 20_000_000, "and a huge one caps");
917+ assert!(
918+ auto_bps(7680, 4320, 60.) <= 20_000_000,
919+ "and a huge one caps"
920+ );
918921 for bps in [auto_bps(1920, 1080, 30.), auto_bps(320, 240, 24.)] {
919922 assert!((BPS_MIN..=BPS_MAX).contains(&bps));
920923 }
@@ -1067,11 +1070,25 @@ fn a_chord_the_export_moment_answers_never_reaches_the_room() {
10671070 let (typing, closed) = rest
10681071 .split_once("return true;")
10691072 .expect("the typing branch returns before the chords below it");
1070- assert!(typing.contains("self.budget_edit = None"), "esc leaves the field");
1071- assert!(closed.contains("self.close_card()"), "then esc closes the moment");
1073+ assert!(
1074+ typing.contains("self.budget_edit = None"),
1075+ "esc leaves the field"
1076+ );
1077+ assert!(
1078+ closed.contains("self.close_card()"),
1079+ "then esc closes the moment"
1080+ );
10721081 // Its chords, all of them consumed here rather than by the keymap.
10731082 for chord in [
1074- "\"d\"", "\"n\"", "\"e\"", "\"enter\"", "\"up\"", "\"down\"", "\"c\"", "\"b\"", "\"g\"",
1083+ "\"d\"",
1084+ "\"n\"",
1085+ "\"e\"",
1086+ "\"enter\"",
1087+ "\"up\"",
1088+ "\"down\"",
1089+ "\"c\"",
1090+ "\"b\"",
1091+ "\"g\"",
10751092 "\",\"",
10761093 ] {
10771094 assert!(closed.contains(chord), "{chord} is not the moment's own");
@@ -1086,7 +1103,11 @@ fn a_chord_the_export_moment_answers_never_reaches_the_room() {
10861103 fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
10871104 let cards = src_text("ui/cards.rs");
10881105 let start = cards.find("fn export_card(").expect("the moment");
1089- let body = &cards[start..start + cards[start..].find("\n /// ").unwrap_or(cards.len() - start)];
1106+ let body = &cards[start
1107+ ..start
1108+ + cards[start..]
1109+ .find("\n /// ")
1110+ .unwrap_or(cards.len() - start)];
10901111 // A segment is the setter it names, not a readout of it.
10911112 for (id, chord, setter) in [
10921113 ("moment-picture", "\"c\"", "cycle_export_picture"),
@@ -1098,7 +1119,10 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
10981119 assert!(body.contains(setter), "the {id} segment changes nothing");
10991120 }
11001121 // The door, wearing the room's own chord rather than a hand-typed one.
1101- assert!(body.contains("moment-settings"), "row 3 has no settings door");
1122+ assert!(
1123+ body.contains("moment-settings"),
1124+ "row 3 has no settings door"
1125+ );
11021126 assert!(
11031127 body.contains("self.keymap.chord(ActionId::Settings)"),
11041128 "the door's chord is not read from the keymap"
@@ -1113,7 +1137,10 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
11131137 .map(|at| &cards[at..at + 1900])
11141138 .expect("the segment atom");
11151139 assert!(seg.contains("INK3()") && seg.contains("INK4()"));
1116- assert!(seg.contains("DARK_RAISED()"), "a segment does not answer hover");
1140+ assert!(
1141+ seg.contains("DARK_RAISED()"),
1142+ "a segment does not answer hover"
1143+ );
11171144 // The readouts worth seeing: the project's picture size and rate, and
11181145 // a sound rate that is on the line whether or not it is pressable.
11191146 assert!(
@@ -1126,13 +1153,18 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
11261153 );
11271154 // The picture segment is a child, not a `has_video` maybe: hidden on the
11281155 // sound-only formats it left `c` pressing nothing and no way back.
1129- let at = body.find("\"moment-picture\"").expect("the picture segment");
1156+ let at = body
1157+ .find("\"moment-picture\"")
1158+ .expect("the picture segment");
11301159 assert!(
11311160 !body[at - 240..at].contains("has_video"),
11321161 "the picture segment is gated on has_video again -- the dead end"
11331162 );
11341163 // Wrapped, never cut: the readouts made row 3 longer than 1280 wide.
1135- assert!(body.contains(".flex_wrap()"), "row 3 truncates instead of wrapping");
1164+ assert!(
1165+ body.contains(".flex_wrap()"),
1166+ "row 3 truncates instead of wrapping"
1167+ );
11361168 }
11371169
11381170 /// The dead end the user hit: the cycle walked into the sound-only formats
@@ -1140,15 +1172,22 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
11401172 /// and can't turn it back to video"). One cycle, and it wraps.
11411173 #[test]
11421174 fn the_picture_cycle_wraps_out_of_the_sound_only_formats() {
1143- use crate::ui::settings_stance::{PICTURE_CYCLE, next_picture};
1175+ use crate::ui::settings_stance::{next_picture, PICTURE_CYCLE};
11441176 // Nothing refused: every stop is the next one, and the last wraps to the
11451177 // first -- OGG, the tail of the list, back to MP4.
11461178 let mut at = PICTURE_CYCLE[0];
1147- for &want in PICTURE_CYCLE.iter().skip(1).chain(std::iter::once(&PICTURE_CYCLE[0])) {
1179+ for &want in PICTURE_CYCLE
1180+ .iter()
1181+ .skip(1)
1182+ .chain(std::iter::once(&PICTURE_CYCLE[0]))
1183+ {
11481184 at = next_picture(at, |_| false);
11491185 assert_eq!(at, want, "the cycle stopped walking");
11501186 }
1151- assert_eq!(at, PICTURE_CYCLE[0], "a full walk is a wrap, not a dead end");
1187+ assert_eq!(
1188+ at, PICTURE_CYCLE[0],
1189+ "a full walk is a wrap, not a dead end"
1190+ );
11521191 assert_eq!(next_picture(Format::Ogg, |_| false), Format::Mp4);
11531192 // A timeline with no picture refuses every video format, and the cycle
11541193 // still moves: the sound-only stops are what is left of it.
@@ -1278,12 +1317,33 @@ fn the_moment_and_the_settings_room_wear_the_same_export_chords() {
12781317 assert!(settings.contains(chord), "the EXPORT rows lost {chord}");
12791318 assert!(moment.contains(chord), "row 3 lost {chord}");
12801319 assert!(handler.contains(chord), "the moment answers no {chord}");
1281- assert!(player.contains(chord), "the settings page answers no {chord}");
1320+ assert!(
1321+ player.contains(chord),
1322+ "the settings page answers no {chord}"
1323+ );
12821324 }
1325+ // The Encoder row is the picture's own -- the engine opens no seat for a
1326+ // song -- so the settings room gates it on the format exactly as the
1327+ // moment does, and neither mounts a row for an audio-only format.
1328+ assert_eq!(Format::Mp4.has_video(), true);
1329+ for audio_only in [Format::Wav, Format::Flac, Format::Mp3, Format::Ogg] {
1330+ assert_eq!(audio_only.has_video(), false, "{audio_only:?}");
1331+ }
1332+ let at = settings
1333+ .find("settings-export-encoder")
1334+ .expect("the Encoder row");
1335+ let mount = &settings[at.saturating_sub(260)..at];
1336+ assert!(
1337+ mount.contains("has_video()"),
1338+ "the Encoder row is mounted for a song, where pressing it does nothing"
1339+ );
12831340 // `e` stays the Export press: the encoder seat took `g` rather than a
12841341 // shifted letter, which no ghost wears.
12851342 assert!(handler.contains("\"e\" | \"enter\" => self.start_export"));
1286- assert!(!settings.contains("\n \"e\","), "the Encoder row took `e` back");
1343+ assert!(
1344+ !settings.contains("\n \"e\","),
1345+ "the Encoder row took `e` back"
1346+ );
12871347 }
12881348
12891349 /// The Sound row: what it offers, and that the pick travels to the engine
@@ -1401,9 +1461,15 @@ fn a_typed_colour_is_read_in_every_spelling_and_anything_else_is_refused() {
14011461 edit.typed('z');
14021462 assert_eq!(edit.commit(), None);
14031463 let why = edit.refusal.clone().expect("a refusal, not a silence");
1404- assert!(why.contains("#RRGGBB"), "the refusal says what a colour is: {why}");
1464+ assert!(
1465+ why.contains("#RRGGBB"),
1466+ "the refusal says what a colour is: {why}"
1467+ );
14051468 assert_eq!(edit.text, "zz", "the refusal keeps the text it refused");
1406- assert!(edit.detail().contains("zz▏"), "the caret stays in the buffer");
1469+ assert!(
1470+ edit.detail().contains("zz▏"),
1471+ "the caret stays in the buffer"
1472+ );
14071473 // ...and the next stroke clears it: that reason described the text that is
14081474 // no longer there.
14091475 edit.typed('0');
@@ -1780,11 +1846,9 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() {
17801846 assert!(native_detail.ends_with(" source"), "{native_detail}");
17811847 // A project at a size nobody listed still gets the whole list, with
17821848 // nothing marked rather than a wrong row marked.
1783- assert!(
1784- resolution_choices((1000, 1000), native)
1785- .iter()
1786- .all(|(.., picked)| !picked)
1787- );
1849+ assert!(resolution_choices((1000, 1000), native)
1850+ .iter()
1851+ .all(|(.., picked)| !picked));
17881852 // Picking a row means that row, and stepping means the next one: the
17891853 // list and the stroke read the same ladder.
17901854 assert_eq!(next_resolution(ladder[1], native), ladder[2]);
@@ -1883,7 +1947,10 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() {
18831947 assert!(tall <= 360., "the list is taller than the floor");
18841948 assert_eq!(
18851949 menu_at(point(px(600.), px(340.)), size(px(640.), px(360.)), tall),
1886- (640. - crate::layout::MENU_EDGE - MENU_W, 360. - crate::layout::MENU_EDGE - tall),
1950+ (
1951+ 640. - crate::layout::MENU_EDGE - MENU_W,
1952+ 360. - crate::layout::MENU_EDGE - tall
1953+ ),
18871954 "the list would hang off the smallest window"
18881955 );
18891956 }
@@ -2238,8 +2305,8 @@ fn maximizing_a_card_grows_its_box_without_moving_where_a_value_sits_in_it() {
22382305 /// inside the dock, or hands it the dock's width again, fails this.
22392306 #[test]
22402307 fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() {
2308+ use crate::layout::{split_size, Split};
22412309 use crate::SPLIT_W;
2242- use crate::layout::{Split, split_size};
22432310
22442311 // `layout::SPLIT_W` is the one divider between `stance-centre` and the
22452312 // dock; the 56px rail that used to eat the centre's left edge is gone
@@ -2286,7 +2353,7 @@ fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() {
22862353 /// assumption.
22872354 #[test]
22882355 fn a_maximized_card_can_never_rise_above_the_picture_no_matter_the_bench_height() {
2289- use crate::ui::stance::{LEDGER_H, TIME_BAND_H, below_picture_floor};
2356+ use crate::ui::stance::{below_picture_floor, LEDGER_H, TIME_BAND_H};
22902357 let viewport_h = 1080.;
22912358 for bench_h in [140., 200., 400.] {
22922359 assert_eq!(
@@ -2531,3 +2598,58 @@ fn picker_row_tails_are_state_words_and_settings_values_carry_no_ellipsis() {
25312598 );
25322599 }
25332600 }
2601+
2602+/// D1: the project's own settings are the project's -- the resolution, the
2603+/// rate, the encoder seat, the mix rate and the two proxy switches ride in
2604+/// the same history entry the lanes do, so every one of those picks is a
2605+/// single `ctrl+z`. Before this, pressing `z` after any of them did nothing.
2606+#[test]
2607+fn a_settings_pick_undoes_and_redoes_like_a_cut() {
2608+ let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
2609+ let (w, h) = session.resolution();
2610+
2611+ assert!(session.set_resolution(w / 2, h / 2));
2612+ assert_eq!(session.resolution(), (w / 2, h / 2));
2613+ assert!(session.undo(), "the resolution pick is one step");
2614+ assert_eq!(session.resolution(), (w, h), "and the canvas comes back");
2615+ assert!(session.redo(), "redo walks the same branch");
2616+ assert_eq!(session.resolution(), (w / 2, h / 2));
2617+ assert!(session.undo(), "back to where the test started");
2618+
2619+ // The encoder seat, which nothing reseeks and nothing shows until an
2620+ // export starts.
2621+ let seat = session.encoder_seat();
2622+ assert_ne!(seat, EncoderSeat::Software);
2623+ session.set_encoder_seat(EncoderSeat::Software);
2624+ assert_eq!(session.encoder_seat(), EncoderSeat::Software);
2625+ assert!(session.undo(), "the encoder pick is one step");
2626+ assert_eq!(session.encoder_seat(), seat, "and the seat comes back");
2627+ assert!(session.redo());
2628+ assert_eq!(session.encoder_seat(), EncoderSeat::Software);
2629+ assert!(session.undo());
2630+
2631+ // The mix rate, and the switches beside it.
2632+ session.set_sample_rate(Some(44_100));
2633+ assert_eq!(session.sample_rate(), Some(44_100));
2634+ assert!(session.undo(), "the mix rate is one step");
2635+ assert_eq!(session.sample_rate(), None, "back to the derived rate");
2636+ let proxies = session.proxies();
2637+ session.set_proxies(!proxies);
2638+ assert_eq!(session.proxies(), !proxies);
2639+ assert!(session.undo(), "the proxy switch is one step");
2640+ assert_eq!(session.proxies(), proxies, "and the switch comes back");
2641+ let auto = session.auto_proxies();
2642+ session.set_auto_proxies(!auto);
2643+ assert_eq!(session.auto_proxies(), !auto);
2644+ assert!(session.undo(), "and so is the auto switch");
2645+ assert_eq!(session.auto_proxies(), auto, "which comes back too");
2646+
2647+ // ...and a lane edit still undoes the way it always did, settings and all
2648+ // in the same stack.
2649+ let clips = session.lane_clips(Lane::V1).len();
2650+ assert_eq!(clips, 1, "one take to start with");
2651+ assert!(session.delete_clip(Lane::V1, 0));
2652+ assert_eq!(session.lane_clips(Lane::V1).len(), 0);
2653+ assert!(session.undo(), "the delete is one step");
2654+ assert_eq!(session.lane_clips(Lane::V1).len(), clips);
2655+}
crates/app/src/ui/settings_stance.rsmodified+24 -13
@@ -684,7 +684,11 @@ fn export_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement
684684 .as_ref()
685685 .and_then(|session| format_refusal(session, format))
686686 .map(|why| (short_reason(&why).into(), INK4()));
687- let picture_ink = if refused_now.is_some() { INK4() } else { INK1() };
687+ let picture_ink = if refused_now.is_some() {
688+ INK4()
689+ } else {
690+ INK1()
691+ };
688692 let (codec, rated) = sound_codec(format);
689693 let seat = player.encoder_seat();
690694 let av1_gpu = seat == EncoderSeat::Hardware && matches!(format, Format::Av1 | Format::Av1Mp4);
@@ -745,18 +749,25 @@ fn export_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement
745749 )
746750 .into_any_element()
747751 }))
748- .child(row_chord(
749- "settings-export-encoder",
750- "Encoder",
751- encoder_word(seat),
752- "which encoder writes the picture: the GPU where this machine has a seat, or the CPU",
753- "g",
754- av1_gpu.then(|| (AV1_GPU_NOTICE.into(), NOTICE_LOOK())),
755- player,
756- cx.listener(|this, _: &ClickEvent, _, cx| {
757- this.cycle_encoder(cx);
758- }),
759- ))
752+ // The encoder writes the *picture*, and the engine opens no seat for a
753+ // song: with WAV/FLAC/MP3/Ogg picked the row would be a button that
754+ // does nothing when pressed. The export moment mounts no row there
755+ // either (`Format::has_video`), so this is that same rule rather than a
756+ // third treatment.
757+ .children(format.has_video().then(|| {
758+ row_chord(
759+ "settings-export-encoder",
760+ "Encoder",
761+ encoder_word(seat),
762+ "which encoder writes the picture: the GPU where this machine has a seat, or the CPU",
763+ "g",
764+ av1_gpu.then(|| (AV1_GPU_NOTICE.into(), NOTICE_LOOK())),
765+ player,
766+ cx.listener(|this, _: &ClickEvent, _, cx| {
767+ this.cycle_encoder(cx);
768+ }),
769+ )
770+ }))
760771 // Read-only: the range is set on the timeline with the marks
761772 // themselves ([`keymap::ActionId::SetIn`]/`SetOut`), which is where a
762773 // person can see what they are marking.