forge
Explore
Log in

Don't you dare go Hollow

merge oldui-hitmap2

Browse files at this commit

484d07d60fa68bd3b068fa98393eddbc6450152cAhmet Kaan GümüşParent: 488d1387f442f4
crates/app/src/tests/layout.rsmodified+73 -3
@@ -2697,9 +2697,7 @@ fn darkroom_bench_wires_transition_controls_and_lane_drop_cue() {
26972697 let dissolve = &clip[clip
26982698 .find(".when(dissolves, |d| {")
26992699 .expect("the dissolve affordance")
2700- ..clip
2701- .find(".when(audio && trims(span)")
2702- .expect("the fade handles")];
2700+ ..clip.find(".when(trims(span),").expect("the fade handles")];
27032701 assert!(
27042702 dissolve.contains(".w(px(FADE_HANDLE_W))"),
27052703 "dissolve click target no longer matches fade-handle width"
@@ -2733,3 +2731,75 @@ fn darkroom_bench_wires_transition_controls_and_lane_drop_cue() {
27332731 );
27342732 }
27352733 }
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(
348348 cx.listener(move |this, event: &MouseDownEvent, _, cx| {
349349 this.open_menu(lane, idx, event.position, cx);
350350 }),
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+ ));
352370 zone = match edge {
353371 Edge::Start => zone.left_0(),
354372 Edge::End => zone.right_0(),
@@ -403,9 +421,9 @@ fn clip_box(
403421 }),
404422 )
405423 })
406- // Fades shade their own ramps over the waveform, including the live
424+ // Fades shade their own ramps over every clip, including the live
407425 // `FadeDrag` value, so the ramp follows the hand before release.
408- .when(audio, |d| {
426+ .when(fade_in > 0 || fade_out > 0, |d| {
409427 d.children(
410428 [
411429 (fade_in > 0).then(|| {
@@ -528,7 +546,7 @@ fn clip_box(
528546 })
529547 // The fade handles sit inside the trim strips, so their small top
530548 // corners change a ramp while the outer full-height strips still trim.
531- .when(audio && trims(span), |d| {
549+ .when(trims(span), |d| {
532550 d.children([Edge::Start, Edge::End].into_iter().map(|edge| {
533551 let is_in = edge == Edge::Start;
534552 let mut handle = div()
@@ -544,7 +562,22 @@ fn clip_box(
544562 cx.listener(move |this, event: &MouseDownEvent, _, cx| {
545563 this.start_fade_drag(lane, idx, is_in, event.position.x, cx);
546564 }),
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+ ));
548581 handle = match edge {
549582 Edge::Start => handle.left(px(EDGE_W)),
550583 Edge::End => handle.right(px(EDGE_W)),
@@ -812,6 +845,15 @@ fn lane_row(
812845 .on_drag(LaneDrag(lane), move |_, _, _, cx| {
813846 cx.new(|_| Tip(head_ghost.clone()))
814847 })
848+ .children(hitmap::dynamic(
849+ move || {
850+ (
851+ format!("lane.{}.reorder", lane.label()),
852+ format!("Reorder {}", lane.label()),
853+ )
854+ },
855+ true,
856+ ))
815857 .child(
816858 div()
817859 .flex()
@@ -892,7 +934,7 @@ fn lane_row(
892934 .children(hitmap::dynamic(
893935 move || {
894936 (
895- format!("lane.{}.subtitles", lane.label()),
937+ format!("lane.{}.eye", lane.label()),
896938 format!("Show {}", lane.label()),
897939 )
898940 },
crates/app/src/ui/dock_stance.rsmodified+27 -1
@@ -307,6 +307,12 @@ fn source_row(
307307 ),
308308 };
309309 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+ };
310316 let proxy_tip: SharedString = proxy_tip.into();
311317 div()
312318 .id(("dock-source", i))
@@ -520,7 +526,7 @@ fn source_row(
520526 this.toggle_proxy(&proxy_path, proxy_stops, cx);
521527 }))
522528 .children(hitmap::dynamic(
523- move || (format!("source.{i}.proxy"), "Toggle proxy".into()),
529+ move || (format!("source.{i}.proxy"), proxy_label),
524530 !proxy_waiting,
525531 ))
526532 .child(
@@ -593,6 +599,8 @@ fn subtitle_palette(player: &Player, cx: &mut Context<Player>) -> Option<AnyElem
593599 .unwrap_or_else(|| "drag onto an S lane to place".to_string())
594600 .into();
595601 let ghost = title.clone();
602+ let hitmap_title = title.clone();
603+ let select_title = title.clone();
596604 div()
597605 .id(("dock-subtitle-track", track))
598606 .flex_none()
@@ -615,6 +623,24 @@ fn subtitle_palette(player: &Player, cx: &mut Context<Player>) -> Option<AnyElem
615623 cx.notify();
616624 }))
617625 })
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+ ))
618644 .child(
619645 div()
620646 .flex_none()
crates/app/src/ui/overlays.rsmodified+13 -2
@@ -295,6 +295,7 @@ impl Player {
295295 // than one truncated one.
296296 .truncate()
297297 .child(action.label())
298+ .children(hitmap::action(action, refusal.yes()))
298299 // The reason rides on the label rather than in
299300 // the stroke column, which the rebind half
300301 // needs whatever the editor's state is: an
@@ -696,7 +697,10 @@ impl Player {
696697 },
697698 ))
698699 })
699- .children(hitmap::action(action, enabled))
700+ .children(hitmap::dynamic(
701+ move || (format!("menu.{action:?}"), full.to_string()),
702+ enabled,
703+ ))
700704 .into_any_element(),
701705 );
702706 }
@@ -713,6 +717,7 @@ impl Player {
713717 }
714718 cx.notify();
715719 }))
720+ .children(hitmap::control("menu.properties", "Properties", true))
716721 .child("Properties")
717722 // No stroke reaches this one, and a blank column would read
718723 // as one that was forgotten.
@@ -814,11 +819,17 @@ impl Player {
814819 ) -> Option<impl IntoElement> {
815820 let picker = self.picker?;
816821 let darkroom = self.darkroom;
822+ let theme_picker = picker.of == Pick::Theme;
817823 let rows: Vec<AnyElement> = self
818824 .choices(picker.of)
819825 .into_iter()
820826 .enumerate()
821827 .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+ };
822833 div()
823834 .id(("picker-row", n))
824835 .flex()
@@ -906,7 +917,7 @@ impl Player {
906917 cx.listener(move |this, _: &ClickEvent, _, cx| this.choose(choice, cx)),
907918 )
908919 .children(hitmap::dynamic(
909- move || (format!("picker.choice.{n}"), "Choose setting value".into()),
920+ move || (hitmap_id, hitmap_label.to_string()),
910921 true,
911922 ))
912923 .into_any_element()
crates/app/src/ui/preview.rsmodified+4 -0
@@ -1,5 +1,6 @@
11 //! The picture: what is drawn over it and what is read off it.
22
3+use crate::ui::hitmap;
34 use crate::ui::type_scale::{self, Typeset};
45 use crate::*;
56 use std::path::{Path, PathBuf};
@@ -41,6 +42,7 @@ impl Player {
4142 .bg(rgb(BG_RAISED()))
4243 .hover(|s| s.bg(rgb(BG_HOVER())))
4344 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.close_preview(cx)))
45+ .children(hitmap::control("preview.stop", "Stop preview", true))
4446 .child("Stop (esc)"),
4547 )
4648 })
@@ -94,6 +96,7 @@ impl Player {
9496 .cursor_pointer()
9597 .hover(|s| s.bg(rgb(DARK_RAISED())))
9698 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.close_preview(cx)))
99+ .children(hitmap::control("preview.stop", "Stop preview", true))
97100 .child(div().text_color(rgb(INK2())).child("Stop"))
98101 .child(
99102 div()
@@ -146,6 +149,7 @@ impl Player {
146149 this.preview_scrub_to(event.position.x, true, cx);
147150 }),
148151 )
152+ .children(hitmap::control("preview.scrub", "Preview scrub bar", true))
149153 .child(
150154 div()
151155 .relative()