The room's fields stretch and shrink, and remember it
Browse files at this commit- feat
- the room's fields stretch and shrink, and remember it
9 changed files +635 -49
- crates/app/src/interact.rs +1 -1
- crates/app/src/layout.rs +157 -3
- crates/app/src/main.rs +2 -2
- crates/app/src/player/timeline_edit.rs +69 -4
- crates/app/src/tests/layout.rs +253 -0
- crates/app/src/ui/bench_stance.rs +35 -6
- crates/app/src/ui/library.rs +1 -1
- crates/app/src/ui/overlays.rs +2 -2
- crates/app/src/ui/stance.rs +115 -30
crates/app/src/interact.rsmodified+1 -1
| @@ -214,7 +214,7 @@ pub(crate) fn drag_scrim(cx: &mut Context<Player>) -> Div { | |||
| 214 | /// stop following the hand on the first move. `stop_propagation` so the press | 214 | /// stop following the hand on the first move. `stop_propagation` so the press |
| 215 | /// never reaches the region under it -- a seam over the timeline must not scrub. | 215 | /// never reaches the region under it -- a seam over the timeline must not scrub. |
| 216 | pub(crate) fn divider(split: Split, cx: &mut Context<Player>) -> Div { | 216 | pub(crate) fn divider(split: Split, cx: &mut Context<Player>) -> Div { |
| 217 | - let across = matches!(split, Split::Timeline); | 217 | + let across = matches!(split, Split::Timeline | Split::Bench); |
| 218 | div() | 218 | div() |
| 219 | .flex_none() | 219 | .flex_none() |
| 220 | .when(across, |d| d.h(px(SPLIT_W)).w_full().cursor_row_resize()) | 220 | .when(across, |d| d.h(px(SPLIT_W)).w_full().cursor_row_resize()) |
crates/app/src/layout.rsmodified+157 -3
| @@ -382,14 +382,37 @@ pub(crate) const PPS_DEFAULT: f64 = 40.; | |||
| 382 | 382 | ||
| 383 | // -- the seams between the regions, and where a hand has dragged them --------- | 383 | // -- the seams between the regions, and where a hand has dragged them --------- |
| 384 | 384 | ||
| 385 | -/// Which divider a hand has hold of. The three seams the main layout has -- | 385 | +/// Which divider a hand has hold of. The legacy tree's three seams -- |
| 386 | -/// library|picture, picture|inspector and the timeline's top edge -- and so the | 386 | +/// library|picture, picture|inspector and the timeline's top edge -- plus the |
| 387 | -/// only three sizes in this window a person sets rather than is given. | 387 | +/// darkroom's own two, dock|centre and time-band|bench: `stance.rs`'s own |
| 388 | +/// `BENCH_H`/`DOCK_W` doc comments named this exact fold as the fix for | ||
| 389 | +/// "fields are not stretchable" before this diff existed. | ||
| 388 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] | 390 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 389 | pub(crate) enum Split { | 391 | pub(crate) enum Split { |
| 390 | Library, | 392 | Library, |
| 391 | Inspector, | 393 | Inspector, |
| 392 | Timeline, | 394 | Timeline, |
| 395 | + Dock, | ||
| 396 | + Bench, | ||
| 397 | +} | ||
| 398 | + | ||
| 399 | +impl Split { | ||
| 400 | + /// The two persisted seams -- library/inspector/timeline stay | ||
| 401 | + /// unpersisted, out of this diff's scope, same as before it. Read by | ||
| 402 | + /// [`load_stance_splits`] and [`save_stance_splits`] together so the | ||
| 403 | + /// two can never learn a different set of keys from each other, the | ||
| 404 | + /// gap a sixth region would otherwise fall through silently. | ||
| 405 | + const PERSISTED: [Split; 2] = [Split::Dock, Split::Bench]; | ||
| 406 | + | ||
| 407 | + fn key(self) -> &'static str { | ||
| 408 | + match self { | ||
| 409 | + Split::Library => "library", | ||
| 410 | + Split::Inspector => "inspector", | ||
| 411 | + Split::Timeline => "timeline", | ||
| 412 | + Split::Dock => "dock", | ||
| 413 | + Split::Bench => "bench", | ||
| 414 | + } | ||
| 415 | + } | ||
| 393 | } | 416 | } |
| 394 | 417 | ||
| 395 | /// How wide a divider is drawn *and* hit. Wider than the 1 px stroke it stands | 418 | /// How wide a divider is drawn *and* hit. Wider than the 1 px stroke it stands |
| @@ -409,6 +432,57 @@ pub(crate) const SIDE_MAX_FRAC: f32 = 1. / 3.; | |||
| 409 | /// timeline is asking on purpose, and the picture still keeps most of a third. | 432 | /// timeline is asking on purpose, and the picture still keeps most of a third. |
| 410 | pub(crate) const TIMELINE_MAX_SHARE: f32 = 0.7; | 433 | pub(crate) const TIMELINE_MAX_SHARE: f32 = 0.7; |
| 411 | 434 | ||
| 435 | +/// The room the ledger's own top border (`ui::stance::ledger`'s | ||
| 436 | +/// `.border_t_1()`) needs kept clear below the bench's own last content | ||
| 437 | +/// pixel. The ledger sits at a *fixed* distance from the window's own foot | ||
| 438 | +/// (`ui::stance::LEDGER_H`), not from wherever the bench's content happens | ||
| 439 | +/// to end, so if the bench's last lane row reaches exactly as far as the | ||
| 440 | +/// ledger's own top row, the ledger's border -- later in the same flex | ||
| 441 | +/// column, so it paints over whatever is already there -- wins the shared | ||
| 442 | +/// pixel rather than sitting cleanly below it. Driven, at [`BENCH_MIN_H`]'s | ||
| 443 | +/// own third clip: `bench=95` (the stack's exact content need, no spare row) | ||
| 444 | +/// still lost A1's status dot's last row to the rule; `bench=96` (one row of | ||
| 445 | +/// clearance) drew it whole. The 95-vs-96 tension is this term, not a | ||
| 446 | +/// rounding accident -- a bench exactly as tall as its content still shares | ||
| 447 | +/// its last row with the ledger's border. | ||
| 448 | +const LEDGER_SEAM_CLEARANCE: f32 = 1.; | ||
| 449 | + | ||
| 450 | +/// The least the darkroom's bench may be dragged to: derived, not measured, | ||
| 451 | +/// from the same stack `ui::stance::bench` and `ui::bench_stance::render` | ||
| 452 | +/// actually build, top to bottom -- | ||
| 453 | +/// [`crate::ui::stance::BENCH_CHROME_H`] (the "bench" section head's real | ||
| 454 | +/// line box, plus the bench div's own top border and top padding -- see its | ||
| 455 | +/// own doc comment) + [`crate::ui::bench_stance::RULER_H`] (the pinned | ||
| 456 | +/// ruler) + [`crate::ui::bench_stance::ROW_GAP`] (the gap `bench-content`'s | ||
| 457 | +/// flex column puts between the ruler and the lane column) + two lane rows | ||
| 458 | +/// at [`crate::ui::bench_stance::LANE_MIN_H`] each (the darkroom's own floor | ||
| 459 | +/// of two lanes -- V1, A1, `bench_stance::render`'s own no-session | ||
| 460 | +/// fallback) + one more `ROW_GAP` between those two rows (`bench-lanes`'s | ||
| 461 | +/// own flex gap) + [`LEDGER_SEAM_CLEARANCE`] (the row the ledger's own | ||
| 462 | +/// border needs kept clear, see its own doc comment). Below this the | ||
| 463 | +/// `bench-lanes` column asks for more height than `bench-content`'s flex_1 | ||
| 464 | +/// gives it, and since that column scrolls rather than clips visibly, the | ||
| 465 | +/// shortfall comes off the bottom row's own pixels unscrolled -- A1's | ||
| 466 | +/// clip-bar border and status dot, first. `LANE_MIN_H` itself is derived | ||
| 467 | +/// from what a lane head actually draws (its own doc comment), not a number | ||
| 468 | +/// copied from nowhere: an earlier floor of `82.` used a `LANE_MIN_H` of | ||
| 469 | +/// `18.` that fit only the lane label and let every lane's status dot | ||
| 470 | +/// overflow into the row beneath it, invisible everywhere but the last | ||
| 471 | +/// lane, which has no next row to spill into and clipped straight into the | ||
| 472 | +/// ledger instead. | ||
| 473 | +/// | ||
| 474 | +/// A third driven pass at the next floor (`94.`, `BENCH_CHROME_H` still | ||
| 475 | +/// undercounted at `20.`) clipped A1's dot again, by one row -- two 1px | ||
| 476 | +/// causes stacked, not one 2px guess: `BENCH_CHROME_H`'s own undercount | ||
| 477 | +/// (`20.` vs its real `21.`) and this term, `LEDGER_SEAM_CLEARANCE`, which | ||
| 478 | +/// the formula never carried at all. `21 + 22 + 2 + 48 + 2 + 1` = `96.`. | ||
| 479 | +pub(crate) const BENCH_MIN_H: f32 = crate::ui::stance::BENCH_CHROME_H | ||
| 480 | + + crate::ui::bench_stance::RULER_H | ||
| 481 | + + crate::ui::bench_stance::ROW_GAP | ||
| 482 | + + 2. * crate::ui::bench_stance::LANE_MIN_H | ||
| 483 | + + crate::ui::bench_stance::ROW_GAP | ||
| 484 | + + LEDGER_SEAM_CLEARANCE; | ||
| 485 | + | ||
| 412 | /// What a hand has done to the three seams: the size it dragged each panel to, | 486 | /// What a hand has done to the three seams: the size it dragged each panel to, |
| 413 | /// or `None` where nobody has touched one and the window's own share still | 487 | /// or `None` where nobody has touched one and the window's own share still |
| 414 | /// answers. Held in the model and not recomputed, so a size outlives the | 488 | /// answers. Held in the model and not recomputed, so a size outlives the |
| @@ -419,6 +493,8 @@ pub(crate) struct Splits { | |||
| 419 | library: Option<f32>, | 493 | library: Option<f32>, |
| 420 | inspector: Option<f32>, | 494 | inspector: Option<f32>, |
| 421 | timeline: Option<f32>, | 495 | timeline: Option<f32>, |
| 496 | + dock: Option<f32>, | ||
| 497 | + bench: Option<f32>, | ||
| 422 | } | 498 | } |
| 423 | 499 | ||
| 424 | impl Splits { | 500 | impl Splits { |
| @@ -427,6 +503,8 @@ impl Splits { | |||
| 427 | Split::Library => self.library, | 503 | Split::Library => self.library, |
| 428 | Split::Inspector => self.inspector, | 504 | Split::Inspector => self.inspector, |
| 429 | Split::Timeline => self.timeline, | 505 | Split::Timeline => self.timeline, |
| 506 | + Split::Dock => self.dock, | ||
| 507 | + Split::Bench => self.bench, | ||
| 430 | } | 508 | } |
| 431 | } | 509 | } |
| 432 | 510 | ||
| @@ -435,10 +513,62 @@ impl Splits { | |||
| 435 | Split::Library => &mut self.library, | 513 | Split::Library => &mut self.library, |
| 436 | Split::Inspector => &mut self.inspector, | 514 | Split::Inspector => &mut self.inspector, |
| 437 | Split::Timeline => &mut self.timeline, | 515 | Split::Timeline => &mut self.timeline, |
| 516 | + Split::Dock => &mut self.dock, | ||
| 517 | + Split::Bench => &mut self.bench, | ||
| 438 | } = Some(size); | 518 | } = Some(size); |
| 439 | } | 519 | } |
| 440 | } | 520 | } |
| 441 | 521 | ||
| 522 | +/// Where the darkroom's own two dragged sizes live -- dock and bench, the | ||
| 523 | +/// only pair with a hand on them so far. Same small, silent round trip as | ||
| 524 | +/// [`crate::ui::dock_stance`]'s tab pick: unreadable or absent leaves both | ||
| 525 | +/// `None`, which [`split_size`] already reads as "give it the window's own | ||
| 526 | +/// share". | ||
| 527 | +pub(crate) fn stance_splits_config_path() -> std::path::PathBuf { | ||
| 528 | + crate::keymap::Keymap::config_path().with_file_name("stance-splits") | ||
| 529 | +} | ||
| 530 | + | ||
| 531 | +pub(crate) fn load_stance_splits() -> Splits { | ||
| 532 | + load_stance_splits_from(&stance_splits_config_path()) | ||
| 533 | +} | ||
| 534 | + | ||
| 535 | +/// One `split=pixels` line per touched seam, read from `path` -- factored out | ||
| 536 | +/// of [`load_stance_splits`] so a test can round-trip a scratch file instead | ||
| 537 | +/// of the real config. | ||
| 538 | +pub(crate) fn load_stance_splits_from(path: &std::path::Path) -> Splits { | ||
| 539 | + let mut splits = Splits::default(); | ||
| 540 | + if let Ok(text) = std::fs::read_to_string(path) { | ||
| 541 | + for line in text.lines() { | ||
| 542 | + let Some((key, value)) = line.split_once('=') else { continue }; | ||
| 543 | + let Ok(px) = value.trim().parse::<f32>() else { continue }; | ||
| 544 | + let Some(split) = Split::PERSISTED.into_iter().find(|s| s.key() == key) else { | ||
| 545 | + continue; | ||
| 546 | + }; | ||
| 547 | + splits.set(split, px); | ||
| 548 | + } | ||
| 549 | + } | ||
| 550 | + splits | ||
| 551 | +} | ||
| 552 | + | ||
| 553 | +/// Writes the sizes a hand has actually dragged -- the legacy three stay | ||
| 554 | +/// unpersisted, as they already were before this diff (out of its scope). | ||
| 555 | +/// Walks [`Split::PERSISTED`] rather than a hand-written `if let` per field, | ||
| 556 | +/// so a region added there needs no second, separately-maintained list here. | ||
| 557 | +pub(crate) fn save_stance_splits(splits: &Splits) { | ||
| 558 | + save_stance_splits_to(splits, &stance_splits_config_path()); | ||
| 559 | +} | ||
| 560 | + | ||
| 561 | +pub(crate) fn save_stance_splits_to(splits: &Splits, path: &std::path::Path) { | ||
| 562 | + let text: String = Split::PERSISTED | ||
| 563 | + .into_iter() | ||
| 564 | + .filter_map(|split| splits.get(split).map(|px| format!("{}={px}\n", split.key()))) | ||
| 565 | + .collect(); | ||
| 566 | + if let Some(dir) = path.parent() { | ||
| 567 | + let _ = std::fs::create_dir_all(dir); | ||
| 568 | + } | ||
| 569 | + let _ = std::fs::write(path, text); | ||
| 570 | +} | ||
| 571 | + | ||
| 442 | /// How small a panel may be dragged and how large: the floor is the size it | 572 | /// How small a panel may be dragged and how large: the floor is the size it |
| 443 | /// still shows something at, the ceiling is what its neighbour needs to stay a | 573 | /// still shows something at, the ceiling is what its neighbour needs to stay a |
| 444 | /// region rather than a sliver. Neither end is passable -- a panel dragged to | 574 | /// region rather than a sliver. Neither end is passable -- a panel dragged to |
| @@ -454,6 +584,23 @@ pub(crate) fn split_bounds( | |||
| 454 | match split { | 584 | match split { |
| 455 | Split::Library => (LIBRARY_MIN_W, w * SIDE_MAX_FRAC), | 585 | Split::Library => (LIBRARY_MIN_W, w * SIDE_MAX_FRAC), |
| 456 | Split::Inspector => (INSPECTOR_MIN_W, w * SIDE_MAX_FRAC), | 586 | Split::Inspector => (INSPECTOR_MIN_W, w * SIDE_MAX_FRAC), |
| 587 | + // The dock is the darkroom's one side column -- same shape as the | ||
| 588 | + // legacy inspector's, so it takes the legacy inspector's own floor | ||
| 589 | + // and ceiling rather than a second pair that would only ever agree. | ||
| 590 | + Split::Dock => (INSPECTOR_MIN_W, w * SIDE_MAX_FRAC), | ||
| 591 | + // The bench is the darkroom's own timeline, but its ceiling is not | ||
| 592 | + // [`Split::Timeline`]'s window-share one: a bench that swallows | ||
| 593 | + // `TIMELINE_MAX_SHARE` of a 720p window leaves the screen and its | ||
| 594 | + // scale plate only 100px, which is not a picture any more. The | ||
| 595 | + // ceiling instead leaves the screen and time band their own fixed | ||
| 596 | + // 160px -- room for the scale plate, the picture and a sliver of | ||
| 597 | + // letterbox -- and `BENCH_MIN_H` still wins the clamp on anything | ||
| 598 | + // shorter than that. | ||
| 599 | + Split::Bench => ( | ||
| 600 | + BENCH_MIN_H, | ||
| 601 | + (h - crate::ui::stance::TIME_BAND_H - crate::ui::stance::LEDGER_H - 160.) | ||
| 602 | + .max(BENCH_MIN_H), | ||
| 603 | + ), | ||
| 457 | // One whole lane under the chrome, the scrollbar strip's row included | 604 | // One whole lane under the chrome, the scrollbar strip's row included |
| 458 | // while there is one to draw ([`timeline_fixed_h`]): a timeline | 605 | // while there is one to draw ([`timeline_fixed_h`]): a timeline |
| 459 | // shorter than that is a ruler with nothing beneath it. A second | 606 | // shorter than that is a ruler with nothing beneath it. A second |
| @@ -497,6 +644,8 @@ pub(crate) fn split_size( | |||
| 497 | Split::Library => library_w(w), | 644 | Split::Library => library_w(w), |
| 498 | Split::Inspector => inspector_w(w), | 645 | Split::Inspector => inspector_w(w), |
| 499 | Split::Timeline => timeline_h(lanes, scroll).min(h * TIMELINE_SHARE), | 646 | Split::Timeline => timeline_h(lanes, scroll).min(h * TIMELINE_SHARE), |
| 647 | + Split::Dock => crate::ui::stance::DOCK_W, | ||
| 648 | + Split::Bench => crate::ui::stance::BENCH_H, | ||
| 500 | }; | 649 | }; |
| 501 | // The floor wins a window too small to honour both ends: a panel at its | 650 | // The floor wins a window too small to honour both ends: a panel at its |
| 502 | // floor is still a panel, and `clamp` panics outright on a ceiling under | 651 | // floor is still a panel, and `clamp` panics outright on a ceiling under |
| @@ -517,6 +666,11 @@ pub(crate) fn split_drag_size(split: Split, at: Point<Pixels>, window: Size<Pixe | |||
| 517 | // This seam sits above the edit toolbar, which is a fixed height: what | 666 | // This seam sits above the edit toolbar, which is a fixed height: what |
| 518 | // is under the pointer is the toolbar and the timeline together. | 667 | // is under the pointer is the toolbar and the timeline together. |
| 519 | Split::Timeline => h - y - TOOLBAR_H - SPLIT_W / 2., | 668 | Split::Timeline => h - y - TOOLBAR_H - SPLIT_W / 2., |
| 669 | + // The dock sits on the same right edge the inspector does. | ||
| 670 | + Split::Dock => w - x - SPLIT_W / 2., | ||
| 671 | + // The bench sits above the fixed ledger strip, the bench's own | ||
| 672 | + // reason the timeline's formula reads the toolbar. | ||
| 673 | + Split::Bench => h - y - crate::ui::stance::LEDGER_H - SPLIT_W / 2., | ||
| 520 | } | 674 | } |
| 521 | } | 675 | } |
| 522 | 676 | ||
crates/app/src/main.rsmodified+2 -2
| @@ -72,7 +72,7 @@ use engine::{Clip, Codec, ExportHandle, Frame, MediaBitrate, PlaybackSession}; | |||
| 72 | use gpui::{ | 72 | use gpui::{ |
| 73 | AnyElement, App, Application, Bounds, ClickEvent, Context, Corners, CursorStyle, Div, | 73 | AnyElement, App, Application, Bounds, ClickEvent, Context, Corners, CursorStyle, Div, |
| 74 | DragMoveEvent, FocusHandle, KeyDownEvent, KeyUpEvent, MouseButton, MouseDownEvent, | 74 | DragMoveEvent, FocusHandle, KeyDownEvent, KeyUpEvent, MouseButton, MouseDownEvent, |
| 75 | - MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, Point, RenderImage, ScrollDelta, | 75 | + MouseExitEvent, MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, Point, RenderImage, ScrollDelta, |
| 76 | ScrollHandle, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign, TitlebarOptions, | 76 | ScrollHandle, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign, TitlebarOptions, |
| 77 | Window, WindowBounds, WindowOptions, canvas, div, point, prelude::*, px, relative, rgb, rgba, | 77 | Window, WindowBounds, WindowOptions, canvas, div, point, prelude::*, px, relative, rgb, rgba, |
| 78 | size, | 78 | size, |
| @@ -912,7 +912,7 @@ fn main() { | |||
| 912 | hw_caps: None, | 912 | hw_caps: None, |
| 913 | clipboard: None, | 913 | clipboard: None, |
| 914 | scrubbing: false, | 914 | scrubbing: false, |
| 915 | - splits: Splits::default(), | 915 | + splits: load_stance_splits(), |
| 916 | split_drag: None, | 916 | split_drag: None, |
| 917 | trim: None, | 917 | trim: None, |
| 918 | fade_drag: None, | 918 | fade_drag: None, |
crates/app/src/player/timeline_edit.rsmodified+69 -4
| @@ -3,6 +3,18 @@ | |||
| 3 | 3 | ||
| 4 | use crate::*; | 4 | use crate::*; |
| 5 | 5 | ||
| 6 | +/// Whether a seam that just lost its drag owes a disk write -- exactly the | ||
| 7 | +/// two persisted seams ([`Split::PERSISTED`]), same rule `drag_release`'s own | ||
| 8 | +/// `matches!` already lived by. Pulled out to its own free function, taking | ||
| 9 | +/// no `Context`, so [`Player::drag_left_window`]'s save-on-leave guard is | ||
| 10 | +/// checkable without a `TestAppContext` this test binary has none of (see | ||
| 11 | +/// `tests/media.rs`'s own note on the same limit) -- the wiring that calls it | ||
| 12 | +/// from a live `MouseExitEvent` still cannot be, and is proven by driving | ||
| 13 | +/// instead. | ||
| 14 | +pub(crate) fn split_drag_owes_save(split: Option<Split>) -> bool { | ||
| 15 | + matches!(split, Some(Split::Dock) | Some(Split::Bench)) | ||
| 16 | +} | ||
| 17 | + | ||
| 6 | impl Player { | 18 | impl Player { |
| 7 | /// Splits the clip under the playhead. Metadata only: the timeline->source | 19 | /// Splits the clip under the playhead. Metadata only: the timeline->source |
| 8 | /// mapping is unchanged, so nothing reseeks and no flag is touched. | 20 | /// mapping is unchanged, so nothing reseeks and no flag is touched. |
| @@ -1479,6 +1491,32 @@ impl Player { | |||
| 1479 | /// where it sits (`Hitbox::is_hovered`, window.rs:788), so while a card is | 1491 | /// where it sits (`Hitbox::is_hovered`, window.rs:788), so while a card is |
| 1480 | /// up the root is not hovered anywhere under it and hears none of this: the | 1492 | /// up the root is not hovered anywhere under it and hears none of this: the |
| 1481 | /// press set a value and the drag then froze on it. | 1493 | /// press set a value and the drag then froze on it. |
| 1494 | + /// The one event a release outside the window's own surface is | ||
| 1495 | + /// guaranteed to raise: Wayland (and X11) tell a client its pointer has | ||
| 1496 | + /// left, unconditionally, whether or not a button is down | ||
| 1497 | + /// (`wl_pointer::Event::Leave`, gpui's `platform/linux/wayland/client.rs`) | ||
| 1498 | + /// -- but a `Button::Released` that lands *after* that Leave is never | ||
| 1499 | + /// forwarded at all, because gpui only dispatches it to the window that | ||
| 1500 | + /// is still `mouse_focused_window`, and Leave just cleared that. So the | ||
| 1501 | + /// seam's own release handler (`drag_release`, bound to `on_mouse_up`) | ||
| 1502 | + /// can be skipped entirely by a drag that ends outside the frame, and | ||
| 1503 | + /// `drag_move`'s "next incidental motion" fallback above only fires once | ||
| 1504 | + /// the pointer comes back -- which a restart before that motion, or a | ||
| 1505 | + /// release the user never revisits, may never do. This is the one | ||
| 1506 | + /// dependable earlier moment: the size a `Split::Dock`/`Split::Bench` | ||
| 1507 | + /// drag is holding right now is exactly what a release beyond this | ||
| 1508 | + /// instant would have kept, since no further sample can arrive from | ||
| 1509 | + /// outside the surface, so it is saved here rather than left to chance. | ||
| 1510 | + /// Wired at the root via [`Player::mount_mouse_exit_listener`]'s | ||
| 1511 | + /// `window.on_mouse_event`, the low-level door `Interactivity`'s fluent | ||
| 1512 | + /// `on_mouse_*` builders do not expose for `MouseExitEvent`. | ||
| 1513 | + pub(crate) fn drag_left_window(&mut self, cx: &mut Context<Self>) { | ||
| 1514 | + if split_drag_owes_save(self.split_drag) { | ||
| 1515 | + save_stance_splits(&self.splits); | ||
| 1516 | + } | ||
| 1517 | + cx.notify(); | ||
| 1518 | + } | ||
| 1519 | + | ||
| 1482 | pub(crate) fn drag_move( | 1520 | pub(crate) fn drag_move( |
| 1483 | &mut self, | 1521 | &mut self, |
| 1484 | event: &MouseMoveEvent, | 1522 | event: &MouseMoveEvent, |
| @@ -1518,9 +1556,16 @@ impl Player { | |||
| 1518 | match event.pressed_button { | 1556 | match event.pressed_button { |
| 1519 | Some(MouseButton::Left) => self.drag_split(split, event.position, window, cx), | 1557 | Some(MouseButton::Left) => self.drag_split(split, event.position, window, cx), |
| 1520 | // Released outside the window: the up below never came, so this | 1558 | // Released outside the window: the up below never came, so this |
| 1521 | - // is where the gesture ends. Nothing is owed -- every move has | 1559 | + // is where the gesture ends. The size is already written to |
| 1522 | - // already been written. | 1560 | + // `self.splits`, but the darkroom's two persisted seams still |
| 1523 | - _ => self.split_drag = None, | 1561 | + // owe the save `drag_release` would have paid -- without it |
| 1562 | + // the drag holds for the session and reverts on restart. | ||
| 1563 | + _ => { | ||
| 1564 | + self.split_drag = None; | ||
| 1565 | + if split_drag_owes_save(Some(split)) { | ||
| 1566 | + save_stance_splits(&self.splits); | ||
| 1567 | + } | ||
| 1568 | + } | ||
| 1524 | } | 1569 | } |
| 1525 | return; | 1570 | return; |
| 1526 | } | 1571 | } |
| @@ -1651,6 +1696,13 @@ impl Player { | |||
| 1651 | } | 1696 | } |
| 1652 | if let Some(split) = self.split_drag.take() { | 1697 | if let Some(split) = self.split_drag.take() { |
| 1653 | self.drag_split(split, event.position, window, cx); | 1698 | self.drag_split(split, event.position, window, cx); |
| 1699 | + // The darkroom's own two seams outlive the window: written once, | ||
| 1700 | + // on the release that ends the gesture, the same small-file | ||
| 1701 | + // round trip `ui::dock_stance`'s tab pick uses -- not on every | ||
| 1702 | + // sample in between, which `drag_move` above never owed a write. | ||
| 1703 | + if split_drag_owes_save(Some(split)) { | ||
| 1704 | + save_stance_splits(&self.splits); | ||
| 1705 | + } | ||
| 1654 | return; | 1706 | return; |
| 1655 | } | 1707 | } |
| 1656 | if std::mem::take(&mut self.eq_dragging) { | 1708 | if std::mem::take(&mut self.eq_dragging) { |
| @@ -1718,8 +1770,21 @@ impl Player { | |||
| 1718 | window: &mut Window, | 1770 | window: &mut Window, |
| 1719 | cx: &mut Context<Self>, | 1771 | cx: &mut Context<Self>, |
| 1720 | ) { | 1772 | ) { |
| 1773 | + let viewport = window.viewport_size(); | ||
| 1774 | + let raw = split_drag_size(split, at, viewport); | ||
| 1775 | + // Clamped here, through the same door [`Player::split_px`] draws | ||
| 1776 | + // through, at the one place a hand's pick ever reaches | ||
| 1777 | + // `self.splits` -- so what a later save writes to disk is never a | ||
| 1778 | + // number the seam itself would have refused to draw at. A floor | ||
| 1779 | + // enforced only on read still leaves a `bench=-1` line in the file. | ||
| 1780 | + let lanes = self | ||
| 1781 | + .session | ||
| 1782 | + .as_ref() | ||
| 1783 | + .map_or(2, |session| session.lanes().len()); | ||
| 1784 | + let view = self.view(); | ||
| 1785 | + let scroll = view.duration > view.span(); | ||
| 1721 | self.splits | 1786 | self.splits |
| 1722 | - .set(split, split_drag_size(split, at, window.viewport_size())); | 1787 | + .set(split, split_size(split, Some(raw), lanes, viewport, scroll)); |
| 1723 | cx.notify(); | 1788 | cx.notify(); |
| 1724 | } | 1789 | } |
| 1725 | } | 1790 | } |
crates/app/src/tests/layout.rsmodified+253 -0
| @@ -1736,6 +1736,252 @@ fn a_dragged_divider_stops_before_either_panel_disappears() { | |||
| 1736 | ); | 1736 | ); |
| 1737 | } | 1737 | } |
| 1738 | 1738 | ||
| 1739 | +/// The darkroom's own two seams (`Split::Dock`, `Split::Bench`): a hand may | ||
| 1740 | +/// not drag either past its floor or its ceiling, the same promise | ||
| 1741 | +/// [`a_dragged_divider_stops_before_either_panel_disappears`] makes for the | ||
| 1742 | +/// legacy three. | ||
| 1743 | +#[test] | ||
| 1744 | +fn the_darkroom_seams_stop_before_either_side_disappears() { | ||
| 1745 | + use crate::ui::theme::INSPECTOR_MIN_W; | ||
| 1746 | + use crate::{BENCH_MIN_H, SIDE_MAX_FRAC, SPLIT_W, Split, split_bounds, split_drag_size, split_size}; | ||
| 1747 | + use gpui::{point, px, size}; | ||
| 1748 | + | ||
| 1749 | + let window = size(px(1280.), px(720.)); | ||
| 1750 | + // Untouched, each answers its own stance default. | ||
| 1751 | + assert_eq!( | ||
| 1752 | + split_size(Split::Dock, None, 2, window, false), | ||
| 1753 | + crate::ui::stance::DOCK_W | ||
| 1754 | + ); | ||
| 1755 | + assert_eq!( | ||
| 1756 | + split_size(Split::Bench, None, 2, window, false), | ||
| 1757 | + crate::ui::stance::BENCH_H | ||
| 1758 | + ); | ||
| 1759 | + // Dragged, it is what the hand asked for... | ||
| 1760 | + assert_eq!(split_size(Split::Dock, Some(400.), 2, window, false), 400.); | ||
| 1761 | + assert_eq!(split_size(Split::Bench, Some(300.), 2, window, false), 300.); | ||
| 1762 | + // ...and never past the floor... | ||
| 1763 | + assert_eq!( | ||
| 1764 | + split_size(Split::Dock, Some(0.), 2, window, false), | ||
| 1765 | + INSPECTOR_MIN_W | ||
| 1766 | + ); | ||
| 1767 | + assert_eq!( | ||
| 1768 | + split_size(Split::Bench, Some(0.), 2, window, false), | ||
| 1769 | + BENCH_MIN_H | ||
| 1770 | + ); | ||
| 1771 | + // ...nor the ceiling. The bench's is not a window-share one -- it leaves | ||
| 1772 | + // the screen and time band a fixed 160px, [`split_bounds`]'s own reason. | ||
| 1773 | + assert_eq!( | ||
| 1774 | + split_size(Split::Dock, Some(9000.), 2, window, false), | ||
| 1775 | + 1280. * SIDE_MAX_FRAC | ||
| 1776 | + ); | ||
| 1777 | + let (_, bench_max) = split_bounds(Split::Bench, 2, window, false); | ||
| 1778 | + assert_eq!( | ||
| 1779 | + split_size(Split::Bench, Some(9000.), 2, window, false), | ||
| 1780 | + bench_max | ||
| 1781 | + ); | ||
| 1782 | + assert!(bench_max < 720.); | ||
| 1783 | + // The pointer turned into a size, half a strip off for the same reason | ||
| 1784 | + // the legacy seams read it that way. | ||
| 1785 | + assert_eq!( | ||
| 1786 | + split_drag_size(Split::Dock, point(px(1000.), px(400.)), window), | ||
| 1787 | + 280. - SPLIT_W / 2. | ||
| 1788 | + ); | ||
| 1789 | + assert_eq!( | ||
| 1790 | + split_drag_size(Split::Bench, point(px(300.), px(500.)), window), | ||
| 1791 | + 220. - crate::ui::stance::LEDGER_H - SPLIT_W / 2. | ||
| 1792 | + ); | ||
| 1793 | +} | ||
| 1794 | + | ||
| 1795 | +/// At the bench's floor, both default lanes' rows actually fit inside the | ||
| 1796 | +/// `bench-lanes` column `bench_stance::render` gives them -- not just each | ||
| 1797 | +/// row's own clamped height, but their *sum plus the gap between them*, | ||
| 1798 | +/// since `bench-lanes` scrolls rather than clipping visibly and a sum that | ||
| 1799 | +/// overruns the column loses its bottom row's pixels off-screen, unscrolled | ||
| 1800 | +/// (this session's F1: the A1 lane's clip-bar border and status dot, cut by | ||
| 1801 | +/// ~2px at the old `BENCH_MIN_H = 80.`). | ||
| 1802 | +#[test] | ||
| 1803 | +fn both_default_lanes_fit_the_bench_at_its_floor() { | ||
| 1804 | + use crate::BENCH_MIN_H; | ||
| 1805 | + use crate::ui::bench_stance::{LANE_MIN_H, ROW_GAP, RULER_H, row_h}; | ||
| 1806 | + use crate::ui::stance::BENCH_CHROME_H; | ||
| 1807 | + | ||
| 1808 | + let box_h = BENCH_MIN_H - BENCH_CHROME_H; | ||
| 1809 | + let avail = box_h - RULER_H - ROW_GAP; | ||
| 1810 | + let h = row_h(2, avail); | ||
| 1811 | + // Not an exact `LANE_MIN_H` any more: `BENCH_MIN_H` now carries one spare | ||
| 1812 | + // row (`layout::LEDGER_SEAM_CLEARANCE`) so the last lane's own last pixel | ||
| 1813 | + // never shares a row with the ledger's border, which lands here as | ||
| 1814 | + // `avail` being a touch over the two-rows-plus-gap tight fit. | ||
| 1815 | + assert!(h >= LANE_MIN_H, "the floor should give both lanes at least their own minimum ({h} < {LANE_MIN_H})"); | ||
| 1816 | + let content = 2. * h + ROW_GAP; | ||
| 1817 | + assert!( | ||
| 1818 | + content <= avail + 1e-4, | ||
| 1819 | + "the two lane rows ({content}px) overrun the column ({avail}px) -- \ | ||
| 1820 | + the bottom lane's pixels get cut, unscrolled" | ||
| 1821 | + ); | ||
| 1822 | +} | ||
| 1823 | + | ||
| 1824 | +/// `BENCH_CHROME_H` on its own: the previous test's `box_h = BENCH_MIN_H - | ||
| 1825 | +/// BENCH_CHROME_H` line trusts `BENCH_CHROME_H` to already be correct, so it | ||
| 1826 | +/// cannot catch `BENCH_CHROME_H` itself drifting -- which is exactly how the | ||
| 1827 | +/// third clip (this session's) survived it: the constant undercounted the | ||
| 1828 | +/// section head's real line box by 1px and this test's predecessor never | ||
| 1829 | +/// looked. Recomputes what `ui::stance::bench` actually draws above | ||
| 1830 | +/// `bench_stance::render`'s content -- the div's own `.border_t_1()` (1px) | ||
| 1831 | +/// + its `py(4.)` top padding + the section head's real line box at gpui's | ||
| 1832 | +/// golden-ratio line-height, not the label's bare font size (the same trap | ||
| 1833 | +/// `a_lane_row_fits_what_its_own_head_draws` already checks for the lane | ||
| 1834 | +/// heads) -- and then checks the *whole* stack -- chrome, ruler, both gaps, | ||
| 1835 | +/// both lanes, and the clear row the ledger's own fixed-position border | ||
| 1836 | +/// needs (`LEDGER_SEAM_CLEARANCE`, not exported, so this recomputes it as | ||
| 1837 | +/// `BENCH_MIN_H` minus every other named term) -- fits inside `BENCH_MIN_H` | ||
| 1838 | +/// with nothing left over uncounted. This binary carries no `TestAppContext` | ||
| 1839 | +/// to mount `ui::stance::bench` and `ui::stance::ledger` for real and read | ||
| 1840 | +/// painted bounds back, so it stays geometry-only, same as its neighbours. | ||
| 1841 | +#[test] | ||
| 1842 | +fn the_whole_bench_stack_fits_its_own_floor_with_the_ledger_seam_clear() { | ||
| 1843 | + use crate::BENCH_MIN_H; | ||
| 1844 | + use crate::ui::bench_stance::{LANE_MIN_H, ROW_GAP, RULER_H}; | ||
| 1845 | + use crate::ui::stance::BENCH_CHROME_H; | ||
| 1846 | + use crate::ui::type_scale::SECTION_HEAD_PX; | ||
| 1847 | + | ||
| 1848 | + const BENCH_BORDER_T: f32 = 1.; | ||
| 1849 | + const BENCH_PY_TOP: f32 = 4.; | ||
| 1850 | + let section_head_line_h = (SECTION_HEAD_PX * 1.618_034).round(); | ||
| 1851 | + let real_chrome = BENCH_BORDER_T + BENCH_PY_TOP + section_head_line_h; | ||
| 1852 | + assert_eq!( | ||
| 1853 | + BENCH_CHROME_H, real_chrome, | ||
| 1854 | + "BENCH_CHROME_H ({BENCH_CHROME_H}) does not match what `stance::bench` \ | ||
| 1855 | + actually draws above the content ({real_chrome}px: {BENCH_BORDER_T}px \ | ||
| 1856 | + border + {BENCH_PY_TOP}px padding + {section_head_line_h}px label line \ | ||
| 1857 | + box) -- bench_stance::render gets handed the wrong box_h and lays its \ | ||
| 1858 | + rows out past its own real space" | ||
| 1859 | + ); | ||
| 1860 | + | ||
| 1861 | + // The ledger's own fixed-position border needs one more clear row below | ||
| 1862 | + // the last lane, on top of chrome + ruler + both gaps + both lanes -- | ||
| 1863 | + // recomputed here rather than importing the private | ||
| 1864 | + // `layout::LEDGER_SEAM_CLEARANCE`, so this test fails if that term is | ||
| 1865 | + // ever silently dropped from `BENCH_MIN_H`'s own sum. | ||
| 1866 | + let content_need = real_chrome + RULER_H + ROW_GAP + 2. * LANE_MIN_H + ROW_GAP; | ||
| 1867 | + let ledger_seam_clearance = BENCH_MIN_H - content_need; | ||
| 1868 | + assert!( | ||
| 1869 | + ledger_seam_clearance >= 1. - 1e-4, | ||
| 1870 | + "BENCH_MIN_H ({BENCH_MIN_H}) leaves only {ledger_seam_clearance}px \ | ||
| 1871 | + between the last lane row and the ledger's own top border -- driven \ | ||
| 1872 | + at exactly the content's need (0px clearance) the border still won \ | ||
| 1873 | + the shared pixel and clipped the last lane's status dot" | ||
| 1874 | + ); | ||
| 1875 | +} | ||
| 1876 | + | ||
| 1877 | +/// The previous test asserted lane ROWS fit the bench column -- not that a | ||
| 1878 | +/// lane's own CONTENT fits its row, which is how the defect it fixed | ||
| 1879 | +/// survived it: at the old `LANE_MIN_H` of `18.` both lanes fit the bench | ||
| 1880 | +/// exactly while V1's status dot silently overflowed into A1's row (masked) | ||
| 1881 | +/// and A1's overflowed into the ledger (visible, since A1 has no next row). | ||
| 1882 | +/// This binary carries no `TestAppContext` to mount a real `lane_row` and | ||
| 1883 | +/// read its painted bounds back, so this recomputes the label's own line | ||
| 1884 | +/// box from the constants `lane_row` actually draws with (gpui's default | ||
| 1885 | +/// `TextStyle::line_height` is the golden ratio, not 1x the font size -- | ||
| 1886 | +/// see `LANE_MIN_H`'s own doc comment) rather than a literal, so a future | ||
| 1887 | +/// shrink of `LANE_MIN_H` or growth of the label size fails this instead of | ||
| 1888 | +/// silently clipping the last lane again. | ||
| 1889 | +#[test] | ||
| 1890 | +fn a_lane_row_fits_what_its_own_head_draws() { | ||
| 1891 | + use crate::ui::bench_stance::{LANE_DOT_D, LANE_HEAD_GAP, LANE_MIN_H}; | ||
| 1892 | + use crate::ui::type_scale::CHORD_METADATA_MIN_PX; | ||
| 1893 | + | ||
| 1894 | + let label_line_h = (CHORD_METADATA_MIN_PX * 1.618_034).round(); | ||
| 1895 | + let content = label_line_h + LANE_HEAD_GAP + LANE_DOT_D; | ||
| 1896 | + assert!( | ||
| 1897 | + LANE_MIN_H >= content, | ||
| 1898 | + "LANE_MIN_H ({LANE_MIN_H}) is shorter than what a lane head actually \ | ||
| 1899 | + draws ({content}px: {label_line_h}px label line box + \ | ||
| 1900 | + {LANE_HEAD_GAP}px gap + {LANE_DOT_D}px dot) -- the status dot \ | ||
| 1901 | + would spill past the row, invisible until it is the last lane \ | ||
| 1902 | + with no next row to spill into" | ||
| 1903 | + ); | ||
| 1904 | +} | ||
| 1905 | + | ||
| 1906 | +/// The notice plate's own anchor ([`crate::ui::stance::notice_bottom_offset`]) | ||
| 1907 | +/// keeps it off the bench, at *any* bench height -- not merely the floor -- | ||
| 1908 | +/// because its bottom offset always lands at or above the bench's own top | ||
| 1909 | +/// edge. `Player`'s live tree has no `TestAppContext` in this binary to mount | ||
| 1910 | +/// a real `notice_plate` in and read its painted bounds back, so this checks | ||
| 1911 | +/// the pure geometry the anchor is built from instead (F2: previously the | ||
| 1912 | +/// plate sat at a fixed `LEDGER_H + 6.` off the ledger and covered the | ||
| 1913 | +/// V1/A1 lane chips whenever the bench was short enough for the plate's own | ||
| 1914 | +/// height to reach past it). | ||
| 1915 | +#[test] | ||
| 1916 | +fn the_notice_plate_cannot_reach_the_bench_at_any_height() { | ||
| 1917 | + use crate::BENCH_MIN_H; | ||
| 1918 | + use crate::ui::stance::{BENCH_H, LEDGER_H, notice_bottom_offset}; | ||
| 1919 | + | ||
| 1920 | + for bench_h in [BENCH_MIN_H, BENCH_H, 400.] { | ||
| 1921 | + let notice_bottom = notice_bottom_offset(bench_h); | ||
| 1922 | + // The bench sits directly above the ledger in the centre column, so | ||
| 1923 | + // its own top edge (measured the same way, from the column's foot) | ||
| 1924 | + // is exactly `LEDGER_H + bench_h`. | ||
| 1925 | + let bench_top = LEDGER_H + bench_h; | ||
| 1926 | + assert!( | ||
| 1927 | + notice_bottom >= bench_top, | ||
| 1928 | + "notice bottom {notice_bottom} sits below the bench's top {bench_top} \ | ||
| 1929 | + at bench_h={bench_h} -- the plate can cover a lane row" | ||
| 1930 | + ); | ||
| 1931 | + } | ||
| 1932 | +} | ||
| 1933 | + | ||
| 1934 | +/// A round trip through the file: what is saved is what the next load reads | ||
| 1935 | +/// back, one seam touched and the other left at its default -- a scratch | ||
| 1936 | +/// path, not the real config, the same isolation `keymap::tests`' own | ||
| 1937 | +/// `load_from`/`save_to` already takes. | ||
| 1938 | +#[test] | ||
| 1939 | +fn a_saved_seam_survives_a_reload() { | ||
| 1940 | + use crate::{Split, Splits, load_stance_splits_from, save_stance_splits_to}; | ||
| 1941 | + | ||
| 1942 | + let dir = engine::scratch::Scratch::dir("edith-stance-splits"); | ||
| 1943 | + let path = dir.join("stance-splits"); | ||
| 1944 | + | ||
| 1945 | + let mut splits = Splits::default(); | ||
| 1946 | + splits.set(Split::Dock, 333.); | ||
| 1947 | + save_stance_splits_to(&splits, &path); | ||
| 1948 | + let loaded = load_stance_splits_from(&path); | ||
| 1949 | + assert_eq!(loaded.get(Split::Dock), Some(333.)); | ||
| 1950 | + assert_eq!(loaded.get(Split::Bench), None); | ||
| 1951 | +} | ||
| 1952 | + | ||
| 1953 | +/// The guard [`crate::split_drag_owes_save`] runs at the moment a drag ends | ||
| 1954 | +/// with no further pointer event ever coming (`Player::drag_left_window`, | ||
| 1955 | +/// wired to a live `MouseExitEvent` a `TestAppContext`-less test binary | ||
| 1956 | +/// cannot raise -- see `tests/media.rs`'s own note on the same limit, and | ||
| 1957 | +/// the harness drive `D2` in this session's report for the wiring itself). | ||
| 1958 | +/// What *is* checkable here without a window: exactly the two persisted | ||
| 1959 | +/// seams owe that save, the same set `Split::PERSISTED` already names, and a | ||
| 1960 | +/// drag that never started (`None`) owes nothing. | ||
| 1961 | +#[test] | ||
| 1962 | +fn only_the_two_persisted_seams_owe_a_save_when_a_drag_loses_the_window() { | ||
| 1963 | + use crate::{Split, player::timeline_edit::split_drag_owes_save}; | ||
| 1964 | + | ||
| 1965 | + assert!(split_drag_owes_save(Some(Split::Dock))); | ||
| 1966 | + assert!(split_drag_owes_save(Some(Split::Bench))); | ||
| 1967 | + assert!(!split_drag_owes_save(Some(Split::Library))); | ||
| 1968 | + assert!(!split_drag_owes_save(Some(Split::Inspector))); | ||
| 1969 | + assert!(!split_drag_owes_save(Some(Split::Timeline))); | ||
| 1970 | + assert!(!split_drag_owes_save(None)); | ||
| 1971 | +} | ||
| 1972 | + | ||
| 1973 | +/// A missing file leaves every region at its default -- the silent fallback | ||
| 1974 | +/// `load_stance_splits`'s doc comment promises. | ||
| 1975 | +#[test] | ||
| 1976 | +fn a_missing_stance_splits_file_leaves_every_region_at_its_default() { | ||
| 1977 | + use crate::{Split, load_stance_splits_from}; | ||
| 1978 | + | ||
| 1979 | + let dir = engine::scratch::Scratch::dir("edith-stance-splits-missing"); | ||
| 1980 | + let splits = load_stance_splits_from(&dir.join("nothing-here")); | ||
| 1981 | + assert_eq!(splits.get(Split::Dock), None); | ||
| 1982 | + assert_eq!(splits.get(Split::Bench), None); | ||
| 1983 | +} | ||
| 1984 | + | ||
| 1739 | /// Every seam in the main layout has a handle on it, and every region draws | 1985 | /// Every seam in the main layout has a handle on it, and every region draws |
| 1740 | /// itself at the size that handle sets: a region still measuring itself off the | 1986 | /// itself at the size that handle sets: a region still measuring itself off the |
| 1741 | /// window's own share is a panel whose divider moves nothing. | 1987 | /// window's own share is a panel whose divider moves nothing. |
| @@ -1748,6 +1994,13 @@ fn every_seam_in_the_layout_has_a_divider_on_it() { | |||
| 1748 | "{split} has no divider to drag" | 1994 | "{split} has no divider to drag" |
| 1749 | ); | 1995 | ); |
| 1750 | } | 1996 | } |
| 1997 | + let stance = src_text("ui/stance.rs"); | ||
| 1998 | + for split in ["Split::Dock", "Split::Bench"] { | ||
| 1999 | + assert!( | ||
| 2000 | + stance.contains(&format!("divider({split}")), | ||
| 2001 | + "{split} has no divider to drag" | ||
| 2002 | + ); | ||
| 2003 | + } | ||
| 1751 | // The strip is drawn wide enough to hit and says which way it moves -- | 2004 | // The strip is drawn wide enough to hit and says which way it moves -- |
| 1752 | // an invisible hairline is a feature nobody finds. | 2005 | // an invisible hairline is a feature nobody finds. |
| 1753 | let interact = src_text("interact.rs"); | 2006 | let interact = src_text("interact.rs"); |
crates/app/src/ui/bench_stance.rsmodified+35 -6
| @@ -45,7 +45,7 @@ use crate::ui::widgets::*; | |||
| 45 | /// The pinned ruler's own height, above the lane stack -- tall enough for a | 45 | /// The pinned ruler's own height, above the lane stack -- tall enough for a |
| 46 | /// tick line plus a mono `MM:SS` label under it (DESIGN §5's "tick marks with | 46 | /// tick line plus a mono `MM:SS` label under it (DESIGN §5's "tick marks with |
| 47 | /// mono ink3 timecodes"). | 47 | /// mono ink3 timecodes"). |
| 48 | -const RULER_H: f32 = 22.; | 48 | +pub(crate) const RULER_H: f32 = 22.; |
| 49 | /// The stops a tick interval is picked from (DESIGN §5, the previous | 49 | /// The stops a tick interval is picked from (DESIGN §5, the previous |
| 50 | /// builder's own note): the smallest one whose pixel width at the current | 50 | /// builder's own note): the smallest one whose pixel width at the current |
| 51 | /// zoom still clears [`TICK_MIN_PX`]. | 51 | /// zoom still clears [`TICK_MIN_PX`]. |
| @@ -62,12 +62,34 @@ const PLATE_W: f32 = 74.; | |||
| 62 | /// the legacy timeline's `HEADER_W` since a darkroom lane carries no mix/eye | 62 | /// the legacy timeline's `HEADER_W` since a darkroom lane carries no mix/eye |
| 63 | /// button yet (deferred with the rest of the header's verbs). | 63 | /// button yet (deferred with the rest of the header's verbs). |
| 64 | const HEAD_W: f32 = 28.; | 64 | const HEAD_W: f32 = 28.; |
| 65 | -const ROW_GAP: f32 = 2.; | 65 | +pub(crate) const ROW_GAP: f32 = 2.; |
| 66 | /// DESIGN §7: lanes compress evenly up to this many rows before the column | 66 | /// DESIGN §7: lanes compress evenly up to this many rows before the column |
| 67 | /// scrolls behind the pinned ruler and heads instead of compressing further. | 67 | /// scrolls behind the pinned ruler and heads instead of compressing further. |
| 68 | const LANES_COMPRESS: usize = 5; | 68 | const LANES_COMPRESS: usize = 5; |
| 69 | const LANE_FULL_H: f32 = 40.; | 69 | const LANE_FULL_H: f32 = 40.; |
| 70 | -const LANE_MIN_H: f32 = 18.; | 70 | +/// The gap `lane_row`'s pinned head column puts between the lane label and |
| 71 | +/// its status dot (its own `.gap(px(...))`), named so [`LANE_MIN_H`]'s | ||
| 72 | +/// derivation below doesn't repeat the literal blind. | ||
| 73 | +pub(crate) const LANE_HEAD_GAP: f32 = 2.; | ||
| 74 | +/// The status dot's own diameter (`lane_row`'s "Pinned track head" child, | ||
| 75 | +/// its own `.w(px(...)).h(px(...))`). | ||
| 76 | +pub(crate) const LANE_DOT_D: f32 = 4.; | ||
| 77 | +/// The lane label's own line box at [`type_scale::CHORD_METADATA_MIN_PX`]: | ||
| 78 | +/// gpui's default `TextStyle::line_height` is not 1x the font size but the | ||
| 79 | +/// golden ratio (`gpui::phi()` == `relative(1.618034)`), and `lane_row` | ||
| 80 | +/// never calls `.line_height()` on the head label to override it -- so this | ||
| 81 | +/// is what the label really occupies, not its glyph height. | ||
| 82 | +/// round(12. * 1.618034) would be wrong here: the head uses | ||
| 83 | +/// `CHORD_METADATA_MIN_PX` (11.), so round(11. * 1.618034) = round(17.798) | ||
| 84 | +/// = 18. | ||
| 85 | +const LANE_LABEL_LINE_H: f32 = 18.; | ||
| 86 | +/// The least a lane row may be: what its own head actually draws, not a | ||
| 87 | +/// number copied from nowhere. The old `18.` fit only the label's line box | ||
| 88 | +/// and let every lane's status dot overflow into the row beneath it -- | ||
| 89 | +/// invisible everywhere but the last lane, which has no next row to spill | ||
| 90 | +/// into and clipped straight into the ledger instead (adversarial pass on | ||
| 91 | +/// the `BENCH_MIN_H = 82` floor). | ||
| 92 | +pub(crate) const LANE_MIN_H: f32 = LANE_LABEL_LINE_H + LANE_HEAD_GAP + LANE_DOT_D; | ||
| 71 | 93 | ||
| 72 | /// One clip's degradation tier (DESIGN §7), picked off the clip's own worth | 94 | /// One clip's degradation tier (DESIGN §7), picked off the clip's own worth |
| 73 | /// in pixels (`span`, unclamped) rather than its drawn floor | 95 | /// in pixels (`span`, unclamped) rather than its drawn floor |
| @@ -141,7 +163,7 @@ fn tier(span: f32) -> Tier { | |||
| 141 | 163 | ||
| 142 | /// The lane stack's own height budget, split evenly across up to | 164 | /// The lane stack's own height budget, split evenly across up to |
| 143 | /// [`LANES_COMPRESS`] rows before the column scrolls instead (DESIGN §7). | 165 | /// [`LANES_COMPRESS`] rows before the column scrolls instead (DESIGN §7). |
| 144 | -fn row_h(lanes: usize, box_h: f32) -> f32 { | 166 | +pub(crate) fn row_h(lanes: usize, box_h: f32) -> f32 { |
| 145 | let n = lanes.clamp(1, LANES_COMPRESS) as f32; | 167 | let n = lanes.clamp(1, LANES_COMPRESS) as f32; |
| 146 | ((box_h - (n - 1.) * ROW_GAP) / n).clamp(LANE_MIN_H, LANE_FULL_H) | 168 | ((box_h - (n - 1.) * ROW_GAP) / n).clamp(LANE_MIN_H, LANE_FULL_H) |
| 147 | } | 169 | } |
| @@ -596,7 +618,7 @@ fn lane_row( | |||
| 596 | .flex_col() | 618 | .flex_col() |
| 597 | .items_center() | 619 | .items_center() |
| 598 | .justify_center() | 620 | .justify_center() |
| 599 | - .gap(px(2.)) | 621 | + .gap(px(LANE_HEAD_GAP)) |
| 600 | .bg(rgb(DARK_PANEL())) | 622 | .bg(rgb(DARK_PANEL())) |
| 601 | .cursor(CursorStyle::OpenHand) | 623 | .cursor(CursorStyle::OpenHand) |
| 602 | .on_drag(LaneDrag(lane), move |_, _, _, cx| { | 624 | .on_drag(LaneDrag(lane), move |_, _, _, cx| { |
| @@ -609,7 +631,14 @@ fn lane_row( | |||
| 609 | )) | 631 | )) |
| 610 | .text_color(rgb(INK2())) | 632 | .text_color(rgb(INK2())) |
| 611 | .child(lane.label()) | 633 | .child(lane.label()) |
| 612 | - .child(div().flex_none().w(px(4.)).h(px(4.)).rounded(px(2.)).bg(rgb(dot))), | 634 | + .child( |
| 635 | + div() | ||
| 636 | + .flex_none() | ||
| 637 | + .w(px(LANE_DOT_D)) | ||
| 638 | + .h(px(LANE_DOT_D)) | ||
| 639 | + .rounded(px(LANE_DOT_D / 2.)) | ||
| 640 | + .bg(rgb(dot)), | ||
| 641 | + ), | ||
| 613 | ) | 642 | ) |
| 614 | .child( | 643 | .child( |
| 615 | // The bed: a drop target for the Sources tab (`AssetDrag`, | 644 | // The bed: a drop target for the Sources tab (`AssetDrag`, |
crates/app/src/ui/library.rsmodified+1 -1
| @@ -688,7 +688,7 @@ impl Player { | |||
| 688 | // floor clamp and the room the list sizes against are `menu_floor`'s, | 688 | // floor clamp and the room the list sizes against are `menu_floor`'s, |
| 689 | // so a menu taller than the footprint scrolls instead of climbing | 689 | // so a menu taller than the footprint scrolls instead of climbing |
| 690 | // back over the picture. | 690 | // back over the picture. |
| 691 | - let (at, room) = menu_floor(menu.at, viewport, darkroom); | 691 | + let (at, room) = menu_floor(menu.at, viewport, darkroom, self.split_px(Split::Bench, viewport)); |
| 692 | let list_h = menu_rows_h(rows.len(), room); | 692 | let list_h = menu_rows_h(rows.len(), room); |
| 693 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); | 693 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); |
| 694 | let full: SharedString = path.display().to_string().into(); | 694 | let full: SharedString = path.display().to_string().into(); |
crates/app/src/ui/overlays.rsmodified+2 -2
| @@ -670,7 +670,7 @@ impl Player { | |||
| 670 | // footprint (`room`), not the whole window, so a menu taller than | 670 | // footprint (`room`), not the whole window, so a menu taller than |
| 671 | // the footprint scrolls inside its own plate instead of walking its | 671 | // the footprint scrolls inside its own plate instead of walking its |
| 672 | // clamped top edge back up over the picture ([`menu_floor`]). | 672 | // clamped top edge back up over the picture ([`menu_floor`]). |
| 673 | - let (at, room) = menu_floor(menu.at, viewport, self.darkroom); | 673 | + let (at, room) = menu_floor(menu.at, viewport, self.darkroom, self.split_px(Split::Bench, viewport)); |
| 674 | let list_h = menu_rows_h(rows.len(), room); | 674 | let list_h = menu_rows_h(rows.len(), room); |
| 675 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); | 675 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); |
| 676 | let full: SharedString = source | 676 | let full: SharedString = source |
| @@ -832,7 +832,7 @@ impl Player { | |||
| 832 | .collect(); | 832 | .collect(); |
| 833 | // The window's own room, and the list scrolls only where the window has | 833 | // The window's own room, and the list scrolls only where the window has |
| 834 | // none -- the clip menu's rule, one function for both. | 834 | // none -- the clip menu's rule, one function for both. |
| 835 | - let (at, room) = menu_floor(picker.at, viewport, darkroom); | 835 | + let (at, room) = menu_floor(picker.at, viewport, darkroom, self.split_px(Split::Bench, viewport)); |
| 836 | let list_h = menu_rows_h(rows.len(), room); | 836 | let list_h = menu_rows_h(rows.len(), room); |
| 837 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); | 837 | let (x, y) = menu_at(at, viewport, MENU_PAD * 2. + list_h); |
| 838 | Some( | 838 | Some( |
crates/app/src/ui/stance.rsmodified+115 -30
| @@ -18,18 +18,36 @@ use crate::ui::type_scale::{self, Typeset}; | |||
| 18 | /// Left rail, full height (DESIGN §5). | 18 | /// Left rail, full height (DESIGN §5). |
| 19 | const SPINE_W: f32 = 56.; | 19 | const SPINE_W: f32 = 56.; |
| 20 | /// Fixed strip under the screen: timecode, transport, cut readout, contact | 20 | /// Fixed strip under the screen: timecode, transport, cut readout, contact |
| 21 | -/// strip, Export -- all placeholder at this step. | 21 | +/// strip, Export -- all placeholder at this step. Kept `pub(crate)` for |
| 22 | -const TIME_BAND_H: f32 = 88.; | 22 | +/// `layout::split_bounds`'s bench ceiling, the same one-door reason |
| 23 | -/// corner-cut: a fixed share of the window rather than one measured against | 23 | +/// [`LEDGER_H`] already is. |
| 24 | -/// the picture's own room, matching the placeholder every other stance | 24 | +pub(crate) const TIME_BAND_H: f32 = 88.; |
| 25 | -/// region still carries at this step. Ceiling: fold into the same split the | 25 | +/// The bench's untouched height -- [`Split::Bench`]'s own default, read by |
| 26 | -/// legacy timeline's `Split::Timeline` answers once the stance grows a | 26 | +/// `layout::split_size` the same way the legacy tree's `library_w`/ |
| 27 | -/// resizable seam of its own. | 27 | +/// `inspector_w` feed `Split::Library`/`Split::Inspector`. A hand on the |
| 28 | -const BENCH_H: f32 = 200.; | 28 | +/// seam above it overrides this; nothing else does. |
| 29 | -/// Thin strip at the foot of the centre column. | 29 | +pub(crate) const BENCH_H: f32 = 200.; |
| 30 | -const LEDGER_H: f32 = 28.; | 30 | +/// Thin strip at the foot of the centre column. Read by `layout`'s |
| 31 | -/// Right side panel, fixed width, carrying the Src/Clip tab pair. | 31 | +/// `Split::Bench` drag formula (the seam sits above the fixed ledger, so a |
| 32 | -const DOCK_W: f32 = 280.; | 32 | +/// drag has to leave room for it) -- kept `pub(crate)` for that one door |
| 33 | +/// rather than a second copy of the number. | ||
| 34 | +pub(crate) const LEDGER_H: f32 = 28.; | ||
| 35 | +/// The dock's untouched width -- [`Split::Dock`]'s own default, the same | ||
| 36 | +/// role [`BENCH_H`] plays for the bench. | ||
| 37 | +pub(crate) const DOCK_W: f32 = 280.; | ||
| 38 | +/// What [`bench`] spends above `bench_stance::render`'s own content: the | ||
| 39 | +/// `bench` div's own `.border_t_1()` (1px) + its `py(4.)` top padding + | ||
| 40 | +/// the section head's real line box -- `type_scale::head()` sizes text at | ||
| 41 | +/// `SECTION_HEAD_PX` (10) but never calls `.line_height()`, so gpui's | ||
| 42 | +/// default `TextStyle::line_height` (the golden ratio, `gpui::phi()` == | ||
| 43 | +/// `1.618034`, not 1x the font size) is what it actually draws: | ||
| 44 | +/// `round(10. * 1.618034)` = `round(16.18034)` = `16`. A driven pass found | ||
| 45 | +/// this constant undercounting that line box as a bare `10`, one of the two | ||
| 46 | +/// causes of `layout::BENCH_MIN_H`'s third clip (see its own doc comment for | ||
| 47 | +/// the other). `1 + 4 + 16` = `21`. Named and `pub(crate)` rather than the | ||
| 48 | +/// `- 20.` it used to be inlined as, so `layout::BENCH_MIN_H` can add it | ||
| 49 | +/// into its own derivation instead of guessing it back out. | ||
| 50 | +pub(crate) const BENCH_CHROME_H: f32 = 21.; | ||
| 33 | 51 | ||
| 34 | /// The lowest a menu's top edge may sit and still land inside the | 52 | /// The lowest a menu's top edge may sit and still land inside the |
| 35 | /// bench/ledger/dock footprint below the screen (DESIGN §5, §9, §11 check 6): | 53 | /// bench/ledger/dock footprint below the screen (DESIGN §5, §9, §11 check 6): |
| @@ -37,9 +55,12 @@ const DOCK_W: f32 = 280.; | |||
| 37 | /// the picture just because the pointer is there. `overlays.rs`/`library.rs` | 55 | /// the picture just because the pointer is there. `overlays.rs`/`library.rs` |
| 38 | /// clamp their `menu.at.y` against this before handing it to `menu_at`, only | 56 | /// clamp their `menu.at.y` against this before handing it to `menu_at`, only |
| 39 | /// in the darkroom stance -- the legacy tree has no fixed screen/time-band | 57 | /// in the darkroom stance -- the legacy tree has no fixed screen/time-band |
| 40 | -/// split for this to mean anything against, and must not move. | 58 | +/// split for this to mean anything against, and must not move. `bench_h` is |
| 41 | -pub(crate) fn below_picture_floor(viewport_h: f32) -> f32 { | 59 | +/// the live, possibly hand-dragged `Split::Bench` height (`Player::split_px`) |
| 42 | - (viewport_h - TIME_BAND_H - BENCH_H - LEDGER_H).max(0.) | 60 | +/// rather than the fixed [`BENCH_H`] default, so a widened bench clamps the |
| 61 | +/// menu against the room actually left, not the room it started with. | ||
| 62 | +pub(crate) fn below_picture_floor(viewport_h: f32, bench_h: f32) -> f32 { | ||
| 63 | + (viewport_h - TIME_BAND_H - bench_h - LEDGER_H).max(0.) | ||
| 43 | } | 64 | } |
| 44 | 65 | ||
| 45 | /// The floor-clamped placement for every scrolling menu (clip context menu, | 66 | /// The floor-clamped placement for every scrolling menu (clip context menu, |
| @@ -59,11 +80,12 @@ pub(crate) fn menu_floor( | |||
| 59 | at: Point<Pixels>, | 80 | at: Point<Pixels>, |
| 60 | viewport: Size<Pixels>, | 81 | viewport: Size<Pixels>, |
| 61 | darkroom: bool, | 82 | darkroom: bool, |
| 83 | + bench_h: f32, | ||
| 62 | ) -> (Point<Pixels>, Size<Pixels>) { | 84 | ) -> (Point<Pixels>, Size<Pixels>) { |
| 63 | if !darkroom { | 85 | if !darkroom { |
| 64 | return (at, viewport); | 86 | return (at, viewport); |
| 65 | } | 87 | } |
| 66 | - let floor = below_picture_floor(f32::from(viewport.height)); | 88 | + let floor = below_picture_floor(f32::from(viewport.height), bench_h); |
| 67 | let at = point(at.x, px(f32::from(at.y).max(floor))); | 89 | let at = point(at.x, px(f32::from(at.y).max(floor))); |
| 68 | let room = size(viewport.width, px(f32::from(viewport.height) - floor)); | 90 | let room = size(viewport.width, px(f32::from(viewport.height) - floor)); |
| 69 | (at, room) | 91 | (at, room) |
| @@ -83,8 +105,8 @@ mod menu_floor_tests { | |||
| 83 | #[test] | 105 | #[test] |
| 84 | fn a_menu_taller_than_the_footprint_stays_pinned_to_the_floor_not_walked_back_over_it() { | 106 | fn a_menu_taller_than_the_footprint_stays_pinned_to_the_floor_not_walked_back_over_it() { |
| 85 | let viewport = size(px(1280.), px(720.)); | 107 | let viewport = size(px(1280.), px(720.)); |
| 86 | - let floor = below_picture_floor(f32::from(viewport.height)); | 108 | + let floor = below_picture_floor(f32::from(viewport.height), BENCH_H); |
| 87 | - let (at, room) = menu_floor(point(px(300.), px(20.)), viewport, true); | 109 | + let (at, room) = menu_floor(point(px(300.), px(20.)), viewport, true, BENCH_H); |
| 88 | assert_eq!(f32::from(at.y), floor); | 110 | assert_eq!(f32::from(at.y), floor); |
| 89 | // 396px of rows (the charter's measured menu height) does not fit in | 111 | // 396px of rows (the charter's measured menu height) does not fit in |
| 90 | // the 316px footprint room, so it must be capped to it, not the | 112 | // the 316px footprint room, so it must be capped to it, not the |
| @@ -425,11 +447,14 @@ fn time_band(player: &mut Player, position: f64, cx: &mut Context<Player>) -> im | |||
| 425 | 447 | ||
| 426 | /// Lanes, under the time band. `canvas` is the bench background too (DESIGN | 448 | /// Lanes, under the time band. `canvas` is the bench background too (DESIGN |
| 427 | /// §2's token table), so it shares its surface with the screen above it. | 449 | /// §2's token table), so it shares its surface with the screen above it. |
| 428 | -fn bench(player: &mut Player, cx: &mut Context<Player>) -> impl IntoElement { | 450 | +/// Height comes from [`Player::split_px`] now, not the fixed [`BENCH_H`]: |
| 451 | +/// the seam [`crate::ui::stance::render`] mounts above this region is what | ||
| 452 | +/// answers "ui fields are not stretchable" for the bench. | ||
| 453 | +fn bench(player: &mut Player, bench_h: f32, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 429 | div() | 454 | div() |
| 430 | .id("stance-bench") | 455 | .id("stance-bench") |
| 431 | .flex_none() | 456 | .flex_none() |
| 432 | - .h(px(BENCH_H)) | 457 | + .h(px(bench_h)) |
| 433 | // §4: lanes take 0 radius. | 458 | // §4: lanes take 0 radius. |
| 434 | .rounded(px(0.)) | 459 | .rounded(px(0.)) |
| 435 | .bg(rgb(DARK_CANVAS())) | 460 | .bg(rgb(DARK_CANVAS())) |
| @@ -440,7 +465,7 @@ fn bench(player: &mut Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 440 | .px(px(12.)) | 465 | .px(px(12.)) |
| 441 | .py(px(4.)) | 466 | .py(px(4.)) |
| 442 | .child(section_head("bench")) | 467 | .child(section_head("bench")) |
| 443 | - .child(bench_stance::render(player, BENCH_H - 20., cx)) | 468 | + .child(bench_stance::render(player, bench_h - BENCH_CHROME_H, cx)) |
| 444 | } | 469 | } |
| 445 | 470 | ||
| 446 | /// Which of the three §8 severities a notice's own words carry. Reuses | 471 | /// Which of the three §8 severities a notice's own words carry. Reuses |
| @@ -461,22 +486,40 @@ fn notice_severity(message: &str) -> u32 { | |||
| 461 | } | 486 | } |
| 462 | } | 487 | } |
| 463 | 488 | ||
| 464 | -/// A notice plate (DESIGN §8): one at a time, rising above the ledger, its | 489 | +/// [`notice_plate`]'s own `bottom` offset, pulled out as a pure function so |
| 490 | +/// a `TestAppContext`-less test binary (this crate's own, no live `Context` | ||
| 491 | +/// to mount a real `notice_plate` in) can still check the plate never lands | ||
| 492 | +/// over the bench, for any `bench_h` -- without duplicating the arithmetic | ||
| 493 | +/// by hand and risking the two drifting apart. | ||
| 494 | +pub(crate) fn notice_bottom_offset(bench_h: f32) -> f32 { | ||
| 495 | + LEDGER_H + bench_h + 6. | ||
| 496 | +} | ||
| 497 | + | ||
| 498 | +/// A notice plate (DESIGN §8): one at a time, rising above the *bench*, its | ||
| 465 | /// severity a 3px left spine rather than a colour flood. Fed by the same | 499 | /// severity a 3px left spine rather than a colour flood. Fed by the same |
| 466 | /// [`Player::notify_user`]/`notices` queue the legacy bar reads | 500 | /// [`Player::notify_user`]/`notices` queue the legacy bar reads |
| 467 | /// ([`Player::notice_bar`]) -- no second notice channel. Dismissal is | 501 | /// ([`Player::notice_bar`]) -- no second notice channel. Dismissal is |
| 468 | /// already wired: [`render`]'s `on_key_down` calls `dismiss_notice()` on | 502 | /// already wired: [`render`]'s `on_key_down` calls `dismiss_notice()` on |
| 469 | /// every stroke, the same door the legacy handler uses. | 503 | /// every stroke, the same door the legacy handler uses. |
| 470 | /// | 504 | /// |
| 505 | +/// Anchored off `bench_h` rather than a fixed offset off the ledger: at the | ||
| 506 | +/// bench's floor a fixed `LEDGER_H + 6.` bottom offset put the plate right | ||
| 507 | +/// over the V1/A1 lane chips -- a transient message hiding the lanes for as | ||
| 508 | +/// long as it sat there. Floating it `bench_h` further up puts its bottom | ||
| 509 | +/// edge at the bench's own *top* edge for any bench height, so it always | ||
| 510 | +/// sits in the divider/time-band's slack above the bench rather than over | ||
| 511 | +/// the lanes, and never has to reserve room in the bench itself for a | ||
| 512 | +/// message that is not always there. | ||
| 513 | +/// | ||
| 471 | /// corner-cut: amber's "carries a jump action" is not wired -- the queue | 514 | /// corner-cut: amber's "carries a jump action" is not wired -- the queue |
| 472 | /// only ever held plain text, no structured jump target, in either the | 515 | /// only ever held plain text, no structured jump target, in either the |
| 473 | /// legacy bar or here. Ceiling: give `notify_user` an optional jump payload | 516 | /// legacy bar or here. Ceiling: give `notify_user` an optional jump payload |
| 474 | /// once a call site actually has one to carry. | 517 | /// once a call site actually has one to carry. |
| 475 | -fn notice_plate(message: SharedString) -> impl IntoElement { | 518 | +fn notice_plate(message: SharedString, bench_h: f32) -> impl IntoElement { |
| 476 | div() | 519 | div() |
| 477 | .id("stance-notice") | 520 | .id("stance-notice") |
| 478 | .absolute() | 521 | .absolute() |
| 479 | - .bottom(px(LEDGER_H + 6.)) | 522 | + .bottom(px(notice_bottom_offset(bench_h))) |
| 480 | .left(px(12.)) | 523 | .left(px(12.)) |
| 481 | .max_w(px(360.)) | 524 | .max_w(px(360.)) |
| 482 | .flex() | 525 | .flex() |
| @@ -567,18 +610,45 @@ fn ledger(player: &Player, position: f64) -> impl IntoElement { | |||
| 567 | /// The dock: the only side panel, right, fixed width, carrying the Src/Clip | 610 | /// The dock: the only side panel, right, fixed width, carrying the Src/Clip |
| 568 | /// tab pair (DESIGN §5). The frame is drawn here; `dock_stance.rs` owns the | 611 | /// tab pair (DESIGN §5). The frame is drawn here; `dock_stance.rs` owns the |
| 569 | /// tab row and both tabs' content (DESIGN §12 step 4). | 612 | /// tab row and both tabs' content (DESIGN §12 step 4). |
| 570 | -fn dock(player: &Player, window_h: Pixels, cx: &mut Context<Player>) -> impl IntoElement { | 613 | +/// Width comes from [`Player::split_px`] now, not the fixed [`DOCK_W`]: the |
| 614 | +/// seam [`crate::ui::stance::render`] mounts to its left is what answers | ||
| 615 | +/// "ui fields are not stretchable" for the dock. | ||
| 616 | +fn dock(player: &Player, dock_w: f32, window_h: Pixels, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 571 | div() | 617 | div() |
| 572 | .id("stance-dock") | 618 | .id("stance-dock") |
| 573 | .flex_none() | 619 | .flex_none() |
| 574 | - .w(px(DOCK_W)) | 620 | + .w(px(dock_w)) |
| 575 | .h_full() | 621 | .h_full() |
| 576 | .bg(rgb(DARK_PANEL())) | 622 | .bg(rgb(DARK_PANEL())) |
| 577 | .border_l_1() | 623 | .border_l_1() |
| 578 | .border_color(rgba(DARK_SEAM())) | 624 | .border_color(rgba(DARK_SEAM())) |
| 579 | .flex() | 625 | .flex() |
| 580 | .flex_col() | 626 | .flex_col() |
| 581 | - .child(dock_stance::render(player, DOCK_W, window_h, cx)) | 627 | + .child(dock_stance::render(player, dock_w, window_h, cx)) |
| 628 | +} | ||
| 629 | + | ||
| 630 | +/// A zero-size element whose only job is `window.on_mouse_event`'s door: | ||
| 631 | +/// `Interactivity`'s fluent `on_mouse_*` builders (the ones `render`'s root | ||
| 632 | +/// div uses for the drag itself, just below) have no `MouseExitEvent` case, | ||
| 633 | +/// so this is the lowest rung that reaches it -- registered fresh every | ||
| 634 | +/// frame, the same way `canvas()` is already used elsewhere in this crate | ||
| 635 | +/// for paint-time access `div()` does not expose. See | ||
| 636 | +/// [`Player::drag_left_window`] for why this event, and not a release, is | ||
| 637 | +/// what a seam drag ending outside the window is saved on. | ||
| 638 | +fn mouse_exit_listener(cx: &mut Context<Player>) -> impl IntoElement { | ||
| 639 | + let player = cx.entity(); | ||
| 640 | + canvas( | ||
| 641 | + |_, _, _| (), | ||
| 642 | + move |_, _, window, _| { | ||
| 643 | + window.on_mouse_event(move |_: &MouseExitEvent, phase, _window, cx| { | ||
| 644 | + if phase == gpui::DispatchPhase::Bubble { | ||
| 645 | + player.update(cx, |this, cx| this.drag_left_window(cx)); | ||
| 646 | + } | ||
| 647 | + }); | ||
| 648 | + }, | ||
| 649 | + ) | ||
| 650 | + .absolute() | ||
| 651 | + .size(px(0.)) | ||
| 582 | } | 652 | } |
| 583 | 653 | ||
| 584 | /// The whole stance: spine, screen, time band, bench, ledger, dock, in the | 654 | /// The whole stance: spine, screen, time band, bench, ledger, dock, in the |
| @@ -593,6 +663,12 @@ pub(crate) fn render( | |||
| 593 | let window_size = window.viewport_size(); | 663 | let window_size = window.viewport_size(); |
| 594 | let window_h = window_size.height; | 664 | let window_h = window_size.height; |
| 595 | let position = player.playhead(player.drawn_duration()); | 665 | let position = player.playhead(player.drawn_duration()); |
| 666 | + // The two seams a hand may drag (`Split::Dock`, `Split::Bench`): read | ||
| 667 | + // through the same door every legacy region measures itself by | ||
| 668 | + // ([`Player::split_px`]), so a dragged size and a drawn one cannot | ||
| 669 | + // disagree here either. | ||
| 670 | + let dock_w = player.split_px(Split::Dock, window_size); | ||
| 671 | + let bench_h = player.split_px(Split::Bench, window_size); | ||
| 596 | div() | 672 | div() |
| 597 | .id("stance-room") | 673 | .id("stance-room") |
| 598 | .track_focus(&player.focus) | 674 | .track_focus(&player.focus) |
| @@ -739,9 +815,16 @@ pub(crate) fn render( | |||
| 739 | cx.notify(); | 815 | cx.notify(); |
| 740 | } | 816 | } |
| 741 | })) | 817 | })) |
| 818 | + // The seam drag is tracked on the root, same reason the legacy | ||
| 819 | + // ruler-scrub is (render.rs): the pointer outruns the 6px divider | ||
| 820 | + // hitbox on the first move, so only the whole-window root keeps | ||
| 821 | + // hearing it once a `Split::Dock`/`Split::Bench` drag has started. | ||
| 822 | + .on_mouse_move(cx.listener(Player::drag_move)) | ||
| 823 | + .on_mouse_up(MouseButton::Left, cx.listener(Player::drag_release)) | ||
| 742 | .size_full() | 824 | .size_full() |
| 743 | .flex() | 825 | .flex() |
| 744 | .bg(rgb(DARK_CANVAS())) | 826 | .bg(rgb(DARK_CANVAS())) |
| 827 | + .child(mouse_exit_listener(cx)) | ||
| 745 | .child(spine(player, cx)) | 828 | .child(spine(player, cx)) |
| 746 | .child( | 829 | .child( |
| 747 | div() | 830 | div() |
| @@ -753,10 +836,11 @@ pub(crate) fn render( | |||
| 753 | .flex_col() | 836 | .flex_col() |
| 754 | .child(screen(player, position, window, cx)) | 837 | .child(screen(player, position, window, cx)) |
| 755 | .child(time_band(player, position, cx)) | 838 | .child(time_band(player, position, cx)) |
| 756 | - .child(bench(player, cx)) | 839 | + .child(divider(Split::Bench, cx)) |
| 840 | + .child(bench(player, bench_h, cx)) | ||
| 757 | .child(ledger(player, position)) | 841 | .child(ledger(player, position)) |
| 758 | .when_some(player.notices.front().cloned(), |el, n| { | 842 | .when_some(player.notices.front().cloned(), |el, n| { |
| 759 | - el.child(notice_plate(n)) | 843 | + el.child(notice_plate(n, bench_h)) |
| 760 | }) | 844 | }) |
| 761 | .when(player.keys_open, |el| el.child(keys_overlay(player))) | 845 | .when(player.keys_open, |el| el.child(keys_overlay(player))) |
| 762 | // The two menus (DESIGN §9: "verbs of the thing under the | 846 | // The two menus (DESIGN §9: "verbs of the thing under the |
| @@ -780,5 +864,6 @@ pub(crate) fn render( | |||
| 780 | .children(player.export_progress_card(cx)) | 864 | .children(player.export_progress_card(cx)) |
| 781 | .children(player.picker_card(window_size, cx)), | 865 | .children(player.picker_card(window_size, cx)), |
| 782 | ) | 866 | ) |
| 783 | - .child(dock(player, window_h, cx)) | 867 | + .child(divider(Split::Dock, cx)) |
| 868 | + .child(dock(player, dock_w, window_h, cx)) | ||
| 784 | } | 869 | } |