Expose Darkroom control hitmap
Browse files at this commit7f7f103084686e7e3f62d21f7bcd6e93359576d7Parent: 9a27ee6- feat
- expose Darkroom control hitmap
11 changed files +297 -0
- crates/app/src/tests/layout.rs +6 -0
- crates/app/src/ui/bench_stance.rs +64 -0
- crates/app/src/ui/cards.rs +2 -0
- crates/app/src/ui/dock_stance.rs +34 -0
- crates/app/src/ui/hitmap.rs +160 -0
- crates/app/src/ui/mod.rs +1 -0
- crates/app/src/ui/overlays.rs +6 -0
- crates/app/src/ui/settings_stance.rs +2 -0
- crates/app/src/ui/spine_stance.rs +3 -0
- crates/app/src/ui/stance.rs +2 -0
- crates/app/src/ui/timeband_stance.rs +17 -0
crates/app/src/tests/layout.rsmodified+6 -0
| @@ -2660,6 +2660,12 @@ fn every_action_has_a_darkroom_widget_home_or_explicit_owner() { | |||
| 2660 | let mentioned = darkroom.contains(&format!("ActionId::{name}")) | 2660 | let mentioned = darkroom.contains(&format!("ActionId::{name}")) |
| 2661 | || (action == ActionId::Resolution && darkroom.contains("Pick::Resolution")) | 2661 | || (action == ActionId::Resolution && darkroom.contains("Pick::Resolution")) |
| 2662 | || (action == ActionId::SubtitleStyle && darkroom.contains("open_subtitle_style(cx)")); | 2662 | || (action == ActionId::SubtitleStyle && darkroom.contains("open_subtitle_style(cx)")); |
| 2663 | + let hitmap_id = crate::ui::hitmap::action_id(action); | ||
| 2664 | + assert_eq!( | ||
| 2665 | + hitmap_id, | ||
| 2666 | + format!("action.{name}"), | ||
| 2667 | + "ActionId::{name} has a Darkroom widget home but no stable hitmap id" | ||
| 2668 | + ); | ||
| 2663 | assert!( | 2669 | assert!( |
| 2664 | mentioned, | 2670 | mentioned, |
| 2665 | "ActionId::{name} is bound to a chord but has no visible affordance \ | 2671 | "ActionId::{name} is bound to a chord but has no visible affordance \ |
crates/app/src/ui/bench_stance.rsmodified+64 -0
| @@ -38,6 +38,7 @@ | |||
| 38 | //! `nudge_cut` and friends still act on `Player::selected` directly, with no | 38 | //! `nudge_cut` and friends still act on `Player::selected` directly, with no |
| 39 | //! element under the pointer required, and stay untouched by any of this. | 39 | //! element under the pointer required, and stay untouched by any of this. |
| 40 | 40 | ||
| 41 | +use crate::ui::hitmap; | ||
| 41 | use crate::ui::type_scale::{self, Typeset}; | 42 | use crate::ui::type_scale::{self, Typeset}; |
| 42 | use crate::ui::widgets::*; | 43 | use crate::ui::widgets::*; |
| 43 | use crate::*; | 44 | use crate::*; |
| @@ -306,6 +307,15 @@ fn clip_box( | |||
| 306 | move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) | 307 | move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) |
| 307 | }, | 308 | }, |
| 308 | ) | 309 | ) |
| 310 | + .children(hitmap::dynamic( | ||
| 311 | + move || { | ||
| 312 | + ( | ||
| 313 | + format!("clip.{}.{}.{}", lane.label(), lane.ord, idx), | ||
| 314 | + "Timeline clip".into(), | ||
| 315 | + ) | ||
| 316 | + }, | ||
| 317 | + true, | ||
| 318 | + )) | ||
| 309 | // The two edge strips a drag lengthens or shortens the clip by | 319 | // The two edge strips a drag lengthens or shortens the clip by |
| 310 | // (`Player::start_trim`), gated on the same `trims(span)` floor the | 320 | // (`Player::start_trim`), gated on the same `trims(span)` floor the |
| 311 | // legacy strips use -- a clip too narrow to aim at keeps its whole | 321 | // legacy strips use -- a clip too narrow to aim at keeps its whole |
| @@ -507,6 +517,15 @@ fn clip_box( | |||
| 507 | this.pick((lane, idx), false, cx); | 517 | this.pick((lane, idx), false, cx); |
| 508 | this.dissolve_selected(cx); | 518 | this.dissolve_selected(cx); |
| 509 | })) | 519 | })) |
| 520 | + .children(hitmap::dynamic( | ||
| 521 | + move || { | ||
| 522 | + ( | ||
| 523 | + format!("clip.{}.{}.{}.dissolve", lane.label(), lane.ord, idx), | ||
| 524 | + "Toggle dissolve".into(), | ||
| 525 | + ) | ||
| 526 | + }, | ||
| 527 | + true, | ||
| 528 | + )) | ||
| 510 | .child(dissolve_glyph()), | 529 | .child(dissolve_glyph()), |
| 511 | ) | 530 | ) |
| 512 | }) | 531 | }) |
| @@ -627,6 +646,15 @@ fn sub_box( | |||
| 627 | move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) | 646 | move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) |
| 628 | }, | 647 | }, |
| 629 | ) | 648 | ) |
| 649 | + .children(hitmap::dynamic( | ||
| 650 | + move || { | ||
| 651 | + ( | ||
| 652 | + format!("subtitle.{}.{}.{}", lane.label(), lane.ord, idx), | ||
| 653 | + "Timeline subtitle".into(), | ||
| 654 | + ) | ||
| 655 | + }, | ||
| 656 | + true, | ||
| 657 | + )) | ||
| 630 | // The same edge-trim strips a clip gets, on the same [`trims`] floor. | 658 | // The same edge-trim strips a clip gets, on the same [`trims`] floor. |
| 631 | .children( | 659 | .children( |
| 632 | [Edge::Start, Edge::End] | 660 | [Edge::Start, Edge::End] |
| @@ -823,6 +851,15 @@ fn lane_row( | |||
| 823 | .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | 851 | .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { |
| 824 | this.act_lane(ActionId::Mix, lane, cx); | 852 | this.act_lane(ActionId::Mix, lane, cx); |
| 825 | })) | 853 | })) |
| 854 | + .children(hitmap::dynamic( | ||
| 855 | + move || { | ||
| 856 | + ( | ||
| 857 | + format!("lane.{}.mix", lane.label()), | ||
| 858 | + format!("Mix {}", lane.label()), | ||
| 859 | + ) | ||
| 860 | + }, | ||
| 861 | + true, | ||
| 862 | + )) | ||
| 826 | .child("≋") | 863 | .child("≋") |
| 827 | .child( | 864 | .child( |
| 828 | div() | 865 | div() |
| @@ -855,6 +892,15 @@ fn lane_row( | |||
| 855 | .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | 892 | .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { |
| 856 | this.show_sub_lane(lane, cx); | 893 | this.show_sub_lane(lane, cx); |
| 857 | })) | 894 | })) |
| 895 | + .children(hitmap::dynamic( | ||
| 896 | + move || { | ||
| 897 | + ( | ||
| 898 | + format!("lane.{}.subtitles", lane.label()), | ||
| 899 | + format!("Show {}", lane.label()), | ||
| 900 | + ) | ||
| 901 | + }, | ||
| 902 | + true, | ||
| 903 | + )) | ||
| 858 | .child("◉"), | 904 | .child("◉"), |
| 859 | ) | 905 | ) |
| 860 | }) | 906 | }) |
| @@ -887,6 +933,15 @@ fn lane_row( | |||
| 887 | .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | 933 | .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { |
| 888 | this.act_lane(action, lane, cx); | 934 | this.act_lane(action, lane, cx); |
| 889 | })) | 935 | })) |
| 936 | + .children(hitmap::dynamic( | ||
| 937 | + move || { | ||
| 938 | + ( | ||
| 939 | + format!("lane.{}.remove", lane.label()), | ||
| 940 | + format!("Remove {}", lane.label()), | ||
| 941 | + ) | ||
| 942 | + }, | ||
| 943 | + player.enable(action, None).yes(), | ||
| 944 | + )) | ||
| 890 | .child("×") | 945 | .child("×") |
| 891 | .child( | 946 | .child( |
| 892 | div() | 947 | div() |
| @@ -1010,6 +1065,15 @@ fn lane_row( | |||
| 1010 | cx.stop_propagation(); | 1065 | cx.stop_propagation(); |
| 1011 | this.timeline_wheel(event, cx); | 1066 | this.timeline_wheel(event, cx); |
| 1012 | })) | 1067 | })) |
| 1068 | + .children(hitmap::dynamic( | ||
| 1069 | + move || { | ||
| 1070 | + ( | ||
| 1071 | + format!("lane.{}.bed", lane.label()), | ||
| 1072 | + format!("{} timeline bed", lane.label()), | ||
| 1073 | + ) | ||
| 1074 | + }, | ||
| 1075 | + true, | ||
| 1076 | + )) | ||
| 1013 | .children(boxes) | 1077 | .children(boxes) |
| 1014 | .children(sub_boxes) | 1078 | .children(sub_boxes) |
| 1015 | // The shadow of the row in flight (`Player::ghost`, set by | 1079 | // The shadow of the row in flight (`Player::ghost`, set by |
crates/app/src/ui/cards.rsmodified+2 -0
| @@ -1,5 +1,6 @@ | |||
| 1 | //! The property cards -- docked into the inspector, or floated when modal. | 1 | //! The property cards -- docked into the inspector, or floated when modal. |
| 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::ui::widgets::*; | 5 | use crate::ui::widgets::*; |
| 5 | use crate::*; | 6 | use crate::*; |
| @@ -121,6 +122,7 @@ fn dark_card_head( | |||
| 121 | .into() | 122 | .into() |
| 122 | }) | 123 | }) |
| 123 | .child(if max { "▣ m" } else { "⤢ m" }) | 124 | .child(if max { "▣ m" } else { "⤢ m" }) |
| 125 | + .children(hitmap::control("card.maximize", "Toggle card size", true)) | ||
| 124 | })) | 126 | })) |
| 125 | .child( | 127 | .child( |
| 126 | div() | 128 | div() |
crates/app/src/ui/dock_stance.rsmodified+34 -0
| @@ -11,6 +11,7 @@ | |||
| 11 | //! still supply the row facts ([`library_rows`], [`source_tint`], | 11 | //! still supply the row facts ([`library_rows`], [`source_tint`], |
| 12 | //! [`clip_middle`]...), only the anatomy around them is new. | 12 | //! [`clip_middle`]...), only the anatomy around them is new. |
| 13 | 13 | ||
| 14 | +use crate::ui::hitmap; | ||
| 14 | use crate::ui::type_scale::{self, Typeset, head, label, mono}; | 15 | use crate::ui::type_scale::{self, Typeset, head, label, mono}; |
| 15 | use crate::*; | 16 | use crate::*; |
| 16 | use gpui::FontWeight; | 17 | use gpui::FontWeight; |
| @@ -136,6 +137,7 @@ fn ghost_verb( | |||
| 136 | .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) | 137 | .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) |
| 137 | .on_click(on_click) | 138 | .on_click(on_click) |
| 138 | }) | 139 | }) |
| 140 | + .children(hitmap::action(action, on)) | ||
| 139 | .child( | 141 | .child( |
| 140 | div() | 142 | div() |
| 141 | .font(label_style.font) | 143 | .font(label_style.font) |
| @@ -184,6 +186,7 @@ fn dock_tab( | |||
| 184 | save(this.dock_src_active); | 186 | save(this.dock_src_active); |
| 185 | cx.notify(); | 187 | cx.notify(); |
| 186 | })) | 188 | })) |
| 189 | + .children(hitmap::control(id, label_text, true)) | ||
| 187 | .child( | 190 | .child( |
| 188 | div() | 191 | div() |
| 189 | .font(style.font) | 192 | .font(style.font) |
| @@ -374,6 +377,10 @@ fn source_row( | |||
| 374 | cx.new(|_| Tip(ghost.clone())) | 377 | cx.new(|_| Tip(ghost.clone())) |
| 375 | }) | 378 | }) |
| 376 | }) | 379 | }) |
| 380 | + .children(hitmap::dynamic( | ||
| 381 | + move || (format!("source.{i}.row"), "Source row".into()), | ||
| 382 | + usable, | ||
| 383 | + )) | ||
| 377 | .child( | 384 | .child( |
| 378 | div() | 385 | div() |
| 379 | .flex() | 386 | .flex() |
| @@ -463,6 +470,10 @@ fn source_row( | |||
| 463 | }, | 470 | }, |
| 464 | )) | 471 | )) |
| 465 | }) | 472 | }) |
| 473 | + .children(hitmap::dynamic( | ||
| 474 | + move || (format!("source.{i}.add"), "Add at playhead".into()), | ||
| 475 | + can_insert, | ||
| 476 | + )) | ||
| 466 | .tooltip(move |_, cx| { | 477 | .tooltip(move |_, cx| { |
| 467 | cx.new(|_| { | 478 | cx.new(|_| { |
| 468 | Tip( | 479 | Tip( |
| @@ -508,6 +519,10 @@ fn source_row( | |||
| 508 | cx.stop_propagation(); | 519 | cx.stop_propagation(); |
| 509 | this.toggle_proxy(&proxy_path, proxy_stops, cx); | 520 | this.toggle_proxy(&proxy_path, proxy_stops, cx); |
| 510 | })) | 521 | })) |
| 522 | + .children(hitmap::dynamic( | ||
| 523 | + move || (format!("source.{i}.proxy"), "Toggle proxy".into()), | ||
| 524 | + !proxy_waiting, | ||
| 525 | + )) | ||
| 511 | .child( | 526 | .child( |
| 512 | div() | 527 | div() |
| 513 | .font(style.font) | 528 | .font(style.font) |
| @@ -644,6 +659,15 @@ fn subtitle_palette(player: &Player, cx: &mut Context<Player>) -> Option<AnyElem | |||
| 644 | cx.stop_propagation(); | 659 | cx.stop_propagation(); |
| 645 | this.remove_subtitle_track(track, cx); | 660 | this.remove_subtitle_track(track, cx); |
| 646 | })) | 661 | })) |
| 662 | + .children(hitmap::dynamic( | ||
| 663 | + move || { | ||
| 664 | + ( | ||
| 665 | + format!("subtitle.{track}.remove"), | ||
| 666 | + "Remove subtitle".into(), | ||
| 667 | + ) | ||
| 668 | + }, | ||
| 669 | + true, | ||
| 670 | + )) | ||
| 647 | .child("×"), | 671 | .child("×"), |
| 648 | ) | 672 | ) |
| 649 | }) | 673 | }) |
| @@ -671,6 +695,15 @@ fn subtitle_palette(player: &Player, cx: &mut Context<Player>) -> Option<AnyElem | |||
| 671 | } | 695 | } |
| 672 | cx.notify(); | 696 | cx.notify(); |
| 673 | })) | 697 | })) |
| 698 | + .children(hitmap::dynamic( | ||
| 699 | + move || { | ||
| 700 | + ( | ||
| 701 | + format!("subtitle-group.{group_ord}.fold"), | ||
| 702 | + "Toggle subtitle group".into(), | ||
| 703 | + ) | ||
| 704 | + }, | ||
| 705 | + true, | ||
| 706 | + )) | ||
| 674 | .child(if folded { "▸" } else { "▾" }) | 707 | .child(if folded { "▸" } else { "▾" }) |
| 675 | .when_some(tint, |d, tint| { | 708 | .when_some(tint, |d, tint| { |
| 676 | d.child( | 709 | d.child( |
| @@ -798,6 +831,7 @@ fn sources_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 798 | this.dock_filter_edit = true; | 831 | this.dock_filter_edit = true; |
| 799 | cx.notify(); | 832 | cx.notify(); |
| 800 | })) | 833 | })) |
| 834 | + .children(hitmap::control("dock.filter", "Filter sources", true)) | ||
| 801 | .child(match player.dock_filter.is_empty() { | 835 | .child(match player.dock_filter.is_empty() { |
| 802 | true => "⌕ type to filter — name, codec, unused…".to_string(), | 836 | true => "⌕ type to filter — name, codec, unused…".to_string(), |
| 803 | false => format!("⌕ {filter_text}"), | 837 | false => format!("⌕ {filter_text}"), |
crates/app/src/ui/hitmap.rsadded+160 -0
| @@ -0,0 +1,160 @@ | |||
| 1 | +//! Machine-readable bounds for the Darkroom's pointer controls. | ||
| 2 | +use crate::ActionId; | ||
| 3 | + | ||
| 4 | +use gpui::*; | ||
| 5 | +use std::{ | ||
| 6 | + cell::RefCell, | ||
| 7 | + fmt::Write as _, | ||
| 8 | + fs, | ||
| 9 | + path::{Path, PathBuf}, | ||
| 10 | + sync::LazyLock, | ||
| 11 | + time::{Duration, Instant}, | ||
| 12 | +}; | ||
| 13 | + | ||
| 14 | +const WRITE_INTERVAL: Duration = Duration::from_millis(250); | ||
| 15 | + | ||
| 16 | +struct Target { | ||
| 17 | + id: String, | ||
| 18 | + label: String, | ||
| 19 | + bounds: Bounds<Pixels>, | ||
| 20 | + enabled: bool, | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +#[derive(Default)] | ||
| 24 | +struct State { | ||
| 25 | + targets: Vec<Target>, | ||
| 26 | + last_write: Option<Instant>, | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +thread_local! { | ||
| 30 | + static STATE: RefCell<State> = RefCell::new(State::default()); | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +fn output_path() -> Option<&'static Path> { | ||
| 34 | + static PATH: LazyLock<Option<PathBuf>> = | ||
| 35 | + LazyLock::new(|| std::env::var_os("EDITH_HITMAP").map(PathBuf::from)); | ||
| 36 | + PATH.as_deref() | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +/// Clears the current-frame controls before descendants record their laid-out | ||
| 40 | +/// bounds, then writes the completed frame after all descendants prepaint. | ||
| 41 | +pub(crate) fn frame() -> Option<impl IntoElement> { | ||
| 42 | + output_path()?; | ||
| 43 | + Some( | ||
| 44 | + canvas( | ||
| 45 | + |_, _, _| STATE.with(|state| state.borrow_mut().targets.clear()), | ||
| 46 | + |_, _, _, _| flush(), | ||
| 47 | + ) | ||
| 48 | + .absolute() | ||
| 49 | + .size_full(), | ||
| 50 | + ) | ||
| 51 | +} | ||
| 52 | + | ||
| 53 | +/// An invisible child that records a control's final window-relative bounds. | ||
| 54 | +pub(crate) fn control( | ||
| 55 | + id: &'static str, | ||
| 56 | + label: &'static str, | ||
| 57 | + enabled: bool, | ||
| 58 | +) -> Option<impl IntoElement> { | ||
| 59 | + dynamic(|| (id.into(), label.into()), enabled) | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +/// Dynamic controls defer identifier allocation until instrumentation is on. | ||
| 63 | +pub(crate) fn dynamic( | ||
| 64 | + target: impl FnOnce() -> (String, String), | ||
| 65 | + enabled: bool, | ||
| 66 | +) -> Option<impl IntoElement> { | ||
| 67 | + output_path()?; | ||
| 68 | + let (id, label) = target(); | ||
| 69 | + Some( | ||
| 70 | + canvas( | ||
| 71 | + move |bounds, _, _| { | ||
| 72 | + STATE.with(|state| { | ||
| 73 | + state.borrow_mut().targets.push(Target { | ||
| 74 | + id, | ||
| 75 | + label, | ||
| 76 | + bounds, | ||
| 77 | + enabled, | ||
| 78 | + }); | ||
| 79 | + }); | ||
| 80 | + }, | ||
| 81 | + |_, _, _, _| (), | ||
| 82 | + ) | ||
| 83 | + .absolute() | ||
| 84 | + .size_full(), | ||
| 85 | + ) | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +fn flush() { | ||
| 89 | + let Some(path) = output_path() else { | ||
| 90 | + return; | ||
| 91 | + }; | ||
| 92 | + let now = Instant::now(); | ||
| 93 | + let body = STATE.with(|state| { | ||
| 94 | + let mut state = state.borrow_mut(); | ||
| 95 | + if state | ||
| 96 | + .last_write | ||
| 97 | + .is_some_and(|last| now.duration_since(last) < WRITE_INTERVAL) | ||
| 98 | + { | ||
| 99 | + return None; | ||
| 100 | + } | ||
| 101 | + state.last_write = Some(now); | ||
| 102 | + let mut json = String::from("["); | ||
| 103 | + for (i, target) in state.targets.iter().enumerate() { | ||
| 104 | + if i != 0 { | ||
| 105 | + json.push(','); | ||
| 106 | + } | ||
| 107 | + json.push_str("{\"id\":"); | ||
| 108 | + json_string(&mut json, &target.id); | ||
| 109 | + json.push_str(",\"label\":"); | ||
| 110 | + json_string(&mut json, &target.label); | ||
| 111 | + let bounds = target.bounds; | ||
| 112 | + let _ = write!( | ||
| 113 | + json, | ||
| 114 | + ",\"x\":{},\"y\":{},\"w\":{},\"h\":{},\"enabled\":{}", | ||
| 115 | + f32::from(bounds.origin.x), | ||
| 116 | + f32::from(bounds.origin.y), | ||
| 117 | + f32::from(bounds.size.width), | ||
| 118 | + f32::from(bounds.size.height), | ||
| 119 | + target.enabled, | ||
| 120 | + ); | ||
| 121 | + json.push('}'); | ||
| 122 | + } | ||
| 123 | + json.push(']'); | ||
| 124 | + Some(json) | ||
| 125 | + }); | ||
| 126 | + let Some(body) = body else { | ||
| 127 | + return; | ||
| 128 | + }; | ||
| 129 | + let temp = path.with_extension(format!("hitmap-{}.tmp", std::process::id())); | ||
| 130 | + if fs::write(&temp, body).is_ok() { | ||
| 131 | + let _ = fs::rename(temp, path); | ||
| 132 | + } | ||
| 133 | +} | ||
| 134 | + | ||
| 135 | +fn json_string(json: &mut String, value: &str) { | ||
| 136 | + json.push('"'); | ||
| 137 | + for c in value.chars() { | ||
| 138 | + match c { | ||
| 139 | + '"' => json.push_str("\\\""), | ||
| 140 | + '\\' => json.push_str("\\\\"), | ||
| 141 | + '\n' => json.push_str("\\n"), | ||
| 142 | + '\r' => json.push_str("\\r"), | ||
| 143 | + '\t' => json.push_str("\\t"), | ||
| 144 | + c if c <= '\u{1f}' => { | ||
| 145 | + let _ = write!(json, "\\u{:04x}", c as u32); | ||
| 146 | + } | ||
| 147 | + c => json.push(c), | ||
| 148 | + } | ||
| 149 | + } | ||
| 150 | + json.push('"'); | ||
| 151 | +} | ||
| 152 | + | ||
| 153 | +pub(crate) fn action_id(action: ActionId) -> String { | ||
| 154 | + format!("action.{action:?}") | ||
| 155 | +} | ||
| 156 | + | ||
| 157 | +/// Records an action control under the action name it dispatches. | ||
| 158 | +pub(crate) fn action(action: ActionId, enabled: bool) -> Option<impl IntoElement> { | ||
| 159 | + dynamic(move || (action_id(action), action.label().into()), enabled) | ||
| 160 | +} | ||
crates/app/src/ui/mod.rsmodified+1 -0
| @@ -6,6 +6,7 @@ | |||
| 6 | pub mod bench_stance; | 6 | pub mod bench_stance; |
| 7 | pub mod cards; | 7 | pub mod cards; |
| 8 | pub mod dock_stance; | 8 | pub mod dock_stance; |
| 9 | +pub mod hitmap; | ||
| 9 | pub mod inspector; | 10 | pub mod inspector; |
| 10 | pub mod library; | 11 | pub mod library; |
| 11 | pub mod overlays; | 12 | pub mod overlays; |
crates/app/src/ui/overlays.rsmodified+6 -0
| @@ -1,5 +1,6 @@ | |||
| 1 | //! The bars and the floating cards that are not inspector sections. | 1 | //! The bars and the floating cards that are not inspector sections. |
| 2 | 2 | ||
| 3 | +use crate::ui::hitmap; | ||
| 3 | use crate::ui::stance::menu_floor; | 4 | use crate::ui::stance::menu_floor; |
| 4 | use crate::ui::type_scale::{self, Typeset}; | 5 | use crate::ui::type_scale::{self, Typeset}; |
| 5 | use crate::ui::widgets::*; | 6 | use crate::ui::widgets::*; |
| @@ -695,6 +696,7 @@ impl Player { | |||
| 695 | }, | 696 | }, |
| 696 | )) | 697 | )) |
| 697 | }) | 698 | }) |
| 699 | + .children(hitmap::action(action, enabled)) | ||
| 698 | .into_any_element(), | 700 | .into_any_element(), |
| 699 | ); | 701 | ); |
| 700 | } | 702 | } |
| @@ -903,6 +905,10 @@ impl Player { | |||
| 903 | .on_click( | 905 | .on_click( |
| 904 | cx.listener(move |this, _: &ClickEvent, _, cx| this.choose(choice, cx)), | 906 | cx.listener(move |this, _: &ClickEvent, _, cx| this.choose(choice, cx)), |
| 905 | ) | 907 | ) |
| 908 | + .children(hitmap::dynamic( | ||
| 909 | + move || (format!("picker.choice.{n}"), "Choose setting value".into()), | ||
| 910 | + true, | ||
| 911 | + )) | ||
| 906 | .into_any_element() | 912 | .into_any_element() |
| 907 | }) | 913 | }) |
| 908 | .collect(); | 914 | .collect(); |
crates/app/src/ui/settings_stance.rsmodified+2 -0
| @@ -32,6 +32,7 @@ | |||
| 32 | //! since nothing in [`engine::project::Project`] holds a place to persist an | 32 | //! since nothing in [`engine::project::Project`] holds a place to persist an |
| 33 | //! override into. | 33 | //! override into. |
| 34 | 34 | ||
| 35 | +use crate::ui::hitmap; | ||
| 35 | use crate::ui::type_scale; | 36 | use crate::ui::type_scale; |
| 36 | use crate::*; | 37 | use crate::*; |
| 37 | use engine::colorspace::ContentLight; | 38 | use engine::colorspace::ContentLight; |
| @@ -147,6 +148,7 @@ fn row_full( | |||
| 147 | .hover(|s| s.bg(rgb(DARK_RAISED()))) | 148 | .hover(|s| s.bg(rgb(DARK_RAISED()))) |
| 148 | .on_click(on_click) | 149 | .on_click(on_click) |
| 149 | }) | 150 | }) |
| 151 | + .children(hitmap::control(id, label_text, !exporting)) | ||
| 150 | .child( | 152 | .child( |
| 151 | div() | 153 | div() |
| 152 | .font(label_style.font) | 154 | .font(label_style.font) |
crates/app/src/ui/spine_stance.rsmodified+3 -0
| @@ -4,6 +4,7 @@ | |||
| 4 | //! drew. `stance.rs::spine()` keeps the panel frame (width, surface, | 4 | //! drew. `stance.rs::spine()` keeps the panel frame (width, surface, |
| 5 | //! border); this module owns the rows inside it. | 5 | //! border); this module owns the rows inside it. |
| 6 | 6 | ||
| 7 | +use crate::ui::hitmap; | ||
| 7 | use crate::ui::type_scale::{self, Typeset}; | 8 | use crate::ui::type_scale::{self, Typeset}; |
| 8 | use crate::*; | 9 | use crate::*; |
| 9 | 10 | ||
| @@ -81,6 +82,7 @@ fn glyph( | |||
| 81 | }), | 82 | }), |
| 82 | ) | 83 | ) |
| 83 | }) | 84 | }) |
| 85 | + .children(hitmap::action(action, on)) | ||
| 84 | .child( | 86 | .child( |
| 85 | div() | 87 | div() |
| 86 | .line_height(relative(1.05)) | 88 | .line_height(relative(1.05)) |
| @@ -141,6 +143,7 @@ fn trim_control(active: bool, player: &Player, cx: &mut Context<Player>) -> impl | |||
| 141 | this.act(action, window, cx) | 143 | this.act(action, window, cx) |
| 142 | })) | 144 | })) |
| 143 | }) | 145 | }) |
| 146 | + .children(hitmap::action(action, on)) | ||
| 144 | .child( | 147 | .child( |
| 145 | div() | 148 | div() |
| 146 | .line_height(relative(1.05)) | 149 | .line_height(relative(1.05)) |
crates/app/src/ui/stance.rsmodified+2 -0
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | use crate::ui::bench_stance; | 11 | use crate::ui::bench_stance; |
| 12 | use crate::ui::dock_stance; | 12 | use crate::ui::dock_stance; |
| 13 | +use crate::ui::hitmap; | ||
| 13 | use crate::ui::settings_stance; | 14 | use crate::ui::settings_stance; |
| 14 | use crate::ui::spine_stance; | 15 | use crate::ui::spine_stance; |
| 15 | use crate::ui::timeband_stance; | 16 | use crate::ui::timeband_stance; |
| @@ -959,6 +960,7 @@ pub(crate) fn render( | |||
| 959 | .size_full() | 960 | .size_full() |
| 960 | .flex() | 961 | .flex() |
| 961 | .bg(rgb(DARK_CANVAS())) | 962 | .bg(rgb(DARK_CANVAS())) |
| 963 | + .children(hitmap::frame()) | ||
| 962 | .child(mouse_exit_listener(cx)) | 964 | .child(mouse_exit_listener(cx)) |
| 963 | .child(spine(player, cx)) | 965 | .child(spine(player, cx)) |
| 964 | .child( | 966 | .child( |
crates/app/src/ui/timeband_stance.rsmodified+17 -0
| @@ -8,6 +8,7 @@ | |||
| 8 | //! close to the mock's ~20px reading. Every size in this module comes from | 8 | //! close to the mock's ~20px reading. Every size in this module comes from |
| 9 | //! `ui::type_scale` (role, not a bare `px()` literal). | 9 | //! `ui::type_scale` (role, not a bare `px()` literal). |
| 10 | 10 | ||
| 11 | +use crate::ui::hitmap; | ||
| 11 | use crate::ui::type_scale::{self, label, mono}; | 12 | use crate::ui::type_scale::{self, label, mono}; |
| 12 | use crate::*; | 13 | use crate::*; |
| 13 | use gpui::FontWeight; | 14 | use gpui::FontWeight; |
| @@ -70,6 +71,7 @@ fn ghost( | |||
| 70 | .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { | 71 | .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { |
| 71 | this.act(action, window, cx); | 72 | this.act(action, window, cx); |
| 72 | })) | 73 | })) |
| 74 | + .children(hitmap::action(action, player.enable(action, None).yes())) | ||
| 73 | .font(glyph_style.font) | 75 | .font(glyph_style.font) |
| 74 | .text_size(glyph_style.size) | 76 | .text_size(glyph_style.size) |
| 75 | .text_color(rgb(if active { INK1() } else { INK2() })) | 77 | .text_color(rgb(if active { INK1() } else { INK2() })) |
| @@ -351,6 +353,7 @@ fn contact_strip(player: &Player, position: f64, cx: &mut Context<Player>) -> im | |||
| 351 | MouseButton::Left, | 353 | MouseButton::Left, |
| 352 | cx.listener(|_, _, _, _| PAN_ANCHOR.with(|a| a.set(None))), | 354 | cx.listener(|_, _, _, _| PAN_ANCHOR.with(|a| a.set(None))), |
| 353 | ) | 355 | ) |
| 356 | + .children(hitmap::control("timeline.contact-strip", "Timeline contact strip", true)) | ||
| 354 | .child(bounds_probe(strip_bounds)) | 357 | .child(bounds_probe(strip_bounds)) |
| 355 | // Baseline: a quiet hairline under the real traces below it, so an | 358 | // Baseline: a quiet hairline under the real traces below it, so an |
| 356 | // audio-free stretch of film still reads as film rather than gap. | 359 | // audio-free stretch of film still reads as film rather than gap. |
| @@ -456,6 +459,7 @@ fn grip(id: &'static str, left: bool, top: bool) -> impl IntoElement { | |||
| 456 | PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x)))); | 459 | PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x)))); |
| 457 | cx.stop_propagation(); | 460 | cx.stop_propagation(); |
| 458 | }) | 461 | }) |
| 462 | + .children(hitmap::control(id, "Timeline viewport grip", true)) | ||
| 459 | } | 463 | } |
| 460 | 464 | ||
| 461 | /// The Export chip (MOCK-SPEC "Export chip", DESIGN §4): the room's single | 465 | /// The Export chip (MOCK-SPEC "Export chip", DESIGN §4): the room's single |
| @@ -494,6 +498,14 @@ fn export_chip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 494 | } | 498 | } |
| 495 | cx.notify(); | 499 | cx.notify(); |
| 496 | })) | 500 | })) |
| 501 | + .children(hitmap::action( | ||
| 502 | + if exporting { | ||
| 503 | + ActionId::CancelExport | ||
| 504 | + } else { | ||
| 505 | + ActionId::Export | ||
| 506 | + }, | ||
| 507 | + true, | ||
| 508 | + )) | ||
| 497 | .child( | 509 | .child( |
| 498 | div() | 510 | div() |
| 499 | .font(label_style.font) | 511 | .font(label_style.font) |
| @@ -541,6 +553,7 @@ fn volume_slider(player: &Player, cx: &mut Context<Player>) -> impl IntoElement | |||
| 541 | ) | 553 | ) |
| 542 | .child(bounds_probe(player.volume_bar.clone())) | 554 | .child(bounds_probe(player.volume_bar.clone())) |
| 543 | }) | 555 | }) |
| 556 | + .children(hitmap::control("timeline.volume", "Volume", enabled)) | ||
| 544 | .child( | 557 | .child( |
| 545 | div() | 558 | div() |
| 546 | .w_full() | 559 | .w_full() |
| @@ -771,6 +784,10 @@ fn save_verb(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | |||
| 771 | .on_click(cx.listener(|this, _: &ClickEvent, window, cx| { | 784 | .on_click(cx.listener(|this, _: &ClickEvent, window, cx| { |
| 772 | this.act(ActionId::Save, window, cx); | 785 | this.act(ActionId::Save, window, cx); |
| 773 | })) | 786 | })) |
| 787 | + .children(hitmap::action( | ||
| 788 | + ActionId::Save, | ||
| 789 | + player.enable(ActionId::Save, None).yes(), | ||
| 790 | + )) | ||
| 774 | .child( | 791 | .child( |
| 775 | div() | 792 | div() |
| 776 | .font(label_style.font) | 793 | .font(label_style.font) |