forge
Explore
Log in

Don't you dare go Hollow

A setting with more than two values is a list, not a click-to-cycle button

Browse files at this commit

d8cd150ee53ed906b5ffb0fae8db8476844f9f10Ahmet Kaan GümüşParent: 75d536b
  • feat
    • a setting with more than two values is a list, not a click-to-cycle button
Show full message
✨ feat(ui): a setting with more than two values is a list, not a click-to-cycle button

The project resolution was a button that stepped one size on per press: to get
back to where you were you clicked round the whole ladder, and the only way to
see what was on offer was to visit every rung. Now the click opens the list --
every size at once, the media's own said so, the one in force marked with a
glyph as well as a highlight -- and picking a row means that row.

One widget, built on the clip menu's own machinery (the scrim that swallows the
click away, `menu_at`'s placement, the `MENU_ROWS_H` scroll cap), so it hangs,
closes and fits the 640x360 floor exactly as the menus already do. Its second
client is the clip menu's Fit item, which had the same shape: four policies
stepped one per click.

Every stroke is untouched -- ctrl+r still steps to the next size and the Fit
chord still steps to the next policy -- and both now go through one door with
the list (`apply_resolution`, `apply_fit`), so a list and a stroke cannot come
to differ in what they do or in what they say they did.

The export card's own enumerated rows were audited and left alone: its format
and quality rows already list every value with the picked one marked, and the
container row is a two-value toggle, which is a button.
crates/app/src/main.rsmodified+410 -19
@@ -339,6 +339,38 @@ struct LibraryMenu {
339 details: bool,339 details: bool,
340 }340 }
341 341
342+/// An open choice list: which setting it offers and where it hangs. What a
343+/// button that stepped one value on per click used to be -- a setting with more
344+/// than two values is a list to look at, not a thing to click round. Placed by
345+/// [`menu_at`] and closed by a stroke, exactly like the two menus above it.
346+#[derive(Clone, Copy, PartialEq)]
347+struct Picker {
348+ of: Pick,
349+ at: Point<Pixels>,
350+}
351+
352+/// Which setting an open list is offering. The fit policy names the clip it is
353+/// about, like the clip menu it opens from -- indices move under every edit, so
354+/// the list closes on the first stroke as that menu does.
355+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
356+enum Pick {
357+ Resolution,
358+ Fit(Lane, usize),
359+}
360+
361+/// One value a list offers, carrying everything picking it needs -- so a click
362+/// goes straight to the value rather than to a position in a list that was
363+/// built somewhere else.
364+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
365+enum Choice {
366+ Size(u32, u32),
367+ Fit(Lane, usize, FitPolicy),
368+}
369+
370+/// One row of an open list: the value, its name, the small print beside it, and
371+/// whether it is the one in force.
372+type ChoiceRow = (Choice, SharedString, SharedString, bool);
373+
342 /// What a library row's menu offers, in the order it lists them. Unlike the clip374 /// What a library row's menu offers, in the order it lists them. Unlike the clip
343 /// menu's items none of these is a stroke -- there is no keyboard way to a row --375 /// menu's items none of these is a stroke -- there is no keyboard way to a row --
344 /// so the label and the hint are written here rather than read off the keymap.376 /// so the label and the hint are written here rather than read off the keymap.
@@ -735,6 +767,10 @@ struct Player {
735 /// `selected` does, so it is closed by anything that can move indices --767 /// `selected` does, so it is closed by anything that can move indices --
736 /// every stroke, and every item of its own.768 /// every stroke, and every item of its own.
737 context_menu: Option<ContextMenu>,769 context_menu: Option<ContextMenu>,
770+ /// The choice list a click on an enumerated setting opened, if one is up:
771+ /// the project resolution or a clip's fit policy, every value on screen at
772+ /// once. Closed by anything that closes the menus, and for the same reason.
773+ picker: Option<Picker>,
738 /// The library menu a right-click on a row opened, if one is up. Names its774 /// The library menu a right-click on a row opened, if one is up. Names its
739 /// row by file and stream rather than by position, so it acts on the row it775 /// row by file and stream rather than by position, so it acts on the row it
740 /// was opened on however the list is rebuilt under it.776 /// was opened on however the list is rebuilt under it.
@@ -1259,9 +1295,18 @@ impl Player {
1259 return;1295 return;
1260 };1296 };
1261 let next = next_fit(session.fit_of(lane, idx));1297 let next = next_fit(session.fit_of(lane, idx));
1262- if session.set_fit(lane, idx, next) {1298+ self.apply_fit(lane, idx, next, cx);
1299+ }
1300+
1301+ /// One clip's fit policy set, whichever asked: the stroke that steps to the
1302+ /// next one and the list that names one outright come through here, so they
1303+ /// cannot differ in what they do or in what they say they did.
1304+ fn apply_fit(&mut self, lane: Lane, idx: usize, fit: FitPolicy, cx: &mut Context<Self>) {
1305+ if let Some(session) = &mut self.session
1306+ && session.set_fit(lane, idx, fit)
1307+ {
1263 let (w, h) = session.resolution();1308 let (w, h) = session.resolution();
1264- self.notice = Some(format!("FIT POLICY: {} on {w}x{h}", fit_label(next)).into());1309+ self.notice = Some(format!("FIT POLICY: {} on {w}x{h}", fit_label(fit)).into());
1265 self.reset_after_reseek();1310 self.reset_after_reseek();
1266 }1311 }
1267 cx.notify();1312 cx.notify();
@@ -1316,13 +1361,59 @@ impl Player {
1316 return;1361 return;
1317 };1362 };
1318 let (width, height) = next_resolution(session.resolution(), session.native_resolution());1363 let (width, height) = next_resolution(session.resolution(), session.native_resolution());
1319- if session.set_resolution(width, height) {1364+ self.apply_resolution(width, height, cx);
1365+ }
1366+
1367+ /// The project resized, whichever asked: the stroke that steps to the next
1368+ /// size and the list that names one outright come through here.
1369+ fn apply_resolution(&mut self, width: u32, height: u32, cx: &mut Context<Self>) {
1370+ if let Some(session) = &mut self.session
1371+ && session.set_resolution(width, height)
1372+ {
1320 self.notice = Some(format!("PROJECT: {width}x{height}").into());1373 self.notice = Some(format!("PROJECT: {width}x{height}").into());
1321 self.reset_after_reseek();1374 self.reset_after_reseek();
1322 }1375 }
1323 cx.notify();1376 cx.notify();
1324 }1377 }
1325 1378
1379+ /// Opens a choice list on a setting, where it was asked for. One floating
1380+ /// thing at a time: the click that opens it is the click that closes
1381+ /// whatever menu it was opened from.
1382+ fn open_picker(&mut self, of: Pick, at: Point<Pixels>, cx: &mut Context<Self>) {
1383+ self.context_menu = None;
1384+ self.library_menu = None;
1385+ self.picker = Some(Picker { of, at });
1386+ cx.notify();
1387+ }
1388+
1389+ /// A row of the open list was picked. Closes the list first -- the rule
1390+ /// every menu item here follows -- then does exactly what the stroke for
1391+ /// that setting does, through the same door.
1392+ fn choose(&mut self, choice: Choice, cx: &mut Context<Self>) {
1393+ self.picker = None;
1394+ match choice {
1395+ Choice::Size(w, h) => self.apply_resolution(w, h, cx),
1396+ Choice::Fit(lane, idx, fit) => self.apply_fit(lane, idx, fit, cx),
1397+ }
1398+ }
1399+
1400+ /// Every value the open list offers, in the order it lists them. Empty
1401+ /// without a timeline, which is the state where nothing here has a value to
1402+ /// offer -- and where the surfaces that open the list are dimmed anyway.
1403+ fn choices(&self, of: Pick) -> Vec<ChoiceRow> {
1404+ let Some(session) = &self.session else {
1405+ return Vec::new();
1406+ };
1407+ match of {
1408+ Pick::Resolution => {
1409+ resolution_choices(session.resolution(), session.native_resolution())
1410+ }
1411+ Pick::Fit(lane, idx) => {
1412+ fit_choices(lane, idx, session.fit_of(lane, idx), session.resolution())
1413+ }
1414+ }
1415+ }
1416+
1326 /// Opens the colour card on the clip a grade would go on: the clip that was1417 /// Opens the colour card on the clip a grade would go on: the clip that was
1327 /// clicked when it is a video one, and otherwise the clip the picture is1418 /// clicked when it is a video one, and otherwise the clip the picture is
1328 /// coming from -- the one the engine's own compositing rule picks, which is1419 /// coming from -- the one the engine's own compositing rule picks, which is
@@ -3837,9 +3928,12 @@ impl Render for Player {
3837 // Both menus, taken rather than short-circuited: the library's3928 // Both menus, taken rather than short-circuited: the library's
3838 // one names a row the edits below can remove, so it closes on a3929 // one names a row the edits below can remove, so it closes on a
3839 // stroke exactly as the clip menu does.3930 // stroke exactly as the clip menu does.
3931+ // A choice list goes the same way and for the same reason: it
3932+ // names a clip index too, and escape is the way out of it.
3840 let clip_menu = this.context_menu.take().is_some();3933 let clip_menu = this.context_menu.take().is_some();
3841 let row_menu = this.library_menu.take().is_some();3934 let row_menu = this.library_menu.take().is_some();
3842- if clip_menu || row_menu {3935+ let list = this.picker.take().is_some();
3936+ if clip_menu || row_menu || list {
3843 cx.notify();3937 cx.notify();
3844 if key == ESCAPE {3938 if key == ESCAPE {
3845 return;3939 return;
@@ -4057,6 +4151,9 @@ impl Render for Player {
4057 .children(self.speed_card(cx))4151 .children(self.speed_card(cx))
4058 .children(self.silence_card(cx))4152 .children(self.silence_card(cx))
4059 .children(self.mix_card(cx))4153 .children(self.mix_card(cx))
4154+ // Last, so it floats over whatever opened it -- the panel's button
4155+ // or a clip menu -- rather than under it.
4156+ .children(self.picker_card(window.viewport_size(), cx))
4060 }4157 }
4061 }4158 }
4062 4159
@@ -4570,23 +4667,26 @@ impl Player {
4570 ))4667 ))
4571 .child(separator())4668 .child(separator())
4572 // The size every clip is composed onto, which is also the4669 // The size every clip is composed onto, which is also the
4573- // size the export comes out at: the one project setting a4670+ // size the export comes out at. Five sizes, so a click opens
4574- // stroke used to be the only way to. Cycles exactly as the4671+ // the list of them with this one marked and picks whichever
4575- // key does, and says where it is now rather than opening a4672+ // was meant: a button that stepped one on per press made the
4576- // list to close again.4673+ // user click round the ladder to get back to where they
4674+ // were. The stroke still steps, for the hand already on it.
4577 .child(control(4675 .child(control(
4578 "resolution",4676 "resolution",
4579 None,4677 None,
4580 resolution.map_or_else(|| "Size".to_string(), |(_, h)| format!("{h}p")),4678 resolution.map_or_else(|| "Size".to_string(), |(_, h)| format!("{h}p")),
4581 match resolution {4679 match resolution {
4582 Some((w, h)) => format!(4680 Some((w, h)) => format!(
4583- "{} — the project is {w}x{h}; cycles source → 2160p → 1080p → 720p → 480p",4681+ "click to pick a size — the project is {w}x{h}; {} steps to the next",
4584 key(ActionId::Resolution)4682 key(ActionId::Resolution)
4585 ),4683 ),
4586 None => format!("{} — open a file first", key(ActionId::Resolution)),4684 None => format!("{} — open a file first", key(ActionId::Resolution)),
4587 },4685 },
4588 live,4686 live,
4589- cx.listener(|this, _: &ClickEvent, _, cx| this.cycle_resolution(cx)),4687+ cx.listener(|this, event: &ClickEvent, _, cx| {
4688+ this.open_picker(Pick::Resolution, event.position(), cx)
4689+ }),
4590 ))4690 ))
4591 // How much of the timeline the panel below is showing --4691 // How much of the timeline the panel below is showing --
4592 // beside the resolution, since neither of them edits4692 // beside the resolution, since neither of them edits
@@ -6682,11 +6782,24 @@ impl Player {
6682 .when(enabled, |d| {6782 .when(enabled, |d| {
6683 d.cursor_pointer()6783 d.cursor_pointer()
6684 .hover(|s| s.bg(rgb(HOVER)))6784 .hover(|s| s.bg(rgb(HOVER)))
6685- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {6785+ .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
6686 // Closed first: the action moves the very6786 // Closed first: the action moves the very
6687 // indices this menu is holding.6787 // indices this menu is holding.
6688 this.context_menu = None;6788 this.context_menu = None;
6689- this.act(action, cx);6789+ // The one item that is a *choice* and not a
6790+ // doing: four policies, so the pointer gets
6791+ // the list of them on this clip rather than
6792+ // the next one stepped to behind the click.
6793+ // The stroke still steps -- same door.
6794+ if action == ActionId::Fit {
6795+ this.open_picker(
6796+ Pick::Fit(menu.lane, menu.idx),
6797+ event.position(),
6798+ cx,
6799+ );
6800+ } else {
6801+ this.act(action, cx);
6802+ }
6690 }))6803 }))
6691 })6804 })
6692 .into_any_element(),6805 .into_any_element(),
@@ -6786,6 +6899,137 @@ impl Player {
6786 )6899 )
6787 }6900 }
6788 6901
6902+ /// The open choice list: every value of one enumerated setting at once, the
6903+ /// one in force marked, and a click on any of them picks *that* one -- what
6904+ /// a button stepping one value on per click could never say. Built on the
6905+ /// clip menu's machinery down to the scrim, the placement and the scroll
6906+ /// cap, so it hangs and closes exactly as the menus do and fits the same
6907+ /// 640x360 floor. The stroke for the setting is untouched: this is the
6908+ /// pointer's door to it, not a second setting.
6909+ fn picker_card(
6910+ &self,
6911+ viewport: Size<Pixels>,
6912+ cx: &mut Context<Self>,
6913+ ) -> Option<impl IntoElement> {
6914+ let picker = self.picker?;
6915+ let rows: Vec<AnyElement> = self
6916+ .choices(picker.of)
6917+ .into_iter()
6918+ .enumerate()
6919+ .map(|(n, (choice, label, detail, picked))| {
6920+ div()
6921+ .id(("picker-row", n))
6922+ .flex()
6923+ // The floor, not the height, and `HIT_MIN` of it: a row of a
6924+ // list is a click target like every other one here (WCAG
6925+ // 2.5.8).
6926+ .min_h(px(MENU_ROW_H))
6927+ .items_center()
6928+ .justify_between()
6929+ .gap(px(12.))
6930+ .px(px(6.))
6931+ .rounded(px(3.))
6932+ .cursor_pointer()
6933+ .hover(|s| s.bg(rgb(HOVER)))
6934+ // The mark is a glyph as well as a highlight, like the
6935+ // export card's rows: a background alone is gone under a
6936+ // hover and invisible to anyone who cannot tell the two
6937+ // greys apart (WCAG 1.4.1).
6938+ .when(picked, |d| d.bg(rgb(SELECTED)))
6939+ .child(
6940+ div()
6941+ .flex()
6942+ .flex_none()
6943+ .items_center()
6944+ .gap(px(8.))
6945+ .child(div().w(px(10.)).child(match picked {
6946+ true => "✓",
6947+ false => " ",
6948+ }))
6949+ .child(label),
6950+ )
6951+ .child(
6952+ div()
6953+ .min_w(px(0.))
6954+ .truncate()
6955+ .text_size(px(11.))
6956+ // On the picked row the dim ink sits on the
6957+ // highlight, where it is only 3.3:1 (WCAG 1.4.3).
6958+ .text_color(rgb(match picked {
6959+ true => INK,
6960+ false => INK_DIM,
6961+ }))
6962+ .child(detail),
6963+ )
6964+ .on_click(
6965+ cx.listener(move |this, _: &ClickEvent, _, cx| this.choose(choice, cx)),
6966+ )
6967+ .into_any_element()
6968+ })
6969+ .collect();
6970+ let (x, y) = menu_at(
6971+ picker.at,
6972+ viewport,
6973+ // Past the cap the list scrolls and the card stops growing, exactly
6974+ // as the menus and the export list do.
6975+ MENU_PAD * 2. + (rows.len() as f32 * MENU_ROW_H).min(MENU_ROWS_H),
6976+ );
6977+ Some(
6978+ div()
6979+ .absolute()
6980+ .inset_0()
6981+ // Click away closes it, either button, swallowed so nothing
6982+ // under the list also takes the press -- the clip menu's rule.
6983+ .on_mouse_down(
6984+ MouseButton::Left,
6985+ cx.listener(|this, _: &MouseDownEvent, _, cx| {
6986+ this.picker = None;
6987+ cx.notify();
6988+ cx.stop_propagation();
6989+ }),
6990+ )
6991+ .on_mouse_down(
6992+ MouseButton::Right,
6993+ cx.listener(|this, _: &MouseDownEvent, _, cx| {
6994+ this.picker = None;
6995+ cx.notify();
6996+ cx.stop_propagation();
6997+ }),
6998+ )
6999+ .child(
7000+ div()
7001+ .id("picker-card")
7002+ .absolute()
7003+ .left(px(x))
7004+ .top(px(y))
7005+ .w(px(MENU_W))
7006+ .flex()
7007+ .flex_col()
7008+ .p(px(MENU_PAD))
7009+ .rounded(px(6.))
7010+ .bg(rgb(SURFACE))
7011+ // Painted after the scrim, so this listener runs first
7012+ // and a press meant for a row never closes the list out
7013+ // from under its own click (`context_card`).
7014+ .on_mouse_down(MouseButton::Left, |_: &MouseDownEvent, _, cx| {
7015+ cx.stop_propagation()
7016+ })
7017+ .on_mouse_down(MouseButton::Right, |_: &MouseDownEvent, _, cx| {
7018+ cx.stop_propagation()
7019+ })
7020+ .child(
7021+ div()
7022+ .id("picker-rows")
7023+ .flex()
7024+ .flex_col()
7025+ .max_h(px(MENU_ROWS_H))
7026+ .overflow_y_scroll()
7027+ .children(rows),
7028+ ),
7029+ ),
7030+ )
7031+ }
7032+
6789 /// One lane of the edit list made visible: a fixed header saying which lane7033 /// One lane of the edit list made visible: a fixed header saying which lane
6790 /// it is, then a bed with a box per clip, placed and sized by its share of7034 /// it is, then a bed with a box per clip, placed and sized by its share of
6791 /// the timeline. A cut adds a box without moving anything, a delete closes7035 /// the timeline. A cut adds a box without moving anything, a delete closes
@@ -8070,6 +8314,16 @@ fn band_mut(params: &mut ColorParams, band: usize) -> &mut f32 {
8070 /// The line under the rows: what the picked format really writes, in the terms8314 /// The line under the rows: what the picked format really writes, in the terms
8071 /// a file is judged by afterwards.8315 /// a file is judged by afterwards.
8072 /// The next policy round the cycle, in the order the action's label reads.8316 /// The next policy round the cycle, in the order the action's label reads.
8317+/// Every fit policy, in the order the list offers them -- which is the order
8318+/// [`next_fit`] steps through them, pinned by the test below: a list and a
8319+/// stroke that disagreed about what comes next would be two settings.
8320+const FITS: [FitPolicy; 4] = [
8321+ FitPolicy::Fit,
8322+ FitPolicy::Fill,
8323+ FitPolicy::Stretch,
8324+ FitPolicy::Center,
8325+];
8326+
8073 fn next_fit(fit: FitPolicy) -> FitPolicy {8327 fn next_fit(fit: FitPolicy) -> FitPolicy {
8074 match fit {8328 match fit {
8075 FitPolicy::Fit => FitPolicy::Fill,8329 FitPolicy::Fit => FitPolicy::Fill,
@@ -8089,11 +8343,11 @@ fn fit_label(fit: FitPolicy) -> &'static str {
8089 }8343 }
8090 }8344 }
8091 8345
8092-/// The next project resolution after `current`, over [`RESOLUTIONS`] with the8346+/// Every project resolution on offer, largest first: [`RESOLUTIONS`] with the
8093-/// media's own size cycled in at its place by size -- so the trip round always8347+/// media's own size cycled in at its place by size -- so a project already at a
8094-/// comes back to the media, whatever odd shape it is, and a project already at a8348+/// listed size does not see it twice, and the media's own shape, whatever it is,
8095-/// listed size does not see it twice.8349+/// is always on the list. The one order both the stroke and the list use.
8096-fn next_resolution(current: (u32, u32), native: (u32, u32)) -> (u32, u32) {8350+fn resolution_ladder(native: (u32, u32)) -> Vec<(u32, u32)> {
8097 let mut sizes: Vec<(u32, u32)> = RESOLUTIONS.to_vec();8351 let mut sizes: Vec<(u32, u32)> = RESOLUTIONS.to_vec();
8098 if !sizes.contains(&native) {8352 if !sizes.contains(&native) {
8099 // By area, descending, like the list itself: the cycle then reads as one8353 // By area, descending, like the list itself: the cycle then reads as one
@@ -8106,6 +8360,57 @@ fn next_resolution(current: (u32, u32), native: (u32, u32)) -> (u32, u32) {
8106 .unwrap_or(sizes.len());8360 .unwrap_or(sizes.len());
8107 sizes.insert(at, native);8361 sizes.insert(at, native);
8108 }8362 }
8363+ sizes
8364+}
8365+
8366+/// The resolution list's rows: every rung of the ladder, the media's own said
8367+/// so, and the one in force marked. A size is named by its height the way the
8368+/// button that opens the list names it, with the full figure beside it.
8369+fn resolution_choices(current: (u32, u32), native: (u32, u32)) -> Vec<ChoiceRow> {
8370+ resolution_ladder(native)
8371+ .into_iter()
8372+ .map(|(w, h)| {
8373+ (
8374+ Choice::Size(w, h),
8375+ format!("{h}p").into(),
8376+ match (w, h) == native {
8377+ // Short enough to sit beside the label inside `MENU_W`:
8378+ // the longer phrase lost its last word to the truncation.
8379+ true => format!("{w}x{h} · the media's own"),
8380+ false => format!("{w}x{h}"),
8381+ }
8382+ .into(),
8383+ (w, h) == current,
8384+ )
8385+ })
8386+ .collect()
8387+}
8388+
8389+/// The fit list's rows: all four policies against the canvas they place a
8390+/// picture on, since the word alone ("fill") says nothing about the size it is
8391+/// filling -- which is the very thing the notice says after a stroke.
8392+fn fit_choices(lane: Lane, idx: usize, current: FitPolicy, (w, h): (u32, u32)) -> Vec<ChoiceRow> {
8393+ FITS.into_iter()
8394+ .map(|fit| {
8395+ (
8396+ Choice::Fit(lane, idx, fit),
8397+ fit_label(fit).into(),
8398+ // The canvas alone, worded as the resolution list words a size:
8399+ // the policy names are long and anything wordier here loses its
8400+ // tail to the truncation.
8401+ format!("{w}x{h}").into(),
8402+ fit == current,
8403+ )
8404+ })
8405+ .collect()
8406+}
8407+
8408+/// The next project resolution after `current`, over [`RESOLUTIONS`] with the
8409+/// media's own size cycled in at its place by size -- so the trip round always
8410+/// comes back to the media, whatever odd shape it is, and a project already at a
8411+/// listed size does not see it twice.
8412+fn next_resolution(current: (u32, u32), native: (u32, u32)) -> (u32, u32) {
8413+ let sizes = resolution_ladder(native);
8109 let at = sizes.iter().position(|&s| s == current);8414 let at = sizes.iter().position(|&s| s == current);
8110 // A project at a size nobody listed (a hand-edited file) joins the cycle at8415 // A project at a size nobody listed (a hand-edited file) joins the cycle at
8111 // the top rather than being stuck.8416 // the top rather than being stuck.
@@ -9283,8 +9588,10 @@ mod tests {
9283 summary_tail, timecode, transport, unseen_paths, unseen_sources, whole_take, window_title,9588 summary_tail, timecode, transport, unseen_paths, unseen_sources, whole_take, window_title,
9284 };9589 };
9285 use super::{9590 use super::{
9286- LaneKind, PPS_DEFAULT, Repeat, Scale, View, ZOOM_MAX_SECONDS, ZOOM_MIN_FRAMES, ZOOM_STEP,9591+ Choice, FITS, LaneKind, PPS_DEFAULT, RESOLUTIONS, Repeat, Scale, View, ZOOM_MAX_SECONDS,
9287- file_name, file_uri, library_rows, px_along, repeats, span_label, unscannable,9592+ ZOOM_MIN_FRAMES, ZOOM_STEP, file_name, file_uri, fit_choices, library_rows, next_fit,
9593+ next_resolution, px_along, repeats, resolution_choices, resolution_ladder, span_label,
9594+ unscannable,
9288 };9595 };
9289 9596
9290 /// What the file manager is handed: the parts a path keeps as they are, and9597 /// What the file manager is handed: the parts a path keeps as they are, and
@@ -11638,6 +11945,89 @@ mod tests {
11638 assert_eq!(silence_rate(4000), Speed::MAX);11945 assert_eq!(silence_rate(4000), Speed::MAX);
11639 }11946 }
11640 11947
11948+ /// The choice lists that replaced two click-to-cycle surfaces: every value
11949+ /// on offer at once, exactly one of them marked as the one in force, the
11950+ /// same order the stroke steps through, and the open list inside the
11951+ /// 640x360 floor with every row a `HIT_MIN` target.
11952+ #[test]
11953+ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() {
11954+ // Odd media: its own size is on the ladder, in its place by area, and
11955+ // nothing else moved.
11956+ let native = (1440, 1080);
11957+ let ladder = resolution_ladder(native);
11958+ assert_eq!(
11959+ ladder,
11960+ [
11961+ (3840, 2160),
11962+ (1920, 1080),
11963+ (1440, 1080),
11964+ (1280, 720),
11965+ (854, 480)
11966+ ]
11967+ );
11968+ for size in RESOLUTIONS {
11969+ assert!(ladder.contains(&size), "{size:?} is not on offer");
11970+ }
11971+ // Media already at a listed size is on the ladder once, not twice.
11972+ assert_eq!(resolution_ladder((1920, 1080)).len(), RESOLUTIONS.len());
11973+
11974+ // The rows say the same thing the ladder does, and mark the one in
11975+ // force -- exactly one row, whichever rung the project is on.
11976+ let rows = resolution_choices((1280, 720), native);
11977+ assert_eq!(rows.len(), ladder.len());
11978+ assert_eq!(rows.iter().filter(|(.., picked)| *picked).count(), 1);
11979+ for ((choice, label, detail, picked), size) in rows.iter().zip(&ladder) {
11980+ assert_eq!(*choice, Choice::Size(size.0, size.1));
11981+ assert_eq!(label.as_ref(), format!("{}p", size.1));
11982+ assert!(detail.contains(&format!("{}x{}", size.0, size.1)));
11983+ assert_eq!(*picked, *size == (1280, 720));
11984+ }
11985+ // The media's own size says so: it is the one rung a person cannot read
11986+ // off a number they chose.
11987+ let (.., native_detail, _) = &rows[2];
11988+ assert!(
11989+ native_detail.contains("the media's own"),
11990+ "{native_detail}"
11991+ );
11992+ // A project at a size nobody listed still gets the whole list, with
11993+ // nothing marked rather than a wrong row marked.
11994+ assert!(
11995+ resolution_choices((1000, 1000), native)
11996+ .iter()
11997+ .all(|(.., picked)| !picked)
11998+ );
11999+ // Picking a row means that row, and stepping means the next one: the
12000+ // list and the stroke read the same ladder.
12001+ assert_eq!(next_resolution(ladder[1], native), ladder[2]);
12002+
12003+ // The fit list, on a clip: all four policies, in the order the stroke
12004+ // steps through them, the clip's own marked and every row naming the
12005+ // canvas it would place the picture on.
12006+ let mut fit = FITS[0];
12007+ for next in FITS.into_iter().skip(1).chain([FITS[0]]) {
12008+ assert_eq!(next_fit(fit), next, "the stroke skips a policy");
12009+ fit = next;
12010+ }
12011+ let fits = fit_choices(Lane::V1, 3, FITS[2], (1920, 1080));
12012+ assert_eq!(fits.len(), FITS.len());
12013+ assert_eq!(fits.iter().filter(|(.., picked)| *picked).count(), 1);
12014+ assert_eq!(fits[2].0, Choice::Fit(Lane::V1, 3, FITS[2]));
12015+ assert!(fits[2].3, "the clip's own policy is not marked");
12016+ assert!(fits[0].2.contains("1920x1080"), "{}", fits[0].2);
12017+
12018+ // The open list fits the floor the menus are measured against: the
12019+ // longest of them is the resolution ladder, and it hangs at the pointer
12020+ // with every row on screen. Rows are click targets (WCAG 2.5.8).
12021+ assert!(MENU_ROW_H >= HIT_MIN);
12022+ let tall = MENU_PAD * 2. + ladder.len() as f32 * MENU_ROW_H;
12023+ assert!(tall <= 360., "the list is taller than the floor");
12024+ assert_eq!(
12025+ menu_at(point(px(600.), px(340.)), size(px(640.), px(360.)), tall),
12026+ (640. - MENU_W, 360. - tall),
12027+ "the list would hang off the smallest window"
12028+ );
12029+ }
12030+
11641 #[test]12031 #[test]
11642 fn the_export_card_fits_the_smallest_window() {12032 fn the_export_card_fits_the_smallest_window() {
11643 // Same 640x360 floor the keybindings card is measured against: the12033 // Same 640x360 floor the keybindings card is measured against: the
@@ -12425,6 +12815,7 @@ fn main() {
12425 scale: Scale::default(),12815 scale: Scale::default(),
12426 selected: None,12816 selected: None,
12427 context_menu: None,12817 context_menu: None,
12818+ picker: None,
12428 library_menu: None,12819 library_menu: None,
12429 selected_asset: None,12820 selected_asset: None,
12430 waves: HashMap::new(),12821 waves: HashMap::new(),