From 7f442f47b46032709c2bc9ef3468862cdbdd8188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 21 Aug 2026 22:38:40 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(hitmap):=20expose=20timeline?= =?UTF-8?q?=20pointer=20targets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/app/src/tests/layout.rs | 76 +++++++++++++++++++++++++++++-- crates/app/src/ui/bench_stance.rs | 54 +++++++++++++++++++--- crates/app/src/ui/dock_stance.rs | 28 +++++++++++- crates/app/src/ui/overlays.rs | 15 +++++- crates/app/src/ui/preview.rs | 4 ++ 5 files changed, 165 insertions(+), 12 deletions(-) diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index a04bf0d..8dbcd0a 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -2697,9 +2697,7 @@ fn darkroom_bench_wires_transition_controls_and_lane_drop_cue() { let dissolve = &clip[clip .find(".when(dissolves, |d| {") .expect("the dissolve affordance") - ..clip - .find(".when(audio && trims(span)") - .expect("the fade handles")]; + ..clip.find(".when(trims(span),").expect("the fade handles")]; assert!( dissolve.contains(".w(px(FADE_HANDLE_W))"), "dissolve click target no longer matches fade-handle width" @@ -2733,3 +2731,75 @@ fn darkroom_bench_wires_transition_controls_and_lane_drop_cue() { ); } } + +/// The pointer harness can only drive controls that report the bounds of the +/// element that owns the gesture. Keep every dynamic Darkroom entry surface +/// named, so UI verification never falls back to guessed pixels. +#[test] +fn hitmap_names_every_darkroom_pointer_entry_surface() { + let bench = src_text("ui/bench_stance.rs"); + for needle in [ + "clip.{}.{}.{}.fade-{}", + "clip.{}.{}.{}.trim-{}", + "clip.{}.{}.{}.dissolve", + "lane.{}.reorder", + "lane.{}.mix", + "lane.{}.eye", + "lane.{}.remove", + ] { + assert!( + bench.contains(needle), + "bench control missing hitmap id: {needle}" + ); + } + assert!( + bench.contains(".when(trims(span), |d| {"), + "fade handles must cover video clips as well as audio clips" + ); + + let dock = src_text("ui/dock_stance.rs"); + for needle in [ + "subtitle.{group_ord}.{track}.row", + "subtitle.{group_ord}.{track}.select", + "source.{i}.proxy", + "Proxy making", + ] { + assert!( + dock.contains(needle), + "dock control missing hitmap contract: {needle}" + ); + } + + for (path, needles) in [ + ( + "ui/timeband_stance.rs", + &[ + "timeline.contact-strip", + "stance-strip-grip-lt", + "stance-strip-grip-rb", + ][..], + ), + ("ui/preview.rs", &["preview.stop", "preview.scrub"][..]), + ( + "ui/overlays.rs", + &[ + "menu.{action:?}", + "menu.properties", + "theme.{n}.row", + "hitmap::action(action, refusal.yes())", + ][..], + ), + ( + "ui/settings_stance.rs", + &[".children(hitmap::control(id, label_text, !exporting))"][..], + ), + ] { + let source = src_text(path); + for needle in needles { + assert!( + source.contains(needle), + "{path} missing hitmap contract: {needle}" + ); + } + } +} diff --git a/crates/app/src/ui/bench_stance.rs b/crates/app/src/ui/bench_stance.rs index 38f0fb3..9ca54b8 100644 --- a/crates/app/src/ui/bench_stance.rs +++ b/crates/app/src/ui/bench_stance.rs @@ -348,7 +348,25 @@ fn clip_box( cx.listener(move |this, event: &MouseDownEvent, _, cx| { this.open_menu(lane, idx, event.position, cx); }), - ); + ) + .children(hitmap::dynamic( + move || { + ( + format!( + "clip.{}.{}.{}.trim-{}", + lane.label(), + lane.ord, + idx, + if edge == Edge::Start { "l" } else { "r" } + ), + format!( + "Trim clip {} edge", + if edge == Edge::Start { "left" } else { "right" } + ), + ) + }, + true, + )); zone = match edge { Edge::Start => zone.left_0(), Edge::End => zone.right_0(), @@ -403,9 +421,9 @@ fn clip_box( }), ) }) - // Fades shade their own ramps over the waveform, including the live + // Fades shade their own ramps over every clip, including the live // `FadeDrag` value, so the ramp follows the hand before release. - .when(audio, |d| { + .when(fade_in > 0 || fade_out > 0, |d| { d.children( [ (fade_in > 0).then(|| { @@ -528,7 +546,7 @@ fn clip_box( }) // The fade handles sit inside the trim strips, so their small top // corners change a ramp while the outer full-height strips still trim. - .when(audio && trims(span), |d| { + .when(trims(span), |d| { d.children([Edge::Start, Edge::End].into_iter().map(|edge| { let is_in = edge == Edge::Start; let mut handle = div() @@ -544,7 +562,22 @@ fn clip_box( cx.listener(move |this, event: &MouseDownEvent, _, cx| { this.start_fade_drag(lane, idx, is_in, event.position.x, cx); }), - ); + ) + .children(hitmap::dynamic( + move || { + ( + format!( + "clip.{}.{}.{}.fade-{}", + lane.label(), + lane.ord, + idx, + if is_in { "in" } else { "out" } + ), + format!("Adjust fade {}", if is_in { "in" } else { "out" }), + ) + }, + true, + )); handle = match edge { Edge::Start => handle.left(px(EDGE_W)), Edge::End => handle.right(px(EDGE_W)), @@ -812,6 +845,15 @@ fn lane_row( .on_drag(LaneDrag(lane), move |_, _, _, cx| { cx.new(|_| Tip(head_ghost.clone())) }) + .children(hitmap::dynamic( + move || { + ( + format!("lane.{}.reorder", lane.label()), + format!("Reorder {}", lane.label()), + ) + }, + true, + )) .child( div() .flex() @@ -892,7 +934,7 @@ fn lane_row( .children(hitmap::dynamic( move || { ( - format!("lane.{}.subtitles", lane.label()), + format!("lane.{}.eye", lane.label()), format!("Show {}", lane.label()), ) }, diff --git a/crates/app/src/ui/dock_stance.rs b/crates/app/src/ui/dock_stance.rs index 5129a40..d91e4d3 100644 --- a/crates/app/src/ui/dock_stance.rs +++ b/crates/app/src/ui/dock_stance.rs @@ -307,6 +307,12 @@ fn source_row( ), }; let proxy_stops = proxy_glyph == "■"; + let proxy_label = match (proxy_on, proxy_waiting, proxy_progress) { + (_, true, _) => "Proxy cancelling".to_string(), + (true, false, Some(progress)) => format!("Proxy making {:.0}%", progress * 100.), + (true, false, None) => "Proxy ready".to_string(), + (false, false, _) => "Proxy off".to_string(), + }; let proxy_tip: SharedString = proxy_tip.into(); div() .id(("dock-source", i)) @@ -520,7 +526,7 @@ fn source_row( this.toggle_proxy(&proxy_path, proxy_stops, cx); })) .children(hitmap::dynamic( - move || (format!("source.{i}.proxy"), "Toggle proxy".into()), + move || (format!("source.{i}.proxy"), proxy_label), !proxy_waiting, )) .child( @@ -593,6 +599,8 @@ fn subtitle_palette(player: &Player, cx: &mut Context) -> Option) -> Option Option { let picker = self.picker?; let darkroom = self.darkroom; + let theme_picker = picker.of == Pick::Theme; let rows: Vec = self .choices(picker.of) .into_iter() .enumerate() .map(|(n, (choice, label, detail, picked))| { + let hitmap_label = label.clone(); + let hitmap_id = match theme_picker { + true => format!("theme.{n}.row"), + false => format!("picker.choice.{n}"), + }; div() .id(("picker-row", n)) .flex() @@ -906,7 +917,7 @@ impl Player { cx.listener(move |this, _: &ClickEvent, _, cx| this.choose(choice, cx)), ) .children(hitmap::dynamic( - move || (format!("picker.choice.{n}"), "Choose setting value".into()), + move || (hitmap_id, hitmap_label.to_string()), true, )) .into_any_element() diff --git a/crates/app/src/ui/preview.rs b/crates/app/src/ui/preview.rs index 1d4745d..0508f54 100644 --- a/crates/app/src/ui/preview.rs +++ b/crates/app/src/ui/preview.rs @@ -1,5 +1,6 @@ //! The picture: what is drawn over it and what is read off it. +use crate::ui::hitmap; use crate::ui::type_scale::{self, Typeset}; use crate::*; use std::path::{Path, PathBuf}; @@ -41,6 +42,7 @@ impl Player { .bg(rgb(BG_RAISED())) .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.close_preview(cx))) + .children(hitmap::control("preview.stop", "Stop preview", true)) .child("Stop (esc)"), ) }) @@ -94,6 +96,7 @@ impl Player { .cursor_pointer() .hover(|s| s.bg(rgb(DARK_RAISED()))) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.close_preview(cx))) + .children(hitmap::control("preview.stop", "Stop preview", true)) .child(div().text_color(rgb(INK2())).child("Stop")) .child( div() @@ -146,6 +149,7 @@ impl Player { this.preview_scrub_to(event.position.x, true, cx); }), ) + .children(hitmap::control("preview.scrub", "Preview scrub bar", true)) .child( div() .relative()