forge
Explore
Log in

Don't you dare go Hollow

Expose timeline pointer targets

Browse files at this commit

7f442f47b46032709c2bc9ef3468862cdbdd8188Ahmet Kaan GümüşParent: 488d138
  • feat
    • expose timeline pointer targets
Show full message
✨ feat(hitmap): expose timeline pointer targets
crates/app/src/tests/layout.rsmodified+73 -3
@@ -2697,9 +2697,7 @@ fn darkroom_bench_wires_transition_controls_and_lane_drop_cue() {
2697 let dissolve = &clip[clip2697 let dissolve = &clip[clip
2698 .find(".when(dissolves, |d| {")2698 .find(".when(dissolves, |d| {")
2699 .expect("the dissolve affordance")2699 .expect("the dissolve affordance")
2700- ..clip2700+ ..clip.find(".when(trims(span),").expect("the fade handles")];
2701- .find(".when(audio && trims(span)")
2702- .expect("the fade handles")];
2703 assert!(2701 assert!(
2704 dissolve.contains(".w(px(FADE_HANDLE_W))"),2702 dissolve.contains(".w(px(FADE_HANDLE_W))"),
2705 "dissolve click target no longer matches fade-handle width"2703 "dissolve click target no longer matches fade-handle width"
@@ -2733,3 +2731,75 @@ fn darkroom_bench_wires_transition_controls_and_lane_drop_cue() {
2733 );2731 );
2734 }2732 }
2735 }2733 }
2734+
2735+/// The pointer harness can only drive controls that report the bounds of the
2736+/// element that owns the gesture. Keep every dynamic Darkroom entry surface
2737+/// named, so UI verification never falls back to guessed pixels.
2738+#[test]
2739+fn hitmap_names_every_darkroom_pointer_entry_surface() {
2740+ let bench = src_text("ui/bench_stance.rs");
2741+ for needle in [
2742+ "clip.{}.{}.{}.fade-{}",
2743+ "clip.{}.{}.{}.trim-{}",
2744+ "clip.{}.{}.{}.dissolve",
2745+ "lane.{}.reorder",
2746+ "lane.{}.mix",
2747+ "lane.{}.eye",
2748+ "lane.{}.remove",
2749+ ] {
2750+ assert!(
2751+ bench.contains(needle),
2752+ "bench control missing hitmap id: {needle}"
2753+ );
2754+ }
2755+ assert!(
2756+ bench.contains(".when(trims(span), |d| {"),
2757+ "fade handles must cover video clips as well as audio clips"
2758+ );
2759+
2760+ let dock = src_text("ui/dock_stance.rs");
2761+ for needle in [
2762+ "subtitle.{group_ord}.{track}.row",
2763+ "subtitle.{group_ord}.{track}.select",
2764+ "source.{i}.proxy",
2765+ "Proxy making",
2766+ ] {
2767+ assert!(
2768+ dock.contains(needle),
2769+ "dock control missing hitmap contract: {needle}"
2770+ );
2771+ }
2772+
2773+ for (path, needles) in [
2774+ (
2775+ "ui/timeband_stance.rs",
2776+ &[
2777+ "timeline.contact-strip",
2778+ "stance-strip-grip-lt",
2779+ "stance-strip-grip-rb",
2780+ ][..],
2781+ ),
2782+ ("ui/preview.rs", &["preview.stop", "preview.scrub"][..]),
2783+ (
2784+ "ui/overlays.rs",
2785+ &[
2786+ "menu.{action:?}",
2787+ "menu.properties",
2788+ "theme.{n}.row",
2789+ "hitmap::action(action, refusal.yes())",
2790+ ][..],
2791+ ),
2792+ (
2793+ "ui/settings_stance.rs",
2794+ &[".children(hitmap::control(id, label_text, !exporting))"][..],
2795+ ),
2796+ ] {
2797+ let source = src_text(path);
2798+ for needle in needles {
2799+ assert!(
2800+ source.contains(needle),
2801+ "{path} missing hitmap contract: {needle}"
2802+ );
2803+ }
2804+ }
2805+}
crates/app/src/ui/bench_stance.rsmodified+48 -6
@@ -348,7 +348,25 @@ fn clip_box(
348 cx.listener(move |this, event: &MouseDownEvent, _, cx| {348 cx.listener(move |this, event: &MouseDownEvent, _, cx| {
349 this.open_menu(lane, idx, event.position, cx);349 this.open_menu(lane, idx, event.position, cx);
350 }),350 }),
351- );351+ )
352+ .children(hitmap::dynamic(
353+ move || {
354+ (
355+ format!(
356+ "clip.{}.{}.{}.trim-{}",
357+ lane.label(),
358+ lane.ord,
359+ idx,
360+ if edge == Edge::Start { "l" } else { "r" }
361+ ),
362+ format!(
363+ "Trim clip {} edge",
364+ if edge == Edge::Start { "left" } else { "right" }
365+ ),
366+ )
367+ },
368+ true,
369+ ));
352 zone = match edge {370 zone = match edge {
353 Edge::Start => zone.left_0(),371 Edge::Start => zone.left_0(),
354 Edge::End => zone.right_0(),372 Edge::End => zone.right_0(),
@@ -403,9 +421,9 @@ fn clip_box(
403 }),421 }),
404 )422 )
405 })423 })
406- // Fades shade their own ramps over the waveform, including the live424+ // Fades shade their own ramps over every clip, including the live
407 // `FadeDrag` value, so the ramp follows the hand before release.425 // `FadeDrag` value, so the ramp follows the hand before release.
408- .when(audio, |d| {426+ .when(fade_in > 0 || fade_out > 0, |d| {
409 d.children(427 d.children(
410 [428 [
411 (fade_in > 0).then(|| {429 (fade_in > 0).then(|| {
@@ -528,7 +546,7 @@ fn clip_box(
528 })546 })
529 // The fade handles sit inside the trim strips, so their small top547 // The fade handles sit inside the trim strips, so their small top
530 // corners change a ramp while the outer full-height strips still trim.548 // corners change a ramp while the outer full-height strips still trim.
531- .when(audio && trims(span), |d| {549+ .when(trims(span), |d| {
532 d.children([Edge::Start, Edge::End].into_iter().map(|edge| {550 d.children([Edge::Start, Edge::End].into_iter().map(|edge| {
533 let is_in = edge == Edge::Start;551 let is_in = edge == Edge::Start;
534 let mut handle = div()552 let mut handle = div()
@@ -544,7 +562,22 @@ fn clip_box(
544 cx.listener(move |this, event: &MouseDownEvent, _, cx| {562 cx.listener(move |this, event: &MouseDownEvent, _, cx| {
545 this.start_fade_drag(lane, idx, is_in, event.position.x, cx);563 this.start_fade_drag(lane, idx, is_in, event.position.x, cx);
546 }),564 }),
547- );565+ )
566+ .children(hitmap::dynamic(
567+ move || {
568+ (
569+ format!(
570+ "clip.{}.{}.{}.fade-{}",
571+ lane.label(),
572+ lane.ord,
573+ idx,
574+ if is_in { "in" } else { "out" }
575+ ),
576+ format!("Adjust fade {}", if is_in { "in" } else { "out" }),
577+ )
578+ },
579+ true,
580+ ));
548 handle = match edge {581 handle = match edge {
549 Edge::Start => handle.left(px(EDGE_W)),582 Edge::Start => handle.left(px(EDGE_W)),
550 Edge::End => handle.right(px(EDGE_W)),583 Edge::End => handle.right(px(EDGE_W)),
@@ -812,6 +845,15 @@ fn lane_row(
812 .on_drag(LaneDrag(lane), move |_, _, _, cx| {845 .on_drag(LaneDrag(lane), move |_, _, _, cx| {
813 cx.new(|_| Tip(head_ghost.clone()))846 cx.new(|_| Tip(head_ghost.clone()))
814 })847 })
848+ .children(hitmap::dynamic(
849+ move || {
850+ (
851+ format!("lane.{}.reorder", lane.label()),
852+ format!("Reorder {}", lane.label()),
853+ )
854+ },
855+ true,
856+ ))
815 .child(857 .child(
816 div()858 div()
817 .flex()859 .flex()
@@ -892,7 +934,7 @@ fn lane_row(
892 .children(hitmap::dynamic(934 .children(hitmap::dynamic(
893 move || {935 move || {
894 (936 (
895- format!("lane.{}.subtitles", lane.label()),937+ format!("lane.{}.eye", lane.label()),
896 format!("Show {}", lane.label()),938 format!("Show {}", lane.label()),
897 )939 )
898 },940 },
crates/app/src/ui/dock_stance.rsmodified+27 -1
@@ -307,6 +307,12 @@ fn source_row(
307 ),307 ),
308 };308 };
309 let proxy_stops = proxy_glyph == "■";309 let proxy_stops = proxy_glyph == "■";
310+ let proxy_label = match (proxy_on, proxy_waiting, proxy_progress) {
311+ (_, true, _) => "Proxy cancelling".to_string(),
312+ (true, false, Some(progress)) => format!("Proxy making {:.0}%", progress * 100.),
313+ (true, false, None) => "Proxy ready".to_string(),
314+ (false, false, _) => "Proxy off".to_string(),
315+ };
310 let proxy_tip: SharedString = proxy_tip.into();316 let proxy_tip: SharedString = proxy_tip.into();
311 div()317 div()
312 .id(("dock-source", i))318 .id(("dock-source", i))
@@ -520,7 +526,7 @@ fn source_row(
520 this.toggle_proxy(&proxy_path, proxy_stops, cx);526 this.toggle_proxy(&proxy_path, proxy_stops, cx);
521 }))527 }))
522 .children(hitmap::dynamic(528 .children(hitmap::dynamic(
523- move || (format!("source.{i}.proxy"), "Toggle proxy".into()),529+ move || (format!("source.{i}.proxy"), proxy_label),
524 !proxy_waiting,530 !proxy_waiting,
525 ))531 ))
526 .child(532 .child(
@@ -593,6 +599,8 @@ fn subtitle_palette(player: &Player, cx: &mut Context<Player>) -> Option<AnyElem
593 .unwrap_or_else(|| "drag onto an S lane to place".to_string())599 .unwrap_or_else(|| "drag onto an S lane to place".to_string())
594 .into();600 .into();
595 let ghost = title.clone();601 let ghost = title.clone();
602+ let hitmap_title = title.clone();
603+ let select_title = title.clone();
596 div()604 div()
597 .id(("dock-subtitle-track", track))605 .id(("dock-subtitle-track", track))
598 .flex_none()606 .flex_none()
@@ -615,6 +623,24 @@ fn subtitle_palette(player: &Player, cx: &mut Context<Player>) -> Option<AnyElem
615 cx.notify();623 cx.notify();
616 }))624 }))
617 })625 })
626+ .children(hitmap::dynamic(
627+ move || {
628+ (
629+ format!("subtitle.{group_ord}.{track}.row"),
630+ hitmap_title.to_string(),
631+ )
632+ },
633+ usable,
634+ ))
635+ .children(hitmap::dynamic(
636+ move || {
637+ (
638+ format!("subtitle.{group_ord}.{track}.select"),
639+ format!("Select {select_title}"),
640+ )
641+ },
642+ usable,
643+ ))
618 .child(644 .child(
619 div()645 div()
620 .flex_none()646 .flex_none()
crates/app/src/ui/overlays.rsmodified+13 -2
@@ -295,6 +295,7 @@ impl Player {
295 // than one truncated one.295 // than one truncated one.
296 .truncate()296 .truncate()
297 .child(action.label())297 .child(action.label())
298+ .children(hitmap::action(action, refusal.yes()))
298 // The reason rides on the label rather than in299 // The reason rides on the label rather than in
299 // the stroke column, which the rebind half300 // the stroke column, which the rebind half
300 // needs whatever the editor's state is: an301 // needs whatever the editor's state is: an
@@ -696,7 +697,10 @@ impl Player {
696 },697 },
697 ))698 ))
698 })699 })
699- .children(hitmap::action(action, enabled))700+ .children(hitmap::dynamic(
701+ move || (format!("menu.{action:?}"), full.to_string()),
702+ enabled,
703+ ))
700 .into_any_element(),704 .into_any_element(),
701 );705 );
702 }706 }
@@ -713,6 +717,7 @@ impl Player {
713 }717 }
714 cx.notify();718 cx.notify();
715 }))719 }))
720+ .children(hitmap::control("menu.properties", "Properties", true))
716 .child("Properties")721 .child("Properties")
717 // No stroke reaches this one, and a blank column would read722 // No stroke reaches this one, and a blank column would read
718 // as one that was forgotten.723 // as one that was forgotten.
@@ -814,11 +819,17 @@ impl Player {
814 ) -> Option<impl IntoElement> {819 ) -> Option<impl IntoElement> {
815 let picker = self.picker?;820 let picker = self.picker?;
816 let darkroom = self.darkroom;821 let darkroom = self.darkroom;
822+ let theme_picker = picker.of == Pick::Theme;
817 let rows: Vec<AnyElement> = self823 let rows: Vec<AnyElement> = self
818 .choices(picker.of)824 .choices(picker.of)
819 .into_iter()825 .into_iter()
820 .enumerate()826 .enumerate()
821 .map(|(n, (choice, label, detail, picked))| {827 .map(|(n, (choice, label, detail, picked))| {
828+ let hitmap_label = label.clone();
829+ let hitmap_id = match theme_picker {
830+ true => format!("theme.{n}.row"),
831+ false => format!("picker.choice.{n}"),
832+ };
822 div()833 div()
823 .id(("picker-row", n))834 .id(("picker-row", n))
824 .flex()835 .flex()
@@ -906,7 +917,7 @@ impl Player {
906 cx.listener(move |this, _: &ClickEvent, _, cx| this.choose(choice, cx)),917 cx.listener(move |this, _: &ClickEvent, _, cx| this.choose(choice, cx)),
907 )918 )
908 .children(hitmap::dynamic(919 .children(hitmap::dynamic(
909- move || (format!("picker.choice.{n}"), "Choose setting value".into()),920+ move || (hitmap_id, hitmap_label.to_string()),
910 true,921 true,
911 ))922 ))
912 .into_any_element()923 .into_any_element()
crates/app/src/ui/preview.rsmodified+4 -0
@@ -1,5 +1,6 @@
1 //! The picture: what is drawn over it and what is read off it.1 //! The picture: what is drawn over it and what is read off it.
2 2
3+use crate::ui::hitmap;
3 use crate::ui::type_scale::{self, Typeset};4 use crate::ui::type_scale::{self, Typeset};
4 use crate::*;5 use crate::*;
5 use std::path::{Path, PathBuf};6 use std::path::{Path, PathBuf};
@@ -41,6 +42,7 @@ impl Player {
41 .bg(rgb(BG_RAISED()))42 .bg(rgb(BG_RAISED()))
42 .hover(|s| s.bg(rgb(BG_HOVER())))43 .hover(|s| s.bg(rgb(BG_HOVER())))
43 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.close_preview(cx)))44 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.close_preview(cx)))
45+ .children(hitmap::control("preview.stop", "Stop preview", true))
44 .child("Stop (esc)"),46 .child("Stop (esc)"),
45 )47 )
46 })48 })
@@ -94,6 +96,7 @@ impl Player {
94 .cursor_pointer()96 .cursor_pointer()
95 .hover(|s| s.bg(rgb(DARK_RAISED())))97 .hover(|s| s.bg(rgb(DARK_RAISED())))
96 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.close_preview(cx)))98 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.close_preview(cx)))
99+ .children(hitmap::control("preview.stop", "Stop preview", true))
97 .child(div().text_color(rgb(INK2())).child("Stop"))100 .child(div().text_color(rgb(INK2())).child("Stop"))
98 .child(101 .child(
99 div()102 div()
@@ -146,6 +149,7 @@ impl Player {
146 this.preview_scrub_to(event.position.x, true, cx);149 this.preview_scrub_to(event.position.x, true, cx);
147 }),150 }),
148 )151 )
152+ .children(hitmap::control("preview.scrub", "Preview scrub bar", true))
149 .child(153 .child(
150 div()154 div()
151 .relative()155 .relative()