The seams answer a dragging hand
Browse files at this commite964420c710f5f2542944bbad9af85aa4f892788Parent: 2d435c2- feat
- the seams answer a dragging hand
8 changed files +201 -32
- crates/app/src/interact.rs +1 -1
- crates/app/src/layout.rs +76 -3
- crates/app/src/main.rs +1 -1
- crates/app/src/player/timeline_edit.rs +7 -0
- crates/app/src/tests/layout.rs +62 -0
- crates/app/src/ui/library.rs +1 -1
- crates/app/src/ui/overlays.rs +2 -2
- crates/app/src/ui/stance.rs +51 -24
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+76 -3
| @@ -382,14 +382,18 @@ 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, | ||
| 393 | } | 397 | } |
| 394 | 398 | ||
| 395 | /// How wide a divider is drawn *and* hit. Wider than the 1 px stroke it stands | 399 | /// How wide a divider is drawn *and* hit. Wider than the 1 px stroke it stands |
| @@ -409,6 +413,11 @@ pub(crate) const SIDE_MAX_FRAC: f32 = 1. / 3.; | |||
| 409 | /// timeline is asking on purpose, and the picture still keeps most of a third. | 413 | /// timeline is asking on purpose, and the picture still keeps most of a third. |
| 410 | pub(crate) const TIMELINE_MAX_SHARE: f32 = 0.7; | 414 | pub(crate) const TIMELINE_MAX_SHARE: f32 = 0.7; |
| 411 | 415 | ||
| 416 | +/// The least the darkroom's bench may be dragged to: a section head and one | ||
| 417 | +/// [`LANE_H`] row -- [`bench_stance::render`]'s own floor, read here rather | ||
| 418 | +/// than duplicated so the seam and the region it drags never disagree. | ||
| 419 | +pub(crate) const BENCH_MIN_H: f32 = 20. + LANE_H; | ||
| 420 | + | ||
| 412 | /// What a hand has done to the three seams: the size it dragged each panel to, | 421 | /// 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 | 422 | /// 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 | 423 | /// answers. Held in the model and not recomputed, so a size outlives the |
| @@ -419,6 +428,8 @@ pub(crate) struct Splits { | |||
| 419 | library: Option<f32>, | 428 | library: Option<f32>, |
| 420 | inspector: Option<f32>, | 429 | inspector: Option<f32>, |
| 421 | timeline: Option<f32>, | 430 | timeline: Option<f32>, |
| 431 | + dock: Option<f32>, | ||
| 432 | + bench: Option<f32>, | ||
| 422 | } | 433 | } |
| 423 | 434 | ||
| 424 | impl Splits { | 435 | impl Splits { |
| @@ -427,6 +438,8 @@ impl Splits { | |||
| 427 | Split::Library => self.library, | 438 | Split::Library => self.library, |
| 428 | Split::Inspector => self.inspector, | 439 | Split::Inspector => self.inspector, |
| 429 | Split::Timeline => self.timeline, | 440 | Split::Timeline => self.timeline, |
| 441 | + Split::Dock => self.dock, | ||
| 442 | + Split::Bench => self.bench, | ||
| 430 | } | 443 | } |
| 431 | } | 444 | } |
| 432 | 445 | ||
| @@ -435,10 +448,54 @@ impl Splits { | |||
| 435 | Split::Library => &mut self.library, | 448 | Split::Library => &mut self.library, |
| 436 | Split::Inspector => &mut self.inspector, | 449 | Split::Inspector => &mut self.inspector, |
| 437 | Split::Timeline => &mut self.timeline, | 450 | Split::Timeline => &mut self.timeline, |
| 451 | + Split::Dock => &mut self.dock, | ||
| 452 | + Split::Bench => &mut self.bench, | ||
| 438 | } = Some(size); | 453 | } = Some(size); |
| 439 | } | 454 | } |
| 440 | } | 455 | } |
| 441 | 456 | ||
| 457 | +/// Where the darkroom's own two dragged sizes live -- dock and bench, the | ||
| 458 | +/// only pair with a hand on them so far. Same small, silent round trip as | ||
| 459 | +/// [`crate::ui::dock_stance`]'s tab pick: unreadable or absent leaves both | ||
| 460 | +/// `None`, which [`split_size`] already reads as "give it the window's own | ||
| 461 | +/// share". | ||
| 462 | +pub(crate) fn stance_splits_config_path() -> std::path::PathBuf { | ||
| 463 | + crate::keymap::Keymap::config_path().with_file_name("stance-splits") | ||
| 464 | +} | ||
| 465 | + | ||
| 466 | +pub(crate) fn load_stance_splits() -> Splits { | ||
| 467 | + let mut splits = Splits::default(); | ||
| 468 | + if let Ok(text) = std::fs::read_to_string(stance_splits_config_path()) { | ||
| 469 | + for line in text.lines() { | ||
| 470 | + let Some((key, value)) = line.split_once('=') else { continue }; | ||
| 471 | + let Ok(px) = value.trim().parse::<f32>() else { continue }; | ||
| 472 | + match key { | ||
| 473 | + "dock" => splits.dock = Some(px), | ||
| 474 | + "bench" => splits.bench = Some(px), | ||
| 475 | + _ => {} | ||
| 476 | + } | ||
| 477 | + } | ||
| 478 | + } | ||
| 479 | + splits | ||
| 480 | +} | ||
| 481 | + | ||
| 482 | +/// Writes the two sizes a hand has actually dragged -- the legacy three stay | ||
| 483 | +/// unpersisted, as they already were before this diff (out of its scope). | ||
| 484 | +pub(crate) fn save_stance_splits(splits: &Splits) { | ||
| 485 | + let mut text = String::new(); | ||
| 486 | + if let Some(d) = splits.dock { | ||
| 487 | + text += &format!("dock={d}\n"); | ||
| 488 | + } | ||
| 489 | + if let Some(b) = splits.bench { | ||
| 490 | + text += &format!("bench={b}\n"); | ||
| 491 | + } | ||
| 492 | + let path = stance_splits_config_path(); | ||
| 493 | + if let Some(dir) = path.parent() { | ||
| 494 | + let _ = std::fs::create_dir_all(dir); | ||
| 495 | + } | ||
| 496 | + let _ = std::fs::write(path, text); | ||
| 497 | +} | ||
| 498 | + | ||
| 442 | /// How small a panel may be dragged and how large: the floor is the size it | 499 | /// 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 | 500 | /// 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 | 501 | /// region rather than a sliver. Neither end is passable -- a panel dragged to |
| @@ -454,6 +511,15 @@ pub(crate) fn split_bounds( | |||
| 454 | match split { | 511 | match split { |
| 455 | Split::Library => (LIBRARY_MIN_W, w * SIDE_MAX_FRAC), | 512 | Split::Library => (LIBRARY_MIN_W, w * SIDE_MAX_FRAC), |
| 456 | Split::Inspector => (INSPECTOR_MIN_W, w * SIDE_MAX_FRAC), | 513 | Split::Inspector => (INSPECTOR_MIN_W, w * SIDE_MAX_FRAC), |
| 514 | + // The dock is the darkroom's one side column -- same shape as the | ||
| 515 | + // legacy inspector's, so it takes the legacy inspector's own floor | ||
| 516 | + // and ceiling rather than a second pair that would only ever agree. | ||
| 517 | + Split::Dock => (INSPECTOR_MIN_W, w * SIDE_MAX_FRAC), | ||
| 518 | + // The bench is the darkroom's own timeline: [`Split::Timeline`]'s | ||
| 519 | + // ceiling share, and a floor tall enough for a section head and one | ||
| 520 | + // lane row -- `bench_stance::render` draws exactly that pair, and | ||
| 521 | + // nothing shorter leaves the lane a whole row. | ||
| 522 | + Split::Bench => (BENCH_MIN_H, h * TIMELINE_MAX_SHARE), | ||
| 457 | // One whole lane under the chrome, the scrollbar strip's row included | 523 | // One whole lane under the chrome, the scrollbar strip's row included |
| 458 | // while there is one to draw ([`timeline_fixed_h`]): a timeline | 524 | // while there is one to draw ([`timeline_fixed_h`]): a timeline |
| 459 | // shorter than that is a ruler with nothing beneath it. A second | 525 | // shorter than that is a ruler with nothing beneath it. A second |
| @@ -497,6 +563,8 @@ pub(crate) fn split_size( | |||
| 497 | Split::Library => library_w(w), | 563 | Split::Library => library_w(w), |
| 498 | Split::Inspector => inspector_w(w), | 564 | Split::Inspector => inspector_w(w), |
| 499 | Split::Timeline => timeline_h(lanes, scroll).min(h * TIMELINE_SHARE), | 565 | Split::Timeline => timeline_h(lanes, scroll).min(h * TIMELINE_SHARE), |
| 566 | + Split::Dock => crate::ui::stance::DOCK_W, | ||
| 567 | + Split::Bench => crate::ui::stance::BENCH_H, | ||
| 500 | }; | 568 | }; |
| 501 | // The floor wins a window too small to honour both ends: a panel at its | 569 | // 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 | 570 | // floor is still a panel, and `clamp` panics outright on a ceiling under |
| @@ -517,6 +585,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 | 585 | // 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. | 586 | // is under the pointer is the toolbar and the timeline together. |
| 519 | Split::Timeline => h - y - TOOLBAR_H - SPLIT_W / 2., | 587 | Split::Timeline => h - y - TOOLBAR_H - SPLIT_W / 2., |
| 588 | + // The dock sits on the same right edge the inspector does. | ||
| 589 | + Split::Dock => w - x - SPLIT_W / 2., | ||
| 590 | + // The bench sits above the fixed ledger strip, the bench's own | ||
| 591 | + // reason the timeline's formula reads the toolbar. | ||
| 592 | + Split::Bench => h - y - crate::ui::stance::LEDGER_H - SPLIT_W / 2., | ||
| 520 | } | 593 | } |
| 521 | } | 594 | } |
| 522 | 595 | ||
crates/app/src/main.rsmodified+1 -1
| @@ -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+7 -0
| @@ -1651,6 +1651,13 @@ impl Player { | |||
| 1651 | } | 1651 | } |
| 1652 | if let Some(split) = self.split_drag.take() { | 1652 | if let Some(split) = self.split_drag.take() { |
| 1653 | self.drag_split(split, event.position, window, cx); | 1653 | self.drag_split(split, event.position, window, cx); |
| 1654 | + // The darkroom's own two seams outlive the window: written once, | ||
| 1655 | + // on the release that ends the gesture, the same small-file | ||
| 1656 | + // round trip `ui::dock_stance`'s tab pick uses -- not on every | ||
| 1657 | + // sample in between, which `drag_move` above never owed a write. | ||
| 1658 | + if matches!(split, Split::Dock | Split::Bench) { | ||
| 1659 | + save_stance_splits(&self.splits); | ||
| 1660 | + } | ||
| 1654 | return; | 1661 | return; |
| 1655 | } | 1662 | } |
| 1656 | if std::mem::take(&mut self.eq_dragging) { | 1663 | if std::mem::take(&mut self.eq_dragging) { |
crates/app/src/tests/layout.rsmodified+62 -0
| @@ -1736,6 +1736,61 @@ 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::{ | ||
| 1747 | + BENCH_MIN_H, SIDE_MAX_FRAC, SPLIT_W, Split, TIMELINE_MAX_SHARE, split_drag_size, split_size, | ||
| 1748 | + }; | ||
| 1749 | + use gpui::{point, px, size}; | ||
| 1750 | + | ||
| 1751 | + let window = size(px(1280.), px(720.)); | ||
| 1752 | + // Untouched, each answers its own stance default. | ||
| 1753 | + assert_eq!( | ||
| 1754 | + split_size(Split::Dock, None, 2, window, false), | ||
| 1755 | + crate::ui::stance::DOCK_W | ||
| 1756 | + ); | ||
| 1757 | + assert_eq!( | ||
| 1758 | + split_size(Split::Bench, None, 2, window, false), | ||
| 1759 | + crate::ui::stance::BENCH_H | ||
| 1760 | + ); | ||
| 1761 | + // Dragged, it is what the hand asked for... | ||
| 1762 | + assert_eq!(split_size(Split::Dock, Some(400.), 2, window, false), 400.); | ||
| 1763 | + assert_eq!(split_size(Split::Bench, Some(300.), 2, window, false), 300.); | ||
| 1764 | + // ...and never past the floor... | ||
| 1765 | + assert_eq!( | ||
| 1766 | + split_size(Split::Dock, Some(0.), 2, window, false), | ||
| 1767 | + INSPECTOR_MIN_W | ||
| 1768 | + ); | ||
| 1769 | + assert_eq!( | ||
| 1770 | + split_size(Split::Bench, Some(0.), 2, window, false), | ||
| 1771 | + BENCH_MIN_H | ||
| 1772 | + ); | ||
| 1773 | + // ...nor the ceiling. | ||
| 1774 | + assert_eq!( | ||
| 1775 | + split_size(Split::Dock, Some(9000.), 2, window, false), | ||
| 1776 | + 1280. * SIDE_MAX_FRAC | ||
| 1777 | + ); | ||
| 1778 | + assert_eq!( | ||
| 1779 | + split_size(Split::Bench, Some(9000.), 2, window, false), | ||
| 1780 | + 720. * TIMELINE_MAX_SHARE | ||
| 1781 | + ); | ||
| 1782 | + // The pointer turned into a size, half a strip off for the same reason | ||
| 1783 | + // the legacy seams read it that way. | ||
| 1784 | + assert_eq!( | ||
| 1785 | + split_drag_size(Split::Dock, point(px(1000.), px(400.)), window), | ||
| 1786 | + 280. - SPLIT_W / 2. | ||
| 1787 | + ); | ||
| 1788 | + assert_eq!( | ||
| 1789 | + split_drag_size(Split::Bench, point(px(300.), px(500.)), window), | ||
| 1790 | + 220. - crate::ui::stance::LEDGER_H - SPLIT_W / 2. | ||
| 1791 | + ); | ||
| 1792 | +} | ||
| 1793 | + | ||
| 1739 | /// Every seam in the main layout has a handle on it, and every region draws | 1794 | /// 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 | 1795 | /// 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. | 1796 | /// window's own share is a panel whose divider moves nothing. |
| @@ -1748,6 +1803,13 @@ fn every_seam_in_the_layout_has_a_divider_on_it() { | |||
| 1748 | "{split} has no divider to drag" | 1803 | "{split} has no divider to drag" |
| 1749 | ); | 1804 | ); |
| 1750 | } | 1805 | } |
| 1806 | + let stance = src_text("ui/stance.rs"); | ||
| 1807 | + for split in ["Split::Dock", "Split::Bench"] { | ||
| 1808 | + assert!( | ||
| 1809 | + stance.contains(&format!("divider({split}")), | ||
| 1810 | + "{split} has no divider to drag" | ||
| 1811 | + ); | ||
| 1812 | + } | ||
| 1751 | // The strip is drawn wide enough to hit and says which way it moves -- | 1813 | // The strip is drawn wide enough to hit and says which way it moves -- |
| 1752 | // an invisible hairline is a feature nobody finds. | 1814 | // an invisible hairline is a feature nobody finds. |
| 1753 | let interact = src_text("interact.rs"); | 1815 | let interact = src_text("interact.rs"); |
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+51 -24
| @@ -20,16 +20,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. |
| 22 | const TIME_BAND_H: f32 = 88.; | 22 | const TIME_BAND_H: f32 = 88.; |
| 23 | -/// corner-cut: a fixed share of the window rather than one measured against | 23 | +/// The bench's untouched height -- [`Split::Bench`]'s own default, read by |
| 24 | -/// the picture's own room, matching the placeholder every other stance | 24 | +/// `layout::split_size` the same way the legacy tree's `library_w`/ |
| 25 | -/// region still carries at this step. Ceiling: fold into the same split the | 25 | +/// `inspector_w` feed `Split::Library`/`Split::Inspector`. A hand on the |
| 26 | -/// legacy timeline's `Split::Timeline` answers once the stance grows a | 26 | +/// seam above it overrides this; nothing else does. |
| 27 | -/// resizable seam of its own. | 27 | +pub(crate) const BENCH_H: f32 = 200.; |
| 28 | -const BENCH_H: f32 = 200.; | 28 | +/// Thin strip at the foot of the centre column. Read by `layout`'s |
| 29 | -/// Thin strip at the foot of the centre column. | 29 | +/// `Split::Bench` drag formula (the seam sits above the fixed ledger, so a |
| 30 | -const LEDGER_H: f32 = 28.; | 30 | +/// drag has to leave room for it) -- kept `pub(crate)` for that one door |
| 31 | -/// Right side panel, fixed width, carrying the Src/Clip tab pair. | 31 | +/// rather than a second copy of the number. |
| 32 | -const DOCK_W: f32 = 280.; | 32 | +pub(crate) const LEDGER_H: f32 = 28.; |
| 33 | +/// The dock's untouched width -- [`Split::Dock`]'s own default, the same | ||
| 34 | +/// role [`BENCH_H`] plays for the bench. | ||
| 35 | +pub(crate) const DOCK_W: f32 = 280.; | ||
| 33 | 36 | ||
| 34 | /// The lowest a menu's top edge may sit and still land inside the | 37 | /// 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): | 38 | /// bench/ledger/dock footprint below the screen (DESIGN §5, §9, §11 check 6): |
| @@ -37,9 +40,12 @@ const DOCK_W: f32 = 280.; | |||
| 37 | /// the picture just because the pointer is there. `overlays.rs`/`library.rs` | 40 | /// 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 | 41 | /// 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 | 42 | /// 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. | 43 | +/// 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 { | 44 | +/// the live, possibly hand-dragged `Split::Bench` height (`Player::split_px`) |
| 42 | - (viewport_h - TIME_BAND_H - BENCH_H - LEDGER_H).max(0.) | 45 | +/// rather than the fixed [`BENCH_H`] default, so a widened bench clamps the |
| 46 | +/// menu against the room actually left, not the room it started with. | ||
| 47 | +pub(crate) fn below_picture_floor(viewport_h: f32, bench_h: f32) -> f32 { | ||
| 48 | + (viewport_h - TIME_BAND_H - bench_h - LEDGER_H).max(0.) | ||
| 43 | } | 49 | } |
| 44 | 50 | ||
| 45 | /// The floor-clamped placement for every scrolling menu (clip context menu, | 51 | /// The floor-clamped placement for every scrolling menu (clip context menu, |
| @@ -59,11 +65,12 @@ pub(crate) fn menu_floor( | |||
| 59 | at: Point<Pixels>, | 65 | at: Point<Pixels>, |
| 60 | viewport: Size<Pixels>, | 66 | viewport: Size<Pixels>, |
| 61 | darkroom: bool, | 67 | darkroom: bool, |
| 68 | + bench_h: f32, | ||
| 62 | ) -> (Point<Pixels>, Size<Pixels>) { | 69 | ) -> (Point<Pixels>, Size<Pixels>) { |
| 63 | if !darkroom { | 70 | if !darkroom { |
| 64 | return (at, viewport); | 71 | return (at, viewport); |
| 65 | } | 72 | } |
| 66 | - let floor = below_picture_floor(f32::from(viewport.height)); | 73 | + let floor = below_picture_floor(f32::from(viewport.height), bench_h); |
| 67 | let at = point(at.x, px(f32::from(at.y).max(floor))); | 74 | let at = point(at.x, px(f32::from(at.y).max(floor))); |
| 68 | let room = size(viewport.width, px(f32::from(viewport.height) - floor)); | 75 | let room = size(viewport.width, px(f32::from(viewport.height) - floor)); |
| 69 | (at, room) | 76 | (at, room) |
| @@ -83,8 +90,8 @@ mod menu_floor_tests { | |||
| 83 | #[test] | 90 | #[test] |
| 84 | fn a_menu_taller_than_the_footprint_stays_pinned_to_the_floor_not_walked_back_over_it() { | 91 | 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.)); | 92 | let viewport = size(px(1280.), px(720.)); |
| 86 | - let floor = below_picture_floor(f32::from(viewport.height)); | 93 | + let floor = below_picture_floor(f32::from(viewport.height), BENCH_H); |
| 87 | - let (at, room) = menu_floor(point(px(300.), px(20.)), viewport, true); | 94 | + let (at, room) = menu_floor(point(px(300.), px(20.)), viewport, true, BENCH_H); |
| 88 | assert_eq!(f32::from(at.y), floor); | 95 | assert_eq!(f32::from(at.y), floor); |
| 89 | // 396px of rows (the charter's measured menu height) does not fit in | 96 | // 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 | 97 | // the 316px footprint room, so it must be capped to it, not the |
| @@ -425,11 +432,14 @@ fn time_band(player: &mut Player, position: f64, cx: &mut Context<Player>) -> im | |||
| 425 | 432 | ||
| 426 | /// Lanes, under the time band. `canvas` is the bench background too (DESIGN | 433 | /// 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. | 434 | /// §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 { | 435 | +/// Height comes from [`Player::split_px`] now, not the fixed [`BENCH_H`]: |
| 436 | +/// the seam [`crate::ui::stance::render`] mounts above this region is what | ||
| 437 | +/// answers "ui fields are not stretchable" for the bench. | ||
| 438 | +fn bench(player: &mut Player, bench_h: f32, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 429 | div() | 439 | div() |
| 430 | .id("stance-bench") | 440 | .id("stance-bench") |
| 431 | .flex_none() | 441 | .flex_none() |
| 432 | - .h(px(BENCH_H)) | 442 | + .h(px(bench_h)) |
| 433 | // §4: lanes take 0 radius. | 443 | // §4: lanes take 0 radius. |
| 434 | .rounded(px(0.)) | 444 | .rounded(px(0.)) |
| 435 | .bg(rgb(DARK_CANVAS())) | 445 | .bg(rgb(DARK_CANVAS())) |
| @@ -440,7 +450,7 @@ fn bench(player: &mut Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 440 | .px(px(12.)) | 450 | .px(px(12.)) |
| 441 | .py(px(4.)) | 451 | .py(px(4.)) |
| 442 | .child(section_head("bench")) | 452 | .child(section_head("bench")) |
| 443 | - .child(bench_stance::render(player, BENCH_H - 20., cx)) | 453 | + .child(bench_stance::render(player, bench_h - 20., cx)) |
| 444 | } | 454 | } |
| 445 | 455 | ||
| 446 | /// Which of the three §8 severities a notice's own words carry. Reuses | 456 | /// Which of the three §8 severities a notice's own words carry. Reuses |
| @@ -567,18 +577,21 @@ fn ledger(player: &Player, position: f64) -> impl IntoElement { | |||
| 567 | /// The dock: the only side panel, right, fixed width, carrying the Src/Clip | 577 | /// 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 | 578 | /// 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). | 579 | /// tab row and both tabs' content (DESIGN §12 step 4). |
| 570 | -fn dock(player: &Player, window_h: Pixels, cx: &mut Context<Player>) -> impl IntoElement { | 580 | +/// Width comes from [`Player::split_px`] now, not the fixed [`DOCK_W`]: the |
| 581 | +/// seam [`crate::ui::stance::render`] mounts to its left is what answers | ||
| 582 | +/// "ui fields are not stretchable" for the dock. | ||
| 583 | +fn dock(player: &Player, dock_w: f32, window_h: Pixels, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 571 | div() | 584 | div() |
| 572 | .id("stance-dock") | 585 | .id("stance-dock") |
| 573 | .flex_none() | 586 | .flex_none() |
| 574 | - .w(px(DOCK_W)) | 587 | + .w(px(dock_w)) |
| 575 | .h_full() | 588 | .h_full() |
| 576 | .bg(rgb(DARK_PANEL())) | 589 | .bg(rgb(DARK_PANEL())) |
| 577 | .border_l_1() | 590 | .border_l_1() |
| 578 | .border_color(rgba(DARK_SEAM())) | 591 | .border_color(rgba(DARK_SEAM())) |
| 579 | .flex() | 592 | .flex() |
| 580 | .flex_col() | 593 | .flex_col() |
| 581 | - .child(dock_stance::render(player, DOCK_W, window_h, cx)) | 594 | + .child(dock_stance::render(player, dock_w, window_h, cx)) |
| 582 | } | 595 | } |
| 583 | 596 | ||
| 584 | /// The whole stance: spine, screen, time band, bench, ledger, dock, in the | 597 | /// The whole stance: spine, screen, time band, bench, ledger, dock, in the |
| @@ -593,6 +606,12 @@ pub(crate) fn render( | |||
| 593 | let window_size = window.viewport_size(); | 606 | let window_size = window.viewport_size(); |
| 594 | let window_h = window_size.height; | 607 | let window_h = window_size.height; |
| 595 | let position = player.playhead(player.drawn_duration()); | 608 | let position = player.playhead(player.drawn_duration()); |
| 609 | + // The two seams a hand may drag (`Split::Dock`, `Split::Bench`): read | ||
| 610 | + // through the same door every legacy region measures itself by | ||
| 611 | + // ([`Player::split_px`]), so a dragged size and a drawn one cannot | ||
| 612 | + // disagree here either. | ||
| 613 | + let dock_w = player.split_px(Split::Dock, window_size); | ||
| 614 | + let bench_h = player.split_px(Split::Bench, window_size); | ||
| 596 | div() | 615 | div() |
| 597 | .id("stance-room") | 616 | .id("stance-room") |
| 598 | .track_focus(&player.focus) | 617 | .track_focus(&player.focus) |
| @@ -739,6 +758,12 @@ pub(crate) fn render( | |||
| 739 | cx.notify(); | 758 | cx.notify(); |
| 740 | } | 759 | } |
| 741 | })) | 760 | })) |
| 761 | + // The seam drag is tracked on the root, same reason the legacy | ||
| 762 | + // ruler-scrub is (render.rs): the pointer outruns the 6px divider | ||
| 763 | + // hitbox on the first move, so only the whole-window root keeps | ||
| 764 | + // hearing it once a `Split::Dock`/`Split::Bench` drag has started. | ||
| 765 | + .on_mouse_move(cx.listener(Player::drag_move)) | ||
| 766 | + .on_mouse_up(MouseButton::Left, cx.listener(Player::drag_release)) | ||
| 742 | .size_full() | 767 | .size_full() |
| 743 | .flex() | 768 | .flex() |
| 744 | .bg(rgb(DARK_CANVAS())) | 769 | .bg(rgb(DARK_CANVAS())) |
| @@ -753,7 +778,8 @@ pub(crate) fn render( | |||
| 753 | .flex_col() | 778 | .flex_col() |
| 754 | .child(screen(player, position, window, cx)) | 779 | .child(screen(player, position, window, cx)) |
| 755 | .child(time_band(player, position, cx)) | 780 | .child(time_band(player, position, cx)) |
| 756 | - .child(bench(player, cx)) | 781 | + .child(divider(Split::Bench, cx)) |
| 782 | + .child(bench(player, bench_h, cx)) | ||
| 757 | .child(ledger(player, position)) | 783 | .child(ledger(player, position)) |
| 758 | .when_some(player.notices.front().cloned(), |el, n| { | 784 | .when_some(player.notices.front().cloned(), |el, n| { |
| 759 | el.child(notice_plate(n)) | 785 | el.child(notice_plate(n)) |
| @@ -780,5 +806,6 @@ pub(crate) fn render( | |||
| 780 | .children(player.export_progress_card(cx)) | 806 | .children(player.export_progress_card(cx)) |
| 781 | .children(player.picker_card(window_size, cx)), | 807 | .children(player.picker_card(window_size, cx)), |
| 782 | ) | 808 | ) |
| 783 | - .child(dock(player, window_h, cx)) | 809 | + .child(divider(Split::Dock, cx)) |
| 810 | + .child(dock(player, dock_w, window_h, cx)) | ||
| 784 | } | 811 | } |