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() {
914 // put on screen.914 // put on screen.
915 assert_eq!(auto_bps(1920, 1080, 30.), 6_220_800);915 assert_eq!(auto_bps(1920, 1080, 30.), 6_220_800);
916 assert_eq!(auto_bps(160, 120, 15.), BPS_MIN, "a tiny picture floors");916 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+ );
918 for bps in [auto_bps(1920, 1080, 30.), auto_bps(320, 240, 24.)] {921 for bps in [auto_bps(1920, 1080, 30.), auto_bps(320, 240, 24.)] {
919 assert!((BPS_MIN..=BPS_MAX).contains(&bps));922 assert!((BPS_MIN..=BPS_MAX).contains(&bps));
920 }923 }
@@ -1067,11 +1070,25 @@ fn a_chord_the_export_moment_answers_never_reaches_the_room() {
1067 let (typing, closed) = rest1070 let (typing, closed) = rest
1068 .split_once("return true;")1071 .split_once("return true;")
1069 .expect("the typing branch returns before the chords below it");1072 .expect("the typing branch returns before the chords below it");
1070- assert!(typing.contains("self.budget_edit = None"), "esc leaves the field");1073+ assert!(
1071- assert!(closed.contains("self.close_card()"), "then esc closes the moment");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+ );
1072 // Its chords, all of them consumed here rather than by the keymap.1081 // Its chords, all of them consumed here rather than by the keymap.
1073 for chord in [1082 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\"",
1075 "\",\"",1092 "\",\"",
1076 ] {1093 ] {
1077 assert!(closed.contains(chord), "{chord} is not the moment's own");1094 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() {
1086 fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {1103 fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
1087 let cards = src_text("ui/cards.rs");1104 let cards = src_text("ui/cards.rs");
1088 let start = cards.find("fn export_card(").expect("the moment");1105 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)];
1090 // A segment is the setter it names, not a readout of it.1111 // A segment is the setter it names, not a readout of it.
1091 for (id, chord, setter) in [1112 for (id, chord, setter) in [
1092 ("moment-picture", "\"c\"", "cycle_export_picture"),1113 ("moment-picture", "\"c\"", "cycle_export_picture"),
@@ -1098,7 +1119,10 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
1098 assert!(body.contains(setter), "the {id} segment changes nothing");1119 assert!(body.contains(setter), "the {id} segment changes nothing");
1099 }1120 }
1100 // The door, wearing the room's own chord rather than a hand-typed one.1121 // 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+ );
1102 assert!(1126 assert!(
1103 body.contains("self.keymap.chord(ActionId::Settings)"),1127 body.contains("self.keymap.chord(ActionId::Settings)"),
1104 "the door's chord is not read from the keymap"1128 "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() {
1113 .map(|at| &cards[at..at + 1900])1137 .map(|at| &cards[at..at + 1900])
1114 .expect("the segment atom");1138 .expect("the segment atom");
1115 assert!(seg.contains("INK3()") && seg.contains("INK4()"));1139 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+ );
1117 // The readouts worth seeing: the project's picture size and rate, and1144 // The readouts worth seeing: the project's picture size and rate, and
1118 // a sound rate that is on the line whether or not it is pressable.1145 // a sound rate that is on the line whether or not it is pressable.
1119 assert!(1146 assert!(
@@ -1126,13 +1153,18 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
1126 );1153 );
1127 // The picture segment is a child, not a `has_video` maybe: hidden on the1154 // The picture segment is a child, not a `has_video` maybe: hidden on the
1128 // sound-only formats it left `c` pressing nothing and no way back.1155 // 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");
1130 assert!(1159 assert!(
1131 !body[at - 240..at].contains("has_video"),1160 !body[at - 240..at].contains("has_video"),
1132 "the picture segment is gated on has_video again -- the dead end"1161 "the picture segment is gated on has_video again -- the dead end"
1133 );1162 );
1134 // Wrapped, never cut: the readouts made row 3 longer than 1280 wide.1163 // 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+ );
1136 }1168 }
1137 1169
1138 /// The dead end the user hit: the cycle walked into the sound-only formats1170 /// 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() {
1140 /// and can't turn it back to video"). One cycle, and it wraps.1172 /// and can't turn it back to video"). One cycle, and it wraps.
1141 #[test]1173 #[test]
1142 fn the_picture_cycle_wraps_out_of_the_sound_only_formats() {1174 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};
1144 // Nothing refused: every stop is the next one, and the last wraps to the1176 // Nothing refused: every stop is the next one, and the last wraps to the
1145 // first -- OGG, the tail of the list, back to MP4.1177 // first -- OGG, the tail of the list, back to MP4.
1146 let mut at = PICTURE_CYCLE[0];1178 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+ {
1148 at = next_picture(at, |_| false);1184 at = next_picture(at, |_| false);
1149 assert_eq!(at, want, "the cycle stopped walking");1185 assert_eq!(at, want, "the cycle stopped walking");
1150 }1186 }
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+ );
1152 assert_eq!(next_picture(Format::Ogg, |_| false), Format::Mp4);1191 assert_eq!(next_picture(Format::Ogg, |_| false), Format::Mp4);
1153 // A timeline with no picture refuses every video format, and the cycle1192 // A timeline with no picture refuses every video format, and the cycle
1154 // still moves: the sound-only stops are what is left of it.1193 // 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() {
1278 assert!(settings.contains(chord), "the EXPORT rows lost {chord}");1317 assert!(settings.contains(chord), "the EXPORT rows lost {chord}");
1279 assert!(moment.contains(chord), "row 3 lost {chord}");1318 assert!(moment.contains(chord), "row 3 lost {chord}");
1280 assert!(handler.contains(chord), "the moment answers no {chord}");1319 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+ );
1282 }1324 }
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+ );
1283 // `e` stays the Export press: the encoder seat took `g` rather than a1340 // `e` stays the Export press: the encoder seat took `g` rather than a
1284 // shifted letter, which no ghost wears.1341 // shifted letter, which no ghost wears.
1285 assert!(handler.contains("\"e\" | \"enter\" => self.start_export"));1342 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+ );
1287 }1347 }
1288 1348
1289 /// The Sound row: what it offers, and that the pick travels to the engine1349 /// 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() {
1401 edit.typed('z');1461 edit.typed('z');
1402 assert_eq!(edit.commit(), None);1462 assert_eq!(edit.commit(), None);
1403 let why = edit.refusal.clone().expect("a refusal, not a silence");1463 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+ );
1405 assert_eq!(edit.text, "zz", "the refusal keeps the text it refused");1468 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+ );
1407 // ...and the next stroke clears it: that reason described the text that is1473 // ...and the next stroke clears it: that reason described the text that is
1408 // no longer there.1474 // no longer there.
1409 edit.typed('0');1475 edit.typed('0');
@@ -1780,11 +1846,9 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() {
1780 assert!(native_detail.ends_with(" source"), "{native_detail}");1846 assert!(native_detail.ends_with(" source"), "{native_detail}");
1781 // A project at a size nobody listed still gets the whole list, with1847 // A project at a size nobody listed still gets the whole list, with
1782 // nothing marked rather than a wrong row marked.1848 // nothing marked rather than a wrong row marked.
1783- assert!(1849+ assert!(resolution_choices((1000, 1000), native)
1784- resolution_choices((1000, 1000), native)1850+ .iter()
1785- .iter()1851+ .all(|(.., picked)| !picked));
1786- .all(|(.., picked)| !picked)
1787- );
1788 // Picking a row means that row, and stepping means the next one: the1852 // Picking a row means that row, and stepping means the next one: the
1789 // list and the stroke read the same ladder.1853 // list and the stroke read the same ladder.
1790 assert_eq!(next_resolution(ladder[1], native), ladder[2]);1854 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() {
1883 assert!(tall <= 360., "the list is taller than the floor");1947 assert!(tall <= 360., "the list is taller than the floor");
1884 assert_eq!(1948 assert_eq!(
1885 menu_at(point(px(600.), px(340.)), size(px(640.), px(360.)), tall),1949 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+ ),
1887 "the list would hang off the smallest window"1954 "the list would hang off the smallest window"
1888 );1955 );
1889 }1956 }
@@ -2238,8 +2305,8 @@ fn maximizing_a_card_grows_its_box_without_moving_where_a_value_sits_in_it() {
2238 /// inside the dock, or hands it the dock's width again, fails this.2305 /// inside the dock, or hands it the dock's width again, fails this.
2239 #[test]2306 #[test]
2240 fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() {2307 fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() {
2308+ use crate::layout::{split_size, Split};
2241 use crate::SPLIT_W;2309 use crate::SPLIT_W;
2242- use crate::layout::{Split, split_size};
2243 2310
2244 // `layout::SPLIT_W` is the one divider between `stance-centre` and the2311 // `layout::SPLIT_W` is the one divider between `stance-centre` and the
2245 // dock; the 56px rail that used to eat the centre's left edge is gone2312 // 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() {
2286 /// assumption.2353 /// assumption.
2287 #[test]2354 #[test]
2288 fn a_maximized_card_can_never_rise_above_the_picture_no_matter_the_bench_height() {2355 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};
2290 let viewport_h = 1080.;2357 let viewport_h = 1080.;
2291 for bench_h in [140., 200., 400.] {2358 for bench_h in [140., 200., 400.] {
2292 assert_eq!(2359 assert_eq!(
@@ -2531,3 +2598,58 @@ fn picker_row_tails_are_state_words_and_settings_values_carry_no_ellipsis() {
2531 );2598 );
2532 }2599 }
2533 }2600 }
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
684 .as_ref()684 .as_ref()
685 .and_then(|session| format_refusal(session, format))685 .and_then(|session| format_refusal(session, format))
686 .map(|why| (short_reason(&why).into(), INK4()));686 .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+ };
688 let (codec, rated) = sound_codec(format);692 let (codec, rated) = sound_codec(format);
689 let seat = player.encoder_seat();693 let seat = player.encoder_seat();
690 let av1_gpu = seat == EncoderSeat::Hardware && matches!(format, Format::Av1 | Format::Av1Mp4);694 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
745 )749 )
746 .into_any_element()750 .into_any_element()
747 }))751 }))
748- .child(row_chord(752+ // The encoder writes the *picture*, and the engine opens no seat for a
749- "settings-export-encoder",753+ // song: with WAV/FLAC/MP3/Ogg picked the row would be a button that
750- "Encoder",754+ // does nothing when pressed. The export moment mounts no row there
751- encoder_word(seat),755+ // either (`Format::has_video`), so this is that same rule rather than a
752- "which encoder writes the picture: the GPU where this machine has a seat, or the CPU",756+ // third treatment.
753- "g",757+ .children(format.has_video().then(|| {
754- av1_gpu.then(|| (AV1_GPU_NOTICE.into(), NOTICE_LOOK())),758+ row_chord(
755- player,759+ "settings-export-encoder",
756- cx.listener(|this, _: &ClickEvent, _, cx| {760+ "Encoder",
757- this.cycle_encoder(cx);761+ encoder_word(seat),
758- }),762+ "which encoder writes the picture: the GPU where this machine has a seat, or the CPU",
759- ))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+ }))
760 // Read-only: the range is set on the timeline with the marks771 // Read-only: the range is set on the timeline with the marks
761 // themselves ([`keymap::ActionId::SetIn`]/`SetOut`), which is where a772 // themselves ([`keymap::ActionId::SetIn`]/`SetOut`), which is where a
762 // person can see what they are marking.773 // person can see what they are marking.