forge
Explore
Log in

Don't you dare go Hollow

The window's look moves out beside its doing

Browse files at this commit

b5935582db5de550013ec84d0e227a6e65885731Ahmet Kaan GümüşParent: 47b29ea
  • refactor
    • the window's look moves out beside its doing
Show full message
🚚 refactor(app): the window's look moves out beside its doing

`impl Render for Player` -- the one render the whole interface hangs
off -- leaves main.rs for render.rs, next to the modules its methods
went to last stage. main.rs is now the state (`struct Player`), the
wiring and `fn main`: 1,343 lines down to 716.

Pure motion: the impl is verbatim, gate and all
(`view().following(position)` at render.rs:84), and the layout guard
that slices the root render finds it by search rather than by name, so
it follows the move untouched.
crates/app/src/main.rsmodified+1 -629
@@ -14,6 +14,7 @@ mod library_meta;
14 mod menus;14 mod menus;
15 mod notices;15 mod notices;
16 mod oracle;16 mod oracle;
17+mod render;
17 mod subs;18 mod subs;
18 mod timeline_math;19 mod timeline_math;
19 mod transport;20 mod transport;
@@ -503,635 +504,6 @@ struct Player {
503 focus: FocusHandle,504 focus: FocusHandle,
504 }505 }
505 506
506-impl Render for Player {
507- fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
508- // A file that has just been opened sits on its first frame with the
509- // clock stopped: opening is not playing, whichever way the file
510- // arrived. The play binding and the transport button start it.
511- if let Some(session) = &mut self.session {
512- session.tick();
513- }
514- self.pump(window);
515- // What every hover label asks before it paints: a card or a menu is
516- // drawn over whatever the pointer is resting on.
517- OVERLAID.store(self.overlaid(), Ordering::Relaxed);
518- // A cleared seek is a frame delivered, which is the one readiness signal
519- // there is: whatever a slider drag held back is written here.
520- if self.seek_since.is_none() {
521- self.flush_drag(cx);
522- }
523- self.poll_export();
524- self.poll_import(cx);
525- self.poll_silence();
526- // Every way a source can arrive -- argv, an import, a project load --
527- // has been through a repaint by the time its clips are drawn, so this
528- // is the one place that has to notice a new one.
529- self.cache_media(cx);
530- self.cache_export_seat(cx);
531- self.cache_hw_caps(cx);
532- // What the compositor calls this window. Pushed only when it changes:
533- // it is a protocol round trip and this runs at vsync.
534- let title = window_title(&self.name);
535- if title != self.titled {
536- window.set_window_title(&title);
537- self.titled = title;
538- }
539- // No shadow flag: the session is the only truth about play state, and
540- // [`Player::transport`] is the one place it is read.
541- let state = self.transport();
542- // A paused timeline has nothing to animate; the toggle handlers notify,
543- // which is what starts the loop again. A paused seek keeps the loop
544- // running by itself until `pump` has the frame it asked for. An export
545- // pauses playback and still needs the loop: its progress only reaches
546- // the screen on a repaint. A notice does not: it waits to be dismissed
547- // rather than for a clock, so keeping the loop alive for it would spin
548- // the GPU until someone answered it.
549- // An import does too, and for the same reason: its clock and its sweep
550- // only reach the screen on a repaint, and a still line is the very
551- // thing it exists to disprove.
552- if state.is_playing()
553- || self.seek_since.is_some()
554- || self.export.is_some()
555- || self.importing.is_some()
556- // A silence scan too: its progress and its two clocks only reach
557- // the screen on a repaint, and a still line is the very thing this
558- // card was rewritten to disprove.
559- || self.silence_scan.is_some()
560- {
561- window.request_animation_frame();
562- }
563-
564- // Read per render, never cached: a delete shortens the timeline and the
565- // timecode, the ruler and the clamp below all have to follow it -- and
566- // so does the room a tail being dragged needs to grow into.
567- let duration = self.drawn_duration();
568- let position = self.playhead(duration);
569- // Re-settled every frame against the duration this one is drawing: an
570- // edit that shortens the timeline moves the far end of the view, and a
571- // playhead that has run off the bed pulls the view after it -- which is
572- // what makes a zoomed-in timeline scroll while it plays.
573- // ...but only a playhead that is *going* somewhere pulls it: following
574- // is what a moving one does, during playback and through a seek. A view
575- // yanked back to a playhead nobody moved is a hand's own scroll undone
576- // by the very next frame, which is what made the wheel look dead.
577- // ...and a hand that scrolled the view away from the head keeps it
578- // ([`Player::panned`]): a follow that centres the head again would undo
579- // the notch before it was seen, which is what made the wheel look dead
580- // while playing. It is given straight back below, the moment the head
581- // is on the bed a person chose to look at -- so the scroll wins now and
582- // the follow resumes by itself, with nothing to press.
583- self.scale = match (state.is_playing() || self.seek_since.is_some()) && !self.panned {
584- true => self.view().following(position),
585- false => self.view().settled(),
586- };
587- if self.panned && self.view().shows(position) {
588- self.panned = false;
589- }
590-
591- div()
592- .track_focus(&self.focus)
593- .on_key_down(cx.listener(|this, event: &KeyDownEvent, _, cx| {
594- let key = event.keystroke.key.as_str();
595- let ctrl = event.keystroke.modifiers.control;
596- // `is_held` is the auto-repeat, and a value is the one thing
597- // worth running on it: a held arrow on a card moves the slider
598- // it picked, and a held volume key runs the volume. Everything
599- // else is filtered exactly as it always was -- a repeat that
600- // toggled playback, or cut the timeline, many times a second is
601- // what this guard is for, and a row waiting for a stroke takes
602- // none of it either (it would bind the key, then fire what it
603- // just bound). See [`repeats`].
604- if event.is_held
605- && !repeats(this.repeat_scope(), key, this.keymap.lookup(key, ctrl))
606- {
607- return;
608- }
609- // Any key answers the message on the bar and brings the next of
610- // them up, whatever it was -- and owes
611- // the repaint itself: a notice no longer keeps the render loop
612- // alive, and the arms below that do notify are not all of them
613- // (an unbound key, or the copy chord, changes nothing else).
614- if this.dismiss_notice() {
615- cx.notify();
616- }
617- // A row is waiting for a stroke, and while it is, that stroke is
618- // data: it means the binding and nothing else, which is why this
619- // answers before the export guard and before the keymap is
620- // consulted at all.
621- if let Some(action) = this.rebinding {
622- if key == ESCAPE {
623- this.rebinding = None;
624- } else if !is_bare_modifier(key) {
625- this.capture(action, key, ctrl);
626- }
627- cx.notify();
628- return;
629- }
630- // On linux gpui reports the copy chord as key "c" with the
631- // control modifier set (the control code is mapped back), which
632- // is why the keymap is keyed on the pair and never on the key
633- // alone.
634- let action = this.keymap.lookup(key, ctrl);
635- // An export is reading the edit list every other action here
636- // would change, so cancelling is the only one that means
637- // anything until it is over.
638- if this.exporting().is_some() {
639- if cancels_export(key, action) {
640- this.cancel_export();
641- }
642- cx.notify();
643- return;
644- }
645- // The overlay owns the keyboard while it is up -- but it types
646- // now: a printable stroke is the search box's, which is why
647- // nothing here reaches the keymap. A waiting row is answered
648- // above and still wins, so a rebind onto "v" binds the key
649- // rather than typing it.
650- if this.keys_open {
651- if key == ESCAPE {
652- // Two steps out, the way a search box anywhere gets
653- // out: the filter first -- the whole list back --
654- // and the card only once there is no search to clear.
655- if this.keys_search.is_empty() {
656- this.keys_open = false;
657- } else {
658- this.keys_search.clear();
659- this.scroll_keys(None);
660- }
661- // The rows past the fold, without a wheel: forty actions
662- // are four times what the viewport shows, and the hand
663- // typing in the search box is already on the keyboard.
664- } else if key == "up" {
665- this.scroll_keys(Some(KEYS_ROW_H));
666- } else if key == "down" {
667- this.scroll_keys(Some(-KEYS_ROW_H));
668- } else if key == "backspace" {
669- this.keys_search.pop();
670- this.scroll_keys(None);
671- } else if let Some(c) = typed(key) {
672- this.keys_search.push(c);
673- this.scroll_keys(None);
674- }
675- cx.notify();
676- return;
677- }
678- // The export card owns it the same way, and for the same
679- // reason. Escape closes it -- nothing has been written yet, so
680- // there is nothing here to cancel -- and the card's own letters
681- // are its input: it has no widget that takes focus (nothing in
682- // it does), so this listener is its keyboard, exactly as it is
683- // a waiting row's.
684- if this.export_open {
685- // A list open over the card is the innermost thing on
686- // screen, so it is what a stroke closes first -- the rule
687- // every menu here follows, said before the card's own keys
688- // so escape does not take the card out from under it.
689- if this.picker.take().is_some() {
690- cx.notify();
691- return;
692- }
693- // A number being typed is the next thing in: while the
694- // field is open every stroke is text, which is what makes
695- // it a field and not a capture -- the card's letters cannot
696- // fire under it, and escape gives up the edit before it
697- // touches the card.
698- if let Some(edit) = &mut this.mbps_edit {
699- if key == ESCAPE {
700- this.mbps_edit = None;
701- } else if key == "enter" {
702- // Committed or refused in its own words; a refused
703- // one stays open on what was typed, so the number
704- // can be fixed rather than typed again.
705- if let Some(mbps) = edit.commit() {
706- this.custom_mbps = mbps;
707- this.quality = Quality::Custom;
708- this.mbps_edit = None;
709- }
710- } else if key == "backspace" {
711- edit.backspace();
712- } else if key == "up" {
713- edit.step(1);
714- } else if key == "down" {
715- edit.step(-1);
716- } else if let Ok(digit) = key.parse::<u32>() {
717- edit.digit(digit);
718- }
719- cx.notify();
720- return;
721- }
722- if key == ESCAPE {
723- this.export_open = false;
724- } else if key == "enter" {
725- // The card's own button, by keyboard: the one thing in
726- // it that writes a file must not be pointer-only either.
727- this.start_export(cx);
728- } else if let Some(format) = format_key(key, this.format) {
729- // The codec rows by their own letter, so the card can be
730- // driven without a mouse -- the same card-local input
731- // the typed bitrate is, and for the same reason: a
732- // choice reachable only by pointer is not reachable by
733- // everyone. Not a keymap binding: it means nothing
734- // outside this card, exactly like the digits.
735- this.set_format(format);
736- } else if key == "c" {
737- this.cycle_container();
738- } else if key == "q" {
739- this.cycle_quality();
740- } else if key == "b" {
741- // The sound's rate, `q`'s pair for the other half of
742- // the file. Not a digit: those are the picture's.
743- this.cycle_audio_kbps();
744- } else if key == "d" {
745- // The save dialog, which was the one row here a
746- // keyboard could not open.
747- this.pick_destination(cx);
748- } else if key == "g" {
749- this.export_grouped = !this.export_grouped;
750- } else if key == "r" {
751- this.export_refusals_inline = !this.export_refusals_inline;
752- } else if key == "n" {
753- // The custom row's field, by keyboard. The digits used
754- // to do this from anywhere in the card, which meant a
755- // stray keystroke changed the bitrate with nothing on
756- // screen to say it had: now a digit outside the field
757- // means nothing at all, and this is the way in.
758- this.edit_mbps();
759- }
760- cx.notify();
761- return;
762- }
763- // And the equalizer card, the same way again. Its own strokes
764- // are the card's input, exactly as the export card's digits
765- // are: a band reachable only by dragging is a band a keyboard
766- // cannot move at all, and every one of them is listed in the
767- // keys menu (keymap.rs `FIXED`) rather than being a secret.
768- if this.eq_open.is_some() {
769- // Shift makes the two horizontal keys Q instead of
770- // frequency: both are the *width* of the same hump, so they
771- // sit on the same axis rather than on two keys nobody would
772- // guess. Wider is a lower Q, which is why left widens.
773- let shift = event.keystroke.modifiers.shift;
774- if key == ESCAPE {
775- // Nothing to undo: every change is already at the clip,
776- // and undo is undo's own key.
777- this.eq_open = None;
778- this.eq_dragging = false;
779- } else if key == "up" {
780- this.nudge_band(|b| b.gain_db += EQ_STEP, cx);
781- } else if key == "down" {
782- this.nudge_band(|b| b.gain_db -= EQ_STEP, cx);
783- } else if key == "left" && shift {
784- this.nudge_band(|b| b.q /= EQ_Q_STEP, cx);
785- } else if key == "right" && shift {
786- this.nudge_band(|b| b.q *= EQ_Q_STEP, cx);
787- } else if key == "left" {
788- this.nudge_band(|b| b.freq_hz /= EQ_FREQ_STEP, cx);
789- } else if key == "right" {
790- this.nudge_band(|b| b.freq_hz *= EQ_FREQ_STEP, cx);
791- } else if key == "r" {
792- for band in &mut this.eq_params.bands {
793- band.gain_db = 0.;
794- }
795- this.commit_eq(cx);
796- } else if key == "f" {
797- // This one band back to flat, which is the undo of one
798- // hand movement -- `r` is the undo of the whole card.
799- this.nudge_band(|b| b.gain_db = 0., cx);
800- } else if key == "a" {
801- this.add_band(cx);
802- } else if key == "x" {
803- this.remove_band(cx);
804- } else if key == "s" {
805- // The analyser off and on. Nothing is committed: it is
806- // what the card *shows*, so it survives no further than
807- // this window.
808- this.eq_spectrum = !this.eq_spectrum;
809- } else if let Ok(digit) = key.parse::<usize>() {
810- // As the keys are laid out: 1-9 then 0 for the tenth,
811- // which is the cap ([`EQ_BANDS_MAX`]). A digit past the
812- // last band picks nothing rather than panics.
813- let band = match digit {
814- 0 => EQ_BANDS_MAX - 1,
815- n => n - 1,
816- };
817- if band < this.eq_params.bands.len() {
818- this.eq_band = band;
819- }
820- }
821- cx.notify();
822- return;
823- }
824- // The colour card owns the keyboard the same way the export
825- // card does, and its keys mean nothing outside it: the arrows
826- // pick a slider and move it, and `r` takes the grade off. Not
827- // keymap bindings for exactly that reason -- see `FIXED`, where
828- // the keys menu still lists them.
829- if this.color_open.is_some() {
830- match color_key(key) {
831- Some(ColorKey::Close) => {
832- this.color_open = None;
833- this.color_dragging = false;
834- }
835- Some(ColorKey::Band(step)) => {
836- this.color_band = (this.color_band + step) % COLOR_BANDS.len();
837- }
838- Some(ColorKey::Nudge(steps)) => this.nudge_color(steps, cx),
839- Some(ColorKey::Reset) => {
840- this.set_color(ColorParams::default(), cx);
841- }
842- None => {}
843- }
844- cx.notify();
845- return;
846- }
847- // The speed card, the same way again: its arrows move the rate
848- // and `r` puts it back to real time, and neither means anything
849- // outside the card -- so neither is a binding (see `FIXED`,
850- // where the keys menu still lists them).
851- if this.speed_open.is_some() {
852- match color_key(key) {
853- Some(ColorKey::Close) => {
854- this.speed_open = None;
855- this.speed_dragging = false;
856- }
857- // The card has one value, so the pair that picks a
858- // slider on the colour card moves this one by a whole
859- // preset's worth instead of a step.
860- Some(ColorKey::Band(step)) => {
861- this.nudge_speed(if step == 1 { -2 } else { 2 }, cx)
862- }
863- Some(ColorKey::Nudge(steps)) => this.nudge_speed(steps as i32, cx),
864- Some(ColorKey::Reset) => this.set_speed(Speed::NORMAL, cx),
865- None => {}
866- }
867- cx.notify();
868- return;
869- }
870- // The silence card, the same way again: the arrows pick one of
871- // its rows and move it, and its two apply keys are the two
872- // things it can do to the timeline. Card-local, every one of
873- // them -- and listed in the keys menu (keymap.rs `FIXED`),
874- // because a key that cuts forty places at once is not a secret.
875- if this.silence_open.is_some() {
876- if key == ESCAPE {
877- // Nothing to undo: a preview is not an edit.
878- this.close_silence();
879- } else if key == "down" {
880- this.silence_field = (this.silence_field + 1) % SILENCE_ROWS;
881- } else if key == "up" {
882- this.silence_field = (this.silence_field + SILENCE_ROWS - 1) % SILENCE_ROWS;
883- } else if key == "right" {
884- this.nudge_silence(1);
885- } else if key == "left" {
886- this.nudge_silence(-1);
887- } else if key == "enter" {
888- this.cut_silences(cx);
889- } else if key == "f" {
890- this.speed_silences(cx);
891- }
892- cx.notify();
893- return;
894- }
895- // The mix card, the same way again: ↑↓ pick a row -- a track's
896- // fader, the limiter's ceiling or its switch -- and ←→ move it,
897- // held or pressed. Card-local like the four above it.
898- if this.mix_open {
899- let rows = this.mix_lanes().len() + MIX_MASTER_ROWS;
900- if key == ESCAPE {
901- this.mix_open = false;
902- } else if key == "down" {
903- this.mix_field = (this.mix_field + 1) % rows;
904- } else if key == "up" {
905- this.mix_field = (this.mix_field + rows - 1) % rows;
906- } else if key == "right" {
907- this.nudge_mix(1, cx);
908- } else if key == "left" {
909- this.nudge_mix(-1, cx);
910- }
911- cx.notify();
912- return;
913- }
914- // A clip menu names an index, and every edit below moves
915- // indices -- so a stroke closes it before it acts. Escape means
916- // that and nothing else, which is the `esc` the keys menu
917- // already lists (keymap.rs `FIXED`).
918- // Both menus, taken rather than short-circuited: the library's
919- // one names a row the edits below can remove, so it closes on a
920- // stroke exactly as the clip menu does.
921- // A choice list goes the same way and for the same reason: it
922- // names a clip index too, and escape is the way out of it.
923- // An open list is the innermost thing on screen, so it takes
924- // the keys before anything under it does: ↑↓ walk it, enter
925- // takes the row, and escape falls through to the close below --
926- // the same three strokes every list in this editor answers.
927- if let Some(mut picker) = this.picker {
928- let rows = this.choices(picker.of);
929- if !rows.is_empty() && matches!(key, "up" | "down" | "enter") {
930- match key {
931- "down" => picker.sel = (picker.sel + 1) % rows.len(),
932- "up" => picker.sel = (picker.sel + rows.len() - 1) % rows.len(),
933- _ => {
934- let (choice, ..) = rows[picker.sel.min(rows.len() - 1)];
935- this.choose(choice, cx);
936- cx.notify();
937- return;
938- }
939- }
940- this.picker = Some(picker);
941- cx.notify();
942- return;
943- }
944- }
945- let clip_menu = this.context_menu.take().is_some();
946- let row_menu = this.library_menu.take().is_some();
947- let list = this.picker.take().is_some();
948- if clip_menu || row_menu || list {
949- cx.notify();
950- if key == ESCAPE {
951- return;
952- }
953- }
954- if let Some(action) = action {
955- this.act(action, cx);
956- }
957- }))
958- // The whole window is the drop target: gpui turns an external file
959- // drop into an `ExternalPaths` drag (window.rs:3626) delivered as a
960- // mouse-up to every hovered hitbox, and the root's is the only one
961- // that covers the picture as well as the panel.
962- .on_drop(cx.listener(|this, paths: &gpui::ExternalPaths, _, cx| {
963- // The overlay owns the pointer as well as the keyboard, and a
964- // drop is a click the scrim cannot swallow: gpui delivers it to
965- // the root's hitbox, which is under the scrim but is not a
966- // sibling it can stop. The export card is over the timeline for
967- // the same reason: importing under it would change the very
968- // edit list the card is about to write out.
969- if this.modal() {
970- return;
971- }
972- for path in paths.paths() {
973- // One queue for all of them, in arrival order: the fork --
974- // a project replaces the timeline, media joins the library
975- // -- is made when each one's worker starts ([`arrival`]),
976- // and neither is read on this thread.
977- this.import(path, cx);
978- }
979- }))
980- // A drop event carries no path of its own -- gpui only tells the
981- // target that something landed -- so the line that promises where
982- // it will land is fed by the drag's own moves, which do carry the
983- // pointer (gpui div.rs:282). On the root, because a drag crosses
984- // the window: it starts on a clip or on a library row and ends over
985- // a lane, and only an ancestor of both hears all of it.
986- .on_drag_move(cx.listener(|this, event: &DragMoveEvent<ClipDrag>, _, cx| {
987- // The clip the payload named, wherever an edit mid-drag has
988- // since put it ([`Player::dragged`]): the line has to promise a
989- // landing for the take actually in the hand.
990- let drag = *event.drag(cx);
991- if let Some(idx) = this.dragged(&drag) {
992- this.preview_drop(drag.lane, idx, event.event.position.x, cx);
993- }
994- // The shadow belongs to a *lane*, and which lane the pointer is
995- // over is the one thing this element cannot see. Cleared here
996- // and drawn again by the lane the pointer is actually inside
997- // (`lane_row`), which gpui runs straight after this one: the
998- // capture phase goes parent first, so a pointer over no lane at
999- // all -- up in the library, say -- promises nothing.
1000- this.set_ghost(None, cx);
1001- }))
1002- .on_drag_move(
1003- cx.listener(|this, event: &DragMoveEvent<AssetDrag>, _, cx| {
1004- this.preview_place(event.event.position.x, cx);
1005- this.set_ghost(None, cx);
1006- }),
1007- )
1008- // Scrubbing is tracked on the root because the pointer leaves the
1009- // 6 px ruler on the first drag and its own listeners then stop
1010- // firing; the root's hitbox is the whole window.
1011- .on_mouse_move(cx.listener(Self::drag_move))
1012- .on_mouse_up(MouseButton::Left, cx.listener(Self::drag_release))
1013- .size_full()
1014- .flex()
1015- .flex_col()
1016- .bg(rgb(BG_CANVAS()))
1017- .text_color(rgb(FG_PRIMARY()))
1018- .text_size(px(12.))
1019- // Four regions, the arrangement every consumer editor shares:
1020- // library left, picture centre, inspector right, and the timeline
1021- // full width along the bottom with its edit toolbar directly above
1022- // it. Nothing here moves when the state changes -- the regions are
1023- // fixed and the panels keep their room whether or not anything is
1024- // open in them.
1025- .child(self.topbar(cx))
1026- .child(
1027- div()
1028- .flex_1()
1029- .min_h(px(0.))
1030- .flex()
1031- .child(self.library(
1032- library_w(f32::from(window.viewport_size().width)),
1033- f32::from(window.viewport_size().height),
1034- cx,
1035- ))
1036- .child(
1037- div()
1038- .flex_1()
1039- .min_w(px(0.))
1040- .flex()
1041- .flex_col()
1042- .child(
1043- div()
1044- .flex_1()
1045- .min_h(px(0.))
1046- .overflow_hidden()
1047- // The bed the cue plate is placed against:
1048- // it hangs off the bottom of the picture
1049- // region, which is the one box that is the
1050- // picture and nothing else.
1051- .relative()
1052- .flex()
1053- .justify_center()
1054- .items_center()
1055- .bg(rgb(BG_CANVAS()))
1056- .children(
1057- self.image
1058- .clone()
1059- .map(|i| {
1060- img(i)
1061- .size_full()
1062- .object_fit(gpui::ObjectFit::Contain)
1063- .into_any_element()
1064- })
1065- // With no file open the letterbox
1066- // is the whole region, and a black
1067- // rectangle says only that
1068- // something is broken -- so it says
1069- // what it wants instead. The window
1070- // is already the drop target.
1071- .or_else(|| {
1072- self.session
1073- .is_none()
1074- .then(|| empty_hint().into_any_element())
1075- }),
1076- )
1077- // After the picture, so the plate is drawn
1078- // over it rather than under.
1079- .children(self.subtitle_overlay(position, window))
1080- // The three transient lines hang off the
1081- // bottom of the picture rather than taking
1082- // a row of the column: a notice that
1083- // arrives must not push the transport, the
1084- // toolbar and the timeline down by its own
1085- // height -- which is a control moving with
1086- // state, on every control below it at once.
1087- .child(
1088- div()
1089- .absolute()
1090- .bottom_0()
1091- .left_0()
1092- .right_0()
1093- .flex()
1094- .flex_col()
1095- .gap(px(2.))
1096- .children(self.import_bar(cx))
1097- .children(self.seek_bar())
1098- .children(self.notice_bar(cx)),
1099- ),
1100- )
1101- .child(self.transport_bar(
1102- position,
1103- state,
1104- f32::from(window.viewport_size().width),
1105- cx,
1106- )),
1107- )
1108- // The settings cards live in here rather than over the
1109- // timeline: adjusting a clip must not hide the clip.
1110- .child(self.inspector(window.viewport_size(), cx)),
1111- )
1112- .child(self.toolbar(cx))
1113- .child(self.timeline(
1114- position,
1115- duration,
1116- state,
1117- f32::from(window.viewport_size().height),
1118- cx,
1119- ))
1120- // Over the region they were opened on, and under the modal cards:
1121- // they are only ever up while none of those is (`modal`).
1122- .children(self.context_card(window.viewport_size(), cx))
1123- .children(self.library_card(window.viewport_size(), cx))
1124- // The two that are genuinely modal -- the whole registry, and the
1125- // card that writes a file -- are the only sheets left over the
1126- // window.
1127- .children(self.keys_overlay(cx))
1128- .children(self.export_card(window.viewport_size(), cx))
1129- // Last, so it floats over whatever opened it -- an inspector row or
1130- // a clip menu -- rather than under it.
1131- .children(self.picker_card(window.viewport_size(), cx))
1132- }
1133-}
1134-
1135 #[cfg(test)]507 #[cfg(test)]
1136 mod tests;508 mod tests;
1137 509
crates/app/src/render.rsadded+633 -0
@@ -0,0 +1,633 @@
1+//! What the window looks like this frame: the one `render` the whole
2+//! interface hangs off, root to overlays.
3+
4+use crate::*;
5+
6+impl Render for Player {
7+ fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
8+ // A file that has just been opened sits on its first frame with the
9+ // clock stopped: opening is not playing, whichever way the file
10+ // arrived. The play binding and the transport button start it.
11+ if let Some(session) = &mut self.session {
12+ session.tick();
13+ }
14+ self.pump(window);
15+ // What every hover label asks before it paints: a card or a menu is
16+ // drawn over whatever the pointer is resting on.
17+ OVERLAID.store(self.overlaid(), Ordering::Relaxed);
18+ // A cleared seek is a frame delivered, which is the one readiness signal
19+ // there is: whatever a slider drag held back is written here.
20+ if self.seek_since.is_none() {
21+ self.flush_drag(cx);
22+ }
23+ self.poll_export();
24+ self.poll_import(cx);
25+ self.poll_silence();
26+ // Every way a source can arrive -- argv, an import, a project load --
27+ // has been through a repaint by the time its clips are drawn, so this
28+ // is the one place that has to notice a new one.
29+ self.cache_media(cx);
30+ self.cache_export_seat(cx);
31+ self.cache_hw_caps(cx);
32+ // What the compositor calls this window. Pushed only when it changes:
33+ // it is a protocol round trip and this runs at vsync.
34+ let title = window_title(&self.name);
35+ if title != self.titled {
36+ window.set_window_title(&title);
37+ self.titled = title;
38+ }
39+ // No shadow flag: the session is the only truth about play state, and
40+ // [`Player::transport`] is the one place it is read.
41+ let state = self.transport();
42+ // A paused timeline has nothing to animate; the toggle handlers notify,
43+ // which is what starts the loop again. A paused seek keeps the loop
44+ // running by itself until `pump` has the frame it asked for. An export
45+ // pauses playback and still needs the loop: its progress only reaches
46+ // the screen on a repaint. A notice does not: it waits to be dismissed
47+ // rather than for a clock, so keeping the loop alive for it would spin
48+ // the GPU until someone answered it.
49+ // An import does too, and for the same reason: its clock and its sweep
50+ // only reach the screen on a repaint, and a still line is the very
51+ // thing it exists to disprove.
52+ if state.is_playing()
53+ || self.seek_since.is_some()
54+ || self.export.is_some()
55+ || self.importing.is_some()
56+ // A silence scan too: its progress and its two clocks only reach
57+ // the screen on a repaint, and a still line is the very thing this
58+ // card was rewritten to disprove.
59+ || self.silence_scan.is_some()
60+ {
61+ window.request_animation_frame();
62+ }
63+
64+ // Read per render, never cached: a delete shortens the timeline and the
65+ // timecode, the ruler and the clamp below all have to follow it -- and
66+ // so does the room a tail being dragged needs to grow into.
67+ let duration = self.drawn_duration();
68+ let position = self.playhead(duration);
69+ // Re-settled every frame against the duration this one is drawing: an
70+ // edit that shortens the timeline moves the far end of the view, and a
71+ // playhead that has run off the bed pulls the view after it -- which is
72+ // what makes a zoomed-in timeline scroll while it plays.
73+ // ...but only a playhead that is *going* somewhere pulls it: following
74+ // is what a moving one does, during playback and through a seek. A view
75+ // yanked back to a playhead nobody moved is a hand's own scroll undone
76+ // by the very next frame, which is what made the wheel look dead.
77+ // ...and a hand that scrolled the view away from the head keeps it
78+ // ([`Player::panned`]): a follow that centres the head again would undo
79+ // the notch before it was seen, which is what made the wheel look dead
80+ // while playing. It is given straight back below, the moment the head
81+ // is on the bed a person chose to look at -- so the scroll wins now and
82+ // the follow resumes by itself, with nothing to press.
83+ self.scale = match (state.is_playing() || self.seek_since.is_some()) && !self.panned {
84+ true => self.view().following(position),
85+ false => self.view().settled(),
86+ };
87+ if self.panned && self.view().shows(position) {
88+ self.panned = false;
89+ }
90+
91+ div()
92+ .track_focus(&self.focus)
93+ .on_key_down(cx.listener(|this, event: &KeyDownEvent, _, cx| {
94+ let key = event.keystroke.key.as_str();
95+ let ctrl = event.keystroke.modifiers.control;
96+ // `is_held` is the auto-repeat, and a value is the one thing
97+ // worth running on it: a held arrow on a card moves the slider
98+ // it picked, and a held volume key runs the volume. Everything
99+ // else is filtered exactly as it always was -- a repeat that
100+ // toggled playback, or cut the timeline, many times a second is
101+ // what this guard is for, and a row waiting for a stroke takes
102+ // none of it either (it would bind the key, then fire what it
103+ // just bound). See [`repeats`].
104+ if event.is_held
105+ && !repeats(this.repeat_scope(), key, this.keymap.lookup(key, ctrl))
106+ {
107+ return;
108+ }
109+ // Any key answers the message on the bar and brings the next of
110+ // them up, whatever it was -- and owes
111+ // the repaint itself: a notice no longer keeps the render loop
112+ // alive, and the arms below that do notify are not all of them
113+ // (an unbound key, or the copy chord, changes nothing else).
114+ if this.dismiss_notice() {
115+ cx.notify();
116+ }
117+ // A row is waiting for a stroke, and while it is, that stroke is
118+ // data: it means the binding and nothing else, which is why this
119+ // answers before the export guard and before the keymap is
120+ // consulted at all.
121+ if let Some(action) = this.rebinding {
122+ if key == ESCAPE {
123+ this.rebinding = None;
124+ } else if !is_bare_modifier(key) {
125+ this.capture(action, key, ctrl);
126+ }
127+ cx.notify();
128+ return;
129+ }
130+ // On linux gpui reports the copy chord as key "c" with the
131+ // control modifier set (the control code is mapped back), which
132+ // is why the keymap is keyed on the pair and never on the key
133+ // alone.
134+ let action = this.keymap.lookup(key, ctrl);
135+ // An export is reading the edit list every other action here
136+ // would change, so cancelling is the only one that means
137+ // anything until it is over.
138+ if this.exporting().is_some() {
139+ if cancels_export(key, action) {
140+ this.cancel_export();
141+ }
142+ cx.notify();
143+ return;
144+ }
145+ // The overlay owns the keyboard while it is up -- but it types
146+ // now: a printable stroke is the search box's, which is why
147+ // nothing here reaches the keymap. A waiting row is answered
148+ // above and still wins, so a rebind onto "v" binds the key
149+ // rather than typing it.
150+ if this.keys_open {
151+ if key == ESCAPE {
152+ // Two steps out, the way a search box anywhere gets
153+ // out: the filter first -- the whole list back --
154+ // and the card only once there is no search to clear.
155+ if this.keys_search.is_empty() {
156+ this.keys_open = false;
157+ } else {
158+ this.keys_search.clear();
159+ this.scroll_keys(None);
160+ }
161+ // The rows past the fold, without a wheel: forty actions
162+ // are four times what the viewport shows, and the hand
163+ // typing in the search box is already on the keyboard.
164+ } else if key == "up" {
165+ this.scroll_keys(Some(KEYS_ROW_H));
166+ } else if key == "down" {
167+ this.scroll_keys(Some(-KEYS_ROW_H));
168+ } else if key == "backspace" {
169+ this.keys_search.pop();
170+ this.scroll_keys(None);
171+ } else if let Some(c) = typed(key) {
172+ this.keys_search.push(c);
173+ this.scroll_keys(None);
174+ }
175+ cx.notify();
176+ return;
177+ }
178+ // The export card owns it the same way, and for the same
179+ // reason. Escape closes it -- nothing has been written yet, so
180+ // there is nothing here to cancel -- and the card's own letters
181+ // are its input: it has no widget that takes focus (nothing in
182+ // it does), so this listener is its keyboard, exactly as it is
183+ // a waiting row's.
184+ if this.export_open {
185+ // A list open over the card is the innermost thing on
186+ // screen, so it is what a stroke closes first -- the rule
187+ // every menu here follows, said before the card's own keys
188+ // so escape does not take the card out from under it.
189+ if this.picker.take().is_some() {
190+ cx.notify();
191+ return;
192+ }
193+ // A number being typed is the next thing in: while the
194+ // field is open every stroke is text, which is what makes
195+ // it a field and not a capture -- the card's letters cannot
196+ // fire under it, and escape gives up the edit before it
197+ // touches the card.
198+ if let Some(edit) = &mut this.mbps_edit {
199+ if key == ESCAPE {
200+ this.mbps_edit = None;
201+ } else if key == "enter" {
202+ // Committed or refused in its own words; a refused
203+ // one stays open on what was typed, so the number
204+ // can be fixed rather than typed again.
205+ if let Some(mbps) = edit.commit() {
206+ this.custom_mbps = mbps;
207+ this.quality = Quality::Custom;
208+ this.mbps_edit = None;
209+ }
210+ } else if key == "backspace" {
211+ edit.backspace();
212+ } else if key == "up" {
213+ edit.step(1);
214+ } else if key == "down" {
215+ edit.step(-1);
216+ } else if let Ok(digit) = key.parse::<u32>() {
217+ edit.digit(digit);
218+ }
219+ cx.notify();
220+ return;
221+ }
222+ if key == ESCAPE {
223+ this.export_open = false;
224+ } else if key == "enter" {
225+ // The card's own button, by keyboard: the one thing in
226+ // it that writes a file must not be pointer-only either.
227+ this.start_export(cx);
228+ } else if let Some(format) = format_key(key, this.format) {
229+ // The codec rows by their own letter, so the card can be
230+ // driven without a mouse -- the same card-local input
231+ // the typed bitrate is, and for the same reason: a
232+ // choice reachable only by pointer is not reachable by
233+ // everyone. Not a keymap binding: it means nothing
234+ // outside this card, exactly like the digits.
235+ this.set_format(format);
236+ } else if key == "c" {
237+ this.cycle_container();
238+ } else if key == "q" {
239+ this.cycle_quality();
240+ } else if key == "b" {
241+ // The sound's rate, `q`'s pair for the other half of
242+ // the file. Not a digit: those are the picture's.
243+ this.cycle_audio_kbps();
244+ } else if key == "d" {
245+ // The save dialog, which was the one row here a
246+ // keyboard could not open.
247+ this.pick_destination(cx);
248+ } else if key == "g" {
249+ this.export_grouped = !this.export_grouped;
250+ } else if key == "r" {
251+ this.export_refusals_inline = !this.export_refusals_inline;
252+ } else if key == "n" {
253+ // The custom row's field, by keyboard. The digits used
254+ // to do this from anywhere in the card, which meant a
255+ // stray keystroke changed the bitrate with nothing on
256+ // screen to say it had: now a digit outside the field
257+ // means nothing at all, and this is the way in.
258+ this.edit_mbps();
259+ }
260+ cx.notify();
261+ return;
262+ }
263+ // And the equalizer card, the same way again. Its own strokes
264+ // are the card's input, exactly as the export card's digits
265+ // are: a band reachable only by dragging is a band a keyboard
266+ // cannot move at all, and every one of them is listed in the
267+ // keys menu (keymap.rs `FIXED`) rather than being a secret.
268+ if this.eq_open.is_some() {
269+ // Shift makes the two horizontal keys Q instead of
270+ // frequency: both are the *width* of the same hump, so they
271+ // sit on the same axis rather than on two keys nobody would
272+ // guess. Wider is a lower Q, which is why left widens.
273+ let shift = event.keystroke.modifiers.shift;
274+ if key == ESCAPE {
275+ // Nothing to undo: every change is already at the clip,
276+ // and undo is undo's own key.
277+ this.eq_open = None;
278+ this.eq_dragging = false;
279+ } else if key == "up" {
280+ this.nudge_band(|b| b.gain_db += EQ_STEP, cx);
281+ } else if key == "down" {
282+ this.nudge_band(|b| b.gain_db -= EQ_STEP, cx);
283+ } else if key == "left" && shift {
284+ this.nudge_band(|b| b.q /= EQ_Q_STEP, cx);
285+ } else if key == "right" && shift {
286+ this.nudge_band(|b| b.q *= EQ_Q_STEP, cx);
287+ } else if key == "left" {
288+ this.nudge_band(|b| b.freq_hz /= EQ_FREQ_STEP, cx);
289+ } else if key == "right" {
290+ this.nudge_band(|b| b.freq_hz *= EQ_FREQ_STEP, cx);
291+ } else if key == "r" {
292+ for band in &mut this.eq_params.bands {
293+ band.gain_db = 0.;
294+ }
295+ this.commit_eq(cx);
296+ } else if key == "f" {
297+ // This one band back to flat, which is the undo of one
298+ // hand movement -- `r` is the undo of the whole card.
299+ this.nudge_band(|b| b.gain_db = 0., cx);
300+ } else if key == "a" {
301+ this.add_band(cx);
302+ } else if key == "x" {
303+ this.remove_band(cx);
304+ } else if key == "s" {
305+ // The analyser off and on. Nothing is committed: it is
306+ // what the card *shows*, so it survives no further than
307+ // this window.
308+ this.eq_spectrum = !this.eq_spectrum;
309+ } else if let Ok(digit) = key.parse::<usize>() {
310+ // As the keys are laid out: 1-9 then 0 for the tenth,
311+ // which is the cap ([`EQ_BANDS_MAX`]). A digit past the
312+ // last band picks nothing rather than panics.
313+ let band = match digit {
314+ 0 => EQ_BANDS_MAX - 1,
315+ n => n - 1,
316+ };
317+ if band < this.eq_params.bands.len() {
318+ this.eq_band = band;
319+ }
320+ }
321+ cx.notify();
322+ return;
323+ }
324+ // The colour card owns the keyboard the same way the export
325+ // card does, and its keys mean nothing outside it: the arrows
326+ // pick a slider and move it, and `r` takes the grade off. Not
327+ // keymap bindings for exactly that reason -- see `FIXED`, where
328+ // the keys menu still lists them.
329+ if this.color_open.is_some() {
330+ match color_key(key) {
331+ Some(ColorKey::Close) => {
332+ this.color_open = None;
333+ this.color_dragging = false;
334+ }
335+ Some(ColorKey::Band(step)) => {
336+ this.color_band = (this.color_band + step) % COLOR_BANDS.len();
337+ }
338+ Some(ColorKey::Nudge(steps)) => this.nudge_color(steps, cx),
339+ Some(ColorKey::Reset) => {
340+ this.set_color(ColorParams::default(), cx);
341+ }
342+ None => {}
343+ }
344+ cx.notify();
345+ return;
346+ }
347+ // The speed card, the same way again: its arrows move the rate
348+ // and `r` puts it back to real time, and neither means anything
349+ // outside the card -- so neither is a binding (see `FIXED`,
350+ // where the keys menu still lists them).
351+ if this.speed_open.is_some() {
352+ match color_key(key) {
353+ Some(ColorKey::Close) => {
354+ this.speed_open = None;
355+ this.speed_dragging = false;
356+ }
357+ // The card has one value, so the pair that picks a
358+ // slider on the colour card moves this one by a whole
359+ // preset's worth instead of a step.
360+ Some(ColorKey::Band(step)) => {
361+ this.nudge_speed(if step == 1 { -2 } else { 2 }, cx)
362+ }
363+ Some(ColorKey::Nudge(steps)) => this.nudge_speed(steps as i32, cx),
364+ Some(ColorKey::Reset) => this.set_speed(Speed::NORMAL, cx),
365+ None => {}
366+ }
367+ cx.notify();
368+ return;
369+ }
370+ // The silence card, the same way again: the arrows pick one of
371+ // its rows and move it, and its two apply keys are the two
372+ // things it can do to the timeline. Card-local, every one of
373+ // them -- and listed in the keys menu (keymap.rs `FIXED`),
374+ // because a key that cuts forty places at once is not a secret.
375+ if this.silence_open.is_some() {
376+ if key == ESCAPE {
377+ // Nothing to undo: a preview is not an edit.
378+ this.close_silence();
379+ } else if key == "down" {
380+ this.silence_field = (this.silence_field + 1) % SILENCE_ROWS;
381+ } else if key == "up" {
382+ this.silence_field = (this.silence_field + SILENCE_ROWS - 1) % SILENCE_ROWS;
383+ } else if key == "right" {
384+ this.nudge_silence(1);
385+ } else if key == "left" {
386+ this.nudge_silence(-1);
387+ } else if key == "enter" {
388+ this.cut_silences(cx);
389+ } else if key == "f" {
390+ this.speed_silences(cx);
391+ }
392+ cx.notify();
393+ return;
394+ }
395+ // The mix card, the same way again: ↑↓ pick a row -- a track's
396+ // fader, the limiter's ceiling or its switch -- and ←→ move it,
397+ // held or pressed. Card-local like the four above it.
398+ if this.mix_open {
399+ let rows = this.mix_lanes().len() + MIX_MASTER_ROWS;
400+ if key == ESCAPE {
401+ this.mix_open = false;
402+ } else if key == "down" {
403+ this.mix_field = (this.mix_field + 1) % rows;
404+ } else if key == "up" {
405+ this.mix_field = (this.mix_field + rows - 1) % rows;
406+ } else if key == "right" {
407+ this.nudge_mix(1, cx);
408+ } else if key == "left" {
409+ this.nudge_mix(-1, cx);
410+ }
411+ cx.notify();
412+ return;
413+ }
414+ // A clip menu names an index, and every edit below moves
415+ // indices -- so a stroke closes it before it acts. Escape means
416+ // that and nothing else, which is the `esc` the keys menu
417+ // already lists (keymap.rs `FIXED`).
418+ // Both menus, taken rather than short-circuited: the library's
419+ // one names a row the edits below can remove, so it closes on a
420+ // stroke exactly as the clip menu does.
421+ // A choice list goes the same way and for the same reason: it
422+ // names a clip index too, and escape is the way out of it.
423+ // An open list is the innermost thing on screen, so it takes
424+ // the keys before anything under it does: ↑↓ walk it, enter
425+ // takes the row, and escape falls through to the close below --
426+ // the same three strokes every list in this editor answers.
427+ if let Some(mut picker) = this.picker {
428+ let rows = this.choices(picker.of);
429+ if !rows.is_empty() && matches!(key, "up" | "down" | "enter") {
430+ match key {
431+ "down" => picker.sel = (picker.sel + 1) % rows.len(),
432+ "up" => picker.sel = (picker.sel + rows.len() - 1) % rows.len(),
433+ _ => {
434+ let (choice, ..) = rows[picker.sel.min(rows.len() - 1)];
435+ this.choose(choice, cx);
436+ cx.notify();
437+ return;
438+ }
439+ }
440+ this.picker = Some(picker);
441+ cx.notify();
442+ return;
443+ }
444+ }
445+ let clip_menu = this.context_menu.take().is_some();
446+ let row_menu = this.library_menu.take().is_some();
447+ let list = this.picker.take().is_some();
448+ if clip_menu || row_menu || list {
449+ cx.notify();
450+ if key == ESCAPE {
451+ return;
452+ }
453+ }
454+ if let Some(action) = action {
455+ this.act(action, cx);
456+ }
457+ }))
458+ // The whole window is the drop target: gpui turns an external file
459+ // drop into an `ExternalPaths` drag (window.rs:3626) delivered as a
460+ // mouse-up to every hovered hitbox, and the root's is the only one
461+ // that covers the picture as well as the panel.
462+ .on_drop(cx.listener(|this, paths: &gpui::ExternalPaths, _, cx| {
463+ // The overlay owns the pointer as well as the keyboard, and a
464+ // drop is a click the scrim cannot swallow: gpui delivers it to
465+ // the root's hitbox, which is under the scrim but is not a
466+ // sibling it can stop. The export card is over the timeline for
467+ // the same reason: importing under it would change the very
468+ // edit list the card is about to write out.
469+ if this.modal() {
470+ return;
471+ }
472+ for path in paths.paths() {
473+ // One queue for all of them, in arrival order: the fork --
474+ // a project replaces the timeline, media joins the library
475+ // -- is made when each one's worker starts ([`arrival`]),
476+ // and neither is read on this thread.
477+ this.import(path, cx);
478+ }
479+ }))
480+ // A drop event carries no path of its own -- gpui only tells the
481+ // target that something landed -- so the line that promises where
482+ // it will land is fed by the drag's own moves, which do carry the
483+ // pointer (gpui div.rs:282). On the root, because a drag crosses
484+ // the window: it starts on a clip or on a library row and ends over
485+ // a lane, and only an ancestor of both hears all of it.
486+ .on_drag_move(cx.listener(|this, event: &DragMoveEvent<ClipDrag>, _, cx| {
487+ // The clip the payload named, wherever an edit mid-drag has
488+ // since put it ([`Player::dragged`]): the line has to promise a
489+ // landing for the take actually in the hand.
490+ let drag = *event.drag(cx);
491+ if let Some(idx) = this.dragged(&drag) {
492+ this.preview_drop(drag.lane, idx, event.event.position.x, cx);
493+ }
494+ // The shadow belongs to a *lane*, and which lane the pointer is
495+ // over is the one thing this element cannot see. Cleared here
496+ // and drawn again by the lane the pointer is actually inside
497+ // (`lane_row`), which gpui runs straight after this one: the
498+ // capture phase goes parent first, so a pointer over no lane at
499+ // all -- up in the library, say -- promises nothing.
500+ this.set_ghost(None, cx);
501+ }))
502+ .on_drag_move(
503+ cx.listener(|this, event: &DragMoveEvent<AssetDrag>, _, cx| {
504+ this.preview_place(event.event.position.x, cx);
505+ this.set_ghost(None, cx);
506+ }),
507+ )
508+ // Scrubbing is tracked on the root because the pointer leaves the
509+ // 6 px ruler on the first drag and its own listeners then stop
510+ // firing; the root's hitbox is the whole window.
511+ .on_mouse_move(cx.listener(Self::drag_move))
512+ .on_mouse_up(MouseButton::Left, cx.listener(Self::drag_release))
513+ .size_full()
514+ .flex()
515+ .flex_col()
516+ .bg(rgb(BG_CANVAS()))
517+ .text_color(rgb(FG_PRIMARY()))
518+ .text_size(px(12.))
519+ // Four regions, the arrangement every consumer editor shares:
520+ // library left, picture centre, inspector right, and the timeline
521+ // full width along the bottom with its edit toolbar directly above
522+ // it. Nothing here moves when the state changes -- the regions are
523+ // fixed and the panels keep their room whether or not anything is
524+ // open in them.
525+ .child(self.topbar(cx))
526+ .child(
527+ div()
528+ .flex_1()
529+ .min_h(px(0.))
530+ .flex()
531+ .child(self.library(
532+ library_w(f32::from(window.viewport_size().width)),
533+ f32::from(window.viewport_size().height),
534+ cx,
535+ ))
536+ .child(
537+ div()
538+ .flex_1()
539+ .min_w(px(0.))
540+ .flex()
541+ .flex_col()
542+ .child(
543+ div()
544+ .flex_1()
545+ .min_h(px(0.))
546+ .overflow_hidden()
547+ // The bed the cue plate is placed against:
548+ // it hangs off the bottom of the picture
549+ // region, which is the one box that is the
550+ // picture and nothing else.
551+ .relative()
552+ .flex()
553+ .justify_center()
554+ .items_center()
555+ .bg(rgb(BG_CANVAS()))
556+ .children(
557+ self.image
558+ .clone()
559+ .map(|i| {
560+ img(i)
561+ .size_full()
562+ .object_fit(gpui::ObjectFit::Contain)
563+ .into_any_element()
564+ })
565+ // With no file open the letterbox
566+ // is the whole region, and a black
567+ // rectangle says only that
568+ // something is broken -- so it says
569+ // what it wants instead. The window
570+ // is already the drop target.
571+ .or_else(|| {
572+ self.session
573+ .is_none()
574+ .then(|| empty_hint().into_any_element())
575+ }),
576+ )
577+ // After the picture, so the plate is drawn
578+ // over it rather than under.
579+ .children(self.subtitle_overlay(position, window))
580+ // The three transient lines hang off the
581+ // bottom of the picture rather than taking
582+ // a row of the column: a notice that
583+ // arrives must not push the transport, the
584+ // toolbar and the timeline down by its own
585+ // height -- which is a control moving with
586+ // state, on every control below it at once.
587+ .child(
588+ div()
589+ .absolute()
590+ .bottom_0()
591+ .left_0()
592+ .right_0()
593+ .flex()
594+ .flex_col()
595+ .gap(px(2.))
596+ .children(self.import_bar(cx))
597+ .children(self.seek_bar())
598+ .children(self.notice_bar(cx)),
599+ ),
600+ )
601+ .child(self.transport_bar(
602+ position,
603+ state,
604+ f32::from(window.viewport_size().width),
605+ cx,
606+ )),
607+ )
608+ // The settings cards live in here rather than over the
609+ // timeline: adjusting a clip must not hide the clip.
610+ .child(self.inspector(window.viewport_size(), cx)),
611+ )
612+ .child(self.toolbar(cx))
613+ .child(self.timeline(
614+ position,
615+ duration,
616+ state,
617+ f32::from(window.viewport_size().height),
618+ cx,
619+ ))
620+ // Over the region they were opened on, and under the modal cards:
621+ // they are only ever up while none of those is (`modal`).
622+ .children(self.context_card(window.viewport_size(), cx))
623+ .children(self.library_card(window.viewport_size(), cx))
624+ // The two that are genuinely modal -- the whole registry, and the
625+ // card that writes a file -- are the only sheets left over the
626+ // window.
627+ .children(self.keys_overlay(cx))
628+ .children(self.export_card(window.viewport_size(), cx))
629+ // Last, so it floats over whatever opened it -- an inspector row or
630+ // a clip menu -- rather than under it.
631+ .children(self.picker_card(window.viewport_size(), cx))
632+ }
633+}