Merge branch 'worktree-agent-a91d0df90f3931bde'
Browse files at this commit8 changed files +210 -64
- crates/app/src/layout.rs +7 -0
- crates/app/src/menus.rs +24 -18
- crates/app/src/oracle.rs +9 -5
- crates/app/src/tests/cards.rs +1 -1
- crates/app/src/tests/editing.rs +67 -4
- crates/app/src/tests/layout.rs +5 -3
- crates/app/src/ui/library.rs +34 -7
- crates/app/src/ui/stance.rs +63 -26
crates/app/src/layout.rsmodified+7 -0
| @@ -89,6 +89,13 @@ pub(crate) const EXPORT_KEY_W: f32 = 26.; | |||
| 89 | pub(crate) const MENU_W: f32 = 260.; | 89 | pub(crate) const MENU_W: f32 = 260.; |
| 90 | pub(crate) const MENU_ROW_H: f32 = HIT_MIN; | 90 | pub(crate) const MENU_ROW_H: f32 = HIT_MIN; |
| 91 | pub(crate) const MENU_PAD: f32 = 6.; | 91 | pub(crate) const MENU_PAD: f32 = 6.; |
| 92 | +/// The breathing room a hanging menu keeps against every window edge. Without | ||
| 93 | +/// it `menu_at`'s clamp let a menu sit flush on the bottom edge -- the last row | ||
| 94 | +/// touching the frame reads as a list cut off rather than a list that ended, | ||
| 95 | +/// which is what the user saw at 1280x720 (`f-clip-menu.png`, rows running to | ||
| 96 | +/// y=720 exactly). Taken out of the room the list may fill as well as off the | ||
| 97 | +/// clamp, so a floored menu never grows back up over the picture to buy it. | ||
| 98 | +pub(crate) const MENU_EDGE: f32 = 4.; | ||
| 92 | 99 | ||
| 93 | /// A cue's text, and the line it sits on. Fixed rather than a share of the | 100 | /// A cue's text, and the line it sits on. Fixed rather than a share of the |
| 94 | /// picture: the video region is 108 px tall at the 640x360 floor and a | 101 | /// picture: the video region is 108 px tall at the 640x360 floor and a |
crates/app/src/menus.rsmodified+24 -18
| @@ -110,8 +110,9 @@ pub(crate) enum Choice { | |||
| 110 | pub(crate) type ChoiceRow = (Choice, SharedString, SharedString, bool); | 110 | pub(crate) type ChoiceRow = (Choice, SharedString, SharedString, bool); |
| 111 | 111 | ||
| 112 | /// What a library row's menu offers, in the order it lists them. Unlike the clip | 112 | /// What a library row's menu offers, in the order it lists them. Unlike the clip |
| 113 | -/// menu's items none of these is a stroke -- there is no keyboard way to a row -- | 113 | +/// menu's items only one of these ([`RowItem::Add`]) is a stroke, and that one |
| 114 | -/// so the label and the hint are written here rather than read off the keymap. | 114 | +/// is not a bindable [`ActionId`] but `ui/stance.rs`'s own `enter` branch, so |
| 115 | +/// the label and the chord are written here rather than read off the keymap. | ||
| 115 | #[derive(Clone, Copy, PartialEq)] | 116 | #[derive(Clone, Copy, PartialEq)] |
| 116 | pub(crate) enum RowItem { | 117 | pub(crate) enum RowItem { |
| 117 | Add, | 118 | Add, |
| @@ -140,29 +141,34 @@ impl RowItem { | |||
| 140 | match self { | 141 | match self { |
| 141 | Self::Add => "Add at playhead", | 142 | Self::Add => "Add at playhead", |
| 142 | Self::Remove => "Remove from library", | 143 | Self::Remove => "Remove from library", |
| 143 | - // Same label as the plain remove: only ever one of the two is on | 144 | + // The consequence is in the label now rather than in the hint |
| 144 | - // the plate (the oracle hides the other), so what differs is the | 145 | + // column beside a label identical to the plain remove's: that |
| 145 | - // consequence, and the consequence belongs in the hint column | 146 | + // column carries chords ([`RowItem::hint`]), and a destructive |
| 146 | - // where every other row states its own. The long dashed title | 147 | + // verb whose difference from the row above it lived in dim grey |
| 147 | - // truncated its own hint at `MENU_W`. | 148 | + // prose is a verb that reads as the same verb. It fits `MENU_W` |
| 148 | - Self::RemoveWithClips => "Remove from library", | 149 | + // whole exactly because nothing is printed to its right. |
| 150 | + Self::RemoveWithClips => "Remove with its clips", | ||
| 149 | Self::Reveal => "Reveal in files", | 151 | Self::Reveal => "Reveal in files", |
| 150 | Self::Properties => "Properties", | 152 | Self::Properties => "Properties", |
| 151 | } | 153 | } |
| 152 | } | 154 | } |
| 153 | 155 | ||
| 154 | - /// The dim right-hand column, where the clip menu prints the stroke: what | 156 | + /// The dim right-hand column: the *stroke* that does the same thing, the |
| 155 | - /// the item will do to the timeline, so nothing here is a surprise. | 157 | + /// one thing DESIGN §4 puts there ("every command wears its chord"), and |
| 158 | + /// nothing at all where no stroke reaches the verb. | ||
| 159 | + /// | ||
| 160 | + /// It used to carry a prose gloss on every row -- a phrase about the whole | ||
| 161 | + /// file, one about the desktop's file browser, one about clips -- which is | ||
| 162 | + /// §8's instructional copy sitting in the column the sibling clip menu | ||
| 163 | + /// spends on chords, and which the user read as the crowding it is. The | ||
| 164 | + /// only row a stroke reaches is the add (`ui/stance.rs`'s `enter` branch, | ||
| 165 | + /// live while a dock row is picked); its own row in the dock already wears | ||
| 166 | + /// the same `↵`. A refusal still prints here in place of the chord | ||
| 167 | + /// (`oracle::row_enable`) -- that is state, not instruction. | ||
| 156 | pub(crate) fn hint(self) -> &'static str { | 168 | pub(crate) fn hint(self) -> &'static str { |
| 157 | match self { | 169 | match self { |
| 158 | - // Short enough to sit beside its label inside `MENU_W`, the clip | 170 | + Self::Add => "↵", |
| 159 | - // menu's rule for a refusal: this column truncates, and a hint cut | 171 | + Self::Remove | Self::RemoveWithClips | Self::Reveal | Self::Properties => "", |
| 160 | - // off mid-word says less than a shorter one. | ||
| 161 | - Self::Add => "the whole file", | ||
| 162 | - Self::Remove => "nothing plays it", | ||
| 163 | - Self::RemoveWithClips => "clips too", | ||
| 164 | - Self::Reveal => "file manager", | ||
| 165 | - Self::Properties => "…", | ||
| 166 | } | 172 | } |
| 167 | } | 173 | } |
| 168 | } | 174 | } |
crates/app/src/oracle.rsmodified+9 -5
| @@ -451,18 +451,22 @@ pub(crate) fn row_items(ctx: RowCtx) -> Vec<RowItem> { | |||
| 451 | /// How tall a menu's list may draw: the whole of it where the window has room, | 451 | /// How tall a menu's list may draw: the whole of it where the window has room, |
| 452 | /// and what the window has where it has not -- only then does the list scroll. | 452 | /// and what the window has where it has not -- only then does the list scroll. |
| 453 | /// A cap fixed at twelve rows put the last items behind a scroll on a window | 453 | /// A cap fixed at twelve rows put the last items behind a scroll on a window |
| 454 | -/// with room to spare, which reads as a menu cut off by the bottom edge. | 454 | +/// with room to spare, which reads as a menu cut off by the bottom edge. Both |
| 455 | +/// [`MENU_EDGE`] margins come off the room first, so the plate `menu_at` places | ||
| 456 | +/// from this always fits between them whatever the anchor. | ||
| 455 | pub(crate) fn menu_rows_h(rows: usize, viewport: Size<Pixels>) -> f32 { | 457 | pub(crate) fn menu_rows_h(rows: usize, viewport: Size<Pixels>) -> f32 { |
| 456 | - let room = f32::from(viewport.height) - MENU_PAD * 2.; | 458 | + let room = f32::from(viewport.height) - MENU_PAD * 2. - MENU_EDGE * 2.; |
| 457 | (rows as f32 * MENU_ROW_H).min(room.max(MENU_ROW_H)) | 459 | (rows as f32 * MENU_ROW_H).min(room.max(MENU_ROW_H)) |
| 458 | } | 460 | } |
| 459 | 461 | ||
| 460 | /// Where the menu actually hangs: at the pointer, pulled back inside the window | 462 | /// Where the menu actually hangs: at the pointer, pulled back inside the window |
| 461 | /// when it would not fit -- an item off the bottom edge is an item nobody can | 463 | /// when it would not fit -- an item off the bottom edge is an item nobody can |
| 462 | -/// click. Never negative, so a window smaller than the menu loses the bottom of | 464 | +/// click. All four edges, [`MENU_EDGE`] clear of each: a plate flush on the |
| 463 | -/// it rather than the top, where the items are. | 465 | +/// frame reads as a list that was cut, not one that ended. Never past the top |
| 466 | +/// or left edge, so a window smaller than the menu loses the bottom of it | ||
| 467 | +/// rather than the top, where the items are. | ||
| 464 | pub(crate) fn menu_at(at: Point<Pixels>, viewport: Size<Pixels>, height: f32) -> (f32, f32) { | 468 | pub(crate) fn menu_at(at: Point<Pixels>, viewport: Size<Pixels>, height: f32) -> (f32, f32) { |
| 465 | - let fit = |v: f32, size: f32, room: f32| v.min(room - size).max(0.); | 469 | + let fit = |v: f32, size: f32, room: f32| v.min(room - MENU_EDGE - size).max(MENU_EDGE); |
| 466 | ( | 470 | ( |
| 467 | fit(f32::from(at.x), MENU_W, f32::from(viewport.width)), | 471 | fit(f32::from(at.x), MENU_W, f32::from(viewport.width)), |
| 468 | fit(f32::from(at.y), height, f32::from(viewport.height)), | 472 | fit(f32::from(at.y), height, f32::from(viewport.height)), |
crates/app/src/tests/cards.rsmodified+1 -1
| @@ -1443,7 +1443,7 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() { | |||
| 1443 | assert!(tall <= 360., "the list is taller than the floor"); | 1443 | assert!(tall <= 360., "the list is taller than the floor"); |
| 1444 | assert_eq!( | 1444 | assert_eq!( |
| 1445 | menu_at(point(px(600.), px(340.)), size(px(640.), px(360.)), tall), | 1445 | menu_at(point(px(600.), px(340.)), size(px(640.), px(360.)), tall), |
| 1446 | - (640. - MENU_W, 360. - tall), | 1446 | + (640. - crate::layout::MENU_EDGE - MENU_W, 360. - crate::layout::MENU_EDGE - tall), |
| 1447 | "the list would hang off the smallest window" | 1447 | "the list would hang off the smallest window" |
| 1448 | ); | 1448 | ); |
| 1449 | } | 1449 | } |
crates/app/src/tests/editing.rsmodified+67 -4
| @@ -983,12 +983,14 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { | |||
| 983 | assert_eq!(menu_at(point(px(10.), px(10.)), viewport, 150.), (10., 10.)); | 983 | assert_eq!(menu_at(point(px(10.), px(10.)), viewport, 150.), (10., 10.)); |
| 984 | assert_eq!( | 984 | assert_eq!( |
| 985 | menu_at(point(px(700.), px(380.)), viewport, 150.), | 985 | menu_at(point(px(700.), px(380.)), viewport, 150.), |
| 986 | - (800. - MENU_W, 250.) | 986 | + (800. - crate::layout::MENU_EDGE - MENU_W, 400. - crate::layout::MENU_EDGE - 150.) |
| 987 | ); | 987 | ); |
| 988 | - // A window smaller than the menu loses its bottom, never its top. | 988 | + // A window smaller than the menu loses its bottom, never its top: the |
| 989 | + // top-left margin wins over the bottom-right one, because the items are | ||
| 990 | + // at the top. | ||
| 989 | assert_eq!( | 991 | assert_eq!( |
| 990 | menu_at(point(px(90.), px(40.)), size(px(100.), px(50.)), 150.), | 992 | menu_at(point(px(90.), px(40.)), size(px(100.), px(50.)), 150.), |
| 991 | - (0., 0.) | 993 | + (crate::layout::MENU_EDGE, crate::layout::MENU_EDGE) |
| 992 | ); | 994 | ); |
| 993 | // Every item is an action the registry knows, so the menu and the keys | 995 | // Every item is an action the registry knows, so the menu and the keys |
| 994 | // menu say the same thing about it -- and none of them is unreachable | 996 | // menu say the same thing about it -- and none of them is unreachable |
| @@ -1015,7 +1017,7 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { | |||
| 1015 | menu_at(point(px(0.), px(0.)), floor, { | 1017 | menu_at(point(px(0.), px(0.)), floor, { |
| 1016 | MENU_PAD * 2. + menu_rows_h(items, floor) | 1018 | MENU_PAD * 2. + menu_rows_h(items, floor) |
| 1017 | }), | 1019 | }), |
| 1018 | - (0., 0.) | 1020 | + (crate::layout::MENU_EDGE, crate::layout::MENU_EDGE) |
| 1019 | ); | 1021 | ); |
| 1020 | // The picker is the same card and the longest list in it is the palette | 1022 | // The picker is the same card and the longest list in it is the palette |
| 1021 | // family list, which grows every time somebody asks for more colours. | 1023 | // family list, which grows every time somebody asks for more colours. |
| @@ -1219,6 +1221,67 @@ fn a_menu_offers_only_what_applies_and_is_drawn_inside_the_window() { | |||
| 1219 | assert!(menu_rows_h(items, size(px(640.), px(360.))) < items as f32 * MENU_ROW_H); | 1221 | assert!(menu_rows_h(items, size(px(640.), px(360.))) < items as f32 * MENU_ROW_H); |
| 1220 | } | 1222 | } |
| 1221 | 1223 | ||
| 1224 | +/// Defects 2 and 3 of the menu-placement lane, as source guards -- this binary | ||
| 1225 | +/// has no `VisualTestContext`, so where an element *mounts* and what its dim | ||
| 1226 | +/// column *says* are read off the source the way every other layout scan here | ||
| 1227 | +/// is. | ||
| 1228 | +/// | ||
| 1229 | +/// 1. All three hanging menus mount on the room's ROOT. Mounted inside | ||
| 1230 | +/// `stance-centre` the clip menu's window-coordinate anchor was laid out | ||
| 1231 | +/// from the centre column's own origin and painted under the dock, which is | ||
| 1232 | +/// the "chords cut mid-word" the user photographed. | ||
| 1233 | +/// 2. The library menu hangs a row clear of the pointer, so it cannot cover the | ||
| 1234 | +/// row it is about. | ||
| 1235 | +/// 3. The library rows carry chords, not prose. DESIGN §4 puts the stroke in | ||
| 1236 | +/// that column and §8 forbids the instructional copy that used to sit there. | ||
| 1237 | +#[test] | ||
| 1238 | +fn the_hanging_menus_mount_at_the_room_root_and_their_rows_wear_chords_not_prose() { | ||
| 1239 | + let stance = src_text("ui/stance.rs"); | ||
| 1240 | + let (centre, root) = stance | ||
| 1241 | + .split_once(".child(divider(Split::Dock,") | ||
| 1242 | + .expect("the dock seam splits the centre column from the room root"); | ||
| 1243 | + for menu in [ | ||
| 1244 | + "children(player.context_card(", | ||
| 1245 | + "children(player.library_card(", | ||
| 1246 | + "children(player.picker_card(", | ||
| 1247 | + ] { | ||
| 1248 | + assert!( | ||
| 1249 | + root.contains(menu), | ||
| 1250 | + "{menu} must mount after the dock, on the room root" | ||
| 1251 | + ); | ||
| 1252 | + assert!( | ||
| 1253 | + !centre.contains(menu), | ||
| 1254 | + "{menu} mounted inside stance-centre paints under the dock" | ||
| 1255 | + ); | ||
| 1256 | + } | ||
| 1257 | + let library = src_text("ui/library.rs"); | ||
| 1258 | + assert!( | ||
| 1259 | + library.contains("menu.at.y + px(ROW_CLEAR)"), | ||
| 1260 | + "the library menu must hang clear of the row it names" | ||
| 1261 | + ); | ||
| 1262 | + // Exactly one row wears a chord, and it is the one `ui/stance.rs`'s | ||
| 1263 | + // `enter` branch actually answers; every other row's column is empty. | ||
| 1264 | + for item in ROW_ITEMS { | ||
| 1265 | + let hint = item.hint(); | ||
| 1266 | + match item { | ||
| 1267 | + RowItem::Add => { | ||
| 1268 | + assert_eq!(hint, "↵"); | ||
| 1269 | + assert!( | ||
| 1270 | + stance.contains("if key == \"enter\"\n && this.dock_src_active"), | ||
| 1271 | + "the ↵ this menu advertises must still be the stroke that adds" | ||
| 1272 | + ); | ||
| 1273 | + } | ||
| 1274 | + _ => assert!(hint.is_empty(), "{:?} prints prose: {hint:?}", item.label()), | ||
| 1275 | + } | ||
| 1276 | + // §9: no junk drawer. A label that fits the plate whole beside its | ||
| 1277 | + // chord, and never a sentence. | ||
| 1278 | + assert!(item.label().split_whitespace().count() <= 4, "{}", item.label()); | ||
| 1279 | + } | ||
| 1280 | + // The two removes must not read as the same verb now that the column | ||
| 1281 | + // beside them is empty. | ||
| 1282 | + assert_ne!(RowItem::Remove.label(), RowItem::RemoveWithClips.label()); | ||
| 1283 | +} | ||
| 1284 | + | ||
| 1222 | /// The other half of the keys menu's guarantee, and the audit this batch was | 1285 | /// The other half of the keys menu's guarantee, and the audit this batch was |
| 1223 | /// asked for kept as a test: no action may be a stroke and nothing else. | 1286 | /// asked for kept as a test: no action may be a stroke and nothing else. |
| 1224 | /// The actions card answers it for all of them at once -- its rows come off | 1287 | /// The actions card answers it for all of them at once -- its rows come off |
crates/app/src/tests/layout.rsmodified+5 -3
| @@ -2206,9 +2206,11 @@ fn every_darkroom_menu_sizes_its_list_against_the_floor_room_not_the_raw_viewpor | |||
| 2206 | to the picture floor (the 'menu in somewhere nonsense' defect)" | 2206 | to the picture floor (the 'menu in somewhere nonsense' defect)" |
| 2207 | ); | 2207 | ); |
| 2208 | assert!( | 2208 | assert!( |
| 2209 | - library.contains("menu_at(menu.at, viewport"), | 2209 | + library.contains("menu_at(at, viewport, h)") |
| 2210 | - "ui/library.rs no longer anchors its menu to the pointer through \ | 2210 | + && library.contains("point(menu.at.x, menu.at.y + px(ROW_CLEAR))"), |
| 2211 | - menu_at -- update this guard" | 2211 | + "ui/library.rs no longer anchors its menu to the pointer -- one row \ |
| 2212 | + clear of it, so the menu cannot cover the row it names -- through \ | ||
| 2213 | + menu_at; update this guard" | ||
| 2212 | ); | 2214 | ); |
| 2213 | } | 2215 | } |
| 2214 | 2216 | ||
crates/app/src/ui/library.rsmodified+34 -7
| @@ -4,6 +4,18 @@ use crate::ui::type_scale::Typeset; | |||
| 4 | use crate::ui::widgets::*; | 4 | use crate::ui::widgets::*; |
| 5 | use crate::*; | 5 | use crate::*; |
| 6 | 6 | ||
| 7 | +/// How far below the pointer a library menu hangs so it clears the row it was | ||
| 8 | +/// opened on: a source row is two lines (`dock_stance::source_row` -- `py(4.)` | ||
| 9 | +/// twice, a `gap(2.)` and two ~20px line boxes), and the pointer may land on | ||
| 10 | +/// its very first pixel. | ||
| 11 | +/// | ||
| 12 | +/// corner-cut: a constant rather than the row's measured bottom, which the | ||
| 13 | +/// `on_mouse_down` listener that sets `LibraryMenu::at` has no access to. The | ||
| 14 | +/// ceiling is a row that grows a third line -- the menu would then start | ||
| 15 | +/// inside it. Upgrade path: carry the row's `Bounds` bottom in `LibraryMenu` | ||
| 16 | +/// via a `canvas`/`prepaint` probe in `source_row` and hang the menu off that. | ||
| 17 | +const ROW_CLEAR: f32 = 52.; | ||
| 18 | + | ||
| 7 | impl Player { | 19 | impl Player { |
| 8 | /// The menu a right-click on a library row opens: what can be done with the | 20 | /// The menu a right-click on a library row opens: what can be done with the |
| 9 | /// *file* rather than with a clip of it, and a turn-over side saying what | 21 | /// *file* rather than with a clip of it, and a turn-over side saying what |
| @@ -161,14 +173,29 @@ impl Player { | |||
| 161 | ); | 173 | ); |
| 162 | } | 174 | } |
| 163 | } | 175 | } |
| 164 | - // Placed at the pointer, clamped only to the window's own bounds -- | 176 | + // Hung BELOW the row it is about, not on the pointer: opened at the |
| 165 | - // standard context-menu behavior. Unlike the clip menu, this menu | 177 | + // pointer it covered the very row it names (`k-lib-menu.png` -- the |
| 166 | - // mounts on the root over the dock (no picture behind it to protect), | 178 | + // source row vanished under its own menu), and a menu that hides its |
| 167 | - // so it does not go through `menu_floor`'s picture-floor clamp; doing | 179 | + // subject is DESIGN §11.6's occlusion rule broken on the other panel. |
| 168 | - // so pulled a right-click high in the dock down to the picture floor, | 180 | + // `menu_at` then does the rest -- left-aligned to the pointer, pulled |
| 169 | - // teleporting the menu away from the pointer that opened it. | 181 | + // back inside all four window edges, and flipped up above the row |
| 182 | + // where the dock has no room below. Unlike the clip menu it does not | ||
| 183 | + // go through `menu_floor`'s picture-floor clamp: it mounts over the | ||
| 184 | + // dock, which has no picture behind it, and clamping there pulled a | ||
| 185 | + // right-click high in the dock down to the picture floor, teleporting | ||
| 186 | + // the menu away from the pointer that opened it. | ||
| 170 | let list_h = menu_rows_h(rows.len(), viewport); | 187 | let list_h = menu_rows_h(rows.len(), viewport); |
| 171 | - let (x, y) = menu_at(menu.at, viewport, MENU_PAD * 2. + list_h); | 188 | + let h = MENU_PAD * 2. + list_h; |
| 189 | + let below = point(menu.at.x, menu.at.y + px(ROW_CLEAR)); | ||
| 190 | + // Above the row instead when the plate would not fit whole below it: | ||
| 191 | + // `menu_at`'s own clamp would otherwise slide it back up *over* the | ||
| 192 | + // row, which is the thing this placement exists to prevent. | ||
| 193 | + let at = if f32::from(below.y) + h + MENU_EDGE > f32::from(viewport.height) { | ||
| 194 | + point(menu.at.x, px((f32::from(menu.at.y) - h).max(0.))) | ||
| 195 | + } else { | ||
| 196 | + below | ||
| 197 | + }; | ||
| 198 | + let (x, y) = menu_at(at, viewport, h); | ||
| 172 | let full: SharedString = path.display().to_string().into(); | 199 | let full: SharedString = path.display().to_string().into(); |
| 173 | Some( | 200 | Some( |
| 174 | scrim() | 201 | scrim() |
crates/app/src/ui/stance.rsmodified+63 -26
| @@ -224,17 +224,59 @@ mod menu_floor_tests { | |||
| 224 | let floor = below_picture_floor(f32::from(viewport.height), BENCH_H); | 224 | let floor = below_picture_floor(f32::from(viewport.height), BENCH_H); |
| 225 | let (at, room) = menu_floor(point(px(300.), px(20.)), viewport, BENCH_H); | 225 | let (at, room) = menu_floor(point(px(300.), px(20.)), viewport, BENCH_H); |
| 226 | assert_eq!(f32::from(at.y), floor); | 226 | assert_eq!(f32::from(at.y), floor); |
| 227 | - // 396px of rows (the charter's measured menu height) does not fit in | 227 | + // 17 rows -- more than the footprint holds -- sized through the real |
| 228 | - // the 316px footprint room, so it must be capped to it, not the | 228 | + // sizer, so the `MENU_EDGE` margin is in the number the clamp sees. |
| 229 | - // window's 720. | 229 | + let list_h = crate::oracle::menu_rows_h(17, room); |
| 230 | - let list_h = (396f32).min(f32::from(room.height)); | ||
| 231 | assert!(list_h <= f32::from(room.height)); | 230 | assert!(list_h <= f32::from(room.height)); |
| 232 | - let (_, y) = crate::oracle::menu_at(at, viewport, list_h); | 231 | + let h = crate::layout::MENU_PAD * 2. + list_h; |
| 232 | + let (_, y) = crate::oracle::menu_at(at, viewport, h); | ||
| 233 | assert_eq!( | 233 | assert_eq!( |
| 234 | y, floor, | 234 | y, floor, |
| 235 | "the top edge must not be walked back above the floor" | 235 | "the top edge must not be walked back above the floor" |
| 236 | ); | 236 | ); |
| 237 | } | 237 | } |
| 238 | + | ||
| 239 | + /// Defect 1 as the user met it (`f-clip-menu.png`): a menu opened near the | ||
| 240 | + /// right and bottom of a 1280x720 window ran off both edges -- chords cut | ||
| 241 | + /// mid-word at the dock seam, rows past the frame. Pure clamp math, both | ||
| 242 | + /// window sizes the charter names, and both the floored (clip) menu and | ||
| 243 | + /// the unfloored (library) one: whatever the anchor, the whole plate lands | ||
| 244 | + /// inside the frame with [`MENU_EDGE`] to spare, and the floored one never | ||
| 245 | + /// buys that room off the picture. | ||
| 246 | + #[test] | ||
| 247 | + fn a_menu_opened_in_the_bottom_right_corner_lands_whole_inside_the_window() { | ||
| 248 | + use crate::layout::{MENU_EDGE, MENU_PAD, MENU_W}; | ||
| 249 | + for viewport in [size(px(1280.), px(720.)), size(px(2560.), px(1440.))] { | ||
| 250 | + let (w, v) = (f32::from(viewport.width), f32::from(viewport.height)); | ||
| 251 | + let floor = below_picture_floor(v, BENCH_H); | ||
| 252 | + for rows in [1usize, 5, 16, 40] { | ||
| 253 | + for anchor in [ | ||
| 254 | + point(px(w - 1.), px(v - 1.)), | ||
| 255 | + point(px(w - 1.), px(0.)), | ||
| 256 | + point(px(0.), px(v - 1.)), | ||
| 257 | + ] { | ||
| 258 | + // The clip menu's path: floored below the picture, sized | ||
| 259 | + // against the room that leaves, then clamped. | ||
| 260 | + let (at, room) = menu_floor(anchor, viewport, BENCH_H); | ||
| 261 | + let h = MENU_PAD * 2. + crate::oracle::menu_rows_h(rows, room); | ||
| 262 | + let (x, y) = crate::oracle::menu_at(at, viewport, h); | ||
| 263 | + assert!(x >= MENU_EDGE && x + MENU_W <= w - MENU_EDGE, "x {x} rows {rows}"); | ||
| 264 | + assert!(y >= MENU_EDGE && y + h <= v - MENU_EDGE, "y {y} h {h} rows {rows}"); | ||
| 265 | + assert!(y >= floor, "y {y} walked above the picture floor {floor}"); | ||
| 266 | + // The library menu's path: no floor, hung a row below the | ||
| 267 | + // pointer, same clamp. | ||
| 268 | + let h = MENU_PAD * 2. + crate::oracle::menu_rows_h(rows, viewport); | ||
| 269 | + let (x, y) = crate::oracle::menu_at( | ||
| 270 | + point(anchor.x, anchor.y + px(52.)), | ||
| 271 | + viewport, | ||
| 272 | + h, | ||
| 273 | + ); | ||
| 274 | + assert!(x >= MENU_EDGE && x + MENU_W <= w - MENU_EDGE, "lib x {x}"); | ||
| 275 | + assert!(y >= MENU_EDGE && y + h <= v - MENU_EDGE, "lib y {y} h {h}"); | ||
| 276 | + } | ||
| 277 | + } | ||
| 278 | + } | ||
| 279 | + } | ||
| 238 | } | 280 | } |
| 239 | 281 | ||
| 240 | #[cfg(test)] | 282 | #[cfg(test)] |
| @@ -1130,17 +1172,6 @@ pub(crate) fn render( | |||
| 1130 | .when(player.settings_open, |el| { | 1172 | .when(player.settings_open, |el| { |
| 1131 | el.child(settings_stance::render(player, window_size, cx)) | 1173 | el.child(settings_stance::render(player, window_size, cx)) |
| 1132 | }) | 1174 | }) |
| 1133 | - // The two menus (DESIGN §9: "verbs of the thing under the | ||
| 1134 | - // cursor", plate styling, the same scrim-and-row component | ||
| 1135 | - // the legacy tree already uses -- `library.rs`'s own doc | ||
| 1136 | - // comment: "Built like `Player::context_card` ... because it | ||
| 1137 | - // is the same menu on the other panel") and the open list a | ||
| 1138 | - // picker sets: none of the three had a home in the stance, | ||
| 1139 | - // so `overlaid()` refused every key over them for nothing | ||
| 1140 | - // ever drawn (FAULT 2). `render.rs`'s children order is kept | ||
| 1141 | - // -- clip menu, then library menu, then the open list last so | ||
| 1142 | - // it floats over whichever row opened it. | ||
| 1143 | - .children(player.context_card(window_size, cx)) | ||
| 1144 | // The export card and its running-progress sheet, mounted | 1175 | // The export card and its running-progress sheet, mounted |
| 1145 | // over the whole room exactly as the legacy tree mounts them | 1176 | // over the whole room exactly as the legacy tree mounts them |
| 1146 | // (`render.rs`) -- the fix for the shipped "Export does | 1177 | // (`render.rs`) -- the fix for the shipped "Export does |
| @@ -1148,7 +1179,6 @@ pub(crate) fn render( | |||
| 1148 | // what draws it once open. | 1179 | // what draws it once open. |
| 1149 | .children(player.export_card(window_size, cx)) | 1180 | .children(player.export_card(window_size, cx)) |
| 1150 | .children(player.export_progress_card(cx)) | 1181 | .children(player.export_progress_card(cx)) |
| 1151 | - .children(player.picker_card(window_size, cx)) | ||
| 1152 | // A maximized clip param card (EQ/Colour/Transform/Speed/ | 1182 | // A maximized clip param card (EQ/Colour/Transform/Speed/ |
| 1153 | // Silence/Mix/Subtitle style) escapes the dock to mount here | 1183 | // Silence/Mix/Subtitle style) escapes the dock to mount here |
| 1154 | // instead, the same window-space `stance-centre` context | 1184 | // instead, the same window-space `stance-centre` context |
| @@ -1173,14 +1203,21 @@ pub(crate) fn render( | |||
| 1173 | ) | 1203 | ) |
| 1174 | .child(divider(Split::Dock, player.split_drag == Some(Split::Dock), cx)) | 1204 | .child(divider(Split::Dock, player.split_drag == Some(Split::Dock), cx)) |
| 1175 | .child(dock(player, dock_w, window_size, window, cx)) | 1205 | .child(dock(player, dock_w, window_size, window, cx)) |
| 1176 | - // The library row menu mounts on the ROOT, not inside | 1206 | + // All three hanging menus (DESIGN §9: "verbs of the thing under the |
| 1177 | - // `stance-centre` like the clip menu beside it: it is opened from a | 1207 | + // cursor") mount on the ROOT, and none of them inside |
| 1178 | - // dock row, so its anchor is a window x past the centre column's own | 1208 | + // `stance-centre`. Their anchors are *window* coordinates -- a |
| 1179 | - // right edge, and the dock -- painted after the centre -- covered | 1209 | + // `MouseDownEvent::position` -- while an absolutely placed child of |
| 1180 | - // every pixel of it. That is the whole of the shipped "can not | 1210 | + // the centre column is laid out from that column's own origin and |
| 1181 | - // remove a media from library" defect: the plate was built, placed | 1211 | + // ends where it ends: the spine shifted every clip menu right by |
| 1182 | - // and never visible. Mounted here it paints last, over the dock it | 1212 | + // `SPINE_W`, and the dock, painted after the centre, covered every |
| 1183 | - // belongs to, and its own `menu_floor` window coordinates finally | 1213 | + // pixel past x = width - dock. That is the shipped "can not remove a |
| 1184 | - // mean what they say. | 1214 | + // media from library" defect (the library plate was built, placed and |
| 1215 | + // never visible) and the clip menu whose chords were cut off mid-word | ||
| 1216 | + // at the dock seam. Mounted here they paint last, over the dock they | ||
| 1217 | + // may overlap, and `menu_floor`/`menu_at`'s window coordinates finally | ||
| 1218 | + // mean what they say. Order is `render.rs`'s -- clip menu, library | ||
| 1219 | + // menu, then the open list last so it floats over whichever row set it. | ||
| 1220 | + .children(player.context_card(window_size, cx)) | ||
| 1185 | .children(player.library_card(window_size, cx)) | 1221 | .children(player.library_card(window_size, cx)) |
| 1222 | + .children(player.picker_card(window_size, cx)) | ||
| 1186 | } | 1223 | } |