edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBfbc29d1Tahinli2 months ago972 commits
| 1 | //! The re-timing sweep: every op that moves or removes timeline time, against |
| 2 | //! every grouping shape, under the universal laws -- `delete_in`/`delete_sub_in`, |
| 3 | //! `set_speed`/`set_speed_live`, `split`/`regroup`, `move_clip`/`trim`, |
| 4 | //! `move_sub`/`trim_sub`, `paste`, `ripple_delete`/`cut_regions`, |
| 5 | //! `lift`/`lift_sub`, `place`/`place_take`/`place_sub`, `delete(idx)` and |
| 6 | //! `retime`. The "there might be other bugs" catcher -- a red cell here is an |
| 7 | //! op whose shape has drifted from the law, found before a user finds it. |
| 8 | //! |
| 9 | //! Left out, by name rather than by omission: `group`/`ungroup`/`group_all` |
| 10 | //! move no time at all (id bookkeeping alone -- their own law is |
| 11 | //! `links_are_consistent`, asked directly by their unit tests and by |
| 12 | //! [`group_all_refuses_a_merge_that_doubles_up_a_lane`](crate::project::tests::group_all_refuses_a_merge_that_doubles_up_a_lane)), |
| 13 | //! and `remove_lane`/`move_lane`/`remove_source`/`remove_subtitles`/`append_clip` |
| 14 | //! touch the lane *list* or the source table, never a placement's span -- |
| 15 | //! outside this module's law and covered by their own unit tests in |
| 16 | //! `project.rs`. |
| 17 | //! |
| 18 | //! The laws are the four nothing downstream can live without: |
| 19 | //! |
| 20 | //! * **Consistency** -- `links_are_consistent`: a link id names at most one |
| 21 | //! placement per lane, clips and captions alike. |
| 22 | //! * **Order** -- every lane sorted and disjoint, both of its lists. |
| 23 | //! * **Survivor continuity** -- the desync-class law: a placement that |
| 24 | //! survives an op keeps a consistent source window, verified through the |
| 25 | //! op's own [`TimelineMap`]: the survivor's old span maps onto a span that |
| 26 | //! contains where it actually landed, or -- for the ops that move whole |
| 27 | //! members -- its position is the map of where it was. |
| 28 | //! * **Undo round-trip** -- one press puts the project back byte for byte, |
| 29 | //! and the op cost exactly one snapshot to do it. |
| 30 | //! |
| 31 | //! Paste is the named exception: it *inserts without rippling* media lanes |
| 32 | //! (a layer is laid over the timeline) and never touches captions at all, |
| 33 | //! so its cells assert the no-move shape directly instead of through a map. |
| 34 | |
| 35 | use crateTimelineMap; |
| 36 | use crate; |
| 37 | use crateFitPolicy; |
| 38 | use crateSubtitleTrack; |
| 39 | use crate::; |
| 40 | |
| 41 | const FILE: &str = "/nonexistent/a.mp4"; |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | /// The shapes a project is swept in: a lone take, a group of two clips, a |
| 88 | /// group of two clips and a caption (aligned), and the same offset -- the |
| 89 | /// hand-built shape the offset model exists for. |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | const SHAPES: = ; |
| 122 | |
| 123 | /// The four laws, asked of a project after an op and after its undo. `map` |
| 124 | /// is the op's own answer to "this frame is now where?" -- `None` for the |
| 125 | /// ops that move whole members rather than time (paste), which the sweep |
| 126 | /// asks the no-move shape of instead. |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | /// The undo round-trip + snapshot count: one press returns the project to |
| 145 | /// `pre` -- the parts captured BEFORE the op, by the caller that had them -- |
| 146 | /// and the op cost exactly one step on top of the history it inherited. |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 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 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | /// The scoped and whole-timeline ripples: [`Project::ripple_delete`] and |
| 327 | /// [`Project::cut_regions`] both close a hole across every lane they touch, |
| 328 | /// clips and captions alike -- a span safely inside every shape's geometry |
| 329 | /// (never on a clip or caption edge, so the cell asks the general law and not |
| 330 | /// one shape's particular boundary). |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | /// The two single-lane, group-blind lifts: [`Project::lift`] and |
| 352 | /// [`Project::lift_sub`] take one placement off its own lane and leave a gap |
| 353 | /// -- no other lane moves, grouped or not, which the law asks by checking |
| 354 | /// every OTHER lane is untouched. |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | /// The caption's own two edits: [`Project::move_sub`] carries its group's |
| 379 | /// clips along it, one delta for all of them (exactly as a clip's |
| 380 | /// [`Project::move_clip`] does), and [`Project::trim_sub`] drags its group's |
| 381 | /// edge along with its own window, one delta each member clamps to its own |
| 382 | /// room (`Project::follow_group`) -- the same law, not a caption exception. |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | /// The three overwrite doors -- [`Project::place`], [`Project::place_take`] |
| 419 | /// and [`Project::place_sub`] -- are [`the_sweep_paste_is_the_named_exception`]'s |
| 420 | /// own shape: they land over whatever is there and nothing else on the lane |
| 421 | /// ripples, media or captions. |
| 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 | /// [`Project::delete`] is sugar for [`Project::delete_in`] on `V1` -- the |
| 451 | /// single-lane front-end door the app's own delete key is wired to. One cell |
| 452 | /// pinning the delegation rather than the whole delete sweep again. |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | /// [`Project::set_speed_live`] is the drag sample of [`Project::set_speed`]: |
| 463 | /// every sample only regrades the rate, and the whole gesture undoes in the |
| 464 | /// one step the press took ([`a_whole_colour_drag_undoes_in_one_step`]'s law, |
| 465 | /// for a rate instead of a grade). |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | |
| 479 | |
| 480 | |
| 481 | |
| 482 | |
| 483 | /// [`Project::retime`] moves every frame number without being an edit anyone |
| 484 | /// made ([`Project::retime`]'s own words) -- no history step to its name, so |
| 485 | /// the sweep asks it the order and consistency laws alone, never the undo |
| 486 | /// round trip the rest of this module leans on. |
| 487 | |
| 488 | |
| 489 | |
| 490 | |
| 491 | |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 497 | |
| 498 | |
| 499 |