forge
Explore
Log in

Don't you dare go Hollow

merge oldui-sources

Browse files at this commit

c41d540b68775b9b072a9bc2c6669fd83c84131bAhmet Kaan GümüşParent: f0ae6fceb7e462
crates/app/src/tests/cards.rsmodified+35 -0
@@ -2072,4 +2072,39 @@ fn darkroom_preview_mounts_stop_and_drag_scrub() {
20722072 && preview.contains("this.preview_scrub_to(event.position.x, true, cx)"),
20732073 "the mounted preview scrub no longer starts its drag-and-seek gesture"
20742074 );
2075+/// Source management must stay reachable in the Darkroom itself: per-row
2076+/// stand-in control/progress, pointer Add-at-playhead alongside its `↵` chord,
2077+/// and the three legacy source questions as dock filters. The test reads the
2078+/// mounted dock source because this binary has no `TestAppContext` to inspect
2079+/// GPUI's painted controls.
2080+#[test]
2081+fn darkroom_source_rows_keep_proxy_add_and_media_audio_text_paths() {
2082+ let dock = src_text("ui/dock_stance.rs");
2083+ let row_at = dock.find("fn source_row(").expect("Darkroom source row");
2084+ let row = &dock[row_at..];
2085+ for needle in [
2086+ "dock-proxy-toggle",
2087+ "toggle_proxy(&proxy_path, proxy_stops, cx)",
2088+ "proxy_progress.map",
2089+ "dock-add-at-playhead",
2090+ "Add at playhead — ↵ does the same",
2091+ "this.insert_source(",
2092+ ] {
2093+ assert!(
2094+ row.contains(needle),
2095+ "Darkroom source row lost `{needle}`: a source must keep its proxy control/progress \
2096+ and mouse-reachable Add-at-playhead path"
2097+ );
2098+ }
2099+ for needle in [
2100+ "LIBRARY_TABS.map",
2101+ "dock-source-filter",
2102+ "player.library_tab.holds(&row.path)",
2103+ "No subtitle sources yet — Import subtitles",
2104+ ] {
2105+ assert!(
2106+ dock.contains(needle),
2107+ "Darkroom Sources lost `{needle}`: Media, Audio, and Text must remain distinct paths"
2108+ );
2109+ }
20752110 }
crates/app/src/ui/dock_stance.rsmodified+183 -9
@@ -95,6 +95,7 @@ impl DockSort {
9595 }
9696 }
9797
98+
9899 /// A ghost verb (DESIGN §4): borderless glyph/label in `ink2`, its chord in
99100 /// `ink3` beside it, read live off the keymap so it can never drift from the
100101 /// key that does the same thing. Hover is one fill step and an ink brighten;
@@ -261,7 +262,50 @@ fn source_row(
261262 let dragged = (path.clone(), stream);
262263 let dot_path = path.clone();
263264 let menu_path = path.clone();
265+ let add_path = path.clone();
266+ let proxy_path = path.clone();
264267 let ghost = name.clone();
268+ let can_insert = usable && player.session.is_some() && player.exporting().is_none();
269+ let (proxy_glyph, proxy_on, proxy_progress, proxy_waiting, proxy_tip) =
270+ match player.proxies.get(&row.path) {
271+ Some(Proxy::Ready) => (
272+ "●",
273+ true,
274+ None,
275+ false,
276+ format!("Stand-in ON for {} — click to delete it", row.name),
277+ ),
278+ Some(Proxy::Making(job)) => (
279+ "■",
280+ true,
281+ Some(job.progress()),
282+ false,
283+ format!("Stop making the stand-in for {}", row.name),
284+ ),
285+ Some(Proxy::Cancelling(_)) => (
286+ "■",
287+ true,
288+ None,
289+ true,
290+ format!("Stopping the stand-in for {}…", row.name),
291+ ),
292+ Some(Proxy::Asked) => (
293+ "○",
294+ false,
295+ None,
296+ true,
297+ format!("Preparing the stand-in for {}…", row.name),
298+ ),
299+ _ => (
300+ "○",
301+ false,
302+ None,
303+ false,
304+ format!("Stand-in OFF for {} — click to make one", row.name),
305+ ),
306+ };
307+ let proxy_stops = proxy_glyph == "■";
308+ let proxy_tip: SharedString = proxy_tip.into();
265309 div()
266310 .id(("dock-source", i))
267311 .flex_none()
@@ -387,6 +431,107 @@ fn source_row(
387431 .text_size(style.size)
388432 .text_color(rgb(INK3()))
389433 .child(usage)
434+ })
435+ .when(usable, |d| {
436+ d.child({
437+ let label_style = label(type_scale::FLOOR_PX, FontWeight::MEDIUM);
438+ let chord_style =
439+ mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM);
440+ div()
441+ .id(("dock-add-at-playhead", i))
442+ .flex_none()
443+ .flex()
444+ .items_center()
445+ .gap(px(3.))
446+ .px(px(4.))
447+ .py(px(2.))
448+ .rounded(px(3.))
449+ .when(!can_insert, |d| d.opacity(0.4).cursor_not_allowed())
450+ .when(can_insert, |d| {
451+ d.cursor_pointer()
452+ .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1())))
453+ .on_click(cx.listener(
454+ move |this, _: &ClickEvent, _, cx| {
455+ cx.stop_propagation();
456+ this.insert_source(
457+ &add_path,
458+ stream,
459+ None,
460+ None,
461+ cx,
462+ );
463+ cx.notify();
464+ },
465+ ))
466+ })
467+ .tooltip(move |_, cx| {
468+ cx.new(|_| {
469+ Tip(
470+ "Add at playhead — ↵ does the same after selecting this source"
471+ .into(),
472+ )
473+ })
474+ .into()
475+ })
476+ .child(
477+ div()
478+ .font(label_style.font)
479+ .text_size(label_style.size)
480+ .text_color(rgb(INK2()))
481+ .child("Add"),
482+ )
483+ .child(
484+ div()
485+ .font(chord_style.font)
486+ .text_size(chord_style.size)
487+ .text_color(rgb(INK3()))
488+ .child("↵"),
489+ )
490+ })
491+ .child({
492+ let style = mono(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
493+ div()
494+ .id(("dock-proxy-toggle", i))
495+ .flex_none()
496+ .flex()
497+ .flex_col()
498+ .items_center()
499+ .gap(px(2.))
500+ .px(px(4.))
501+ .py(px(2.))
502+ .rounded(px(3.))
503+ .when(proxy_on, |d| d.bg(rgb(DARK_RAISED())))
504+ .when(proxy_waiting, |d| d.opacity(0.55))
505+ .cursor_pointer()
506+ .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1())))
507+ .tooltip(move |_, cx| cx.new(|_| Tip(proxy_tip.clone())).into())
508+ .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
509+ cx.stop_propagation();
510+ this.toggle_proxy(&proxy_path, proxy_stops, cx);
511+ }))
512+ .child(
513+ div()
514+ .font(style.font)
515+ .text_size(style.size)
516+ .text_color(rgb(if proxy_on { INK1() } else { INK3() }))
517+ .child(proxy_glyph),
518+ )
519+ .children(proxy_progress.map(|progress| {
520+ div()
521+ .flex_none()
522+ .w(px(20.))
523+ .h(px(2.))
524+ .rounded(px(1.))
525+ .bg(rgb(DARK_HAIRLINE()))
526+ .child(
527+ div()
528+ .h_full()
529+ .w(px(20. * progress.clamp(0., 1.)))
530+ .rounded(px(1.))
531+ .bg(rgb(INK2())),
532+ )
533+ }))
534+ })
390535 }),
391536 )
392537 .child({
@@ -410,7 +555,6 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
410555 .session
411556 .as_ref()
412557 .map_or(&[][..], PlaybackSession::sources);
413- let meta = player.session.as_ref().map(PlaybackSession::meta);
414558 let all_rows: Vec<Row> = library_rows(
415559 sources,
416560 &player.streams,
@@ -423,14 +567,10 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
423567 .map_or(0, |session| session.file_frames(path))
424568 },
425569 );
426- let _ = meta;
427- let unused_count = all_rows
428- .iter()
429- .filter(|row| player.row_ctx(&row.path, row.stream).placed == 0)
430- .count();
431570 let filter = player.dock_filter.to_lowercase();
432571 let mut rows: Vec<(Row, usize)> = all_rows
433572 .into_iter()
573+ .filter(|row| player.library_tab.holds(&row.path))
434574 .map(|row| {
435575 let placed = player.row_ctx(&row.path, row.stream).placed;
436576 (row, placed)
@@ -442,6 +582,10 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
442582 || ("unused".contains(&filter) && *placed == 0)
443583 })
444584 .collect();
585+ let unused_count = rows
586+ .iter()
587+ .filter(|(_, placed)| *placed == 0)
588+ .count();
445589 match player.dock_sort {
446590 DockSort::Recent => {}
447591 DockSort::Name => {
@@ -462,7 +606,8 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
462606 .p(px(8.))
463607 .overflow_y_scroll()
464608 .child(section_head(format!(
465- "SOURCES · {total} · {unused_count} UNUSED"
609+ "{} · {total} · {unused_count} UNUSED",
610+ player.library_tab.label().to_uppercase()
466611 )))
467612 .child({
468613 let style = mono(type_scale::CHORD_METADATA_MAX_PX, FontWeight::MEDIUM);
@@ -486,6 +631,33 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
486631 false => format!("⌕ {filter_text}"),
487632 })
488633 })
634+ .child(
635+ div()
636+ .flex_none()
637+ .flex()
638+ .gap(px(4.))
639+ .children(LIBRARY_TABS.map(|tab| {
640+ let on = tab == player.library_tab;
641+ let style = label(type_scale::FLOOR_PX, FontWeight::MEDIUM);
642+ div()
643+ .id(("dock-source-filter", tab as usize))
644+ .flex_none()
645+ .px(px(6.))
646+ .py(px(2.))
647+ .rounded(px(3.))
648+ .font(style.font)
649+ .text_size(style.size)
650+ .when(on, |d| d.bg(rgb(DARK_RAISED())).text_color(rgb(INK1())))
651+ .when(!on, |d| d.text_color(rgb(INK3())))
652+ .cursor_pointer()
653+ .hover(|s| s.bg(rgb(DARK_RAISED())))
654+ .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
655+ this.library_tab = tab;
656+ cx.notify();
657+ }))
658+ .child(tab.label())
659+ })),
660+ )
489661 .child(
490662 div()
491663 .flex_none()
@@ -530,8 +702,10 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
530702 .text_size(style.size)
531703 .text_color(rgb(INK3()))
532704 .child(match player.dock_filter.is_empty() {
533- true => "No sources yet — Add files, or drop one on the window"
534- .to_string(),
705+ true if player.library_tab == LibraryTab::Text => {
706+ "No subtitle sources yet — Import subtitles".to_string()
707+ }
708+ true => player.library_tab.empty().to_string(),
535709 false => "nothing matches the filter".to_string(),
536710 }),
537711 )