The menu floor is the picture's painted edge, not the screen region
Browse files at this commit22a8a533897e5f320567a9f5d419de9bf12314e8Parent: 24b3bde- fix
- the menu floor is the picture's painted edge, not the screen region
3 changed files +145 -15
- DESIGN.md +8 -0
- crates/app/src/ui/overlays.rs +19 -5
- crates/app/src/ui/stance.rs +118 -10
DESIGN.mdmodified+8 -0
| @@ -208,6 +208,14 @@ string over ~4 words that instructs rather than reports state is a defect. | |||
| 208 | - **Right-click = verbs of the thing under the cursor** (clip menu: clip verbs; lane head: lane | 208 | - **Right-click = verbs of the thing under the cursor** (clip menu: clip verbs; lane head: lane |
| 209 | verbs; source dot: ink acts). Plate styling, chords on every row, destructive verbs below a | 209 | verbs; source dot: ink acts). Plate styling, chords on every row, destructive verbs below a |
| 210 | rule line. Never a junk drawer. | 210 | rule line. Never a junk drawer. |
| 211 | + | ||
| 212 | + **Amendment (2026-09-09), R4:** the floor a menu is kept below is the picture's **painted | ||
| 213 | + edge**, not the screen region's bottom. The region letterboxes — with a 3840x1608 film in a | ||
| 214 | + 2560x1440 window ~99px of the region's bottom is black bar, not picture, and §5's "nothing | ||
| 215 | + occludes the picture" has nothing to say about black. A menu takes that room (and may open | ||
| 216 | + *above* its pointer to use it), never a pixel of the frame; still too tall for what is left, it | ||
| 217 | + scrolls inside its own plate as before. | ||
| 218 | + | ||
| 211 | - **`?` held** dims the room one fill step and surfaces chords *in place* beside their controls; | 219 | - **`?` held** dims the room one fill step and surfaces chords *in place* beside their controls; |
| 212 | release restores, and a click on the scrim also dismisses it. Hold-to-peek, not a latch; | 220 | release restores, and a click on the scrim also dismisses it. Hold-to-peek, not a latch; |
| 213 | learning stays geographic. The film keeps playing. | 221 | learning stays geographic. The film keeps playing. |
crates/app/src/ui/overlays.rsmodified+19 -5
| @@ -1,7 +1,7 @@ | |||
| 1 | //! The bars and the floating cards that are not inspector sections. | 1 | //! The bars and the floating cards that are not inspector sections. |
| 2 | 2 | ||
| 3 | use crate::ui::hitmap; | 3 | use crate::ui::hitmap; |
| 4 | -use crate::ui::stance::menu_floor; | 4 | +use crate::ui::stance::{menu_above, menu_floor, picture_bottom}; |
| 5 | use crate::ui::type_scale::{self, Typeset}; | 5 | use crate::ui::type_scale::{self, Typeset}; |
| 6 | use crate::ui::widgets::*; | 6 | use crate::ui::widgets::*; |
| 7 | use crate::*; | 7 | use crate::*; |
| @@ -420,9 +420,17 @@ impl Player { | |||
| 420 | // footprint (`room`), not the whole window, so a menu taller than | 420 | // footprint (`room`), not the whole window, so a menu taller than |
| 421 | // the footprint scrolls inside its own plate instead of walking its | 421 | // the footprint scrolls inside its own plate instead of walking its |
| 422 | // clamped top edge back up over the picture ([`menu_floor`]). | 422 | // clamped top edge back up over the picture ([`menu_floor`]). |
| 423 | - let (at, room) = menu_floor(menu.at, viewport, self.split_px(Split::Bench, viewport)); | 423 | + // ...and that floor is the picture's painted edge, so the black bars |
| 424 | + // of a letterboxed film are room the menu may use (R4). | ||
| 425 | + let (at, room, floor) = menu_floor( | ||
| 426 | + menu.at, | ||
| 427 | + viewport, | ||
| 428 | + self.split_px(Split::Bench, viewport), | ||
| 429 | + picture_bottom(self), | ||
| 430 | + ); | ||
| 424 | let list_h = menu_rows_h(rows.len(), room); | 431 | let list_h = menu_rows_h(rows.len(), room); |
| 425 | - let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); | 432 | + let h = MENU_PAD * 2. + list_h; |
| 433 | + let (x, y) = menu_at(menu_above(at, viewport, floor, h), viewport, h); | ||
| 426 | let full: SharedString = source | 434 | let full: SharedString = source |
| 427 | .map(|source| source.path.display().to_string()) | 435 | .map(|source| source.path.display().to_string()) |
| 428 | .unwrap_or_default() | 436 | .unwrap_or_default() |
| @@ -592,9 +600,15 @@ impl Player { | |||
| 592 | .collect(); | 600 | .collect(); |
| 593 | // The window's own room, and the list scrolls only where the window has | 601 | // The window's own room, and the list scrolls only where the window has |
| 594 | // none -- the clip menu's rule, one function for both. | 602 | // none -- the clip menu's rule, one function for both. |
| 595 | - let (at, room) = menu_floor(picker.at, viewport, self.split_px(Split::Bench, viewport)); | 603 | + let (at, room, floor) = menu_floor( |
| 604 | + picker.at, | ||
| 605 | + viewport, | ||
| 606 | + self.split_px(Split::Bench, viewport), | ||
| 607 | + picture_bottom(self), | ||
| 608 | + ); | ||
| 596 | let list_h = menu_rows_h(rows.len(), room); | 609 | let list_h = menu_rows_h(rows.len(), room); |
| 597 | - let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); | 610 | + let h = MENU_PAD * 2. + list_h; |
| 611 | + let (x, y) = menu_at(menu_above(at, viewport, floor, h), viewport, h); | ||
| 598 | Some( | 612 | Some( |
| 599 | scrim() | 613 | scrim() |
| 600 | // Click away closes it, either button, swallowed so nothing | 614 | // Click away closes it, either button, swallowed so nothing |
crates/app/src/ui/stance.rsmodified+118 -10
| @@ -193,15 +193,47 @@ pub(crate) fn maximized_card_top(viewport_h: f32, bench_h: f32) -> f32 { | |||
| 193 | /// room *below the floor* instead means it never needs more than that room, | 193 | /// room *below the floor* instead means it never needs more than that room, |
| 194 | /// so `menu_at` never has a reason to walk it back up; a list still taller | 194 | /// so `menu_at` never has a reason to walk it back up; a list still taller |
| 195 | /// than the room scrolls inside its own plate, same as the keys overlay. | 195 | /// than the room scrolls inside its own plate, same as the keys overlay. |
| 196 | +/// | ||
| 197 | +/// The floor is the picture's own *painted* bottom edge | ||
| 198 | +/// ([`picture_bottom`]) when a frame is up, not the screen region's: the | ||
| 199 | +/// region letterboxes, and a black bar is not picture. With a 3840x1608 | ||
| 200 | +/// film in a 2560x1440 window that edge sits ~170px above the region's own | ||
| 201 | +/// bottom, which is two more row slots the menu no longer has to scroll | ||
| 202 | +/// through. Nothing is shown (safelight, empty room, before the first | ||
| 203 | +/// paint) -> the region's bottom, unchanged. Returned alongside the anchor | ||
| 204 | +/// so the caller can flip the plate *above* its pointer without a second | ||
| 205 | +/// copy of this arithmetic. | ||
| 196 | pub(crate) fn menu_floor( | 206 | pub(crate) fn menu_floor( |
| 197 | at: Point<Pixels>, | 207 | at: Point<Pixels>, |
| 198 | viewport: Size<Pixels>, | 208 | viewport: Size<Pixels>, |
| 199 | bench_h: f32, | 209 | bench_h: f32, |
| 200 | -) -> (Point<Pixels>, Size<Pixels>) { | 210 | + picture_bottom: Option<f32>, |
| 201 | - let floor = below_picture_floor(f32::from(viewport.height), bench_h); | 211 | +) -> (Point<Pixels>, Size<Pixels>, f32) { |
| 212 | + let region = below_picture_floor(f32::from(viewport.height), bench_h); | ||
| 213 | + let floor = picture_bottom.unwrap_or(region).clamp(0., region); | ||
| 202 | let at = point(at.x, px(f32::from(at.y).max(floor))); | 214 | let at = point(at.x, px(f32::from(at.y).max(floor))); |
| 203 | let room = size(viewport.width, px(f32::from(viewport.height) - floor)); | 215 | let room = size(viewport.width, px(f32::from(viewport.height) - floor)); |
| 204 | - (at, room) | 216 | + (at, room, floor) |
| 217 | +} | ||
| 218 | + | ||
| 219 | +/// The plate's top edge, flipped to sit *above* the pointer when the room | ||
| 220 | +/// below it does not hold the whole list -- `library.rs` already places its | ||
| 221 | +/// menu this way for the same reason, and every row above the fold is a row | ||
| 222 | +/// nobody has to wheel to. Never above `floor`: a menu that gained rows by | ||
| 223 | +/// climbing over the picture is the occlusion this file exists to prevent | ||
| 224 | +/// (DESIGN §5, §11 check 6). `room` from [`menu_floor`] already sizes the | ||
| 225 | +/// list to fit between `floor` and the window's bottom edge, so the clamped | ||
| 226 | +/// flip always fits. | ||
| 227 | +pub(crate) fn menu_above( | ||
| 228 | + at: Point<Pixels>, | ||
| 229 | + viewport: Size<Pixels>, | ||
| 230 | + floor: f32, | ||
| 231 | + h: f32, | ||
| 232 | +) -> Point<Pixels> { | ||
| 233 | + if f32::from(at.y) + h + MENU_EDGE <= f32::from(viewport.height) { | ||
| 234 | + return at; | ||
| 235 | + } | ||
| 236 | + point(at.x, px((f32::from(at.y) - h).max(floor))) | ||
| 205 | } | 237 | } |
| 206 | 238 | ||
| 207 | #[cfg(test)] | 239 | #[cfg(test)] |
| @@ -219,7 +251,7 @@ mod menu_floor_tests { | |||
| 219 | fn a_menu_taller_than_the_footprint_stays_pinned_to_the_floor_not_walked_back_over_it() { | 251 | fn a_menu_taller_than_the_footprint_stays_pinned_to_the_floor_not_walked_back_over_it() { |
| 220 | let viewport = size(px(1280.), px(720.)); | 252 | let viewport = size(px(1280.), px(720.)); |
| 221 | let floor = below_picture_floor(f32::from(viewport.height), BENCH_H); | 253 | let floor = below_picture_floor(f32::from(viewport.height), BENCH_H); |
| 222 | - let (at, room) = menu_floor(point(px(300.), px(20.)), viewport, BENCH_H); | 254 | + let (at, room, _) = menu_floor(point(px(300.), px(20.)), viewport, BENCH_H, None); |
| 223 | assert_eq!(f32::from(at.y), floor); | 255 | assert_eq!(f32::from(at.y), floor); |
| 224 | // 17 rows -- more than the footprint holds -- sized through the real | 256 | // 17 rows -- more than the footprint holds -- sized through the real |
| 225 | // sizer, so the `MENU_EDGE` margin is in the number the clamp sees. | 257 | // sizer, so the `MENU_EDGE` margin is in the number the clamp sees. |
| @@ -254,12 +286,22 @@ mod menu_floor_tests { | |||
| 254 | ] { | 286 | ] { |
| 255 | // The clip menu's path: floored below the picture, sized | 287 | // The clip menu's path: floored below the picture, sized |
| 256 | // against the room that leaves, then clamped. | 288 | // against the room that leaves, then clamped. |
| 257 | - let (at, room) = menu_floor(anchor, viewport, BENCH_H); | 289 | + // Both the picture floors a menu can get: the region's |
| 258 | - let h = MENU_PAD * 2. + crate::oracle::menu_rows_h(rows, room); | 290 | + // own bottom (nothing shown) and a letterboxed film's |
| 259 | - let (x, y) = crate::oracle::menu_at(at, viewport, h); | 291 | + // painted edge, 120px above it. |
| 260 | - assert!(x >= MENU_EDGE && x + MENU_W <= w - MENU_EDGE, "x {x} rows {rows}"); | 292 | + for pic in [None, Some(floor - 120.)] { |
| 261 | - assert!(y >= MENU_EDGE && y + h <= v - MENU_EDGE, "y {y} h {h} rows {rows}"); | 293 | + let (at, room, f) = menu_floor(anchor, viewport, BENCH_H, pic); |
| 262 | - assert!(y >= floor, "y {y} walked above the picture floor {floor}"); | 294 | + let h = MENU_PAD * 2. + crate::oracle::menu_rows_h(rows, room); |
| 295 | + // Through the flip: the placement the app actually uses. | ||
| 296 | + let at = menu_above(at, viewport, f, h); | ||
| 297 | + let (x, y) = crate::oracle::menu_at(at, viewport, h); | ||
| 298 | + assert!(y >= f, "y {y} walked above the menu floor {f}"); | ||
| 299 | + assert!(x >= MENU_EDGE && x + MENU_W <= w - MENU_EDGE, "x {x} rows {rows}"); | ||
| 300 | + assert!( | ||
| 301 | + y >= MENU_EDGE && y + h <= v - MENU_EDGE, | ||
| 302 | + "y {y} h {h} rows {rows}" | ||
| 303 | + ); | ||
| 304 | + } | ||
| 263 | // The library menu's path: no floor, hung a row below the | 305 | // The library menu's path: no floor, hung a row below the |
| 264 | // pointer, same clamp. | 306 | // pointer, same clamp. |
| 265 | let h = MENU_PAD * 2. + crate::oracle::menu_rows_h(rows, viewport); | 307 | let h = MENU_PAD * 2. + crate::oracle::menu_rows_h(rows, viewport); |
| @@ -274,6 +316,47 @@ mod menu_floor_tests { | |||
| 274 | } | 316 | } |
| 275 | } | 317 | } |
| 276 | } | 318 | } |
| 319 | + | ||
| 320 | + /// The floor the charter names (R4): a wide film letterboxed into a tall | ||
| 321 | + /// region stops being picture well above that region's bottom, and the | ||
| 322 | + /// menu may have that black. A 3840x1608 film fit into the real | ||
| 323 | + /// 2560x1440 darkroom's picture box (2224x1129) lands 931px tall -- a | ||
| 324 | + /// 99px bar top and bottom -- so the floor rises 99px, two more row | ||
| 325 | + /// slots. A 4:3 source in a 4:3 box has no bar at all and the floor stays | ||
| 326 | + /// the region's own bottom. | ||
| 327 | + #[test] | ||
| 328 | + fn the_menu_floor_is_the_picture_s_painted_edge_not_the_region_s() { | ||
| 329 | + let native = |w, h| size(gpui::DevicePixels(w), gpui::DevicePixels(h)); | ||
| 330 | + let box_of = |w: f32, h: f32| Bounds { | ||
| 331 | + origin: point(px(0.), px(88.)), | ||
| 332 | + size: size(px(w), px(h)), | ||
| 333 | + }; | ||
| 334 | + // Wide film, tall box: bars top and bottom, so the edge rises. | ||
| 335 | + let wide = fitted_bottom(box_of(2224., 1129.), native(3840, 1608)).unwrap(); | ||
| 336 | + let painted_h = 2224. * 1608. / 3840.; | ||
| 337 | + let want = 88. + (1129. - painted_h) / 2. + painted_h; | ||
| 338 | + assert!( | ||
| 339 | + (wide - want).abs() < 1., | ||
| 340 | + "wide film's painted bottom {wide}, wanted {want}" | ||
| 341 | + ); | ||
| 342 | + assert!(88. + 1129. - wide > 90., "the bar the menu gains is real"); | ||
| 343 | + // Same ratio as its box: no bar, the edge IS the box's bottom. | ||
| 344 | + let square = fitted_bottom(box_of(800., 600.), native(1600, 1200)).unwrap(); | ||
| 345 | + assert!((square - 688.).abs() < 0.01, "4:3 in a 4:3 box: {square}"); | ||
| 346 | + // Nothing measured yet reads as no floor, never a NaN one. | ||
| 347 | + assert_eq!(fitted_bottom(box_of(0., 0.), native(1600, 1200)), None); | ||
| 348 | + | ||
| 349 | + // And the floor menu_floor hands the sizer follows it: the wide film | ||
| 350 | + // buys the menu rows, the region's bottom is still the ceiling on it. | ||
| 351 | + let viewport = size(px(2560.), px(1440.)); | ||
| 352 | + let region = below_picture_floor(1440., BENCH_H); | ||
| 353 | + let (_, room, floor) = menu_floor(point(px(10.), px(10.)), viewport, BENCH_H, Some(wide)); | ||
| 354 | + assert_eq!(floor, wide); | ||
| 355 | + assert!(f32::from(room.height) > 1440. - region); | ||
| 356 | + // A bogus reading below the bench never lets a menu climb: clamped. | ||
| 357 | + let (_, _, floor) = menu_floor(point(px(10.), px(10.)), viewport, BENCH_H, Some(9999.)); | ||
| 358 | + assert_eq!(floor, region); | ||
| 359 | + } | ||
| 277 | } | 360 | } |
| 278 | 361 | ||
| 279 | #[cfg(test)] | 362 | #[cfg(test)] |
| @@ -343,6 +426,31 @@ fn fit_scale(bounds: Bounds<Pixels>, native: gpui::Size<gpui::DevicePixels>) -> | |||
| 343 | Some(f32::from(fitted.size.width) / native.width.0 as f32) | 426 | Some(f32::from(fitted.size.width) / native.width.0 as f32) |
| 344 | } | 427 | } |
| 345 | 428 | ||
| 429 | +/// The pure half of [`picture_bottom`]: the bottom edge of the `Contain` | ||
| 430 | +/// fit of `native` into `bounds` -- gpui's own `get_bounds`, the same call | ||
| 431 | +/// [`letterboxed_image`] paints through, so this is the frame's real edge | ||
| 432 | +/// and not aspect math reimplemented here. | ||
| 433 | +fn fitted_bottom(bounds: Bounds<Pixels>, native: gpui::Size<gpui::DevicePixels>) -> Option<f32> { | ||
| 434 | + if bounds.size.width <= px(0.) | ||
| 435 | + || bounds.size.height <= px(0.) | ||
| 436 | + || native.width.0 <= 0 | ||
| 437 | + || native.height.0 <= 0 | ||
| 438 | + { | ||
| 439 | + return None; | ||
| 440 | + } | ||
| 441 | + let fitted = gpui::ObjectFit::Contain.get_bounds(bounds, native); | ||
| 442 | + Some(f32::from(fitted.origin.y + fitted.size.height)) | ||
| 443 | +} | ||
| 444 | + | ||
| 445 | +/// Where the picture actually stops being picture: the letterboxed frame's | ||
| 446 | +/// bottom edge in window coordinates, read off the last frame's measured box | ||
| 447 | +/// ([`PICTURE_BOUNDS`]). `None` with nothing shown or before the first paint | ||
| 448 | +/// measured anything -- [`menu_floor`] falls back to the region's bottom. | ||
| 449 | +pub(crate) fn picture_bottom(player: &Player) -> Option<f32> { | ||
| 450 | + let image = player.image.clone()?; | ||
| 451 | + fitted_bottom(PICTURE_BOUNDS.with(Rc::clone).get(), image.size(0)) | ||
| 452 | +} | ||
| 453 | + | ||
| 346 | /// The picture's own fit factor against its native size, read off the last | 454 | /// The picture's own fit factor against its native size, read off the last |
| 347 | /// frame's measured box (see [`PICTURE_BOUNDS`]). `None` with nothing open | 455 | /// frame's measured box (see [`PICTURE_BOUNDS`]). `None` with nothing open |
| 348 | /// or before the first paint has measured anything. | 456 | /// or before the first paint has measured anything. |