Add Darkroom transition glyphs
Browse files at this commit6536ed7b3905ec17557ff6fbaa077fd7055e4ef7Parent: 3e04aeb- feat
- add Darkroom transition glyphs
2 changed files +169 -5
crates/app/src/tests/layout.rsmodified+36 -0
| @@ -2463,3 +2463,39 @@ fn every_chord_bound_action_has_a_darkroom_affordance_or_is_named_chord_only() { | |||
| 2463 | ); | 2463 | ); |
| 2464 | } | 2464 | } |
| 2465 | } | 2465 | } |
| 2466 | + | ||
| 2467 | +/// Transition affordances must be painted and use the existing edit state: | ||
| 2468 | +/// fades own their drag handles, an active dissolve remains a mouse toggle, | ||
| 2469 | +/// and a carried lane names the exact slot `reorder_lane` will use. | ||
| 2470 | +#[test] | ||
| 2471 | +fn darkroom_bench_wires_transition_controls_and_lane_drop_cue() { | ||
| 2472 | + let bench = src_text("ui/bench_stance.rs"); | ||
| 2473 | + let clip = &bench[bench.find("fn clip_box(").expect("the clip renderer") | ||
| 2474 | + ..bench.find("fn sub_box(").expect("the subtitle renderer")]; | ||
| 2475 | + for needle in [ | ||
| 2476 | + "fade_wedge(true)", | ||
| 2477 | + "fade_wedge(false)", | ||
| 2478 | + "dissolve_glyph()", | ||
| 2479 | + "this.start_fade_drag(lane, idx, is_in, event.position.x, cx)", | ||
| 2480 | + "this.dissolve_selected(cx)", | ||
| 2481 | + ] { | ||
| 2482 | + assert!( | ||
| 2483 | + clip.contains(needle), | ||
| 2484 | + "the Darkroom clip lost its transition affordance: {needle}" | ||
| 2485 | + ); | ||
| 2486 | + } | ||
| 2487 | + | ||
| 2488 | + let lane = &bench[bench.find("fn lane_row(").expect("the lane renderer") | ||
| 2489 | + ..bench.find("pub(crate) fn render(").expect("the bench renderer")]; | ||
| 2490 | + for needle in [ | ||
| 2491 | + "this.preview_lane_drop(event.drag(cx).0, lane, cx)", | ||
| 2492 | + "this.forget_lane_drop(lane, cx)", | ||
| 2493 | + ".lane_drop", | ||
| 2494 | + "if drop.above", | ||
| 2495 | + ] { | ||
| 2496 | + assert!( | ||
| 2497 | + lane.contains(needle), | ||
| 2498 | + "the Darkroom lane lost its reorder feedback: {needle}" | ||
| 2499 | + ); | ||
| 2500 | + } | ||
| 2501 | +} | ||
crates/app/src/ui/bench_stance.rsmodified+133 -5
| @@ -30,10 +30,10 @@ | |||
| 30 | //! started it, for the darkroom tree exactly as for the legacy one -- no | 30 | //! started it, for the darkroom tree exactly as for the legacy one -- no |
| 31 | //! root wiring lives here. | 31 | //! root wiring lives here. |
| 32 | //! | 32 | //! |
| 33 | -//! Still deferred: fades/dissolve glyphs, and the lane header's own | 33 | +//! Fade wedges, dissolve joins, and the lane header's drop-line cue reuse the |
| 34 | -//! drop-line cue (the legacy `LaneDrop` preview) -- a plain drag_over | 34 | +//! legacy interaction state: `FadeDrag` previews the ramp until release, |
| 35 | -//! highlight stands in for it here, since the cue itself is display-only and | 35 | +//! `dissolve_selected` still owns the toggle, and `LaneDrop` answers the same |
| 36 | -//! `reorder_lane` at the release does not need it. | 36 | +//! slot that `reorder_lane` commits. |
| 37 | //! | 37 | //! |
| 38 | //! `nudge_cut` and friends still act on `Player::selected` directly, with no | 38 | //! `nudge_cut` and friends still act on `Player::selected` directly, with no |
| 39 | //! element under the pointer required, and stay untouched by any of this. | 39 | //! element under the pointer required, and stay untouched by any of this. |
| @@ -180,6 +180,7 @@ fn clip_box( | |||
| 180 | lane: Lane, | 180 | lane: Lane, |
| 181 | idx: usize, | 181 | idx: usize, |
| 182 | clip: &Clip, | 182 | clip: &Clip, |
| 183 | + next: Option<Clip>, | ||
| 183 | scale: Scale, | 184 | scale: Scale, |
| 184 | picks: &[(Lane, usize)], | 185 | picks: &[(Lane, usize)], |
| 185 | pick_links: &[Option<u32>], | 186 | pick_links: &[Option<u32>], |
| @@ -202,6 +203,16 @@ fn clip_box( | |||
| 202 | let source = player.sources().get(clip.source); | 203 | let source = player.sources().get(clip.source); |
| 203 | let label = source.map(|s| file_name(&s.path)); | 204 | let label = source.map(|s| file_name(&s.path)); |
| 204 | let audio = lane.kind == LaneKind::Audio; | 205 | let audio = lane.kind == LaneKind::Audio; |
| 206 | + let fade_in = player.shown_fade_in(lane, idx, clip); | ||
| 207 | + let fade_out = player.shown_fade_out(lane, idx, clip); | ||
| 208 | + let dissolves = lane.kind == LaneKind::Video | ||
| 209 | + && clip.transition_out > 0 | ||
| 210 | + && next.is_some_and(|next| next.start == clip.end()); | ||
| 211 | + let dissolve_tip: SharedString = format!( | ||
| 212 | + "Remove dissolve — {}", | ||
| 213 | + player.keymap.display(ActionId::Dissolve) | ||
| 214 | + ) | ||
| 215 | + .into(); | ||
| 205 | let wave = source | 216 | let wave = source |
| 206 | .and_then(|s| player.waves.get(&(s.path.clone(), s.audio_stream))) | 217 | .and_then(|s| player.waves.get(&(s.path.clone(), s.audio_stream))) |
| 207 | .cloned(); | 218 | .cloned(); |
| @@ -383,6 +394,38 @@ fn clip_box( | |||
| 383 | }), | 394 | }), |
| 384 | ) | 395 | ) |
| 385 | }) | 396 | }) |
| 397 | + // Fades shade their own ramps over the waveform, including the live | ||
| 398 | + // `FadeDrag` value, so the ramp follows the hand before release. | ||
| 399 | + .when(audio, |d| { | ||
| 400 | + d.children( | ||
| 401 | + [ | ||
| 402 | + (fade_in > 0).then(|| { | ||
| 403 | + div() | ||
| 404 | + .absolute() | ||
| 405 | + .left_0() | ||
| 406 | + .top_0() | ||
| 407 | + .h_full() | ||
| 408 | + .w(px(scale | ||
| 409 | + .width_px(f64::from(fade_in) / player.fps) | ||
| 410 | + .min(width))) | ||
| 411 | + .child(fade_wedge(true)) | ||
| 412 | + }), | ||
| 413 | + (fade_out > 0).then(|| { | ||
| 414 | + div() | ||
| 415 | + .absolute() | ||
| 416 | + .right_0() | ||
| 417 | + .top_0() | ||
| 418 | + .h_full() | ||
| 419 | + .w(px(scale | ||
| 420 | + .width_px(f64::from(fade_out) / player.fps) | ||
| 421 | + .min(width))) | ||
| 422 | + .child(fade_wedge(false)) | ||
| 423 | + }), | ||
| 424 | + ] | ||
| 425 | + .into_iter() | ||
| 426 | + .flatten(), | ||
| 427 | + ) | ||
| 428 | + }) | ||
| 386 | // Name plate + trim/duration readout: one strip, DESIGN §4's plate | 429 | // Name plate + trim/duration readout: one strip, DESIGN §4's plate |
| 387 | // (canvas-on-panel), sat at the clip's top-left/top-right per the mock | 430 | // (canvas-on-panel), sat at the clip's top-left/top-right per the mock |
| 388 | // rather than the name alone hanging below the box. Its 21px height is | 431 | // rather than the name alone hanging below the box. Its 21px height is |
| @@ -444,6 +487,56 @@ fn clip_box( | |||
| 444 | .child(format!("{speed}")), | 487 | .child(format!("{speed}")), |
| 445 | ) | 488 | ) |
| 446 | }) | 489 | }) |
| 490 | + // The dissolve is the join's click target: it remains visible only | ||
| 491 | + // where the engine says two video clips really abut, and a click | ||
| 492 | + // selects that leading clip then takes the same toggle as Ctrl+X. | ||
| 493 | + .when(dissolves, |d| { | ||
| 494 | + d.child( | ||
| 495 | + div() | ||
| 496 | + .id(("bench-dissolve", lane.ord * 1000 + idx)) | ||
| 497 | + .absolute() | ||
| 498 | + .right_0() | ||
| 499 | + .top_0() | ||
| 500 | + .h_full() | ||
| 501 | + .w(px(scale | ||
| 502 | + .width_px(f64::from(clip.transition_out) / player.fps) | ||
| 503 | + .min(width))) | ||
| 504 | + .occlude() | ||
| 505 | + .cursor_pointer() | ||
| 506 | + .tooltip(move |_, cx| cx.new(|_| Tip(dissolve_tip.clone())).into()) | ||
| 507 | + .on_click(cx.listener(move |this, _, _, cx| { | ||
| 508 | + this.pick((lane, idx), false, cx); | ||
| 509 | + this.dissolve_selected(cx); | ||
| 510 | + })) | ||
| 511 | + .child(dissolve_glyph()), | ||
| 512 | + ) | ||
| 513 | + }) | ||
| 514 | + // The fade handles sit inside the trim strips, so their small top | ||
| 515 | + // corners change a ramp while the outer full-height strips still trim. | ||
| 516 | + .when(audio && trims(span), |d| { | ||
| 517 | + d.children([Edge::Start, Edge::End].into_iter().map(|edge| { | ||
| 518 | + let is_in = edge == Edge::Start; | ||
| 519 | + let mut handle = div() | ||
| 520 | + .absolute() | ||
| 521 | + .top_0() | ||
| 522 | + .w(px(FADE_HANDLE_W)) | ||
| 523 | + .h(px(FADE_HANDLE_H)) | ||
| 524 | + .occlude() | ||
| 525 | + .cursor(CursorStyle::ResizeLeftRight) | ||
| 526 | + .hover(|s| s.bg(rgb(INK2()))) | ||
| 527 | + .on_mouse_down( | ||
| 528 | + MouseButton::Left, | ||
| 529 | + cx.listener(move |this, event: &MouseDownEvent, _, cx| { | ||
| 530 | + this.start_fade_drag(lane, idx, is_in, event.position.x, cx); | ||
| 531 | + }), | ||
| 532 | + ); | ||
| 533 | + handle = match edge { | ||
| 534 | + Edge::Start => handle.left(px(EDGE_W)), | ||
| 535 | + Edge::End => handle.right(px(EDGE_W)), | ||
| 536 | + }; | ||
| 537 | + handle | ||
| 538 | + })) | ||
| 539 | + }) | ||
| 447 | // Splice gap: the lamp-white sliver at every clip's trailing edge -- | 540 | // Splice gap: the lamp-white sliver at every clip's trailing edge -- |
| 448 | // DESIGN §1 law 3's other legal white, present at every tier (a | 541 | // DESIGN §1 law 3's other legal white, present at every tier (a |
| 449 | // sliver at film scale is spine gone too, so the splice is what is | 542 | // sliver at film scale is spine gone too, so the splice is what is |
| @@ -611,7 +704,19 @@ fn lane_row( | |||
| 611 | let boxes: Vec<_> = clips | 704 | let boxes: Vec<_> = clips |
| 612 | .iter() | 705 | .iter() |
| 613 | .enumerate() | 706 | .enumerate() |
| 614 | - .map(|(idx, clip)| clip_box(player, lane, idx, clip, scale, picks, pick_links, cx)) | 707 | + .map(|(idx, clip)| { |
| 708 | + clip_box( | ||
| 709 | + player, | ||
| 710 | + lane, | ||
| 711 | + idx, | ||
| 712 | + clip, | ||
| 713 | + clips.get(idx + 1).copied(), | ||
| 714 | + scale, | ||
| 715 | + picks, | ||
| 716 | + pick_links, | ||
| 717 | + cx, | ||
| 718 | + ) | ||
| 719 | + }) | ||
| 615 | .collect(); | 720 | .collect(); |
| 616 | // The bed's other kind of box: a subtitle lane holds no `Clip` at all | 721 | // The bed's other kind of box: a subtitle lane holds no `Clip` at all |
| 617 | // (`LaneKind::Subtitle`'s own doc), so this is empty everywhere but S1.. | 722 | // (`LaneKind::Subtitle`'s own doc), so this is empty everywhere but S1.. |
| @@ -634,11 +739,15 @@ fn lane_row( | |||
| 634 | .first() | 739 | .first() |
| 635 | .map_or_else(INK4, |clip| source_tint(clip.source)); | 740 | .map_or_else(INK4, |clip| source_tint(clip.source)); |
| 636 | let head_ghost: SharedString = lane.label().into(); | 741 | let head_ghost: SharedString = lane.label().into(); |
| 742 | + let drop = player | ||
| 743 | + .lane_drop | ||
| 744 | + .filter(|drop| drop.lane == lane && cx.has_active_drag()); | ||
| 637 | div() | 745 | div() |
| 638 | .id(("bench-lane", lane.ord * 10 + lane.kind as usize)) | 746 | .id(("bench-lane", lane.ord * 10 + lane.kind as usize)) |
| 639 | .flex_none() | 747 | .flex_none() |
| 640 | .h(px(h)) | 748 | .h(px(h)) |
| 641 | .flex() | 749 | .flex() |
| 750 | + .relative() | ||
| 642 | // Dragged, the whole track moves in the stack (`LaneDrag`, | 751 | // Dragged, the whole track moves in the stack (`LaneDrag`, |
| 643 | // `Player::reorder_lane`) -- let go anywhere along the row, not just | 752 | // `Player::reorder_lane`) -- let go anywhere along the row, not just |
| 644 | // over the head column, since a slot is what is being aimed at. | 753 | // over the head column, since a slot is what is being aimed at. |
| @@ -648,6 +757,14 @@ fn lane_row( | |||
| 648 | .on_drop(cx.listener(move |this, drag: &LaneDrag, _, cx| { | 757 | .on_drop(cx.listener(move |this, drag: &LaneDrag, _, cx| { |
| 649 | this.reorder_lane(drag.0, lane, cx); | 758 | this.reorder_lane(drag.0, lane, cx); |
| 650 | })) | 759 | })) |
| 760 | + .on_drag_move( | ||
| 761 | + cx.listener(move |this, event: &DragMoveEvent<LaneDrag>, _, cx| { | ||
| 762 | + if !event.bounds.contains(&event.event.position) { | ||
| 763 | + return this.forget_lane_drop(lane, cx); | ||
| 764 | + } | ||
| 765 | + this.preview_lane_drop(event.drag(cx).0, lane, cx); | ||
| 766 | + }), | ||
| 767 | + ) | ||
| 651 | .child( | 768 | .child( |
| 652 | // Pinned track head. | 769 | // Pinned track head. |
| 653 | div() | 770 | div() |
| @@ -833,6 +950,17 @@ fn lane_row( | |||
| 833 | }), | 950 | }), |
| 834 | ), | 951 | ), |
| 835 | ) | 952 | ) |
| 953 | + // The drop-line is inside its target row so it survives the lane | ||
| 954 | + // column's clipping at the first row; it marks exactly the slot the | ||
| 955 | + // release will reorder into, rather than a generic drag highlight. | ||
| 956 | + .children(drop.map(|drop| { | ||
| 957 | + let line = div().absolute().left_0().w_full().h(px(2.)).bg(rgb(INK1())); | ||
| 958 | + if drop.above { | ||
| 959 | + line.top_0() | ||
| 960 | + } else { | ||
| 961 | + line.bottom_0() | ||
| 962 | + } | ||
| 963 | + })) | ||
| 836 | } | 964 | } |
| 837 | 965 | ||
| 838 | /// The bench's content: pinned ruler, pinned heads, lane stack -- compressed | 966 | /// The bench's content: pinned ruler, pinned heads, lane stack -- compressed |