edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! The bench's own content: lanes, ruler and clips (DESIGN.md §5's clip |
| 2 | //! anatomy, §7's degradation ladder). `stance.rs::bench()` owns the frame |
| 3 | //! (height, surfaces, section head); this module owns what fills it, the way |
| 4 | //! `dock_stance.rs` owns the dock's content next to `stance.rs::dock()`'s |
| 5 | //! frame. |
| 6 | //! |
| 7 | //! Reused rather than reimplemented (`ui/timeline.rs` already shipped this |
| 8 | //! plumbing on the legacy timeline): `Player::insert_source` and the |
| 9 | //! `AssetDrag` payload for add-at-playhead and drag-drop from the Sources |
| 10 | //! tab, `Player::pick`/`Player::marks`/`marked` for selection, and |
| 11 | //! `Player::nudge_cut`/`walk_cut`/`cut`/`toggle_loop_trim` (DESIGN §6, wired |
| 12 | //! in `player/actions.rs` already, and answered to by every keystroke the |
| 13 | //! stance's own key handler forwards) for the whole cut grammar -- none of |
| 14 | //! that is touched here, because a clip's `start`/`frames()` already reflect |
| 15 | //! a commit the moment the keymap makes one (`nudge_cut` writes straight to |
| 16 | //! the session), so this module reads the session straight, needing no live |
| 17 | //! drag-preview state to mirror it. New here: the clip anatomy (ink spine, |
| 18 | //! trace, name plate, splice gaps) and the width ladder that degrades it |
| 19 | //! (DESIGN §7) -- neither existed on the legacy timeline in this shape. |
| 20 | //! |
| 21 | //! Now also reused: `ClipDrag` (moving a placed clip along its lane and onto |
| 22 | //! another, `Player::dragged`/`Player::move_clip`), the mouse edge-trim |
| 23 | //! strips (`Player::start_trim`/`trims(span)`, the same minimum-width rule |
| 24 | //! the legacy strips use), `Player::timeline_wheel` (ctrl+wheel zooms about |
| 25 | //! the pointer, a bare wheel scrolls the bed -- the same mapping on the |
| 26 | //! ruler and on every bed) and `LaneDrag`/`Player::reorder_lane` (drag a |
| 27 | //! track head onto another to swap their order). `Player::drag_move`/ |
| 28 | //! `Player::drag_release`, wired once on the window's own root |
| 29 | //! (`render.rs`), already carry a trim or a scroll off the 6px strip that |
| 30 | //! started it, for the darkroom tree exactly as for the legacy one -- no |
| 31 | //! root wiring lives here. |
| 32 | //! |
| 33 | //! Fade wedges, dissolve joins, and the lane header's drop-line cue reuse the |
| 34 | //! legacy interaction state: `FadeDrag` previews the ramp until release, |
| 35 | //! `dissolve_selected` still owns the toggle, and `LaneDrop` answers the same |
| 36 | //! slot that `reorder_lane` commits. |
| 37 | //! |
| 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. |
| 40 | |
| 41 | pub |
| 42 | pub |
| 43 | pub |
| 44 | |
| 45 | |
| 46 | |
| 47 | pub |
| 48 | |
| 49 | use cratehitmap; |
| 50 | use crate; |
| 51 | use crate*; |
| 52 | use crate::*; |
| 53 | |
| 54 | use lane_row; |
| 55 | use ruler; |
| 56 | |
| 57 | /// The pinned ruler's own height, above the lane stack -- tall enough for a |
| 58 | /// tick line plus a mono label under it, and the playhead's lamp tab along |
| 59 | /// its top edge (DESIGN §6.5). |
| 60 | pub const RULER_H: f32 = crateRULER_H; |
| 61 | /// A mono character's width at `size_px`, from the shared |
| 62 | /// [`crate::layout::LIST_CHAR_W`] calibration (taken at |
| 63 | /// [`type_scale::CHORD_METADATA_MIN_PX`]). |
| 64 | pub |
| 65 | |
| 66 | |
| 67 | |
| 68 | /// The pinned track-head column: the source dot and the lane's name, and |
| 69 | /// nothing else since the head's verbs moved into its own menu (cleanse |
| 70 | /// round 2) -- the pixels it gave up are the bed's now. |
| 71 | pub const HEAD_W: f32 = 156.; |
| 72 | pub const ROW_GAP: f32 = 2.; |
| 73 | /// The height a lane is drawn at when nobody has dragged it (DESIGN §5 "Lane |
| 74 | /// heights", REDESIGN §3.6): by kind. An empty lane keeps its kind's height, so |
| 75 | /// dropping the first clip on it moves nothing. |
| 76 | const LANE_VIDEO_H: f32 = crateLANE_H_V; |
| 77 | const LANE_AUDIO_H: f32 = crateLANE_H_A; |
| 78 | const LANE_SUB_H: f32 = 28.; |
| 79 | /// The range a dragged lane may be held to. Past the top the lane stops |
| 80 | /// growing and the column scrolls instead. |
| 81 | pub const LANE_MAX_H: f32 = 120.; |
| 82 | /// The gap `lane_row`'s pinned head column puts between the lane label and |
| 83 | /// its status dot (its own `.gap(px(...))`), named so [`LANE_MIN_H`]'s |
| 84 | /// derivation below doesn't repeat the literal blind. |
| 85 | pub const LANE_HEAD_GAP: f32 = 2.; |
| 86 | /// The status dot's own diameter (`lane_row`'s "Pinned track head" child, |
| 87 | /// its own `.w(px(...)).h(px(...))`). |
| 88 | pub const LANE_DOT_D: f32 = 4.; |
| 89 | /// The source patch box's side (its slot at the head's left edge is always this wide, shown or not). |
| 90 | pub const PATCH_W: f32 = 16.; |
| 91 | /// The widest a lane's label may be inside the head (a long track name is ellipsised to it; |
| 92 | /// the head itself stays [`HEAD_W`]): the head less the patch slot, the dot, the two switches and |
| 93 | /// their gaps. |
| 94 | pub const LANE_NAME_MAX_W: f32 = 68.; |
| 95 | /// The least a lane row may be (DESIGN §5). The head is one row -- dot, name, |
| 96 | /// switches -- so its tallest piece is the 24px switch hit area ([`HIT_MIN`]), |
| 97 | /// not a stack of label, gap and dot; `a_lane_row_fits_what_its_own_head_draws` |
| 98 | /// checks that this still holds. 28 leaves the switches a little air. |
| 99 | pub const LANE_MIN_H: f32 = 28.; |
| 100 | |
| 101 | /// Holds a lane's height to what the bench may draw: [`LANE_MIN_H`] to |
| 102 | /// [`LANE_MAX_H`]. |
| 103 | pub |
| 104 | |
| 105 | |
| 106 | |
| 107 | /// A lane's key in the view file (`view_state`): its kind's letter and its |
| 108 | /// ord plus one, the same number its head names it by -- "v1", "a2", "s1". |
| 109 | pub |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | /// The height a lane has when nobody has dragged it: its kind's own, whether |
| 119 | /// or not it holds anything (no auto-collapse; the layout is stable); on a window |
| 120 | /// shorter than 800 px the short pair (REDESIGN §2.2). |
| 121 | pub |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | thread_local! |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | /// Tells the bench the window height, so the default lane heights can follow it. |
| 139 | pub |
| 140 | |
| 141 | |
| 142 | |
| 143 | /// The height `lane` is drawn at: the one a hand dragged it to and saved for |
| 144 | /// this project, else [`default_lane_h`]. A saved value that is not a number |
| 145 | /// is ignored, and the result is always held to the lane range. |
| 146 | pub |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | /// Saves the height a lane was dragged to, replacing its earlier one. |
| 158 | pub |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | /// Forgets a lane's saved height, so it draws at its kind's default again. |
| 167 | pub |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | /// The three track heights a lane can be set to, from its header's menu, the |
| 173 | /// Timeline menu or the keyboard (Premiere's and Resolution's "track height"). |
| 174 | /// Small is the floor a lane may be held to, Medium is the kind's own default |
| 175 | /// and Large is the taller one that shows its thumbnails and waveform in full. |
| 176 | |
| 177 | pub |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | /// Large lanes: a video lane's thumbnails and an audio lane's waveform get |
| 216 | /// the room they need; the subtitle lane's text simply gets more air. |
| 217 | const LANE_LARGE_VIDEO_H: f32 = 96.; |
| 218 | const LANE_LARGE_AUDIO_H: f32 = 72.; |
| 219 | const LANE_LARGE_SUB_H: f32 = 40.; |
| 220 | |
| 221 | /// The height a lane of `kind` has at `size`. Medium follows the window |
| 222 | /// (`default_lane_h`), so it stays the height the lane is drawn at unless |
| 223 | /// somebody has set it. |
| 224 | pub |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | /// The size a lane is drawn at: the preset nearest its height. A tie (a |
| 235 | /// subtitle lane's Small and Medium are one height) is Medium, the default. |
| 236 | pub |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | /// Sets a lane to a size. Medium forgets the saved height, so the lane keeps |
| 245 | /// following the window the way it does before anyone touches it. |
| 246 | pub |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | /// How close a dragged lane has to come to a size's height to land on it. |
| 254 | pub const LANE_SNAP_PX: f32 = 4.; |
| 255 | |
| 256 | /// A dragged height, held to the size it sits next to when it is within |
| 257 | /// [`LANE_SNAP_PX`] of one; otherwise the height as dragged. |
| 258 | pub |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | /// The order the bench draws its lanes top to bottom, the way every NLE stacks them: video |
| 267 | /// lanes climb upward, the highest (`V3`) on top and `V1` just above the audio, and audio |
| 268 | /// lanes descend below. Only the drawing changes; the engine's own lane order and every |
| 269 | /// lane's address stay as they are. Anything else (captions) keeps its engine place, |
| 270 | /// after the audio it sat with. |
| 271 | pub |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | /// Where each lane's band lies in a column of lanes drawn one under another |
| 279 | /// with [`ROW_GAP`] between them, top first: `(lane, top, bottom)`. Each |
| 280 | /// lane takes its own height, so the bands of a mixed stack are not evenly |
| 281 | /// spaced. |
| 282 | |
| 283 | pub |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | /// The lane whose band holds `y`, if any; a y in the gap between two lanes |
| 296 | /// holds neither. |
| 297 | |
| 298 | pub |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | /// One clip's degradation tier (DESIGN §7), picked off the clip's own worth |
| 306 | /// in pixels (`span`, unclamped) rather than its drawn floor |
| 307 | /// ([`clip_width`]'s `HIT_MIN`) -- a clip zoomed far out is worth a fraction |
| 308 | /// of a pixel long before its box stops shrinking, and the ladder has to see |
| 309 | /// that or "sliver" would never fire under the floor that keeps it clickable. |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | /// The narrowest a clip's spine is drawn at all (DESIGN §7): under this the |
| 323 | /// spine would be wider than the box it sits in. |
| 324 | const SPINE_MIN_W: f32 = 3.; |
| 325 | |
| 326 | /// `MM:SS` for a clip's own readout -- the bench talks in the film's units, |
| 327 | /// not in seconds with a decimal point. |
| 328 | pub |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | /// A clip's thumbnail, filling its box. `Cover` rather than `Contain`: a clip |
| 337 | /// is a strip of film, so it crops rather than letterboxing inside a lane. |
| 338 | pub |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | /// A clip's thumbnail as a film strip: the picture at the strip's height, whole and uncropped, |
| 350 | /// repeated along the clip from its left edge -- one frame stretched over a long clip was cut |
| 351 | /// through its middle (and its text) as the clip grew. Only the tiles in view are painted. |
| 352 | pub |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | /// The width ladder (REDESIGN §3.6): the name strip from 40 px, the trace from 24 |
| 378 | /// px, and the solid fill below that. |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | /// The bench's side gutter, spent inside [`render`]'s own content box. |
| 389 | const BENCH_GUTTER: f32 = 12.; |
| 390 | |
| 391 | /// The bench's content: pinned ruler, pinned heads, lane stack. Each lane is |
| 392 | /// drawn at its own height ([`lane_height`]); the lane column takes what the |
| 393 | /// box leaves and scrolls behind the pinned ruler and heads when the lanes |
| 394 | /// add up to more (DESIGN §7). The box no longer sizes the rows, so it is not |
| 395 | /// read here. |
| 396 | pub |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | |
| 479 | |
| 480 | |
| 481 | |
| 482 | |
| 483 | |
| 484 | |
| 485 | |
| 486 | |
| 487 | |
| 488 | |
| 489 | |
| 490 | |
| 491 | |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | |
| 510 | |
| 511 | |
| 512 | |
| 513 | |
| 514 | |
| 515 | |
| 516 | |
| 517 | |
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | |
| 527 | |
| 528 | |
| 529 | |
| 530 | |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 | |
| 554 | |
| 555 | |
| 556 | |
| 557 | |
| 558 | |
| 559 | |
| 560 | |
| 561 | |
| 562 | |
| 563 | |
| 564 | |
| 565 | |
| 566 | |
| 567 | |
| 568 | |
| 569 | |
| 570 | |
| 571 | |
| 572 | |
| 573 | |
| 574 | |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | |
| 582 | |
| 583 | |
| 584 | |
| 585 | |
| 586 | |
| 587 | |
| 588 | |
| 589 | |
| 590 | |
| 591 | |
| 592 | |
| 593 | /// A short, gentle fade over the foot of the lane stack while lanes are hidden below it. Only |
| 594 | /// 18px and never past 60% of the bed's own ground, so the last partly visible lane stays |
| 595 | /// readable. Painted, so it reads the scroll extent of the frame it is drawn in. |
| 596 | |
| 597 | |
| 598 | |
| 599 | |
| 600 | |
| 601 | |
| 602 | |
| 603 | |
| 604 | |
| 605 | |
| 606 | |
| 607 | |
| 608 | |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | /// The playhead's line carried down through the lanes, over the clips: 2px |
| 621 | /// (3 while playing), lamp colour, a 1px black halo each side. The ruler draws |
| 622 | /// its own part and the pentagon head. |
| 623 | + use<> |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | |
| 643 | |
| 644 | |
| 645 | |
| 646 | |
| 647 | |
| 648 | |
| 649 | |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | |
| 659 | |
| 660 | |
| 661 | |
| 662 | |
| 663 | |
| 664 | |
| 665 | |
| 666 | |
| 667 | |
| 668 | |
| 669 | |
| 670 | |
| 671 | |
| 672 | |
| 673 | |
| 674 | |
| 675 | |
| 676 | |
| 677 | |
| 678 | |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | |
| 688 | |
| 689 | |
| 690 | |
| 691 | |
| 692 | |
| 693 | |
| 694 | |
| 695 | |
| 696 | |
| 697 | |
| 698 | |
| 699 | |
| 700 | |
| 701 | |
| 702 | |
| 703 | |
| 704 | |
| 705 | |
| 706 | |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | |
| 713 | |
| 714 | |
| 715 | |
| 716 | |
| 717 | |
| 718 | |
| 719 | |
| 720 | |
| 721 | |
| 722 | |
| 723 | |
| 724 | |
| 725 | |
| 726 | |
| 727 | |
| 728 | |
| 729 | |
| 730 | |
| 731 | |
| 732 | |
| 733 | |
| 734 | |
| 735 |