edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching·0 forks·Rust·18.3 MiB·ff99ad6·Tahinli·6 days ago·1055 commits
| 1 | #![forbid(unsafe_code)] |
| 2 | mod keymap; |
| 3 | mod player; |
| 4 | mod ui; |
| 5 | |
| 6 | mod creator; |
| 7 | mod audio_cards; |
| 8 | mod color_ui; |
| 9 | mod eq_ui; |
| 10 | mod export_queue; |
| 11 | mod export_ui; |
| 12 | mod files; |
| 13 | mod follow; |
| 14 | mod importing; |
| 15 | mod interact; |
| 16 | mod layout; |
| 17 | mod library_meta; |
| 18 | mod menus; |
| 19 | mod recent; |
| 20 | mod open_hook; |
| 21 | mod notices; |
| 22 | mod output_window; |
| 23 | mod oracle; |
| 24 | mod render; |
| 25 | mod subs; |
| 26 | mod timeline_math; |
| 27 | mod titles; |
| 28 | mod transform_ui; |
| 29 | mod transport; |
| 30 | mod view_state; |
| 31 | mod viewer_view; |
| 32 | mod viewport; |
| 33 | |
| 34 | pub(crate) use audio_cards::*; |
| 35 | pub(crate) use color_ui::*; |
| 36 | pub(crate) use eq_ui::*; |
| 37 | pub(crate) use export_ui::*; |
| 38 | pub(crate) use files::*; |
| 39 | pub(crate) use importing::*; |
| 40 | pub(crate) use interact::*; |
| 41 | pub(crate) use layout::*; |
| 42 | pub(crate) use library_meta::*; |
| 43 | pub(crate) use menus::*; |
| 44 | // The Contain letterbox, shared with the subtitle picture overlay |
| 45 | // (ui/preview.rs) so both draw the same fitted rect the same way. |
| 46 | pub(crate) use notices::*; |
| 47 | pub(crate) use oracle::*; |
| 48 | pub(crate) use render::letterboxed_image; |
| 49 | pub(crate) use subs::*; |
| 50 | pub(crate) use timeline_math::*; |
| 51 | pub(crate) use transform_ui::*; |
| 52 | pub(crate) use transport::*; |
| 53 | pub(crate) use viewport::*; |
| 54 | |
| 55 | use ui::theme::*; |
| 56 | use ui::widgets::*; |
| 57 | |
| 58 | use keymap::{ActionId, Keymap}; |
| 59 | |
| 60 | use std::cell::Cell; |
| 61 | use std::collections::{BTreeSet, HashMap, HashSet}; |
| 62 | use std::path::{Path, PathBuf}; |
| 63 | use std::rc::Rc; |
| 64 | use std::sync::Arc; |
| 65 | use std::sync::atomic::{AtomicBool, Ordering}; |
| 66 | use std::time::{Duration, Instant}; |
| 67 | |
| 68 | use engine::audio::StreamInfo; |
| 69 | use engine::color::ColorParams; |
| 70 | use engine::decode::Backend; |
| 71 | use engine::eq::{Band, BandKind, EqParams}; |
| 72 | use engine::export::{ |
| 73 | AUDIO_KBPS, DEFAULT_AUDIO_KBPS, EncoderSeat, ExportSettings, Format, HdrOutput, HdrTransfer, HevcSpeed, ProResProfile, |
| 74 | }; |
| 75 | use engine::limiter::Limiter; |
| 76 | use engine::project::{Edge, Lane, LaneKind, Source, Speed, SubClip}; |
| 77 | use engine::scale::FitPolicy; |
| 78 | use engine::tonemap::Preset; |
| 79 | use engine::transform::TransformParams; |
| 80 | use engine::{Clip, Codec, ExportHandle, Frame, MediaBitrate, PlaybackSession}; |
| 81 | use gpui::{ |
| 82 | AnyElement, App, Application, Bounds, ClickEvent, Context, Corners, CursorStyle, Div, |
| 83 | DragMoveEvent, FocusHandle, KeyDownEvent, MouseButton, MouseDownEvent, MouseExitEvent, |
| 84 | MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, Point, RenderImage, ScrollDelta, |
| 85 | ScrollHandle, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign, TitlebarOptions, |
| 86 | DisplayId, Window, WindowBounds, WindowHandle, WindowOptions, canvas, div, point, prelude::*, px, |
| 87 | relative, rgb, rgba, size, |
| 88 | }; |
| 89 | |
| 90 | /// The export probe's answer: the settings, the canvas, the cuts, and the |
| 91 | /// picture's seat (if any) plus the sound's. |
| 92 | type ExportSeat = ( |
| 93 | ExportSettings, |
| 94 | (u32, u32), |
| 95 | Vec<Clip>, |
| 96 | Option<(Option<&'static str>, &'static str)>, |
| 97 | ); |
| 98 | |
| 99 | /// A gap picked on a lane: the empty stretch `start..start + frames` that |
| 100 | /// Delete closes (DESIGN §7). Held beside [`Player::selected`] and not in it, |
| 101 | /// since a gap owns no clip index. Checked against the timeline before every |
| 102 | /// use ([`Player::gap_pick`]): an edit or an undo that moves the hole drops it. |
| 103 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
| 104 | pub(crate) struct GapPick { |
| 105 | pub(crate) lane: Lane, |
| 106 | pub(crate) start: u32, |
| 107 | pub(crate) frames: u32, |
| 108 | } |
| 109 | |
| 110 | /// The lane beds' boxes, in lane order. |
| 111 | type LaneBeds = Vec<(Lane, Bounds<Pixels>)>; |
| 112 | |
| 113 | struct Player { |
| 114 | /// The timeline, once there is one. A run with no file opens without it and |
| 115 | /// waits: the first media import or project load is what fills it, and |
| 116 | /// until then every action that needs a timeline says so instead of acting. |
| 117 | session: Option<PlaybackSession>, |
| 118 | /// A resolution and/or frame rate picked before any file exists to derive |
| 119 | /// them from -- what the resolution and rate lists edit |
| 120 | /// instead of refusing, with nothing open yet. Applied as the explicit |
| 121 | /// override [`engine::PlaybackSession::set_resolution`]/`set_frame_rate` |
| 122 | /// already are for a `.edith`'s own saved values ([`Player::install_media`]) |
| 123 | /// the moment the first session exists, and cleared there: consumed once, |
| 124 | /// the way a project's own saved settings are read once at |
| 125 | /// [`engine::PlaybackSession::open_project`]. |
| 126 | pending_settings: (Option<(u32, u32)>, Option<f64>, Option<u32>), |
| 127 | /// The template a project started by File > New from template takes its lanes, names, caption |
| 128 | /// style and export preset from, when its first footage arrives. |
| 129 | pending_template: Option<String>, |
| 130 | /// The welcome screen's From template list is open. |
| 131 | welcome_templates: bool, |
| 132 | /// A library row's own file, opened and playing in place of the |
| 133 | /// timeline's picture, and never written to `session` or its undo stack: |
| 134 | /// a preview is watched, not edited. `Some` is what [`Player::pump`] and |
| 135 | /// [`Player::transport`] read first -- the timeline's own session and its |
| 136 | /// silence scan sit untouched underneath until this clears again |
| 137 | /// ([`Player::close_preview`]). |
| 138 | preview_session: Option<PlaybackSession>, |
| 139 | /// Whether the timeline was playing when a preview took it over |
| 140 | /// ([`Player::open_preview`] pauses it so the two sounds never overlap): |
| 141 | /// what [`Player::close_preview`] resumes, and only then. |
| 142 | preview_playing: bool, |
| 143 | /// In/out marks on library items, in seconds of the file and keyed by the |
| 144 | /// row's `(file, audio stream)`: what `I`/`O` set while a preview is up |
| 145 | /// ([`Player::mark_source`]) and what the three-point edit reads |
| 146 | /// ([`Player::source_edit`]). Not saved with the project. |
| 147 | source_marks: HashMap<(PathBuf, usize), (Option<f64>, Option<f64>)>, |
| 148 | /// The library item the source edits act on: the one being previewed, or |
| 149 | /// the last one that was. |
| 150 | source_target: Option<(PathBuf, usize)>, |
| 151 | /// The Source pill was pressed with nothing opened yet: the viewer says how to open a clip. |
| 152 | source_hint: bool, |
| 153 | /// Which halves of the source monitor's item an insert or overwrite |
| 154 | /// places: the picture, the sound. Both on whenever a source opens. |
| 155 | source_video: bool, |
| 156 | source_audio: bool, |
| 157 | /// The source patch (Premiere's V and A boxes on the lane heads): the video and audio lanes |
| 158 | /// the source monitor's picture and sound go to on Insert and Overwrite. V1 and A1 at start. |
| 159 | patch_video: Lane, |
| 160 | patch_audio: Lane, |
| 161 | /// The picture alone, filling the window -- what `Fullscreen` gives every |
| 162 | /// consumer video player, and not what gpui's own `toggle_fullscreen` |
| 163 | /// gives on its own (the OS window, chrome and all). Kept apart from |
| 164 | /// `window.is_fullscreen()` because the two can fall out of step: a |
| 165 | /// compositor keybind changes the window's without this flag hearing |
| 166 | /// about it, so [`Player::act`] reconciles them rather than trusting |
| 167 | /// either alone. |
| 168 | player_fullscreen: bool, |
| 169 | /// Whether the active session -- the timeline or a library preview, |
| 170 | /// whichever [`Player::active_session`] is reading -- restarts from the |
| 171 | /// top on reaching its end instead of stopping there. One flag for both, |
| 172 | /// since only one of them is ever playing at a time. |
| 173 | loop_on: bool, |
| 174 | /// The in/out mark an export is clipped to, half-open `[start, end)` in |
| 175 | /// timeline frames -- `None` for the whole timeline. Session state, like |
| 176 | /// the mark itself: never saved to a `.edith` ([`ExportSettings::range`]). |
| 177 | range: Option<(u32, u32)>, |
| 178 | /// Loop-trim (DESIGN.md §6, `/`): the frame window `[start, end)` the |
| 179 | /// transport loops inside while it is on -- the subject cut's own clip |
| 180 | /// span, which is what a `[`/`]` nudge is moving. `None` is the mode off, |
| 181 | /// which is also what lets [`Player::pump`] answer |
| 182 | /// [`should_loop_restart`] with one field instead of asking whether the |
| 183 | /// mode is on and then separately what the window is. |
| 184 | loop_trim: Option<(u32, u32)>, |
| 185 | /// Timeline seconds -> frame index, so the clock can be compared to what |
| 186 | /// the decoder hands over. |
| 187 | fps: f64, |
| 188 | name: SharedString, |
| 189 | image: Option<Arc<RenderImage>>, |
| 190 | /// Frames the viewer has replaced and must drop from every window's sprite |
| 191 | /// atlas. Dropped from `Player::render`, which is the one place that can |
| 192 | /// reach every window: the output window shows the same picture. |
| 193 | retired_images: Vec<Arc<RenderImage>>, |
| 194 | /// The video output window, while it is open (View > Video output window). |
| 195 | /// Session state only: never saved in a project. |
| 196 | output: Option<WindowHandle<output_window::OutputView>>, |
| 197 | /// The display the output window goes to; `None` is the primary one. |
| 198 | output_display: Option<DisplayId>, |
| 199 | /// The displays as the View menu lists them this frame, in order, with their names. |
| 200 | output_displays: Vec<(DisplayId, SharedString)>, |
| 201 | /// The picture of the bitmap cue on screen, and which cue that is: the |
| 202 | /// track it is a row of and where it starts on the timeline. A PGS display |
| 203 | /// set is run-length and has to be walked into a canvas-sized buffer to be |
| 204 | /// drawn ([`engine::subtitle::CueImage::rgba`]), which is a thing to do |
| 205 | /// when the cue changes -- every few seconds -- and not at every repaint. |
| 206 | /// |
| 207 | /// The *lane* is half the key because the four PGS tracks of a remux are |
| 208 | /// one film's subtitles in four languages: placed one over the other they |
| 209 | /// start at the same microsecond, and a lane whose eye was shut would leave |
| 210 | /// the one before it on screen. The other half is the cue itself |
| 211 | /// ([`crate::ui::preview::SubImageKey`]): two different cues can share a |
| 212 | /// lane and a start too, and a key of those two alone served one caption's |
| 213 | /// picture for another's. |
| 214 | sub_image: Option<(crate::ui::preview::SubImageKey, Arc<RenderImage>)>, |
| 215 | /// A frame that arrived before its time; shown on the tick it comes due. |
| 216 | /// The pump's buffer, not transport state -- but a frame waiting here is |
| 217 | /// what keeps a finished decoder from reading as [`Transport::Ended`] one |
| 218 | /// tick early. See [`Player::transport`]. |
| 219 | held: Option<Frame>, |
| 220 | /// A seek is waiting for its frame, and since when. Keeps the repaint loop |
| 221 | /// alive while paused, which is the only way the new still ever reaches the |
| 222 | /// screen; the instant is what a drag's samples are gated on |
| 223 | /// ([`Player::flush_drag`]) and what says so in words when one open stands |
| 224 | /// too long ([`seek_line`]). |
| 225 | seek_since: Option<Instant>, |
| 226 | /// The ruler's own box, recorded at prepaint: a mouse listener is handed |
| 227 | /// the window position and nothing else. |
| 228 | ruler: Rc<Cell<Bounds<Pixels>>>, |
| 229 | /// Each lane bed's box, recorded at prepaint like the ruler's: the box |
| 230 | /// select reads which lanes a pointer rectangle crosses off it. |
| 231 | lane_beds: Rc<std::cell::RefCell<LaneBeds>>, |
| 232 | /// A box select in flight, pressed on empty bed ([`Marquee`]). |
| 233 | marquee: Option<Marquee>, |
| 234 | /// The scrollbar track's laid-out box, recorded at prepaint like the |
| 235 | /// ruler's: a thumb drag is followed on the root (the pointer leaves the |
| 236 | /// strip at once), and the root has only window coordinates to work with. |
| 237 | scroll_track: Rc<Cell<Bounds<Pixels>>>, |
| 238 | /// A thumb in the hand: how far into the thumb the press landed, in |
| 239 | /// track pixels. `None` with no drag in flight. |
| 240 | scroll_drag: Option<f32>, |
| 241 | /// A thumb of the lane stack's own scrollbar in the hand: how far into |
| 242 | /// the thumb the press landed, in track pixels. `None` with no drag in |
| 243 | /// flight. The stack's box itself is read straight off the scroll handle |
| 244 | /// each frame, so unlike the time axis's strip it needs no probe of its |
| 245 | /// own. |
| 246 | lanes_drag: Option<f32>, |
| 247 | /// How wide a second of timeline is drawn, and from which moment. Held here |
| 248 | /// and nowhere else: every frame-to-pixel answer in the panel comes out of |
| 249 | /// it, so the boxes, the playhead and the pointer cannot disagree. |
| 250 | scale: Scale, |
| 251 | /// A hand has moved the view itself -- a wheel scroll, a zoom about the |
| 252 | /// pointer -- and until the playhead runs back into what it chose to look |
| 253 | /// at, the view is the hand's and the follow keeps off it. Without this a |
| 254 | /// notch during playback was undone by the very next frame: the follow |
| 255 | /// centres a playhead that has left the bed, and a scroll away from it is |
| 256 | /// exactly a playhead leaving the bed. Given back by [`Render`] the moment |
| 257 | /// the head is on screen again, and by every transport ask (a seek, a |
| 258 | /// play/pause) outright -- those are a person saying where to look. |
| 259 | panned: bool, |
| 260 | /// A fit asked for before the bed was measured ([`Player::zoom_fit`]): the |
| 261 | /// bed is only known once the timeline has been painted, and a fit taken |
| 262 | /// against no bed would fall back to the default scale. Consumed by |
| 263 | /// [`Render`] on the first frame that has one. |
| 264 | fit_pending: bool, |
| 265 | /// The bed width the last fit was worked out for, while the view is still |
| 266 | /// that fit: [`Render`] refits when the bed has a different width, and a |
| 267 | /// hand's zoom or scroll sets it back to `None`, which keeps the view the |
| 268 | /// hand chose through a resize. `None` for a view nobody fitted. |
| 269 | fitted_bed: Option<f32>, |
| 270 | /// Each lane's height by its key ("v1", "a2"), as a hand left it. Kept with |
| 271 | /// the scale in [`view_state`] so a reopened project gets its lanes back. |
| 272 | lane_h: Vec<(String, f32)>, |
| 273 | /// The viewer's zoom, playback quality, guides and mask ([`viewer_view`]); view state, saved |
| 274 | /// with the project's view and never part of the project or an export. |
| 275 | viewer: viewer_view::Prefs, |
| 276 | /// How far the zoomed picture is dragged from centred, in logical pixels. |
| 277 | viewer_pan: (f32, f32), |
| 278 | /// The pointer of a pan drag in progress, where it last was. |
| 279 | viewer_drag: Option<Point<Pixels>>, |
| 280 | /// A drag on the selected clip's picture or its corners, while one is held. |
| 281 | viewer_handle: Option<viewer_view::ViewerHandle>, |
| 282 | /// Where the viewer header's four controls paint, so their lists hang from them. |
| 283 | viewer_btns: [Rc<Cell<Bounds<Pixels>>>; 4], |
| 284 | /// The lane whose bottom edge is being dragged, with the grab that turns |
| 285 | /// the pointer's y into its height (see `interact::lane_resize_band`). |
| 286 | /// `None` when no edge is held. |
| 287 | lane_resize: Option<(Lane, f32)>, |
| 288 | /// Which placements the edit keys act on: the lane each is in and its |
| 289 | /// index there, every ctrl-click in the order it was made. The *clicked* |
| 290 | /// half and not the group -- a group is what gets marked on screen, but |
| 291 | /// Lift has to know which half it was aimed at -- and the last pick is the |
| 292 | /// [`anchor`](Selection::anchor) every single-thing action uses. Indices |
| 293 | /// move under every edit, so this is cleared by all of them. |
| 294 | selected: Selection, |
| 295 | /// The gap a click picked, if one is (DESIGN §7). Mutually exclusive with |
| 296 | /// `selected`: a gap pick clears the clip marks, and a live clip mark hides |
| 297 | /// the gap ([`Player::gap_pick`]). |
| 298 | gap: Option<GapPick>, |
| 299 | /// The clip menu a right-click opened, if one is up. Holds an index like |
| 300 | /// `selected` does, so it is closed by anything that can move indices -- |
| 301 | /// every stroke, and every item of its own. |
| 302 | context_menu: Option<ContextMenu>, |
| 303 | /// The menu-bar dropdown that is open, if one is (DESIGN §6.1). Closed by |
| 304 | /// esc, a press below the bar, or running one of its rows. |
| 305 | menu_open: Option<ui::menubar::Title>, |
| 306 | /// The title a hover switched the open menu to: the click that follows on |
| 307 | /// it keeps that menu open (a switch) instead of toggling it shut. |
| 308 | menu_hopped: Option<ui::menubar::Title>, |
| 309 | /// The flyout open beside the menu bar's plate: its title and the group's name. |
| 310 | menu_sub: Option<(ui::menubar::Title, &'static str)>, |
| 311 | /// A second flyout, beside the first: a list-row inside a group (Picture fit under Adjust). |
| 312 | /// Drawn only while the first one is the group it hangs from. |
| 313 | menu_sub2: Option<(ui::menubar::Title, &'static str)>, |
| 314 | /// Where the status bar's size, rate and clip readout paint: what a shortcut-opened list hangs from. |
| 315 | ledger_readout: Rc<Cell<Bounds<Pixels>>>, |
| 316 | /// Where the status bar's toast text paints: its width is how much of the message fits. |
| 317 | toast_text: Rc<Cell<Bounds<Pixels>>>, |
| 318 | /// The clip menu's submenu row (Adjust, Compound, Label or Fit) the pointer is on, if any: |
| 319 | /// its 150 ms timer opens that submenu only if it is still the one under the pointer. |
| 320 | sub_hot: Sub, |
| 321 | /// Where the pointer came onto the Adjust row, and the submenu's near edge |
| 322 | /// `(x, top, bottom)` (written while drawing): together the "safe triangle" |
| 323 | /// a diagonal move toward the submenu may cross without closing it. |
| 324 | adjust_aim: Option<Point<Pixels>>, |
| 325 | adjust_sub: Cell<Option<(f32, f32, f32)>>, |
| 326 | /// The choice list a click on an enumerated setting opened, if one is up: |
| 327 | /// the project resolution or a clip's fit policy, every value on screen at |
| 328 | /// once. Closed by anything that closes the menus, and for the same reason. |
| 329 | picker: Option<Picker>, |
| 330 | /// The library menu a right-click on a row opened, if one is up. Names its |
| 331 | /// row by file and stream rather than by position, so it acts on the row it |
| 332 | /// was opened on however the list is rebuilt under it. |
| 333 | library_menu: Option<LibraryMenu>, |
| 334 | /// Which library row is picked: the file and the audio stream that row |
| 335 | /// names, which is what an insert needs and what survives a row list being |
| 336 | /// rebuilt. Its own selection and not the timeline's: Delete keeps acting |
| 337 | /// on the clip that was clicked in a lane, whatever the library is showing. |
| 338 | selected_asset: Option<(PathBuf, usize)>, |
| 339 | /// Library rows picked together (ctrl-click) for a multicam clip; empty means just `selected_asset`. |
| 340 | asset_picks: Vec<(PathBuf, usize)>, |
| 341 | /// The angle monitor is shown beside the program picture ([`Player::angle_monitor_view`]). |
| 342 | angle_monitor: bool, |
| 343 | /// The monitor's composed tiles. |
| 344 | angle_shots: player::multicam::AngleShots, |
| 345 | /// Which category of the library is being looked at. A tab and not a |
| 346 | /// filter box: the categories are what the media *is*, and every editor |
| 347 | /// this one is measured against splits its pool the same way. |
| 348 | /// Which of the darkroom dock's Src/Clip tabs is showing (DESIGN §5). |
| 349 | /// `Player`-owned rather than the process-global static it used to be |
| 350 | /// (VIOLATION 3), and persisted the way `ui::theme`'s pick is |
| 351 | /// (`ui::dock_stance::load`/`save`) so "a room reopens exactly as left" |
| 352 | /// survives a quit and relaunch, not just this window. |
| 353 | pub(crate) dock_src_active: bool, |
| 354 | /// The Sources tab's own filter text (darkroom dock, MOCK-SPEC "Dock" §2) |
| 355 | /// and whether it is the thing typed strokes go to right now -- the same |
| 356 | /// capture-flag shape `keys_open` already uses, so a letter |
| 357 | /// filters the list instead of firing a spine action while the box is |
| 358 | /// focused, and does nothing to the keymap once it is not. |
| 359 | pub(crate) dock_filter: String, |
| 360 | pub(crate) dock_filter_edit: bool, |
| 361 | /// Type-to-filter on the KEYS tab. Owned the same way the Sources filter |
| 362 | /// is, except KEYS captures letters the moment the tab is showing -- the |
| 363 | /// list is a lookup, and a letter that still fired a spine action while |
| 364 | /// it was up is why search felt missing. |
| 365 | pub(crate) keys_filter: String, |
| 366 | /// Which of the four sort chips is showing (MOCK-SPEC "Dock" §3). |
| 367 | /// What is known about each source's audio, taken once and kept. Keyed on |
| 368 | /// the path *and stream* -- two streams of one file are two envelopes -- and |
| 369 | /// the key is inserted the moment the decode is *started*: presence means |
| 370 | /// "asked", so a repaint mid-decode cannot ask again. |
| 371 | waves: HashMap<(PathBuf, usize), Wave>, |
| 372 | /// The bench's poster frame per file ([`Thumb`]), filled like `waves` -- |
| 373 | /// presence means "asked" -- one per file rather than one per clip, since |
| 374 | /// every clip cut from a file shares its picture. |
| 375 | thumbs: HashMap<PathBuf, Thumb>, |
| 376 | /// What each source's stand-in is up to ([`engine::proxy`]), filled like |
| 377 | /// `waves`: presence means "asked", so the encode is started once per file |
| 378 | /// however many times the library is drawn. The switch that decides whether |
| 379 | /// they are *played* is the session's own -- it is the project's and is |
| 380 | /// saved with it, where this map is this window's view of the cache. |
| 381 | proxies: HashMap<PathBuf, Proxy>, |
| 382 | /// The render preview being made and the frames it covers ([`player::render_cache`]). |
| 383 | render: Option<(engine::render_cache::Job, (u32, u32))>, |
| 384 | /// The ruler's render bar, and the key ([`Player::refresh_render_bands`]) it was worked out at. |
| 385 | render_bands: Vec<player::render_cache::RenderBand>, |
| 386 | render_bands_stamp: Option<(u64, u32, usize)>, |
| 387 | /// The render being made, as the frames it covers and how far it has got. |
| 388 | render_progress: Option<((u32, u32), f32)>, |
| 389 | /// The stabilisation analyses this window started and is waiting on, as |
| 390 | /// (source, first file frame, end): polled each frame, and the picture is |
| 391 | /// redrawn when one lands ([`engine::stabilise`]). |
| 392 | stab_waiting: Vec<(PathBuf, u32, u32)>, |
| 393 | /// The mask tracks running or waiting to be written onto their masks, polled each frame |
| 394 | /// ([`Player::poll_tracks`]). |
| 395 | track_jobs: Vec<engine::playback::TrackJob>, |
| 396 | /// The auto reframe being measured, if one is ([`Player::start_reframe`]). |
| 397 | reframe_run: Option<player::cards::ReframeRun>, |
| 398 | /// The last auto reframe that landed: its lane, clip and how many keys it wrote, so the |
| 399 | /// Transform card can say the exact count for that clip ([`Player::poll_reframe`]). |
| 400 | reframed: Option<(Lane, usize, usize)>, |
| 401 | /// Angles being synced for a multicam clip ([`Player::create_multicam_selected`]). |
| 402 | mcam_run: Option<player::multicam::McamRun>, |
| 403 | /// The sequences compound clips were opened from, outermost first: Back pops one |
| 404 | /// ([`Player::close_compound`]). A tab click starts the trail over. |
| 405 | seq_trail: Vec<u32>, |
| 406 | /// The open sequence's name being retyped on its tab, which owns the keyboard while it |
| 407 | /// is `Some` ([`Player::seq_edit_key`]). |
| 408 | seq_edit: Option<player::text_field::TextField>, |
| 409 | /// A track's name being retyped on its head, which owns the keyboard while it is `Some` |
| 410 | /// ([`Player::lane_edit_key`]). |
| 411 | lane_edit: Option<(Lane, player::text_field::TextField)>, |
| 412 | /// The transport timecode retyped as a time (Go to time), which owns the keyboard while it is |
| 413 | /// `Some` ([`Player::time_edit_key`]). A click elsewhere cancels it ([`Player::blur_text_fields`]). |
| 414 | time_edit: Option<player::text_field::TextField>, |
| 415 | /// The compare view (View > Compare grade); preview only, never exported. |
| 416 | compare: viewer_view::Compare, |
| 417 | /// The picture as shot at [`Player::before_at`], the other half of the compare view. |
| 418 | before: Option<Arc<RenderImage>>, |
| 419 | /// The timeline frame `before` shows; `None` when it has to be read again. |
| 420 | before_at: Option<u32>, |
| 421 | /// A read of the picture as shot is in flight. |
| 422 | before_busy: bool, |
| 423 | /// The frame the pump last drew: its timeline index and pixel size. |
| 424 | shown_frame: Option<(u32, u32, u32)>, |
| 425 | /// The colour card's Looks dropdown is open. |
| 426 | look_open: bool, |
| 427 | /// Saved look names, read when the dropdown opens and after a save. |
| 428 | saved_looks: Vec<String>, |
| 429 | /// The name typed for "Save current as look…", while it is being typed. |
| 430 | look_name: Option<player::text_field::TextField>, |
| 431 | /// The look last applied to a clip, for the Looks row's name. |
| 432 | look_mark: Option<player::grading::LookMark>, |
| 433 | /// The bins the media list shows folded ([`Player::toggle_bin_open`]); kept while the project is open. |
| 434 | collapsed_bins: std::collections::HashSet<u32>, |
| 435 | /// Which Clip-tab sections are open per clip kind ([`player::sections`]), as the view file keeps them. |
| 436 | sections_mem: Vec<(String, Vec<String>)>, |
| 437 | /// The clip the sections were last synced to; a different one re-opens the remembered sections. |
| 438 | sections_anchor: Option<(Lane, usize)>, |
| 439 | /// The bin picked in the media list, if one is (what Rename bin and Remove bin act on). |
| 440 | selected_bin: Option<u32>, |
| 441 | /// A bin's name being retyped on its row, which owns the keyboard while it is `Some` |
| 442 | /// ([`Player::bin_edit_key`]). |
| 443 | bin_edit: Option<(u32, player::text_field::TextField)>, |
| 444 | /// The title selected for editing, as an index into the session's titles; it shows in the |
| 445 | /// Clip tab while no clip is selected ([`Player::title_target`]). |
| 446 | title_sel: Option<usize>, |
| 447 | /// The words of that title while its text field has the keyboard, which it owns while it is |
| 448 | /// `Some` ([`Player::title_key`]). Written to the project when the field is left. |
| 449 | title_draft: Option<player::text_field::TextField>, |
| 450 | /// A colour of the selected title being typed as hex (the letters' or the box's), which owns |
| 451 | /// the keyboard while it is `Some`; written to the project when the field is left. |
| 452 | title_hex: Option<(player::titling::HexTarget, player::text_field::TextField)>, |
| 453 | /// The hex of a shape's fill or stroke being typed in the Generator card. |
| 454 | gen_hex: Option<(player::generators::GenPaint, player::text_field::TextField)>, |
| 455 | /// A number of the Generator card being scrubbed: shown live, written on release. |
| 456 | gen_scrub: Option<player::generators::GenScrub>, |
| 457 | /// The Transform card's Deinterlace list is open. |
| 458 | deinterlace_open: bool, |
| 459 | /// The Transform card's Place list is open. |
| 460 | place_open: bool, |
| 461 | /// The Title card's Entrance and Exit lists are open. |
| 462 | title_in_open: bool, |
| 463 | title_out_open: bool, |
| 464 | /// The index of the effect whose Blend mode list is open on the Effects card. |
| 465 | effects_mode_open: Option<usize>, |
| 466 | /// The EQ card's band Shape list is open. |
| 467 | eq_shape_open: bool, |
| 468 | /// The Clip tab's Transition Kind list is open. |
| 469 | transition_kind_open: bool, |
| 470 | /// The Clip tab's Transition section is folded open. |
| 471 | transition_section_open: bool, |
| 472 | /// The Custom accent's hex being typed in Settings, which owns the keyboard while it is `Some`; |
| 473 | /// each valid edit is in force at once and the file is written when the field is left. |
| 474 | accent_hex: Option<player::text_field::TextField>, |
| 475 | /// The Vivid or hue slider under the hand, and the two tracks' boxes ([`frac_along`]). |
| 476 | accent_drag: Option<player::accent::AccentSlider>, |
| 477 | accent_vivid_bar: Rc<Cell<Bounds<Pixels>>>, |
| 478 | accent_hue_bar: Rc<Cell<Bounds<Pixels>>>, |
| 479 | /// A scrub of one of the selected title's numbers, or a move of its block on the timeline, |
| 480 | /// in flight: shown live, written as one undo step on release. |
| 481 | title_scrub: Option<player::titling::TitleScrub>, |
| 482 | /// A pan field of the Mix section being scrubbed: shown live, written on release. |
| 483 | pan_scrub: Option<player::pan::PanScrub>, |
| 484 | /// Which audio streams each imported file has, as its header describes |
| 485 | /// them: one library row per entry. Keyed and filled like `waves` -- |
| 486 | /// presence means "asked" -- and an empty list is a silent file, which is |
| 487 | /// exactly one row and no stream tags. |
| 488 | streams: HashMap<PathBuf, Vec<StreamInfo>>, |
| 489 | /// What each source is coded at, read off its header once and kept: what a |
| 490 | /// properties card says about a file's rate. Filled like `streams` -- |
| 491 | /// presence means "asked" -- and the inner `None` is "asked, not answered |
| 492 | /// yet", which the card draws as an ellipsis: the probe walks a Matroska's |
| 493 | /// clusters, so a big film answers in seconds rather than at once. |
| 494 | bitrates: HashMap<PathBuf, Option<MediaBitrate>>, |
| 495 | /// What each source's header says about its container, size and picture |
| 496 | /// ([`engine::probe_media`]), probed once and kept for the properties |
| 497 | /// plates. Filled like `bitrates`: presence means "asked", and the inner |
| 498 | /// `None` is "asked, not answered yet". |
| 499 | facts: HashMap<PathBuf, Option<engine::MediaFacts>>, |
| 500 | /// How big each still source's picture is, read from its header once and |
| 501 | /// kept -- what a library row and its card say about a file that has no |
| 502 | /// streams to describe. Filled like `streams`: presence means "asked", and |
| 503 | /// `None` is a file with no picture to report (every source that is not an |
| 504 | /// image, and one whose header would not read). |
| 505 | sizes: HashMap<PathBuf, Option<(u32, u32)>>, |
| 506 | /// Whether a source's own header says it carries a picture at all, |
| 507 | /// probed once and kept: what [`Player::has_video`] reads for the lane a |
| 508 | /// drag may land on ([`timeline_math::lane_refuses`]). An extension can |
| 509 | /// lie -- a song muxed into an `.mp4` -- and only the header says the |
| 510 | /// truth (`engine::demux::NoVideoTrack`). Filled like `sizes`: presence |
| 511 | /// means "asked", and until the probe answers a file is read by its |
| 512 | /// extension, the same guess the ghost always made. |
| 513 | has_video: HashMap<PathBuf, bool>, |
| 514 | /// Every frame of each source a decoder may be started from -- its sync |
| 515 | /// points ([`engine::demux::sync_points`]), which are the frames a cut may |
| 516 | /// be placed on for an export to *copy* the film instead of coding all of |
| 517 | /// it again. Filled like `bitrates` and off the render thread for the same |
| 518 | /// reason, and more so: the answer is that Matroska cluster walk. An empty |
| 519 | /// list is a source with no grid to offer (an mp4, a still, a song), which |
| 520 | /// must stay in the map or every repaint would ask again. |
| 521 | syncs: HashMap<PathBuf, Vec<u32>>, |
| 522 | /// Which decoder each source will run on, probed once at import and kept: |
| 523 | /// the codec (`None` for a still) and the seat the engine picked for it -- |
| 524 | /// or, where the decoder refused the file, the refusal in its own words. |
| 525 | /// What a library row says *before* anything plays; the running answer is |
| 526 | /// the session's own (`PlaybackSession::decode_backend`), which follows a |
| 527 | /// fallback this cannot. Filled like `sizes`: presence means "asked", and |
| 528 | /// `Decoder::Pending` is that asked-but-unanswered window -- which must |
| 529 | /// stay in the map or every repaint would ask again. |
| 530 | decoders: HashMap<PathBuf, Decoder>, |
| 531 | /// What an export of the picked settings would open -- the picture's seat |
| 532 | /// or the copy that means it opens none, and the sound's -- and what it was |
| 533 | /// asked about: the settings, the canvas and the *cuts*, since where they |
| 534 | /// land is what decides whether the picture is copied at all. The probe |
| 535 | /// opens a real VA-API encoder (~100 ms) and reads every source's header, |
| 536 | /// so it runs off the render thread and only while the export card is up. |
| 537 | /// The inner `None` is "asked, not answered yet". |
| 538 | export_seat: Option<ExportSeat>, |
| 539 | /// What this machine's GPU decodes and encodes, as the plugin answered it: |
| 540 | /// asked once, off the render thread like `export_seat` and for the same |
| 541 | /// reason (a VA-API init), and kept for the life of the process because the |
| 542 | /// answer cannot change while we run. `None` is "not asked yet". |
| 543 | hw_caps: Option<SharedString>, |
| 544 | /// The copied clip, or clips: frame ranges and the lane each was on, in |
| 545 | /// click order, so it survives the clip (or clips) it was taken from |
| 546 | /// being deleted -- and it outlives the selection. One entry for a plain |
| 547 | /// Copy, the whole ctrl-click set for one made over a selection; either |
| 548 | /// way [`Player::paste`] drops the set at the playhead keeping the gaps |
| 549 | /// and lanes between its members intact. |
| 550 | clipboard: Vec<(Lane, Clip)>, |
| 551 | /// What the last copy remembers of the clip's look, for Paste attributes. |
| 552 | copied_look: Option<crate::player::editkeys::CopiedLook>, |
| 553 | /// A drag that started on the ruler. Moves anywhere in the window scrub |
| 554 | /// while it is set; the release commits the exact position. |
| 555 | scrubbing: bool, |
| 556 | /// What the hand has made of the three panel seams, and which one it is |
| 557 | /// holding now. Kept here rather than worked out per frame from the |
| 558 | /// window's own shares: a size a person dragged is a size that has to |
| 559 | /// survive the release ([`Splits`]). |
| 560 | splits: Splits, |
| 561 | /// A drag that started on a divider, tracked on the root for `scrubbing`'s |
| 562 | /// reason -- the strip is 6 px and the pointer leaves it at once. |
| 563 | split_drag: Option<Split>, |
| 564 | /// Where the seam was pressed and whether the pointer has since gone far enough |
| 565 | /// to call it a drag: a click that never moves changes and saves nothing. |
| 566 | split_press: Option<(Point<Pixels>, bool)>, |
| 567 | /// A drag that started on a clip's edge, tracked on the root for |
| 568 | /// `scrubbing`'s reason: a 6 px strip is not where the pointer stays. See |
| 569 | /// [`Trim`]. |
| 570 | trim: Option<Trim>, |
| 571 | /// A shift-drag roll, slip or slide in flight, tracked on the root for |
| 572 | /// `trim`'s reason. See [`ProDrag`]. |
| 573 | pro_drag: Option<ProDrag>, |
| 574 | /// The clip under the pointer and the modifiers held over it, for the |
| 575 | /// status bar's line on what a drag there would do |
| 576 | /// ([`crate::ui::bench_stance::clip::drag_status`]). `None` off every clip. |
| 577 | hover_hint: Option<crate::ui::bench_stance::clip::DragHover>, |
| 578 | /// The media-wall stop the dragged edge is pinned against, while it is |
| 579 | /// pinned: the handle flashes warn for [`TRIM_FLASH`] at the first sample |
| 580 | /// that holds there, and no later one re-arms it. `None` once the pointer |
| 581 | /// comes back inside the room, and between trims. |
| 582 | trim_flash: Option<TrimFlash>, |
| 583 | /// The clip a move is carrying, by the lane and index its press named it |
| 584 | /// under: drawn dimmed in place until the drop or the release lets it go. |
| 585 | /// `None` between drags. |
| 586 | drag_src: Option<(Lane, usize)>, |
| 587 | /// A drag that started on a fade handle, tracked on the root for the same |
| 588 | /// reason a trim is: a 10 px square is not where the pointer stays. See |
| 589 | /// [`FadeDrag`]. |
| 590 | fade_drag: Option<FadeDrag>, |
| 591 | /// A drag on a clip's volume envelope: a key or the line between two keys. See [`GainEdit`]. |
| 592 | gain_edit: Option<crate::interact::GainEdit>, |
| 593 | /// The envelope key the pointer is over, as `(lane, clip, key)`, which is what the cursor and |
| 594 | /// the line's own hover read. |
| 595 | gain_hover: Option<(Lane, usize, crate::ui::bench_stance::clip_envelope::EnvHit)>, |
| 596 | /// The envelope key last pressed, as `(lane, clip, source frame)`: Delete takes it out. |
| 597 | gain_pick: Option<(Lane, usize, u32)>, |
| 598 | /// How far into the clip the last press on a box landed, in timeline |
| 599 | /// frames: what a drag lets go of is the *point that was grabbed*, so the |
| 600 | /// head lands that much in front of the pointer and the clip does not jump |
| 601 | /// under the hand. Recorded at the press because gpui hands the drop only |
| 602 | /// the value being dragged, and stale between drags, which costs nothing -- |
| 603 | /// no drag starts without a press on the box it moves. |
| 604 | grab: u32, |
| 605 | /// Whether a drag or a trim is pulled onto the edges near it. On by |
| 606 | /// default, because clips meeting exactly is what a timeline is for, and off |
| 607 | /// by one stroke ([`ActionId::ToggleSnap`]) for the frame-by-frame placement |
| 608 | /// no magnet may take away. |
| 609 | snap: bool, |
| 610 | /// Whether `alt` was down on the last sample of the gesture in flight: |
| 611 | /// snapping off for *this* drag only, the override every NLE has for the |
| 612 | /// one clip that has to sit a frame off an edge, leaving [`Player::snap`] |
| 613 | /// -- the switch -- exactly as the hand left it. Read by |
| 614 | /// [`Player::snap_live`], written by the bench's own drag samples and by |
| 615 | /// the trim's, and stale between gestures, which costs nothing: every |
| 616 | /// gesture writes it before it asks. |
| 617 | drag_alt: bool, |
| 618 | /// Whether Ctrl is held during a library drag: the drop inserts and pushes the rest along, |
| 619 | /// and the status bar says so ([`ui::bench_stance::clip::asset_drop_status`]). |
| 620 | drag_ctrl: bool, |
| 621 | /// Whether a library drag hovers the empty bench below the last lane, where the drop makes |
| 622 | /// a new track ([`ui::bench_stance::clip::asset_drop_status`]). Set by the bench's own move |
| 623 | /// sample, cleared by a drop and by a row the pointer enters. |
| 624 | drag_below: bool, |
| 625 | /// Whether the subtitle lanes draw at all -- the mute over the shown lane |
| 626 | /// ([`Player::sub_lane`]), not a lane of its own. On by default and off by |
| 627 | /// one stroke |
| 628 | /// ([`ActionId::ToggleSubtitles`](keymap::ActionId::ToggleSubtitles)) for |
| 629 | /// anyone watching the picture rather than reading it. The player's, not the |
| 630 | /// project's: it changes nothing that is saved and nothing that is exported. |
| 631 | subs_on: bool, |
| 632 | /// Whether audio clips draw their waveform ([`ActionId::ToggleWaveforms`]). Kept |
| 633 | /// with the project's view ([`view_state`]), so it reopens as it was left. |
| 634 | waveforms: bool, |
| 635 | /// Whether a ruler scrub while paused plays sound ([`ActionId::ToggleScrubAudio`]). Kept with |
| 636 | /// the project's view, like the waveforms. |
| 637 | scrub_audio: bool, |
| 638 | /// The Play Around run in flight, if any: where the playhead came from, and |
| 639 | /// where the run stops. See [`PlayAround`]. |
| 640 | play_around: Option<PlayAround>, |
| 641 | /// Which palette row is *selected*: an index into |
| 642 | /// [`PlaybackSession::subtitles`], which is what the × takes off |
| 643 | /// ([`ActionId::RemoveSubtitleTrack`](keymap::ActionId::RemoveSubtitleTrack)) |
| 644 | /// and what the list marks. A selection and nothing more -- what is on |
| 645 | /// screen is what is placed on a subtitle lane |
| 646 | /// ([`Player::subtitle_overlay`]), so picking a row shows nothing by itself, |
| 647 | /// exactly as clicking a media row plays nothing. Cleared with the timeline |
| 648 | /// like every other index here -- track 2 of one project is not track 2 of |
| 649 | /// the next. |
| 650 | sub_track: usize, |
| 651 | /// Which files' subtitle groups in the library are folded shut, keyed by |
| 652 | /// the group's own path -- the same key [`subtitle_rows`] groups on, so a |
| 653 | /// fold survives a track being added or removed off the file it belongs |
| 654 | /// to. Session-lifetime only: a fold is a "not looking at this one right |
| 655 | /// now", not a project setting, so it is never saved and every file opens |
| 656 | /// unfolded. |
| 657 | sub_folded: HashSet<PathBuf>, |
| 658 | /// Which subtitle lane is *shown*: one of them and never two, the way a |
| 659 | /// player has one subtitle track chosen at a time -- two hundred lanes of |
| 660 | /// different words all drawn at once is two hundred plates over one |
| 661 | /// picture, and nothing readable. |
| 662 | /// |
| 663 | /// `None` is nobody having picked yet, which reads as the first subtitle |
| 664 | /// lane ([`Player::active_sub_lane`]) -- so one lane is shown without a |
| 665 | /// pick, the first lane added draws, and a pick naming a lane that has |
| 666 | /// since gone falls back to the first rather than showing nothing. |
| 667 | /// |
| 668 | /// Read where the cues are drawn ([`Player::subtitle_overlay`]) and nowhere |
| 669 | /// else: what an *export* writes is every lane on the timeline |
| 670 | /// ([`engine::export`]), which this pick has no say in. Not saved -- a |
| 671 | /// `.edith` has no line for it yet. |
| 672 | /// |
| 673 | /// A [`Lane`] handle is a position among its kind, so a removal or a |
| 674 | /// reorder leaves a pick naming another track: it is dropped there, |
| 675 | /// exactly as the selection and the open cards are ([`Player::remove_lane`], |
| 676 | /// [`Player::reorder_lane`]), which shows the first lane again. |
| 677 | sub_lane: Option<Lane>, |
| 678 | /// The frame the live gesture is about to land on, or `None` while it is |
| 679 | /// over open bed: the line every lane draws so the snap is seen before it |
| 680 | /// happens rather than discovered after the release. Stale between gestures, |
| 681 | /// which costs nothing -- it is drawn only while one is live. |
| 682 | snap_cue: Option<u32>, |
| 683 | /// The frame a ruler or empty-track menu was opened on: what "Add marker here" and |
| 684 | /// "Move playhead here" act on. Stale once the menu is gone, read only by those two rows. |
| 685 | menu_frame: Option<u32>, |
| 686 | /// The box the same gesture is about to fill, or `None` while the pointer is |
| 687 | /// over no lane: the shadow every proper editor draws under a drag. Set by |
| 688 | /// the lane the pointer is actually over -- that is the one question the |
| 689 | /// line above does not answer -- and drawn only while a drag is live, for |
| 690 | /// [`Player::snap_cue`]'s reason. More than one entry only while a |
| 691 | /// set-drag ([`Player::move_clip`]'s `set_move`) is carrying more than |
| 692 | /// the clip under the hand: every other pick draws its own shadow too, at |
| 693 | /// the same delta the anchor's is landing at ([`Player::preview_ghost`]). |
| 694 | ghost: Vec<Ghost>, |
| 695 | /// The window `x` the last live `on_drag_move` sample over a bed used to |
| 696 | /// draw [`Player::ghost`] -- read back by that drag's `on_drop` instead of |
| 697 | /// a fresh `window.mouse_position()`. gpui's drop callback carries no |
| 698 | /// event of its own to read a position off, and a second, later poll of |
| 699 | /// the pointer is not guaranteed to answer what the ghost just showed |
| 700 | /// (DESIGN: "drop == shadow, by construction"). `None` between drags. |
| 701 | drag_x: Option<Pixels>, |
| 702 | /// The lane the last live sample of the drag in flight was over -- the one |
| 703 | /// a release off the rows themselves (left of the heads, between two rows, |
| 704 | /// below the last track) lands on, so a gesture that has already promised a |
| 705 | /// landing in the shadow cannot end in nothing. `None` before the pointer |
| 706 | /// has been over any lane, where there is no landing to promise. |
| 707 | drag_lane: Option<Lane>, |
| 708 | /// The slot a track header being dragged is about to drop into, or `None` |
| 709 | /// while the pointer is over no lane: the line drawn between two headers, |
| 710 | /// for the reason [`Player::ghost`] draws a shadow -- where a gesture lands |
| 711 | /// is seen before the release. Drawn only while a drag is live. |
| 712 | lane_drop: Option<LaneDrop>, |
| 713 | last_scrub: Instant, |
| 714 | last_target: u32, |
| 715 | /// The running export. While it owns the UI the editor is read-only. |
| 716 | export: Option<ExportHandle>, |
| 717 | /// The export above was cancelled and is only winding down. The editor is |
| 718 | /// already free -- the worker took its own copy of the edit list -- but the |
| 719 | /// handle is held until the worker settles, because its last act is to |
| 720 | /// delete the output file and a second export must not be what it deletes. |
| 721 | cancelling: bool, |
| 722 | /// The pointer asked to cancel and the progress card is showing the pair |
| 723 | /// that answers it ("Keep exporting" / "Cancel export"). One press is never |
| 724 | /// the cancel itself: an hour of encoding must not end on a stray click, |
| 725 | /// which is the reason the stroke is a chord too ([`cancels_export`]). |
| 726 | cancel_armed: bool, |
| 727 | /// When the running export started, and how far it had come at each sample |
| 728 | /// since, as `(elapsed, progress)` marks. The elapsed clock and the |
| 729 | /// rolling-window estimate the progress line reads; see [`note_progress`]. |
| 730 | export_started: Option<Instant>, |
| 731 | export_marks: Vec<(f32, f32)>, |
| 732 | /// Exports set up to run later, one after another, each from the timeline |
| 733 | /// as it was when added ([`export_queue`]). Lives for the session. |
| 734 | queue: export_queue::ExportQueue, |
| 735 | /// The file an import worker is reading right now, and the files waiting |
| 736 | /// behind it in arrival order. Unlike an export, an import owns nothing: |
| 737 | /// the editor stays live, the timeline keeps playing, and the only thing |
| 738 | /// this holds is the line above the panel ([`Player::import_bar`]). |
| 739 | importing: Option<Import>, |
| 740 | imports: std::collections::VecDeque<PathBuf>, |
| 741 | /// The file argv named, until its read lands. It goes through the queue |
| 742 | /// above like any other file -- that is what puts the window on screen |
| 743 | /// before a byte of a 25 GB film is read -- and this is what tells |
| 744 | /// [`Player::take_import`] that this one is an *open* and not an import: |
| 745 | /// it becomes the timeline, and the clock, the title and the export path |
| 746 | /// come from it. Cleared the moment it lands, so a later drop of the very |
| 747 | /// same path is an import like any other. |
| 748 | opening: Option<PathBuf>, |
| 749 | /// Where an export writes. Built once from the source path, which is not |
| 750 | /// otherwise kept. |
| 751 | export_path: PathBuf, |
| 752 | /// The export target this window itself last wrote or confirmed, so the |
| 753 | /// overwrite question ([`Player::export_ask`]) can tell "the file exists" |
| 754 | /// apart from "the file exists and is a stranger's": an export over a |
| 755 | /// path this window never wrote asks first, a re-export over its own |
| 756 | /// output does not (user 2026-09-11, "not just save but export too"). |
| 757 | /// Path equality, not a flag: retargeting the destination to somewhere |
| 758 | /// else makes the answer foreign again. |
| 759 | export_known: Option<PathBuf>, |
| 760 | /// Where the save action writes: the project this timeline was loaded from, |
| 761 | /// or the one derived beside the media it started as. Saving twice |
| 762 | /// overwrites the same file rather than making a second one. |
| 763 | project_path: PathBuf, |
| 764 | /// Whether an edit has landed since the sidecar last caught up with it -- |
| 765 | /// set at every edit's own door ([`Player::mark_dirty`]) and cleared once |
| 766 | /// [`Player::autosave_tick`] has written it out. `project_path` itself is |
| 767 | /// never touched here: only [`Player::save_project`] writes the real file. |
| 768 | autosave_dirty: bool, |
| 769 | /// Edits landed since the autosave last caught up. Reaching |
| 770 | /// [`AUTOSAVE_EDITS`] makes the next tick write without waiting for the timer. |
| 771 | autosave_edits: u32, |
| 772 | /// When the autosave was last actually written. A dirty session goes at |
| 773 | /// most [`AUTOSAVE_PERIOD`] without one. |
| 774 | autosave_last_run: Option<Instant>, |
| 775 | /// A structural edit landed ([`Player::mark_structural`]): the next autosave goes out as |
| 776 | /// soon as [`AUTOSAVE_THROTTLE`] allows, rather than at the next 20 edits. |
| 777 | autosave_urgent: bool, |
| 778 | /// An autosave found newer than the project it sits beside, offered as a |
| 779 | /// notice with Recover and Discard buttons the moment that project opens |
| 780 | /// ([`Player::install_project`]). The path is the autosave's own, so |
| 781 | /// recovering needs nowhere else to look. Nothing is discarded unless the |
| 782 | /// person says so -- `project_path` is never touched by either answer. |
| 783 | recovery_sidecar: Option<PathBuf>, |
| 784 | /// Why the last Recover could not bring the unsaved edits back, in plain words, |
| 785 | /// while its dialog is up. The window is as it was and the autosave is kept. |
| 786 | recovery_failure: Option<String>, |
| 787 | /// Whether the unsaved-work question is on screen: raised by the window's |
| 788 | /// own close request when [`Player::close_needs_answer`] says the timeline |
| 789 | /// holds work the project file does not (user 2026-09-10, "if timeline is |
| 790 | /// not empty and user does alt+f4 or exit somehow, ask user to save"). |
| 791 | /// While it is up it owns the keyboard -- three answers and nothing else |
| 792 | /// ([`ui::stance`]'s root `on_key_down`). |
| 793 | quit_ask: bool, |
| 794 | /// Whether the overwrite question is on screen: raised by Save's own |
| 795 | /// door ([`Player::save_guarded`]) when the save's target exists on |
| 796 | /// disk but `autosave_armed` says this window never loaded or wrote it |
| 797 | /// -- a `.edith` the timeline only derives its name from beside an |
| 798 | /// imported media file (user 2026-09-11, "saving over an existing file |
| 799 | /// must warn first"). Same shape as `quit_ask` above: while it is up |
| 800 | /// it owns the keyboard, and answering `enter` confirms the overwrite |
| 801 | /// -- the save then arms `autosave_armed`, so later saves on this |
| 802 | /// file are silent. |
| 803 | save_ask: bool, |
| 804 | /// The File menu's project dialogs -- Save version, Versions, Collect media -- while one |
| 805 | /// is up; it owns the keyboard ([`Player::project_dialog_key`]). |
| 806 | proj_dialog: Option<player::project_dialogs::Dialog>, |
| 807 | /// A project started from File > New > Project…: where it will be saved, and the name it |
| 808 | /// goes by, until its first footage arrives and the file can exist (a project names at |
| 809 | /// least one source). `new_project_fresh` says that arrival still owes the first save. |
| 810 | new_project: Option<PathBuf>, |
| 811 | new_project_fresh: bool, |
| 812 | /// Whether the export's overwrite question is on screen: raised inside |
| 813 | /// [`Player::start_export`] -- after its refusals, so an export that |
| 814 | /// cannot run never asks -- when `export_path` exists on disk and |
| 815 | /// `export_known` says this window never wrote it. Same shape as |
| 816 | /// `save_ask` above: while it is up it owns the keyboard, and answering |
| 817 | /// `enter` marks the target known and starts the export. |
| 818 | export_ask: bool, |
| 819 | /// The export sheet's own state beside the settings above: the range |
| 820 | /// radio, the preset last picked, the destination fields, the measured |
| 821 | /// pace and the finished face ([`export_ui::ExportSheet`]). |
| 822 | export_sheet: export_ui::ExportSheet, |
| 823 | /// Whether `project_path` names a file this window itself put there -- |
| 824 | /// loaded from a `.edith` ([`Player::install_project`]) or written by a |
| 825 | /// manual save ([`Player::save_project`]) -- rather than one merely |
| 826 | /// derived beside an imported media file. [`Player::autosave_tick`] |
| 827 | /// requires it: a path derived from `media.mp4` names `media.edith` |
| 828 | /// whether or not that file is the user's own saved project, and writing |
| 829 | /// a sidecar beside a *foreign* `.edith` the user never opened is what |
| 830 | /// let a scratch timeline's autosave outdate and "recover" over a real |
| 831 | /// one. `mark_dirty` does not touch this -- an edit earns nothing an open |
| 832 | /// or save has not already granted. |
| 833 | autosave_armed: bool, |
| 834 | /// The project file's stamp as the window last accounted for it: set on |
| 835 | /// open, on its own save, and when a change on disk has been answered. |
| 836 | /// [`Player::follow_tick`] compares the file against it. |
| 837 | disk_known: Option<follow::Stamp>, |
| 838 | /// Whether the window holds edits the project file does not. Unlike |
| 839 | /// `autosave_dirty` this is not cleared by the sidecar write, so it |
| 840 | /// still says the file is behind after an autosave. |
| 841 | edited_since_save: bool, |
| 842 | /// The engine's revision ([`engine::PlaybackSession::revision`]) of the |
| 843 | /// timeline at the last save, open or discard. Undo and redo compare the |
| 844 | /// revision they land on with it, so undoing back to the saved timeline |
| 845 | /// clears `edited_since_save`. `None` when there is no saved timeline yet. |
| 846 | saved_revision: Option<u64>, |
| 847 | /// Which stroke means what, and what every shortcut on screen is called. |
| 848 | /// The one place either question is answered. |
| 849 | keymap: Keymap, |
| 850 | /// How loud the monitoring is, and whether it is muted. Lives here rather |
| 851 | /// than in the session so it survives closing one file and opening the |
| 852 | /// next -- it is a setting of the player, not of the timeline, which is |
| 853 | /// also why it is not written to the project file and cannot reach an |
| 854 | /// export. This is the *owner*: the engine holds the level per session, on |
| 855 | /// the device that runs it, and restores it when that device is replaced |
| 856 | /// ([`engine::PlaybackSession::set_gain`]), so every session is a |
| 857 | /// follower of this one copy and none of them can answer for it. |
| 858 | /// [`Player::apply_volume`] is what pushes it, at every session there is. |
| 859 | volume: Volume, |
| 860 | /// Where the volume slider was last painted, and whether a hand is on it -- |
| 861 | /// the speed bar's pair, for the speed bar's reason: the pointer moves |
| 862 | /// arrive at the root, so the bar's own geometry has to be readable there. |
| 863 | volume_bar: Rc<Cell<Bounds<Pixels>>>, |
| 864 | volume_dragging: bool, |
| 865 | /// Where the preview's own seek bar was last painted, and whether a hand |
| 866 | /// is on it -- `volume_bar`'s pair and `scrubbing`'s reason: the bar |
| 867 | /// spans the preview's whole length rather than a zoomed [`Scale`], so |
| 868 | /// it needs no `ruler` of its own, only its geometry. |
| 869 | preview_bar: Rc<Cell<Bounds<Pixels>>>, |
| 870 | preview_scrubbing: bool, |
| 871 | /// The two stand-in switches ([`engine::proxy`]) as this window has them |
| 872 | /// set: whether the picture is cut on the stand-ins, and whether an |
| 873 | /// arriving film gets one made for it. Kept here for the volume's reason |
| 874 | /// and one more of their own -- they are *import* options, so they have to |
| 875 | /// be settable before there is any import to have a session about. |
| 876 | /// |
| 877 | /// The session's own pair is the project's (it is saved with it): these are |
| 878 | /// pushed at every new one ([`Player::apply_proxies`]) and taken back from |
| 879 | /// a project as it loads ([`Player::install_project`]), so the button, the |
| 880 | /// switch and the file cannot come to disagree. Their initial values are |
| 881 | /// the ones a fresh session comes up at. |
| 882 | proxies_on: bool, |
| 883 | auto_proxies_on: bool, |
| 884 | /// The autosave period in seconds, `None` for Off ([`player::library::AUTOSAVE_CHOICES`]). |
| 885 | autosave_secs: Option<u64>, |
| 886 | /// The keybindings overlay is up. While it is, it owns the keyboard and the |
| 887 | /// pointer: a stroke or a click meant for a row must not also cut the |
| 888 | /// timeline. |
| 889 | keys_open: bool, |
| 890 | /// The About dialog is up (Help → About edith…). |
| 891 | about_open: bool, |
| 892 | /// The settings page is up (`?` overlay's sibling, but a latch rather |
| 893 | /// than a hold -- it carries clickable rows, not a glance-and-release |
| 894 | /// list). Cleared by [`Player::close_card`], the one reset list every |
| 895 | /// opener routes through. |
| 896 | settings_open: bool, |
| 897 | /// Which of the settings page's three tabs is showing |
| 898 | /// ([`ui::settings_stance::render`]'s strip). A field rather than state |
| 899 | /// inside the page so a close and a reopen return to the section a hand |
| 900 | /// left; it is deliberately *not* in [`Player::close_card`]'s reset list, |
| 901 | /// the same way the dock's tab pick outlives its panel |
| 902 | /// ([`Player::dock_src_active`]). Nothing but the strip reads it, and |
| 903 | /// picking a tab writes no project value, so the pick never arms |
| 904 | /// autosave. |
| 905 | settings_tab: ui::settings_stance::SettingsTab, |
| 906 | /// What the KEYS tab is waiting on (a filter, a capture, a swap question), |
| 907 | /// and the filter's text. Display state only: nothing here reaches a |
| 908 | /// project, and the keymap itself is saved once a stroke is taken. |
| 909 | settings_key_edit: Option<ui::settings_stance::KeyEdit>, |
| 910 | settings_keys_filter: String, |
| 911 | /// Which of the showing tab's choice rows the keyboard is on |
| 912 | /// ([`ui::settings_stance::settings_arrow`]): `↑`/`↓` move it, `←`/`→` |
| 913 | /// step that row's value. Display state only, cleared with a tab switch. |
| 914 | settings_focus: Option<usize>, |
| 915 | /// Where the actions list is scrolled to. Held here rather than left to |
| 916 | /// the wheel alone: forty actions are four times what a 360 px window |
| 917 | /// shows, and the rows past the fold have to be reachable from the |
| 918 | /// keyboard. |
| 919 | keys_scroll: ScrollHandle, |
| 920 | /// The export panel body's scroll (wheel, and up/down/page keys). |
| 921 | export_scroll: ScrollHandle, |
| 922 | /// The Ctrl+K command palette is up (DESIGN §4.4). While it is, it owns the |
| 923 | /// keyboard: its field takes the typed letters and the arrows move the |
| 924 | /// highlight. Opened and closed through `Player::show_actions` and the |
| 925 | /// palette's own keys in `ui::stance`. |
| 926 | pub(crate) palette_open: bool, |
| 927 | /// What the palette's field holds, matched against every action's label. |
| 928 | pub(crate) palette_query: String, |
| 929 | /// The highlighted row, an index into `Player::palette_list`. |
| 930 | pub(crate) palette_sel: usize, |
| 931 | /// The palette's row list. Scrolled to keep the highlight in view. |
| 932 | pub(crate) palette_scroll: ScrollHandle, |
| 933 | /// Where the lane column and the inspector's rows have been taken to. Read |
| 934 | /// back at render, not only written by the wheel: the line each of them |
| 935 | /// carries about what is below the fold is a count of what is *still* below |
| 936 | /// it, and a scroll that nothing reads is a scroll the affordance cannot |
| 937 | /// follow. |
| 938 | lanes_scroll: ScrollHandle, |
| 939 | /// And where the equalizer card's own body has been taken to. It is the |
| 940 | /// tallest card in the column -- a graph with a row of numbers and a row of |
| 941 | /// buttons under it -- and at the 360 px floor its title and its buttons |
| 942 | /// were off both ends of the column with no way to reach them. |
| 943 | eq_scroll: ScrollHandle, |
| 944 | /// The export sheet's scrolled body: read at paint time so its "more |
| 945 | /// below" fade shows only while there is more below. |
| 946 | pub(crate) export_body_scroll: ScrollHandle, |
| 947 | /// The Settings rows' scroll, for the same fade. |
| 948 | pub(crate) settings_rows_scroll: ScrollHandle, |
| 949 | /// The export options card is up: what the export action opens now, so |
| 950 | /// nothing is written until the card's own button says so. One card at a |
| 951 | /// time -- opening either closes the other, since both are the whole window |
| 952 | /// and two stacked scrims say nothing about which one is listening. |
| 953 | export_open: bool, |
| 954 | /// The dock's Transcript tab is showing, and its words. |
| 955 | transcript_open: bool, |
| 956 | transcript: player::transcript::Transcript, |
| 957 | /// The export budget, in bits per second -- the moment's one number, and |
| 958 | /// the only thing the encoder actually takes. Zero means nobody has |
| 959 | /// chosen: the lever then reads the engine's own automatic figure for |
| 960 | /// this picture ([`Player::budget_bps`]), which is what keeps it off the |
| 961 | /// "0 Mbps" the old `custom_mbps: 0` default put on screen. |
| 962 | custom_bps: u64, |
| 963 | /// The budget *while it is being typed*, or `None` when nobody is typing. |
| 964 | /// Free text and not digits: `850k`, `6.5M`, `6.5` and `1.2G` are all |
| 965 | /// ways of saying one budget ([`parse_budget`]). Nothing on this surface |
| 966 | /// takes gpui focus (the root keeps the keyboard), so the field is a |
| 967 | /// modal state on the player and the root's handler types into it. |
| 968 | budget_edit: Option<String>, |
| 969 | /// The Clip tab's transition duration row, the same way (DEBT #111): |
| 970 | /// the anchor clip's frame count while it is being typed, `None` when |
| 971 | /// nobody is. Opened on the row's own click, closed on the same field's |
| 972 | /// enter/esc the export card's field already answers to |
| 973 | /// ([`Player::param_card_key`]). |
| 974 | transition_edit: Option<ui::kit::NumberEdit>, |
| 975 | /// What the *sound* is coded at, in kbps, for every format that encodes it |
| 976 | /// -- the AAC inside a video export as much as an MP3. Kept across closes |
| 977 | /// like the picture's quality, and starts at the figure this program wrote |
| 978 | /// before the row existed ([`engine::export::DEFAULT_AUDIO_KBPS`]), so a |
| 979 | /// user who never touches the row gets the file they always got. |
| 980 | audio_kbps: u32, |
| 981 | /// Which file the card will write. Kept across closes like the quality, and |
| 982 | /// what [`Player::export_path`](Player) is named after. |
| 983 | format: Format, |
| 984 | /// The equalizer card is up on this clip -- the lane and index it was |
| 985 | /// opened on. Held rather than re-read from `selected` every paint because |
| 986 | /// the card is modal: while it is up nothing else can move an index, and |
| 987 | /// the one edit it makes (`set_eq`) moves none. |
| 988 | eq_open: Option<(Lane, usize)>, |
| 989 | /// Whichever of the seven param cards is open, filling the room in place |
| 990 | /// of the bench/ledger rows instead of its usual capped, floating size |
| 991 | /// (`Player::toggle_maximize`). One flag, not one per card, because only |
| 992 | /// one of them is ever open at a time (`close_card`'s own rule) and it |
| 993 | /// outlives any one card's close/reopen, persisted like the dock tab pick |
| 994 | /// (`ui::dock_stance::load_maximized`/`save_maximized`). |
| 995 | card_maximized: bool, |
| 996 | /// The curve the card is showing, which is the clip's own or the flat |
| 997 | /// five-band default. Edited live and written at the clip once per gesture |
| 998 | /// ([`Player::commit_eq`]): the project's equalizer table is append-only, so |
| 999 | /// a write per pointer sample would be a table entry -- and an undo step -- |
| 1000 | /// per pixel. |
| 1001 | eq_params: EqParams, |
| 1002 | /// Which band the keyboard moves, and which one a drag is holding. |
| 1003 | eq_band: usize, |
| 1004 | /// A handle on the curve is being dragged. Tracked on the root like |
| 1005 | /// `scrubbing`, for the same reason: a hand pulling a band to +12 dB runs |
| 1006 | /// off the top of the graph long before it lets go. |
| 1007 | eq_dragging: bool, |
| 1008 | /// The curve box, recorded at prepaint: gpui hands a mouse listener the |
| 1009 | /// window position only, so this is what a press and a drag are read |
| 1010 | /// against ([`frac_along`], [`frac_down`]). |
| 1011 | eq_graph: Rc<Cell<Bounds<Pixels>>>, |
| 1012 | /// Whether the analyser is drawn behind the curve. On by default -- what |
| 1013 | /// the curve is being *shaped against* is the point of drawing it -- and |
| 1014 | /// off with one press for anyone who would rather read the curve alone. |
| 1015 | /// Card state, not the project's: it changes nothing that plays. |
| 1016 | eq_spectrum: bool, |
| 1017 | /// The colour card is up on this clip -- the lane it is on and its index |
| 1018 | /// there. `None` when it is closed, which is the only place that state |
| 1019 | /// lives: the grade itself is the project's. |
| 1020 | color_open: Option<(Lane, usize)>, |
| 1021 | /// The speed card is up on this clip -- the lane it is on and its index |
| 1022 | /// there, exactly as the colour card's handle is. `None` when it is closed; |
| 1023 | /// the rate itself is the project's, so there is nothing else to hold. |
| 1024 | speed_open: Option<(Lane, usize)>, |
| 1025 | /// The speed bar's box, recorded at prepaint: a mouse listener is handed the |
| 1026 | /// window position only, so this is what a press and a drag are read against |
| 1027 | /// ([`frac_along`]). |
| 1028 | speed_bar: Rc<Cell<Bounds<Pixels>>>, |
| 1029 | /// The bar is being dragged. On the root like the colour card's, for the |
| 1030 | /// same reason: the pointer leaves a 4 px bar on the first move. |
| 1031 | speed_dragging: bool, |
| 1032 | /// The rate the hand is on, held back because the worker still owes a frame |
| 1033 | /// ([`Player::flush_drag`]). What the bar draws while it stands, so the |
| 1034 | /// handle stays under the hand even though the picture has not caught up. |
| 1035 | pending_speed: Option<Speed>, |
| 1036 | /// The speed card is in its ramp mode: the bar sets the speed of the key the next |
| 1037 | /// "Add key" puts at the playhead, not the clip's constant rate. On when the card |
| 1038 | /// opens on a clip that already has a ramp, and by the card's Ramp tab. |
| 1039 | speed_ramp_mode: bool, |
| 1040 | /// The speed the ramp mode's bar holds for the next key; `None` follows the |
| 1041 | /// ramp's own speed at the playhead. |
| 1042 | ramp_key_speed: Option<Speed>, |
| 1043 | /// The mix card is up: every audio track's own volume and the master |
| 1044 | /// limiter, which are project settings and not any clip's -- so unlike the |
| 1045 | /// four clip cards there is no handle to hold, only whether it is open. |
| 1046 | mix_open: bool, |
| 1047 | /// The markers card is up ([`Player::open_markers`]): the project's comment markers |
| 1048 | /// as rows, one card at a time like the rest. |
| 1049 | markers_open: bool, |
| 1050 | /// The undo history card (Edit > History), in the Clip tab beside the others. |
| 1051 | history_open: bool, |
| 1052 | /// The creator tools card is up ([`Player::open_tools`]): Normalize, Captions, Fillers and |
| 1053 | /// Voiceover on four tabs, one card at a time like the rest. |
| 1054 | tools: Option<player::tools::Tools>, |
| 1055 | /// Which run of a tool's background job is current, so a late result is dropped. |
| 1056 | tools_runs: u64, |
| 1057 | /// The effects card is up on this clip -- the lane it is on and its index |
| 1058 | /// ([`Player::open_effects`]). |
| 1059 | effects_open: Option<(Lane, usize)>, |
| 1060 | /// The stack a held bar is showing, written as one undo step on release. |
| 1061 | effects_draft: Option<Vec<engine::effects::Effect>>, |
| 1062 | /// The bar held: the effect's place in the stack and the parameter's in the effect. |
| 1063 | effects_drag: Option<(usize, usize)>, |
| 1064 | /// The kinds are listed under the card's Add effect button. |
| 1065 | effects_adding: bool, |
| 1066 | /// Each bar's box, recorded at prepaint, at `effect * MAX_PARAMS + param`. |
| 1067 | effects_bars: std::cell::RefCell<Vec<Rc<Cell<Bounds<Pixels>>>>>, |
| 1068 | /// The row the markers card has picked, an index into the session's markers. |
| 1069 | marker_sel: usize, |
| 1070 | /// The name or note being retyped on the card, which owns the keyboard while it is |
| 1071 | /// `Some` ([`Player::marker_edit_key`]). |
| 1072 | marker_edit: Option<MarkerEdit>, |
| 1073 | /// Which of its rows the arrow keys move -- a fader, the limiter's ceiling |
| 1074 | /// or its switch. The card's own focus, since nothing in it takes gpui's |
| 1075 | /// (ledger:182). |
| 1076 | mix_field: usize, |
| 1077 | /// The lanes soloed for listening. Not saved and not an undo step: the |
| 1078 | /// session is handed the set ([`PlaybackSession::set_solo`]), and an export |
| 1079 | /// never reads it. |
| 1080 | mix_solo: Vec<Lane>, |
| 1081 | /// The mix card's meters and slider bars, drawn from `&self`, so behind a |
| 1082 | /// `RefCell` ([`player::cards::MixPanel`]). |
| 1083 | mix_panel: std::cell::RefCell<player::cards::MixPanel>, |
| 1084 | /// The mix slider a drag is moving, if one is. |
| 1085 | mix_drag: Option<player::cards::MixDrag>, |
| 1086 | /// The cue plate's own size, in force this session and kept in |
| 1087 | /// `~/.config/edith/subtitle-style` beside the keybindings -- an |
| 1088 | /// app-global preference like the theme, since export never burns |
| 1089 | /// subtitles into the picture. [`SUB_TEXT`] is the default it opens at, |
| 1090 | /// never the value read at paint; [`sub_line_h`](Player::sub_line_h) is |
| 1091 | /// what preview.rs reads for the line height, derived from this. |
| 1092 | sub_text: f32, |
| 1093 | /// Which family the cue plate draws in, or the platform default with |
| 1094 | /// nothing picked -- `None` calls no [`gpui::Styled::font_family`] at |
| 1095 | /// all, which is what leaves the window's own choice in force. |
| 1096 | sub_family: Option<String>, |
| 1097 | /// The outline, the background box and the place of the cue plate: the |
| 1098 | /// rest of the look, kept in the same file as the size and the family. |
| 1099 | sub_outline: SubOutline, |
| 1100 | sub_boxed: bool, |
| 1101 | sub_place: SubPlace, |
| 1102 | /// The size slider is held: a move sets the size, the release keeps it. |
| 1103 | sub_dragging: bool, |
| 1104 | /// The caption style card's font dropdown is open. |
| 1105 | sub_font_open: bool, |
| 1106 | /// The words typed into the open font dropdown's search line (empty when it is closed). |
| 1107 | sub_font_query: String, |
| 1108 | /// The subtitle style card is up. |
| 1109 | subtitle_style_open: bool, |
| 1110 | /// Which of its rows the arrow keys move: 0 is the size stepper, every |
| 1111 | /// row after it a family in [`Self::subtitle_fonts`]. The card's own |
| 1112 | /// focus, since nothing in it takes gpui's (ledger:182). |
| 1113 | subtitle_style_field: usize, |
| 1114 | /// The Animation dropdown of the style card is open (its list hangs from the field). |
| 1115 | sub_anim_open: bool, |
| 1116 | /// The arrow keys have moved a row of the style card, so its pick wears the row |
| 1117 | /// wash; a mouse press on the card clears it again, so a mouse-only user sees no wash. |
| 1118 | sub_keys_used: bool, |
| 1119 | /// Every family the platform can draw, asked for once when the card |
| 1120 | /// opens and kept for as long as it is up: [`gpui::TextSystem::all_font_names`] |
| 1121 | /// walks the whole font registry, which is not a repaint's business. |
| 1122 | subtitle_fonts: Vec<String>, |
| 1123 | /// The silence card is up on this clip -- the lane it is on and its index |
| 1124 | /// there, exactly as the speed card's handle is. |
| 1125 | silence_open: Option<(Lane, usize)>, |
| 1126 | /// The mark-the-beats card is up on this clip, the same handle as `silence_open`. |
| 1127 | beats_open: Option<(Lane, usize)>, |
| 1128 | /// Which beat the card marks: 0 every beat, 1 every second, 2 every fourth. |
| 1129 | beats_every: usize, |
| 1130 | /// When the listening started, while the analysis runs; `None` when idle. |
| 1131 | beats_scan: Option<Instant>, |
| 1132 | /// What the last run said, shown under the section's controls. |
| 1133 | beats_last: Option<String>, |
| 1134 | /// What a scan is told to look for, and how fast the speed-up button plays |
| 1135 | /// what it found. Kept across closes like the export card's quality: a |
| 1136 | /// second run offers what the first one settled on. |
| 1137 | silence: engine::silence::Settings, |
| 1138 | silence_factor: Speed, |
| 1139 | /// How wide the apply reaches ([`Scope`]). Kept across closes for the same |
| 1140 | /// reason, and never *widened* on anyone's behalf: the whole point of it is |
| 1141 | /// that a track nobody named does not move. |
| 1142 | silence_scope: Scope, |
| 1143 | /// Which of the card's [`SILENCE_ROWS`] the arrow keys move. The card's own |
| 1144 | /// focus, since nothing in it takes gpui's (ledger:182). |
| 1145 | silence_field: usize, |
| 1146 | /// Whether the threshold is *labelled* dBFS or dB. Display only, and the |
| 1147 | /// number is the same either way: the setting is a level below full scale, |
| 1148 | /// so 0 is the loudest sample a file can hold and -40 is forty decibels |
| 1149 | /// under it -- "dBFS" names that reference out loud, "dB" leaves it unsaid. |
| 1150 | /// No conversion is hiding behind the row (there is no reference here worth |
| 1151 | /// inventing, and a made-up SPL would be a lie about what was measured); |
| 1152 | /// what it changes is which of the two spellings a person reads. |
| 1153 | silence_dbfs: bool, |
| 1154 | /// Keep only the silences: the card's applies act on the *complement* of |
| 1155 | /// what the scan found -- the speech between the quiet stretches -- so a |
| 1156 | /// cut removes the words and leaves the room tone. Off, today's jumpcut, |
| 1157 | /// until asked; kept across closes like [`Self::silence_dbfs`], which is |
| 1158 | /// the same kind of switch: how the card reads, not what it scans. |
| 1159 | silence_keep_only: bool, |
| 1160 | /// What the last scan found, in timeline frames: what the lane draws marks |
| 1161 | /// over and what an apply acts on -- *exactly* the previewed set, never a |
| 1162 | /// second scan at the moment of the press. |
| 1163 | silence_marks: Vec<(u32, u32)>, |
| 1164 | /// The levels of every stretch scanned this session, kept so moving a |
| 1165 | /// threshold is arithmetic rather than another decode. Keyed by |
| 1166 | /// [`ScanKey`], and not one entry: two films on one timeline would |
| 1167 | /// otherwise evict each other, and the decode being paid twice is the fifty |
| 1168 | /// seconds this card exists to not spend. |
| 1169 | silence_levels: HashMap<ScanKey, Arc<Vec<f32>>>, |
| 1170 | /// The scan a worker is running for the card, if one is. `None` means the |
| 1171 | /// card is drawing numbers it already has. |
| 1172 | silence_scan: Option<SilenceScan>, |
| 1173 | /// Whole-source background scans in flight, keyed the same as |
| 1174 | /// [`Self::silence_levels`]'s own whole-source entries |
| 1175 | /// ([`full_scan_key`]). Started at import ([`Player::cache_media`]) so a |
| 1176 | /// card opened later finds the levels already read; presence here is what |
| 1177 | /// stops a re-add of the same source from starting a second one, and its |
| 1178 | /// [`engine::silence::Progress::cancel`] is what a removed source is told. |
| 1179 | silence_bg: HashMap<(PathBuf, usize), Arc<engine::silence::Progress>>, |
| 1180 | /// Which of the card's four sliders the arrow keys and a drag move. The |
| 1181 | /// card's own focus, since nothing in it takes gpui's (ledger:182). |
| 1182 | color_band: usize, |
| 1183 | /// A slider is being dragged. Tracked on the root like `scrubbing` and the |
| 1184 | /// equalizer's drag, for the same reason: a 4 px bar is left by the pointer |
| 1185 | /// on the first move and its own listeners then stop firing. |
| 1186 | color_dragging: bool, |
| 1187 | /// HSV wheel on CLIP: same 4 px reason as `color_dragging` — the pointer |
| 1188 | /// leaves the disk on the first move, so samples live on the root. |
| 1189 | viz_hs_dragging: bool, |
| 1190 | /// The wheel's box, recorded at prepaint for a drag's window position. |
| 1191 | viz_wheel: Rc<Cell<Bounds<Pixels>>>, |
| 1192 | /// Where the picture actually lands on screen, probed by the picture area |
| 1193 | /// (`render.rs`): what tells the session to paint at the size the preview |
| 1194 | /// is *watched* at rather than at the project's own |
| 1195 | /// ([`engine::PlaybackSession::set_view_size`]). |
| 1196 | picture_box: Rc<Cell<Bounds<Pixels>>>, |
| 1197 | /// A screenshot asked for while the picture was painted at the preview's |
| 1198 | /// own size: `(session, stem, timecode)`, written by [`Player::flush_shot`] |
| 1199 | /// once the seat has painted one frame at the project's size. Taken at the |
| 1200 | /// ask so a shot mid-playback is named for the frame it was asked at, not |
| 1201 | /// for the one it landed on -- and *keyed to the session that asked*, so a |
| 1202 | /// swap mid-flight (a preview opened, another file opened, a session |
| 1203 | /// closed) cannot have the new session's frame written under the old name |
| 1204 | /// ([`Player::session_swapped`]). |
| 1205 | shot_pending: Option<(u64, String, String)>, |
| 1206 | /// The viewer size a playing picture was last asked for, and when it first |
| 1207 | /// asked for it: a resize is applied only once it has held still for |
| 1208 | /// `VIEW_SETTLE` ([`Player::push_view_size`]). `None` while paused. |
| 1209 | view_seen: Option<((u32, u32), Instant)>, |
| 1210 | /// The active session's identity, for the above: bumped by every door that |
| 1211 | /// swaps `session` or `preview_session`. |
| 1212 | session_gen: u64, |
| 1213 | /// The engine's own word on the sound device, as the last pump saw it: the |
| 1214 | /// cache [`Player::watch_audio`] compares each frame against so a reason is |
| 1215 | /// announced once when it *changes* and taken back when it clears. `None` |
| 1216 | /// while the sound is up; seeded by [`Player::session_swapped`], which every |
| 1217 | /// door that installs or drops a session already calls. |
| 1218 | audio_reason: Option<String>, |
| 1219 | /// The engine's last word on the *picture*, cached so a frame can tell a |
| 1220 | /// reason that changed from one that was merely read again. Keyed to |
| 1221 | /// `session_gen` for the same reason `audio_watch_gen` is: `pump` serves |
| 1222 | /// the preview while one is up and the timeline otherwise, and an unkeyed |
| 1223 | /// cache would read the other session's reason. |
| 1224 | decode_reason_cache: Option<String>, |
| 1225 | decode_watch_gen: u64, |
| 1226 | /// Which session generation (`session_gen`) the cached reason above describes: |
| 1227 | /// the watch is keyed to the session it is a statement about, so a preview |
| 1228 | /// opening or closing seeds the cache instead of announcing the *other* |
| 1229 | /// session's device. |
| 1230 | audio_watch_gen: u64, |
| 1231 | /// Which of the clip's two inks the look section's wheel and colour field |
| 1232 | /// act on ([`VizSlot`]): the clip's own colour, or the ring's dual half. |
| 1233 | /// The pick stays picked across clips, the way the dock tab's does. |
| 1234 | viz_slot: VizSlot, |
| 1235 | /// The colour field's text, while the Clip tab's colour row is being typed |
| 1236 | /// into ([`Player::edit_viz_hex`]). `None` is the row showing the colour |
| 1237 | /// itself; `Some` is the buffer, its refusal, and the caret on screen. |
| 1238 | viz_hex_edit: Option<ColorEdit>, |
| 1239 | /// The subtitle cue being retyped on its block, while one is open |
| 1240 | /// ([`Player::open_cue_edit`]). `None` is every block showing its words. |
| 1241 | cue_edit: Option<CueEdit>, |
| 1242 | /// The caption cue picked on a subtitle lane (`Lane`, track, cue): the one block a click |
| 1243 | /// selected, which the caption menu and the Delete key act on ([`player::caption_cues`]). |
| 1244 | sel_cue: Option<(Lane, usize, usize)>, |
| 1245 | /// A number of the caption panel being typed (start, end or length) and its buffer. |
| 1246 | cue_num: Option<(player::caption_cues::CueNum, ui::kit::NumberEdit)>, |
| 1247 | /// A caption panel number being dragged sideways ([`player::caption_cues::CueNumScrub`]). |
| 1248 | cue_num_scrub: Option<player::caption_cues::CueNumScrub>, |
| 1249 | /// The settings page's still image length, while it is typed in seconds. |
| 1250 | still_num: Option<ui::kit::NumberEdit>, |
| 1251 | /// A caption's edge or body being dragged, until the release writes it as one edit. |
| 1252 | cue_drag: Option<player::caption_cues::CueDrag>, |
| 1253 | /// The caption menu, while a right-click on a cue block has it open. |
| 1254 | cue_menu: Option<player::caption_cues::CueMenu>, |
| 1255 | /// The ink the hand is on, held back because the worker still owes a frame |
| 1256 | /// ([`Self::pending_color`]'s own reason, and a wheel sample is heavier |
| 1257 | /// than a grade's: it is not a table entry but the painter's own input, so |
| 1258 | /// the write is what rebuilds the picture). What the wheel draws while it |
| 1259 | /// stands, and never lost -- the frame that lands writes it, and so does |
| 1260 | /// the release. The slot the sample was taken on rides with it. |
| 1261 | pending_viz: Option<(VizSlot, u8, u8)>, |
| 1262 | /// Each slider's box, recorded at prepaint: a mouse listener is handed the |
| 1263 | /// window position only, so this is what a press and a drag are read against |
| 1264 | /// ([`frac_along`]). One per band, because the press picks the row it landed |
| 1265 | /// on and the drag then belongs to that row's range. |
| 1266 | color_bars: [Rc<Cell<Bounds<Pixels>>>; COLOR_SLOTS], |
| 1267 | /// The colour card's section on show ([`ColorSection`]): one at a time, so |
| 1268 | /// the card keeps its height whichever the hand is in. |
| 1269 | color_section: ColorSection, |
| 1270 | /// The Wheels section's wheel (lift, gamma, gain) and the Curves section's |
| 1271 | /// channel (master, red, green, blue). |
| 1272 | color_wheel: usize, |
| 1273 | /// A wheel's puck (`false`) or master bar (`true`) is being dragged, on that |
| 1274 | /// wheel: the root follows the pointer, as for `color_dragging`. |
| 1275 | color_wheel_drag: Option<(usize, bool)>, |
| 1276 | /// Each wheel's pad box and master bar box, recorded at prepaint. |
| 1277 | color_pads: [Rc<Cell<Bounds<Pixels>>>; 3], |
| 1278 | color_masters: [Rc<Cell<Bounds<Pixels>>>; 3], |
| 1279 | color_curve: usize, |
| 1280 | /// What the graph over the colour controls shows, and the scopes counted |
| 1281 | /// off the frame on screen while it shows one (`None` for the histogram, |
| 1282 | /// which counts nothing extra). |
| 1283 | scope_view: ScopeView, |
| 1284 | scopes: Option<engine::scopes::Scopes>, |
| 1285 | /// The grade the hand is on, held back because the worker still owes a |
| 1286 | /// frame ([`Player::flush_drag`]): a live write into a busy worker only |
| 1287 | /// cancels the open the picture is already waiting for, so a bar-wide sweep |
| 1288 | /// would pay for forty of them and show one. What the sliders draw while it |
| 1289 | /// stands, and never lost -- the frame that lands writes it, and so does the |
| 1290 | /// release. |
| 1291 | pending_color: Option<ColorParams>, |
| 1292 | /// The transform card is up on this clip -- the lane it is on and its |
| 1293 | /// index there, exactly as the colour card's handle is. `None` when it is |
| 1294 | /// closed: the placement itself is the project's. |
| 1295 | transform_open: Option<(Lane, usize)>, |
| 1296 | /// Which of the card's eight sliders the arrow keys and a drag move. The |
| 1297 | /// card's own focus, since nothing in it takes gpui's (ledger:182). |
| 1298 | transform_band: usize, |
| 1299 | /// A slider is being dragged. Tracked on the root like the colour card's, |
| 1300 | /// for the same reason: a 4 px bar is left by the pointer on the first |
| 1301 | /// move and its own listeners then stop firing. |
| 1302 | transform_dragging: bool, |
| 1303 | /// The opacity row's bar is being dragged: its samples go to the opacity, not a band. |
| 1304 | opacity_drag: bool, |
| 1305 | /// The opacity row's bar, recorded at prepaint like the transform bars. |
| 1306 | opacity_bar: Rc<Cell<Bounds<Pixels>>>, |
| 1307 | /// Each easing curve editor's box, by the target it edits, recorded at prepaint: a press and |
| 1308 | /// a drag on an editor are read against its own box. The transform card can show two editors |
| 1309 | /// at once, one per key row, and an effect's editor sits beside them. |
| 1310 | curve_bounds: std::cell::RefCell<HashMap<ui::cards::curve::CurveTarget, Rc<Cell<Bounds<Pixels>>>>>, |
| 1311 | /// A curve handle is held: its draft curve, written to the key when the button comes up. |
| 1312 | curve_drag: Option<ui::cards::curve::CurveDrag>, |
| 1313 | /// Each slider's box, recorded at prepaint -- [`Self::color_bars`]' own |
| 1314 | /// reason, one per band. |
| 1315 | transform_bars: [Rc<Cell<Bounds<Pixels>>>; TRANSFORM_BANDS.len()], |
| 1316 | /// The placement the hand is on, held back because the worker still owes a |
| 1317 | /// frame -- [`Self::pending_color`]'s own reason. |
| 1318 | pending_transform: Option<TransformParams>, |
| 1319 | /// The frame on screen counted into `HIST_BINS` bins per channel -- the |
| 1320 | /// *graded* frame, because the grade is applied in the decode worker and |
| 1321 | /// what arrives here is already through it. Refilled by every pumped frame, |
| 1322 | /// which is what makes the colour card's graph move as a slider is dragged: |
| 1323 | /// each live write reseeks, and the reseek's frame is the next count. |
| 1324 | histogram: [u32; HIST_BINS], |
| 1325 | /// The open `More …` folds, by panel id, kept in the panel-folds file |
| 1326 | /// ([`load_folds`] / [`save_folds`]) so a fold stays as the user left it. |
| 1327 | folds: BTreeSet<String>, |
| 1328 | /// What the file actions have had to say, oldest first. A *queue* and not a |
| 1329 | /// slot: two imports that fail back to back used to be one message, because |
| 1330 | /// the second overwrote the first before a frame had drawn it -- the failure |
| 1331 | /// a user never learns about is the one that was answered by another |
| 1332 | /// failure. The front holds its own bar above the panel until it is answered |
| 1333 | /// -- any key retires it, so does a click on it -- the bar says how many are |
| 1334 | /// behind it, and answering it brings the next one up. |
| 1335 | notices: std::collections::VecDeque<crate::notices::Toast>, |
| 1336 | /// How tall the transient bars hanging off the bottom of the picture (the |
| 1337 | /// import line, the seek line, the notice) came out at prepaint, so the cue |
| 1338 | /// plate can sit clear of them ([`sub_bottom`]). Measured and not counted: |
| 1339 | /// a notice wraps to as many lines as the window is narrow. |
| 1340 | notice_h: Rc<Cell<Pixels>>, |
| 1341 | /// What the last finished export wrote, so the notice can be the way to it. |
| 1342 | /// Only the [`EXPORT_DONE`] line reads it -- any later notice has replaced |
| 1343 | /// that text -- so a click never opens a file the bar is not naming. |
| 1344 | exported: Option<PathBuf>, |
| 1345 | /// What the compositor was last told this window is called. Setting a title |
| 1346 | /// is a protocol round trip and a repaint is sixty a second, so the title is |
| 1347 | /// pushed only when it is not this any more. |
| 1348 | titled: String, |
| 1349 | displayed: u32, |
| 1350 | /// Frames the picture skipped in the current run, because it was behind the clock |
| 1351 | /// ([`Player::dropped_words`]); restarts at each play. |
| 1352 | dropped: u32, |
| 1353 | /// Whether the transport was playing at the last pump, and when it last stopped, so the |
| 1354 | /// dropped-frames words stay up for a few seconds after a stop. |
| 1355 | playing_last: bool, |
| 1356 | drop_stop: Option<Instant>, |
| 1357 | /// When the picture was last restarted at the clock for falling behind it |
| 1358 | /// ([`should_resync`]). The cool-down's only state. |
| 1359 | resynced: Option<Instant>, |
| 1360 | /// Wall clock of the first displayed frame -- the real-speed measurement. |
| 1361 | started: Option<Instant>, |
| 1362 | focus: FocusHandle, |
| 1363 | /// The three focus-ring surfaces (`ui::stance::Surface`) Tab/Shift-Tab |
| 1364 | /// cycles between once one of them holds focus -- `focus` above stays |
| 1365 | /// the fallback none of these keys ever leave. |
| 1366 | focus_dock: FocusHandle, |
| 1367 | focus_bench: FocusHandle, |
| 1368 | focus_inspector: FocusHandle, |
| 1369 | /// The settings page's KEYS list. Takes the keyboard while the page is |
| 1370 | /// capturing or filtering, so its own key listener sees the strokes first. |
| 1371 | focus_settings: FocusHandle, |
| 1372 | /// Tab stops handed to a dialog's controls as it is built ([`ui::kit::tab_scope`]). |
| 1373 | dlg_pool: Vec<FocusHandle>, |
| 1374 | /// Whether a dialog was up at the last frame, to give the root the keyboard when one opens. |
| 1375 | dlg_was_up: bool, |
| 1376 | /// A [`Player::guard_focus`] check is already waiting for its frame. |
| 1377 | focus_guard_pending: bool, |
| 1378 | } |
| 1379 | |
| 1380 | #[cfg(test)] |
| 1381 | mod tests; |
| 1382 | |
| 1383 | fn main() { |
| 1384 | // What a killed editor left behind: `.part` proxies from an encode that |
| 1385 | // never got to unlink its own half-written file. Run once, here, before |
| 1386 | // anything in this process could claim one of its own -- every `.part` on |
| 1387 | // disk at this instant belongs to nobody still running. |
| 1388 | engine::proxy::sweep_stale_parts(); |
| 1389 | // A keymap file that cannot be read leaves the defaults in force, and takes |
| 1390 | // the notice slot ahead of an open or import refusal: it is about every key |
| 1391 | // the window has, and those refusals are on stderr either way. |
| 1392 | let (keymap, notice) = Keymap::load(); |
| 1393 | if let Some(text) = ¬ice { |
| 1394 | eprintln!("{text}"); |
| 1395 | } |
| 1396 | // The palette the last session picked, before the first paint: a window that |
| 1397 | // opened in the default and turned warm a frame later would be the theme |
| 1398 | // announcing itself. Silent on a missing or unreadable file -- the default |
| 1399 | // (`PaletteId::DEFAULT`, darkroom) is a whole answer, and nothing of the |
| 1400 | // user's is lost by it. |
| 1401 | ui::theme::load(); |
| 1402 | ui::theme::load_accent(); |
| 1403 | // The subtitle style the last session picked, same silence on a missing |
| 1404 | // or unreadable file. |
| 1405 | let sub_style = load_subtitle_style(); |
| 1406 | // The auto-proxies default the last session left the switch at, before |
| 1407 | // any project's own line ([`engine::edith::Document::auto_proxy`]) |
| 1408 | // overrides it the moment one opens. |
| 1409 | let auto_proxies_on = player::library::load_auto_proxies_pref(); |
| 1410 | // The Proxies default the last session left the switch at, same |
| 1411 | // before-any-project-line precedence as the auto-proxies default above. |
| 1412 | let proxies_on = player::library::load_proxies_pref(); |
| 1413 | // The autosave period the last session left the Settings row at. |
| 1414 | let autosave_secs = player::library::load_autosave_pref(); |
| 1415 | // The picture and sound this computer last exported with, same silence on |
| 1416 | // a missing or unreadable file as the switches above. |
| 1417 | let export_prefs = export_ui::load_export_prefs(); |
| 1418 | // Nothing named on the command line is read here. The first file makes the |
| 1419 | // timeline -- a `.edith` restores a whole one, anything else *is* one -- |
| 1420 | // and the rest are imports like any other: rows in the library, dragged |
| 1421 | // onto a lane when they are wanted there. All of them go through the queue |
| 1422 | // a drop uses ([`Player::import`]), which is the door with a progress line |
| 1423 | // on it, and their refusals arrive in the notice bar as a drop's do. |
| 1424 | // |
| 1425 | // Queued rather than opened because a 25 GB film cold is twelve seconds of |
| 1426 | // header walk, and it used to be twelve seconds of *no window at all* -- a |
| 1427 | // window that has not opened cannot say what it is waiting for. Now the |
| 1428 | // window is up in the time it takes to make one, naming the file and the |
| 1429 | // read that is running, and the timeline appears when that read lands |
| 1430 | // ([`Player::take_import`]). |
| 1431 | // |
| 1432 | // No argument at all opens the window empty, exactly as before: the library |
| 1433 | // then arrives by drop or by the Import button. |
| 1434 | let (arg, queue) = launch_queue(std::env::args().skip(1).map(PathBuf::from)); |
| 1435 | let name: SharedString = arg |
| 1436 | .as_deref() |
| 1437 | .map_or_else(|| NO_FILE.into(), |arg| file_name(arg).into()); |
| 1438 | |
| 1439 | Application::new().with_assets(ui::icons::Assets).run(move |cx: &mut App| { |
| 1440 | // Bundled Archivo / Spline Sans Mono, before the first paint -- |
| 1441 | // DESIGN §3's two faces, embedded so no build depends on the host |
| 1442 | // having them installed (see `ui::type_scale`'s doc comment). |
| 1443 | ui::type_scale::register(cx); |
| 1444 | // 720p: the picture's own size is not known yet -- knowing it is the |
| 1445 | // twelve seconds this window exists to be up during -- and a window |
| 1446 | // that resized itself under a hand already dragging it would be worse |
| 1447 | // than one that opened at the size the empty window has always used. |
| 1448 | let bounds = Bounds::centered(None, size(px(1280.), px(720.)), cx); |
| 1449 | cx.open_window( |
| 1450 | WindowOptions { |
| 1451 | window_bounds: Some(WindowBounds::Windowed(bounds)), |
| 1452 | titlebar: Some(TitlebarOptions { |
| 1453 | title: Some("edith".into()), |
| 1454 | ..Default::default() |
| 1455 | }), |
| 1456 | // What a desktop groups this window under. The title beside it |
| 1457 | // is pushed from the render, because wayland takes neither of |
| 1458 | // them from the titlebar options above (gpui's wayland window |
| 1459 | // reads only `app_id`, window.rs:1202 / window.rs:939) and the |
| 1460 | // title has to follow the file being opened anyway. |
| 1461 | app_id: Some("edith".to_string()), |
| 1462 | ..Default::default() |
| 1463 | }, |
| 1464 | |window, cx| { |
| 1465 | let queue = queue.clone(); |
| 1466 | let player = cx.new(|cx| Player { |
| 1467 | // Nothing to wait for yet: the file named on the command |
| 1468 | // line is still queued, and the repaint that carries its |
| 1469 | // poster frame to the screen is asked for when it lands |
| 1470 | // (`open_media` -> `reset_after_reseek`). |
| 1471 | seek_since: None, |
| 1472 | resynced: None, |
| 1473 | session: None, |
| 1474 | pending_settings: (None, None, None), |
| 1475 | pending_template: None, |
| 1476 | welcome_templates: false, |
| 1477 | preview_session: None, |
| 1478 | preview_playing: false, |
| 1479 | source_marks: HashMap::new(), |
| 1480 | source_target: None, |
| 1481 | source_hint: false, |
| 1482 | source_video: true, |
| 1483 | source_audio: true, |
| 1484 | patch_video: Lane::V1, |
| 1485 | patch_audio: Lane::A1, |
| 1486 | player_fullscreen: false, |
| 1487 | loop_on: false, |
| 1488 | range: None, |
| 1489 | loop_trim: None, |
| 1490 | // Full and unmuted, which is what the session it was just |
| 1491 | // handed is already set to: nothing to push at startup. |
| 1492 | volume: Volume::default(), |
| 1493 | volume_bar: Rc::default(), |
| 1494 | preview_bar: Rc::default(), |
| 1495 | preview_scrubbing: false, |
| 1496 | volume_dragging: false, |
| 1497 | // What a session comes up at, so the first one opened is |
| 1498 | // pushed the values it already holds. |
| 1499 | proxies_on, |
| 1500 | auto_proxies_on, |
| 1501 | autosave_secs, |
| 1502 | // Only ever used with a timeline; 30 keeps the empty |
| 1503 | // timecode reading in frames rather than in NaN. |
| 1504 | fps: 30., |
| 1505 | ruler: Rc::default(), |
| 1506 | lane_beds: Rc::default(), |
| 1507 | marquee: None, |
| 1508 | scroll_track: Rc::default(), |
| 1509 | scroll_drag: None, |
| 1510 | lanes_drag: None, |
| 1511 | // draws: the title bar and the header name it while its |
| 1512 | // header is still being read. |
| 1513 | name: name.clone(), |
| 1514 | image: None, |
| 1515 | retired_images: Vec::new(), |
| 1516 | output: None, |
| 1517 | output_display: None, |
| 1518 | output_displays: Vec::new(), |
| 1519 | sub_image: None, |
| 1520 | held: None, |
| 1521 | notice_h: Rc::default(), |
| 1522 | // A second is [`PPS_DEFAULT`] pixels wide until someone |
| 1523 | // zooms or asks for the fit: a project opens at a scale, not |
| 1524 | // at whatever its first import happens to be long. |
| 1525 | scale: Scale::default(), |
| 1526 | // Nobody has scrolled anything yet, so the follow has the |
| 1527 | // view: the first frame is drawn where the head is. |
| 1528 | panned: false, |
| 1529 | fit_pending: false, |
| 1530 | fitted_bed: None, |
| 1531 | lane_h: Vec::new(), |
| 1532 | viewer: viewer_view::Prefs::default(), |
| 1533 | viewer_pan: (0., 0.), |
| 1534 | viewer_drag: None, |
| 1535 | viewer_handle: None, |
| 1536 | viewer_btns: Default::default(), |
| 1537 | lane_resize: None, |
| 1538 | selected: Selection::new(), |
| 1539 | gap: None, |
| 1540 | context_menu: None, |
| 1541 | menu_open: None, |
| 1542 | menu_hopped: None, |
| 1543 | menu_sub: None, |
| 1544 | menu_sub2: None, |
| 1545 | ledger_readout: Rc::default(), |
| 1546 | toast_text: Rc::default(), |
| 1547 | sub_hot: Sub::Closed, |
| 1548 | adjust_aim: None, |
| 1549 | adjust_sub: Cell::new(None), |
| 1550 | picker: None, |
| 1551 | library_menu: None, |
| 1552 | selected_asset: None, |
| 1553 | asset_picks: Vec::new(), |
| 1554 | angle_monitor: false, |
| 1555 | angle_shots: Default::default(), |
| 1556 | dock_src_active: ui::dock_stance::load(), |
| 1557 | dock_filter: String::new(), |
| 1558 | dock_filter_edit: false, |
| 1559 | keys_filter: String::new(), |
| 1560 | waves: HashMap::new(), |
| 1561 | thumbs: HashMap::new(), |
| 1562 | proxies: HashMap::new(), |
| 1563 | render: None, |
| 1564 | render_bands: Vec::new(), |
| 1565 | render_bands_stamp: None, |
| 1566 | render_progress: None, |
| 1567 | stab_waiting: Vec::new(), |
| 1568 | track_jobs: Vec::new(), |
| 1569 | reframe_run: None, |
| 1570 | reframed: None, |
| 1571 | mcam_run: None, |
| 1572 | seq_trail: Vec::new(), |
| 1573 | seq_edit: None, |
| 1574 | lane_edit: None, |
| 1575 | time_edit: None, |
| 1576 | compare: viewer_view::Compare::Off, |
| 1577 | before: None, |
| 1578 | before_at: None, |
| 1579 | before_busy: false, |
| 1580 | shown_frame: None, |
| 1581 | look_open: false, |
| 1582 | saved_looks: Vec::new(), |
| 1583 | look_name: None, |
| 1584 | look_mark: None, |
| 1585 | collapsed_bins: Default::default(), |
| 1586 | sections_mem: Vec::new(), |
| 1587 | sections_anchor: None, |
| 1588 | selected_bin: None, |
| 1589 | bin_edit: None, |
| 1590 | title_sel: None, |
| 1591 | title_draft: None, |
| 1592 | title_hex: None, |
| 1593 | gen_hex: None, |
| 1594 | gen_scrub: None, |
| 1595 | deinterlace_open: false, |
| 1596 | place_open: false, |
| 1597 | title_in_open: false, |
| 1598 | title_out_open: false, |
| 1599 | effects_mode_open: None, |
| 1600 | eq_shape_open: false, |
| 1601 | transition_kind_open: false, |
| 1602 | transition_section_open: false, |
| 1603 | accent_hex: None, |
| 1604 | accent_drag: None, |
| 1605 | accent_vivid_bar: Rc::default(), |
| 1606 | accent_hue_bar: Rc::default(), |
| 1607 | title_scrub: None, |
| 1608 | pan_scrub: None, |
| 1609 | streams: HashMap::new(), |
| 1610 | has_video: HashMap::new(), |
| 1611 | bitrates: HashMap::new(), |
| 1612 | facts: HashMap::new(), |
| 1613 | sizes: HashMap::new(), |
| 1614 | syncs: HashMap::new(), |
| 1615 | decoders: HashMap::new(), |
| 1616 | export_seat: None, |
| 1617 | hw_caps: None, |
| 1618 | clipboard: Vec::new(), |
| 1619 | copied_look: None, |
| 1620 | scrubbing: false, |
| 1621 | splits: load_stance_splits(bounds.size), |
| 1622 | split_drag: None, |
| 1623 | split_press: None, |
| 1624 | trim: None, |
| 1625 | pro_drag: None, |
| 1626 | hover_hint: None, |
| 1627 | trim_flash: None, |
| 1628 | drag_src: None, |
| 1629 | fade_drag: None, |
| 1630 | gain_edit: None, |
| 1631 | gain_hover: None, |
| 1632 | gain_pick: None, |
| 1633 | grab: 0, |
| 1634 | snap: true, |
| 1635 | drag_alt: false, |
| 1636 | drag_ctrl: false, |
| 1637 | drag_below: false, |
| 1638 | subs_on: true, |
| 1639 | waveforms: true, |
| 1640 | scrub_audio: true, |
| 1641 | play_around: None, |
| 1642 | sub_track: 0, |
| 1643 | sub_folded: HashSet::new(), |
| 1644 | sub_lane: None, |
| 1645 | snap_cue: None, |
| 1646 | menu_frame: None, |
| 1647 | ghost: Vec::new(), |
| 1648 | drag_x: None, |
| 1649 | drag_lane: None, |
| 1650 | lane_drop: None, |
| 1651 | last_scrub: Instant::now(), |
| 1652 | last_target: 0, |
| 1653 | export: None, |
| 1654 | cancelling: false, |
| 1655 | cancel_armed: false, |
| 1656 | export_started: None, |
| 1657 | export_marks: Vec::new(), |
| 1658 | queue: export_queue::ExportQueue::default(), |
| 1659 | // Both derived from the file when it lands, by the same |
| 1660 | // `open_media`/`load_project` a drop goes through: an |
| 1661 | // export beside the picture, a save beside it too. |
| 1662 | export_path: PathBuf::new(), |
| 1663 | export_known: None, |
| 1664 | project_path: PathBuf::new(), |
| 1665 | autosave_dirty: false, |
| 1666 | autosave_edits: 0, |
| 1667 | autosave_last_run: None, |
| 1668 | autosave_urgent: false, |
| 1669 | recovery_sidecar: None, |
| 1670 | recovery_failure: None, |
| 1671 | quit_ask: false, |
| 1672 | save_ask: false, |
| 1673 | proj_dialog: None, |
| 1674 | new_project: None, |
| 1675 | new_project_fresh: false, |
| 1676 | export_ask: false, |
| 1677 | export_sheet: export_ui::ExportSheet { |
| 1678 | size: export_prefs.size, |
| 1679 | bit_depth: export_prefs.depth, |
| 1680 | prores: export_prefs.prores, |
| 1681 | hdr: export_prefs.hdr, |
| 1682 | hevc_speed: export_prefs.hevc_speed, |
| 1683 | sound_bits: export_prefs.sound_bits, |
| 1684 | ..Default::default() |
| 1685 | }, |
| 1686 | autosave_armed: false, |
| 1687 | disk_known: None, |
| 1688 | edited_since_save: false, |
| 1689 | saved_revision: None, |
| 1690 | keymap: keymap.clone(), |
| 1691 | keys_open: false, |
| 1692 | about_open: false, |
| 1693 | settings_open: false, |
| 1694 | settings_tab: ui::settings_stance::SettingsTab::Project, |
| 1695 | settings_key_edit: None, |
| 1696 | settings_keys_filter: String::new(), |
| 1697 | settings_focus: None, |
| 1698 | keys_scroll: ScrollHandle::new(), |
| 1699 | export_scroll: ScrollHandle::new(), |
| 1700 | palette_open: false, |
| 1701 | palette_query: String::new(), |
| 1702 | palette_sel: 0, |
| 1703 | palette_scroll: ScrollHandle::new(), |
| 1704 | lanes_scroll: ScrollHandle::new(), |
| 1705 | eq_scroll: ScrollHandle::new(), |
| 1706 | export_body_scroll: ScrollHandle::new(), |
| 1707 | settings_rows_scroll: ScrollHandle::new(), |
| 1708 | export_open: false, |
| 1709 | transcript_open: false, |
| 1710 | transcript: player::transcript::Transcript::new(), |
| 1711 | eq_open: None, |
| 1712 | card_maximized: false, |
| 1713 | // Replaced by the clip's own curve the moment the card |
| 1714 | // opens; nothing reads it before that. |
| 1715 | eq_params: EqParams::default(), |
| 1716 | eq_band: 0, |
| 1717 | eq_dragging: false, |
| 1718 | eq_graph: Rc::default(), |
| 1719 | eq_spectrum: true, |
| 1720 | speed_open: None, |
| 1721 | speed_bar: Rc::default(), |
| 1722 | speed_dragging: false, |
| 1723 | pending_speed: None, |
| 1724 | speed_ramp_mode: false, |
| 1725 | ramp_key_speed: None, |
| 1726 | mix_open: false, |
| 1727 | markers_open: false, |
| 1728 | history_open: false, |
| 1729 | tools: None, |
| 1730 | tools_runs: 0, |
| 1731 | effects_open: None, |
| 1732 | effects_draft: None, |
| 1733 | effects_drag: None, |
| 1734 | effects_adding: false, |
| 1735 | effects_bars: Default::default(), |
| 1736 | marker_sel: 0, |
| 1737 | marker_edit: None, |
| 1738 | mix_field: 0, |
| 1739 | mix_solo: Vec::new(), |
| 1740 | mix_panel: Default::default(), |
| 1741 | mix_drag: None, |
| 1742 | sub_text: sub_style.size, |
| 1743 | sub_family: sub_style.family, |
| 1744 | sub_outline: sub_style.outline, |
| 1745 | sub_boxed: sub_style.boxed, |
| 1746 | sub_place: sub_style.place, |
| 1747 | sub_dragging: false, |
| 1748 | sub_font_open: false, |
| 1749 | sub_font_query: String::new(), |
| 1750 | subtitle_style_open: false, |
| 1751 | subtitle_style_field: 0, |
| 1752 | sub_anim_open: false, |
| 1753 | sub_keys_used: false, |
| 1754 | subtitle_fonts: Vec::new(), |
| 1755 | silence_open: None, |
| 1756 | beats_open: None, |
| 1757 | beats_every: 0, |
| 1758 | beats_scan: None, |
| 1759 | beats_last: None, |
| 1760 | // The conservative defaults the engine documents: a first |
| 1761 | // scan that leaves a little too much is one nobody undoes. |
| 1762 | silence: engine::silence::Settings::default(), |
| 1763 | silence_factor: Speed::MAX, |
| 1764 | // The take, not the timeline: the narrower answer is the |
| 1765 | // one a person can widen on purpose. |
| 1766 | silence_scope: Scope::Take, |
| 1767 | silence_field: 0, |
| 1768 | // The reference named, which is what the card said before |
| 1769 | // there was a choice about it. |
| 1770 | silence_dbfs: true, |
| 1771 | silence_keep_only: false, |
| 1772 | silence_marks: Vec::new(), |
| 1773 | silence_levels: HashMap::new(), |
| 1774 | silence_scan: None, |
| 1775 | silence_bg: HashMap::new(), |
| 1776 | color_open: None, |
| 1777 | color_band: 0, |
| 1778 | color_dragging: false, |
| 1779 | viz_hs_dragging: false, |
| 1780 | viz_wheel: Rc::default(), |
| 1781 | picture_box: Rc::default(), |
| 1782 | shot_pending: None, |
| 1783 | view_seen: None, |
| 1784 | session_gen: 0, |
| 1785 | // Nothing heard yet: the first pump seeds it off the session |
| 1786 | // it serves. |
| 1787 | audio_reason: None, |
| 1788 | audio_watch_gen: 0, |
| 1789 | decode_reason_cache: None, |
| 1790 | decode_watch_gen: 0, |
| 1791 | viz_slot: VizSlot::Main, |
| 1792 | viz_hex_edit: None, |
| 1793 | cue_edit: None, |
| 1794 | sel_cue: None, |
| 1795 | cue_num: None, |
| 1796 | cue_num_scrub: None, |
| 1797 | still_num: None, |
| 1798 | cue_drag: None, |
| 1799 | cue_menu: None, |
| 1800 | pending_viz: None, |
| 1801 | color_bars: std::array::from_fn(|_| Rc::default()), |
| 1802 | color_section: ColorSection::Basic, |
| 1803 | color_wheel: 0, |
| 1804 | color_wheel_drag: None, |
| 1805 | color_pads: std::array::from_fn(|_| Rc::default()), |
| 1806 | color_masters: std::array::from_fn(|_| Rc::default()), |
| 1807 | color_curve: 0, |
| 1808 | scope_view: ScopeView::Histogram, |
| 1809 | scopes: None, |
| 1810 | pending_color: None, |
| 1811 | transform_open: None, |
| 1812 | transform_band: 0, |
| 1813 | transform_dragging: false, |
| 1814 | opacity_drag: false, |
| 1815 | opacity_bar: Rc::default(), |
| 1816 | curve_bounds: Default::default(), |
| 1817 | curve_drag: None, |
| 1818 | transform_bars: std::array::from_fn(|_| Rc::default()), |
| 1819 | pending_transform: None, |
| 1820 | // Empty until the first frame is pumped, which draws as a |
| 1821 | // flat line rather than as a shape nothing measured. |
| 1822 | histogram: [0; HIST_BINS], |
| 1823 | folds: load_folds(), |
| 1824 | // Nobody has chosen a budget yet, which is not the same |
| 1825 | // as a budget of nothing: the lever opens on the engine's |
| 1826 | // own automatic figure for the picture that is open. |
| 1827 | custom_bps: export_prefs.bps, |
| 1828 | budget_edit: None, |
| 1829 | transition_edit: None, |
| 1830 | // ...and the rate the sound has always been written at. |
| 1831 | audio_kbps: export_prefs.audio_kbps, |
| 1832 | // The picture and sound this computer last used, or the |
| 1833 | // ones an export always was before there was anything to pick. |
| 1834 | format: export_prefs.format, |
| 1835 | notices: notice |
| 1836 | .clone() |
| 1837 | .map(|text| Toast::new(text.into())) |
| 1838 | .into_iter() |
| 1839 | .collect(), |
| 1840 | exported: None, |
| 1841 | // The whole of argv, waiting for the first repaint to start |
| 1842 | // it: the window is up before a byte of it is read. |
| 1843 | importing: None, |
| 1844 | imports: queue, |
| 1845 | opening: arg.clone(), |
| 1846 | // Nothing pushed yet, and never a real title: the first |
| 1847 | // render is what names the window. |
| 1848 | titled: String::new(), |
| 1849 | displayed: 0, |
| 1850 | dropped: 0, |
| 1851 | playing_last: false, |
| 1852 | drop_stop: None, |
| 1853 | started: None, |
| 1854 | focus: cx.focus_handle(), |
| 1855 | focus_dock: cx.focus_handle(), |
| 1856 | focus_bench: cx.focus_handle(), |
| 1857 | focus_inspector: cx.focus_handle(), |
| 1858 | focus_settings: cx.focus_handle(), |
| 1859 | dlg_pool: (0..64).map(|_| cx.focus_handle().tab_stop(true)).collect(), |
| 1860 | dlg_was_up: false, |
| 1861 | focus_guard_pending: false, |
| 1862 | }); |
| 1863 | // Nothing else takes focus, and without it the key listener |
| 1864 | // above is never reached. |
| 1865 | window.focus(&player.read(cx).focus); |
| 1866 | // The compositor's close request -- alt+F4, the titlebar's |
| 1867 | // button, `swaymsg kill`, a session logout -- is the one door |
| 1868 | // out of this window (there is no Quit action and nothing in |
| 1869 | // the tree calls `cx.quit()`). Answering `false` keeps the |
| 1870 | // window up, which is what turns "closing" into a question |
| 1871 | // when the timeline holds work no file has. |
| 1872 | let asking = player.clone(); |
| 1873 | window.on_window_should_close(cx, move |window, cx| { |
| 1874 | asking.update(cx, |player, cx| { |
| 1875 | if !player.close_needs_answer() { |
| 1876 | // The one door out with nothing to ask: the view is |
| 1877 | // kept for the next open, best effort. |
| 1878 | player.save_view_state(); |
| 1879 | return true; |
| 1880 | } |
| 1881 | player.quit_ask = true; |
| 1882 | // The question owns the keyboard, so the root must hold the focus |
| 1883 | // whatever had it when the request came in. |
| 1884 | window.focus(&player.focus); |
| 1885 | cx.notify(); |
| 1886 | false |
| 1887 | }) |
| 1888 | }); |
| 1889 | player.update(cx, |player, cx| player.start_autosave(cx)); |
| 1890 | player.update(cx, |player, cx| player.start_follow(cx)); |
| 1891 | // `EDITH_OPEN`: screenshot runs reach panels; unset, nothing. |
| 1892 | if let Ok(spec) = std::env::var("EDITH_OPEN") { |
| 1893 | let wanted = open_hook::parse(&spec); |
| 1894 | player.update(cx, |player, cx| player.start_open_hook(wanted, cx)); |
| 1895 | } |
| 1896 | player |
| 1897 | }, |
| 1898 | ) |
| 1899 | .unwrap(); |
| 1900 | cx.activate(true); |
| 1901 | }); |
| 1902 | } |