wip(tooltips): shared tooltip helper + first sites — capped mid-work
Browse files at this commitd55192d6f1064e2eb334f69baaa3d0e07fe3e08fParent: 388faa610 changed files +220 -28
- crates/app/src/tests/layout.rs +113 -0
- crates/app/src/ui/bench_stance.rs +16 -0
- crates/app/src/ui/cards.rs +7 -0
- crates/app/src/ui/dock_stance.rs +13 -17
- crates/app/src/ui/overlays.rs +3 -0
- crates/app/src/ui/preview.rs +1 -0
- crates/app/src/ui/spine_stance.rs +5 -10
- crates/app/src/ui/stance.rs +1 -0
- crates/app/src/ui/timeband_stance.rs +7 -0
- crates/app/src/ui/widgets.rs +54 -1
crates/app/src/tests/layout.rsmodified+113 -0
| @@ -3447,3 +3447,116 @@ fn the_only_hue_in_the_export_section_is_the_av1_gpu_notice() { | ||
| 3447 | 3447 | ); |
| 3448 | 3448 | } |
| 3449 | 3449 | } |
| 3450 | + | |
| 3451 | +/// Every control the hitmap names wears a hover line (the user, 2026-09-09, | |
| 3452 | +/// over a screenshot of the time band: "each and every button needs hover | |
| 3453 | +/// over information ... I don't know some of them"). The hitmap already | |
| 3454 | +/// carries the pair a plate needs -- an id and a label -- so the sweep walks | |
| 3455 | +/// the same emitters: a builder chain that records a control and never calls | |
| 3456 | +/// `.tooltip` is a glyph the user cannot name. | |
| 3457 | +/// | |
| 3458 | +/// A scan and not a render: this crate has no gpui window in its tests, so | |
| 3459 | +/// the function body is the finest grain available. One control may emit two | |
| 3460 | +/// hitmap ids (a row and the selection inside it), which is what | |
| 3461 | +/// `DOUBLE_NAMED` allows for, by name and with its reason. | |
| 3462 | +#[test] | |
| 3463 | +fn every_hitmap_control_wears_a_hover_line() { | |
| 3464 | + // (file, fn, ids beyond the first that name the SAME control) | |
| 3465 | + const DOUBLE_NAMED: &[(&str, &str, usize)] = &[( | |
| 3466 | + "dock_stance.rs", | |
| 3467 | + "subtitle_tab_rows", | |
| 3468 | + // `subtitle.N.M.row` and `subtitle.N.M.select` are one row: the | |
| 3469 | + // second id is the harness's aim point for picking it. | |
| 3470 | + 1, | |
| 3471 | + )]; | |
| 3472 | + let mut controls = 0; | |
| 3473 | + let mut naked = Vec::new(); | |
| 3474 | + for path in source_files() { | |
| 3475 | + let text = std::fs::read_to_string(&path).expect("a source file"); | |
| 3476 | + if !text.contains("hitmap::") { | |
| 3477 | + continue; | |
| 3478 | + } | |
| 3479 | + let file = path | |
| 3480 | + .file_name() | |
| 3481 | + .and_then(|n| n.to_str()) | |
| 3482 | + .expect("a file name") | |
| 3483 | + .to_string(); | |
| 3484 | + let mut at = 0; | |
| 3485 | + while let Some(found) = text[at..].find("fn ") { | |
| 3486 | + let start = at + found; | |
| 3487 | + at = start + 3; | |
| 3488 | + let name: String = text[at..] | |
| 3489 | + .chars() | |
| 3490 | + .take_while(|c| c.is_alphanumeric() || *c == '_') | |
| 3491 | + .collect(); | |
| 3492 | + if name.is_empty() { | |
| 3493 | + continue; | |
| 3494 | + } | |
| 3495 | + let Some(open) = text[at..].find('{').map(|i| at + i) else { | |
| 3496 | + continue; | |
| 3497 | + }; | |
| 3498 | + let mut depth = 0usize; | |
| 3499 | + let mut end = text.len(); | |
| 3500 | + for (i, c) in text[open..].char_indices() { | |
| 3501 | + match c { | |
| 3502 | + '{' => depth += 1, | |
| 3503 | + '}' => { | |
| 3504 | + depth -= 1; | |
| 3505 | + if depth == 0 { | |
| 3506 | + end = open + i; | |
| 3507 | + break; | |
| 3508 | + } | |
| 3509 | + } | |
| 3510 | + _ => (), | |
| 3511 | + } | |
| 3512 | + } | |
| 3513 | + let body = &text[start..end]; | |
| 3514 | + let emitters = ["hitmap::control(", "hitmap::dynamic(", "hitmap::action("] | |
| 3515 | + .iter() | |
| 3516 | + .map(|needle| body.matches(needle).count()) | |
| 3517 | + .sum::<usize>(); | |
| 3518 | + if emitters == 0 { | |
| 3519 | + continue; | |
| 3520 | + } | |
| 3521 | + controls += emitters; | |
| 3522 | + let allowed = DOUBLE_NAMED | |
| 3523 | + .iter() | |
| 3524 | + .find(|(f, n, _)| *f == file && *n == name) | |
| 3525 | + .map_or(0, |(_, _, extra)| *extra); | |
| 3526 | + let tips = body.matches(".tooltip(").count(); | |
| 3527 | + if tips + allowed < emitters { | |
| 3528 | + naked.push(format!( | |
| 3529 | + "{file}::{name} -- {emitters} hitmap controls, {tips} tooltips" | |
| 3530 | + )); | |
| 3531 | + } | |
| 3532 | + } | |
| 3533 | + } | |
| 3534 | + assert!( | |
| 3535 | + controls >= 40, | |
| 3536 | + "the hover sweep found only {controls} controls -- it has gone blind" | |
| 3537 | + ); | |
| 3538 | + assert!( | |
| 3539 | + naked.is_empty(), | |
| 3540 | + "controls with no hover line (attach `widgets::tip_hover`/`action_hover` \ | |
| 3541 | + in the shared constructor): {naked:#?}" | |
| 3542 | + ); | |
| 3543 | +} | |
| 3544 | + | |
| 3545 | +/// The one hover shape for the whole room: `<name> · <chord>`, and a control | |
| 3546 | +/// the state refuses says why instead of naming a stroke that will not fire | |
| 3547 | +/// (DESIGN §4/§8 -- a tooltip is not a sentence). | |
| 3548 | +#[test] | |
| 3549 | +fn a_hover_line_is_a_name_and_a_chord() { | |
| 3550 | + use crate::ui::widgets::tip_line; | |
| 3551 | + assert_eq!( | |
| 3552 | + tip_line("One frame forward", "right", None), | |
| 3553 | + "One frame forward · right" | |
| 3554 | + ); | |
| 3555 | + assert_eq!( | |
| 3556 | + tip_line("Split", "s", Some("nothing selected")), | |
| 3557 | + "Split · nothing selected" | |
| 3558 | + ); | |
| 3559 | + // `Keymap::chord`'s unbound badge is not a stroke. | |
| 3560 | + assert_eq!(tip_line("Add files", "--", None), "Add files"); | |
| 3561 | + assert_eq!(tip_line("Source", "", None), "Source"); | |
| 3562 | +} |
crates/app/src/ui/bench_stance.rsmodified+16 -0
| @@ -337,6 +337,7 @@ fn clip_box( | ||
| 337 | 337 | move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) |
| 338 | 338 | }, |
| 339 | 339 | ) |
| 340 | + .tooltip(crate::ui::widgets::tip_hover("Clip", "drag to move", None)) | |
| 340 | 341 | .children(hitmap::dynamic( |
| 341 | 342 | move || { |
| 342 | 343 | ( |
| @@ -357,6 +358,12 @@ fn clip_box( | ||
| 357 | 358 | .filter(|_| trims(span)) |
| 358 | 359 | .map(|edge| { |
| 359 | 360 | let mut zone = div() |
| 361 | + // An id only so the strip can carry a hover plate -- | |
| 362 | + // gpui's `.tooltip` lives on a stateful div. | |
| 363 | + .id(( | |
| 364 | + "bench-clip-trim", | |
| 365 | + (lane.ord * 1000 + idx) * 2 + usize::from(edge == Edge::End), | |
| 366 | + )) | |
| 360 | 367 | .absolute() |
| 361 | 368 | .top_0() |
| 362 | 369 | .h_full() |
| @@ -379,6 +386,7 @@ fn clip_box( | ||
| 379 | 386 | this.open_menu(lane, idx, event.position, cx); |
| 380 | 387 | }), |
| 381 | 388 | ) |
| 389 | + .tooltip(crate::ui::widgets::tip_hover("Trim clip edge", "drag", None)) | |
| 382 | 390 | .children(hitmap::dynamic( |
| 383 | 391 | move || { |
| 384 | 392 | ( |
| @@ -580,6 +588,10 @@ fn clip_box( | ||
| 580 | 588 | d.children([Edge::Start, Edge::End].into_iter().map(|edge| { |
| 581 | 589 | let is_in = edge == Edge::Start; |
| 582 | 590 | let mut handle = div() |
| 591 | + .id(( | |
| 592 | + "bench-clip-fade", | |
| 593 | + (lane.ord * 1000 + idx) * 2 + usize::from(!is_in), | |
| 594 | + )) | |
| 583 | 595 | .absolute() |
| 584 | 596 | .top_0() |
| 585 | 597 | .w(px(FADE_HANDLE_W)) |
| @@ -593,6 +605,7 @@ fn clip_box( | ||
| 593 | 605 | this.start_fade_drag(lane, idx, is_in, event.position.x, cx); |
| 594 | 606 | }), |
| 595 | 607 | ) |
| 608 | + .tooltip(crate::ui::widgets::tip_hover("Fade handle", "drag", None)) | |
| 596 | 609 | .children(hitmap::dynamic( |
| 597 | 610 | move || { |
| 598 | 611 | ( |
| @@ -713,6 +726,7 @@ fn sub_box( | ||
| 713 | 726 | move |_, _, _, cx| cx.new(|_| Tip(ghost.clone())) |
| 714 | 727 | }, |
| 715 | 728 | ) |
| 729 | + .tooltip(crate::ui::widgets::tip_hover("Subtitle", "drag to move", None)) | |
| 716 | 730 | .children(hitmap::dynamic( |
| 717 | 731 | move || { |
| 718 | 732 | ( |
| @@ -893,6 +907,7 @@ fn lane_row( | ||
| 893 | 907 | .on_drag(LaneDrag(lane), move |_, _, _, cx| { |
| 894 | 908 | cx.new(|_| Tip(head_ghost.clone())) |
| 895 | 909 | }) |
| 910 | + .tooltip(crate::ui::widgets::tip_hover("Reorder lane", "drag", None)) | |
| 896 | 911 | .children(hitmap::dynamic( |
| 897 | 912 | move || { |
| 898 | 913 | ( |
| @@ -1189,6 +1204,7 @@ fn lane_row( | ||
| 1189 | 1204 | this.preview_ghost_pick(track, lane, event.event.position.x, cx); |
| 1190 | 1205 | }), |
| 1191 | 1206 | ) |
| 1207 | + .tooltip(crate::ui::widgets::tip_hover("Lane bed", "drop media here", None)) | |
| 1192 | 1208 | .children(hitmap::dynamic( |
| 1193 | 1209 | move || { |
| 1194 | 1210 | ( |
crates/app/src/ui/cards.rsmodified+7 -0
| @@ -121,6 +121,7 @@ fn dark_card_head( | ||
| 121 | 121 | .into() |
| 122 | 122 | }) |
| 123 | 123 | .child(if max { "▣ m" } else { "⤢ m" }) |
| 124 | + .tooltip(crate::ui::widgets::overlay_tip_hover("Toggle card size", "", None)) | |
| 124 | 125 | .children(hitmap::control("card.maximize", "Toggle card size", true)) |
| 125 | 126 | })) |
| 126 | 127 | .child( |
| @@ -205,6 +206,11 @@ fn dark_step_glyph( | ||
| 205 | 206 | .cursor_pointer() |
| 206 | 207 | .hover(|s| s.bg(rgb(DARK_RAISED()))) |
| 207 | 208 | .on_click(on_click) |
| 209 | + .tooltip(crate::ui::widgets::overlay_tip_hover( | |
| 210 | + if plus { "Step up" } else { "Step down" }, | |
| 211 | + "", | |
| 212 | + None, | |
| 213 | + )) | |
| 208 | 214 | .children(hitmap.flatten()) |
| 209 | 215 | .child(dark_row_value(if plus { "+" } else { "−" })) |
| 210 | 216 | } |
| @@ -236,6 +242,7 @@ fn dark_ghost_button( | ||
| 236 | 242 | .cursor_pointer() |
| 237 | 243 | .hover(|s| s.bg(rgb(DARK_RAISED()))) |
| 238 | 244 | .on_click(on_click) |
| 245 | + .tooltip(crate::ui::widgets::overlay_tip_hover(&text, chord, None)) | |
| 239 | 246 | .children(hitmap.flatten()) |
| 240 | 247 | .child( |
| 241 | 248 | div() |
crates/app/src/ui/dock_stance.rsmodified+13 -17
| @@ -118,7 +118,6 @@ fn ghost_verb( | ||
| 118 | 118 | verb_label: &'static str, |
| 119 | 119 | action: ActionId, |
| 120 | 120 | active: bool, |
| 121 | - hint: &str, | |
| 122 | 121 | player: &Player, |
| 123 | 122 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, |
| 124 | 123 | ) -> Option<impl IntoElement> { |
| @@ -127,11 +126,6 @@ fn ghost_verb( | ||
| 127 | 126 | return None; |
| 128 | 127 | } |
| 129 | 128 | let key = player.keymap.chord(action); |
| 130 | - let say: SharedString = match enabled.why() { | |
| 131 | - Some(why) => format!("{key} — {why}"), | |
| 132 | - None => format!("{key} — {hint}"), | |
| 133 | - } | |
| 134 | - .into(); | |
| 135 | 129 | let on = enabled.yes(); |
| 136 | 130 | let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM); |
| 137 | 131 | let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); |
| @@ -146,7 +140,10 @@ fn ghost_verb( | ||
| 146 | 140 | .px(px(8.)) |
| 147 | 141 | .rounded(px(3.)) |
| 148 | 142 | .when(active, |d| d.bg(rgb(DARK_RAISED()))) |
| 149 | - .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into()) | |
| 143 | + // One hover line for the whole room (`widgets::tip_line`): the | |
| 144 | + // verb and its stroke, not the sentence this row used to carry | |
| 145 | + // (DESIGN §8 -- a tooltip is not instructional prose). | |
| 146 | + .tooltip(crate::ui::widgets::action_hover(player, action)) | |
| 150 | 147 | .when(!on, |d| d.opacity(0.4).cursor_not_allowed()) |
| 151 | 148 | .when(on, |d| { |
| 152 | 149 | d.cursor_pointer() |
| @@ -203,6 +200,7 @@ fn dock_tab( | ||
| 203 | 200 | save(this.dock_src_active); |
| 204 | 201 | cx.notify(); |
| 205 | 202 | })) |
| 203 | + .tooltip(crate::ui::widgets::tip_hover(&format!("Show {}", label_text.to_lowercase()), "", None)) | |
| 206 | 204 | .children(hitmap::control(id, label_text, true)) |
| 207 | 205 | .child( |
| 208 | 206 | div() |
| @@ -408,6 +406,7 @@ fn source_row( | ||
| 408 | 406 | cx.new(|_| Tip(ghost.clone())) |
| 409 | 407 | }) |
| 410 | 408 | }) |
| 409 | + .tooltip(crate::ui::widgets::tip_hover("Source", "drag to a lane", None)) | |
| 411 | 410 | .children(hitmap::dynamic( |
| 412 | 411 | move || (format!("source.{i}.row"), "Source row".into()), |
| 413 | 412 | usable, |
| @@ -734,6 +733,7 @@ fn subtitle_tab_rows(player: &Player, cx: &mut Context<Player>) -> (usize, Vec<A | ||
| 734 | 733 | cx.notify(); |
| 735 | 734 | })) |
| 736 | 735 | }) |
| 736 | + .tooltip(crate::ui::widgets::tip_hover("Subtitle track", "drag to a lane", None)) | |
| 737 | 737 | .children(hitmap::dynamic( |
| 738 | 738 | move || { |
| 739 | 739 | ( |
| @@ -803,6 +803,7 @@ fn subtitle_tab_rows(player: &Player, cx: &mut Context<Player>) -> (usize, Vec<A | ||
| 803 | 803 | cx.stop_propagation(); |
| 804 | 804 | this.remove_subtitle_track(track, cx); |
| 805 | 805 | })) |
| 806 | + .tooltip(crate::ui::widgets::tip_hover("Remove subtitle track", "", None)) | |
| 806 | 807 | .children(hitmap::dynamic( |
| 807 | 808 | move || { |
| 808 | 809 | ( |
| @@ -839,6 +840,7 @@ fn subtitle_tab_rows(player: &Player, cx: &mut Context<Player>) -> (usize, Vec<A | ||
| 839 | 840 | } |
| 840 | 841 | cx.notify(); |
| 841 | 842 | })) |
| 843 | + .tooltip(crate::ui::widgets::tip_hover("Fold this source", "click", None)) | |
| 842 | 844 | .children(hitmap::dynamic( |
| 843 | 845 | move || { |
| 844 | 846 | ( |
| @@ -1022,6 +1024,7 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context<Player>) - | ||
| 1022 | 1024 | this.dock_filter_edit = true; |
| 1023 | 1025 | cx.notify(); |
| 1024 | 1026 | })) |
| 1027 | + .tooltip(crate::ui::widgets::tip_hover("Filter sources", "type to narrow", None)) | |
| 1025 | 1028 | .children(hitmap::control("dock.filter", "Filter sources", true)) |
| 1026 | 1029 | .child(match player.dock_filter.is_empty() { |
| 1027 | 1030 | true => "⌕ filter".to_string(), |
| @@ -1052,6 +1055,7 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context<Player>) - | ||
| 1052 | 1055 | this.library_tab = tab; |
| 1053 | 1056 | cx.notify(); |
| 1054 | 1057 | })) |
| 1058 | + .tooltip(crate::ui::widgets::tip_hover(&format!("Show {} only", tab.label().to_lowercase()), "", None)) | |
| 1055 | 1059 | .children(hitmap::dynamic( |
| 1056 | 1060 | move || { |
| 1057 | 1061 | ( |
| @@ -1132,7 +1136,6 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context<Player>) - | ||
| 1132 | 1136 | "Add files", |
| 1133 | 1137 | ActionId::AddFiles, |
| 1134 | 1138 | false, |
| 1135 | - "adds a file to this list — or drop one on the window", | |
| 1136 | 1139 | player, |
| 1137 | 1140 | cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_import(cx)), |
| 1138 | 1141 | )) |
| @@ -1141,7 +1144,6 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context<Player>) - | ||
| 1141 | 1144 | "Paste path", |
| 1142 | 1145 | ActionId::PasteFilePath, |
| 1143 | 1146 | false, |
| 1144 | - "imports the file named on the clipboard", | |
| 1145 | 1147 | player, |
| 1146 | 1148 | cx.listener(|this, _: &ClickEvent, _, cx| this.paste_file_path(cx)), |
| 1147 | 1149 | )) |
| @@ -1156,7 +1158,6 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context<Player>) - | ||
| 1156 | 1158 | "Import subtitles", |
| 1157 | 1159 | ActionId::ImportSubtitles, |
| 1158 | 1160 | false, |
| 1159 | - "reads an .srt/.ass file onto a subtitle lane", | |
| 1160 | 1161 | player, |
| 1161 | 1162 | cx.listener(|this, _: &ClickEvent, window, cx| { |
| 1162 | 1163 | this.act(ActionId::ImportSubtitles, window, cx) |
| @@ -1217,6 +1218,7 @@ fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl Into | ||
| 1217 | 1218 | .bg(rgb(DARK_RAISED())) |
| 1218 | 1219 | .cursor_pointer() |
| 1219 | 1220 | .hover(|s| s.text_color(rgb(INK1()))) |
| 1221 | + .tooltip(crate::ui::widgets::tip_hover(label, "", None)) | |
| 1220 | 1222 | .children(hitmap::control(id, label, true)) |
| 1221 | 1223 | .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { |
| 1222 | 1224 | this.nudge_transition(lane, idx, by, cx); |
| @@ -1239,6 +1241,7 @@ fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl Into | ||
| 1239 | 1241 | .text_size(label_style.size) |
| 1240 | 1242 | .text_color(rgb(INK2())) |
| 1241 | 1243 | .cursor_pointer() |
| 1244 | + .tooltip(crate::ui::widgets::tip_hover("Transition duration", "click to type", None)) | |
| 1242 | 1245 | .children(hitmap::control( |
| 1243 | 1246 | "transition-duration-field", |
| 1244 | 1247 | "Transition duration, type-in", |
| @@ -1313,7 +1316,6 @@ fn clip_tab( | ||
| 1313 | 1316 | "Speed", |
| 1314 | 1317 | ActionId::Speed, |
| 1315 | 1318 | player.speed_open.is_some(), |
| 1316 | - "how fast this clip and its group play", | |
| 1317 | 1319 | player, |
| 1318 | 1320 | cx.listener(|this, _: &ClickEvent, _, cx| this.open_speed(cx)), |
| 1319 | 1321 | )) |
| @@ -1322,7 +1324,6 @@ fn clip_tab( | ||
| 1322 | 1324 | "Colour", |
| 1323 | 1325 | ActionId::Color, |
| 1324 | 1326 | player.color_open.is_some(), |
| 1325 | - "exposure, contrast, saturation and temperature", | |
| 1326 | 1327 | player, |
| 1327 | 1328 | cx.listener(|this, _: &ClickEvent, _, cx| this.open_color(cx)), |
| 1328 | 1329 | )) |
| @@ -1331,7 +1332,6 @@ fn clip_tab( | ||
| 1331 | 1332 | "Transform", |
| 1332 | 1333 | ActionId::Transform, |
| 1333 | 1334 | player.transform_open.is_some(), |
| 1334 | - "position, scale, rotation and crop for this clip", | |
| 1335 | 1335 | player, |
| 1336 | 1336 | cx.listener(|this, _: &ClickEvent, _, cx| this.open_transform(cx)), |
| 1337 | 1337 | )) |
| @@ -1340,7 +1340,6 @@ fn clip_tab( | ||
| 1340 | 1340 | "EQ", |
| 1341 | 1341 | ActionId::Equalizer, |
| 1342 | 1342 | player.eq_open.is_some(), |
| 1343 | - "the bands this clip's sound is filtered through", | |
| 1344 | 1343 | player, |
| 1345 | 1344 | cx.listener(|this, _: &ClickEvent, _, cx| this.open_eq(cx)), |
| 1346 | 1345 | )) |
| @@ -1357,7 +1356,6 @@ fn clip_tab( | ||
| 1357 | 1356 | "Silence", |
| 1358 | 1357 | ActionId::Silence, |
| 1359 | 1358 | player.silence_open.is_some(), |
| 1360 | - "scans for quiet stretches to cut or speed up", | |
| 1361 | 1359 | player, |
| 1362 | 1360 | cx.listener(|this, _: &ClickEvent, _, cx| this.open_silence(cx)), |
| 1363 | 1361 | )) |
| @@ -1366,7 +1364,6 @@ fn clip_tab( | ||
| 1366 | 1364 | "Mix", |
| 1367 | 1365 | ActionId::Mix, |
| 1368 | 1366 | player.mix_open, |
| 1369 | - "track volumes and the limiter", | |
| 1370 | 1367 | player, |
| 1371 | 1368 | cx.listener(|this, _: &ClickEvent, _, cx| this.open_mix(None, cx)), |
| 1372 | 1369 | )) |
| @@ -1383,7 +1380,6 @@ fn clip_tab( | ||
| 1383 | 1380 | "Fit", |
| 1384 | 1381 | ActionId::Fit, |
| 1385 | 1382 | false, |
| 1386 | - "how this picture is placed on the project canvas", | |
| 1387 | 1383 | player, |
| 1388 | 1384 | cx.listener(|this, _: &ClickEvent, _, cx| this.cycle_fit(cx)), |
| 1389 | 1385 | )), |
crates/app/src/ui/overlays.rsmodified+3 -0
| @@ -368,6 +368,7 @@ impl Player { | ||
| 368 | 368 | } |
| 369 | 369 | cx.notify(); |
| 370 | 370 | })) |
| 371 | + .tooltip(crate::ui::widgets::tip_hover("Properties", "", None)) | |
| 371 | 372 | .children(hitmap::control("menu.properties", "Properties", true)) |
| 372 | 373 | .child("Properties") |
| 373 | 374 | // No stroke reaches this one, and a blank column would read |
| @@ -470,6 +471,7 @@ impl Player { | ||
| 470 | 471 | .enumerate() |
| 471 | 472 | .map(|(n, (choice, label, detail, picked))| { |
| 472 | 473 | let hitmap_label = label.clone(); |
| 474 | + let row_tip = label.clone(); | |
| 473 | 475 | let hitmap_id = match theme_picker { |
| 474 | 476 | true => format!("theme.{n}.row"), |
| 475 | 477 | false => format!("picker.choice.{n}"), |
| @@ -547,6 +549,7 @@ impl Player { | ||
| 547 | 549 | .on_click( |
| 548 | 550 | cx.listener(move |this, _: &ClickEvent, _, cx| this.choose(choice, cx)), |
| 549 | 551 | ) |
| 552 | + .tooltip(crate::ui::widgets::overlay_tip_hover(&row_tip, "", None)) | |
| 550 | 553 | .children(hitmap::dynamic( |
| 551 | 554 | move || (hitmap_id, hitmap_label.to_string()), |
| 552 | 555 | true, |
crates/app/src/ui/preview.rsmodified+1 -0
| @@ -49,6 +49,7 @@ impl Player { | ||
| 49 | 49 | .cursor_pointer() |
| 50 | 50 | .hover(|s| s.bg(rgb(DARK_RAISED()))) |
| 51 | 51 | .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.close_preview(cx))) |
| 52 | + .tooltip(crate::ui::widgets::tip_hover("Stop preview", "esc", None)) | |
| 52 | 53 | .children(hitmap::control("preview.stop", "Stop preview", true)) |
| 53 | 54 | .child(div().text_color(rgb(INK2())).child("Stop")) |
| 54 | 55 | .child( |
crates/app/src/ui/spine_stance.rsmodified+5 -10
| @@ -91,11 +91,10 @@ fn glyph_sized( | ||
| 91 | 91 | // action answers to, and the keys overlay ([`crate::ui::stance`]) is |
| 92 | 92 | // still where the full truth lives. |
| 93 | 93 | let full = player.keymap.display(action); |
| 94 | - let say: SharedString = match enabled.why() { | |
| 95 | - Some(why) => format!("{full} — {why}"), | |
| 96 | - None => format!("{full} — {}", action.label()), | |
| 97 | - } | |
| 98 | - .into(); | |
| 94 | + // The room's one hover shape (`widgets::tip_line`): the name first, then | |
| 95 | + // the strokes -- `display`'s every stroke here rather than the compact | |
| 96 | + // badge, since the spine's glyph is already showing the compact one. | |
| 97 | + let say = crate::ui::widgets::tip_line(action.label(), &full, enabled.why()); | |
| 99 | 98 | let compact = player.keymap.chord(action); |
| 100 | 99 | let on = enabled.yes(); |
| 101 | 100 | div() |
| @@ -158,11 +157,7 @@ fn trim_control(active: bool, player: &Player, cx: &mut Context<Player>) -> impl | ||
| 158 | 157 | let half = |id: &'static str, txt: &'static str, action: ActionId, cx: &mut Context<Player>| { |
| 159 | 158 | let enabled = player.enable(action, None); |
| 160 | 159 | let full = player.keymap.display(action); |
| 161 | - let say: SharedString = match enabled.why() { | |
| 162 | - Some(why) => format!("{full} — {why}"), | |
| 163 | - None => format!("{full} — {}", action.label()), | |
| 164 | - } | |
| 165 | - .into(); | |
| 160 | + let say = crate::ui::widgets::tip_line(action.label(), &full, enabled.why()); | |
| 166 | 161 | let on = enabled.yes(); |
| 167 | 162 | div() |
| 168 | 163 | .id(id) |
crates/app/src/ui/stance.rsmodified+1 -0
| @@ -442,6 +442,7 @@ fn ghost( | ||
| 442 | 442 | .rounded(px(3.)) |
| 443 | 443 | .cursor_pointer() |
| 444 | 444 | .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1()))) |
| 445 | + .tooltip(crate::ui::widgets::action_hover(player, action)) | |
| 445 | 446 | .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| this.act(action, window, cx))) |
| 446 | 447 | .type_style(type_scale::label( |
| 447 | 448 | type_scale::LABEL_ROW_PX, |
crates/app/src/ui/timeband_stance.rsmodified+7 -0
| @@ -165,6 +165,10 @@ fn ghost( | ||
| 165 | 165 | this.act(action, window, cx); |
| 166 | 166 | })) |
| 167 | 167 | .children(hitmap::action(action, player.enable(action, None).yes())) |
| 168 | + // The glyphs nobody could name (`|◂`, `∞`, `‹|`): the hover line is built | |
| 169 | + // where the ghost is, so a glyph added to this band tomorrow cannot | |
| 170 | + // ship without one. | |
| 171 | + .tooltip(crate::ui::widgets::action_hover(player, action)) | |
| 168 | 172 | .font(glyph_style.font) |
| 169 | 173 | .text_size(glyph_style.size) |
| 170 | 174 | .text_color(rgb(if active { INK1() } else { INK2() })) |
| @@ -571,6 +575,7 @@ fn grip(id: &'static str, left: bool, top: bool) -> impl IntoElement { | ||
| 571 | 575 | PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x)))); |
| 572 | 576 | cx.stop_propagation(); |
| 573 | 577 | }) |
| 578 | + .tooltip(crate::ui::widgets::tip_hover("Pan the timeline window", "drag", None)) | |
| 574 | 579 | .children(hitmap::control(id, "Timeline viewport grip", true)) |
| 575 | 580 | } |
| 576 | 581 | |
| @@ -610,6 +615,7 @@ fn export_chip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 610 | 615 | } |
| 611 | 616 | cx.notify(); |
| 612 | 617 | })) |
| 618 | + .tooltip(crate::ui::widgets::action_hover(player, if exporting { ActionId::CancelExport } else { ActionId::Export })) | |
| 613 | 619 | .children(hitmap::action( |
| 614 | 620 | if exporting { |
| 615 | 621 | ActionId::CancelExport |
| @@ -928,6 +934,7 @@ fn save_verb(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 928 | 934 | .on_click(cx.listener(|this, _: &ClickEvent, window, cx| { |
| 929 | 935 | this.act(ActionId::Save, window, cx); |
| 930 | 936 | })) |
| 937 | + .tooltip(crate::ui::widgets::action_hover(player, ActionId::Save)) | |
| 931 | 938 | .children(hitmap::action( |
| 932 | 939 | ActionId::Save, |
| 933 | 940 | player.enable(ActionId::Save, None).yes(), |
crates/app/src/ui/widgets.rsmodified+54 -1
| @@ -122,6 +122,59 @@ pub(crate) fn dissolve_glyph() -> impl IntoElement { | ||
| 122 | 122 | .size_full() |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | +/// The hover line every control in the room wears (the user, 2026-09-09: | |
| 126 | +/// "each and every button gets hover over information" -- nobody could name | |
| 127 | +/// the band's own glyphs). One shape, built from the same pair the hitmap | |
| 128 | +/// already names the control by: `<name> · <chord>`, DESIGN §4's "every | |
| 129 | +/// command wears its chord" and §8's no-prose rule -- never a sentence. A | |
| 130 | +/// control the current state refuses says *why* in the chord's place: naming | |
| 131 | +/// a stroke that will not fire is the lie §4 forbids. | |
| 132 | +pub(crate) fn tip_line(name: &str, chord: &str, why: Option<&str>) -> SharedString { | |
| 133 | + match why { | |
| 134 | + Some(why) => format!("{name} · {why}"), | |
| 135 | + // `Keymap::chord`'s own "unbound" badge: a glyph with no stroke says | |
| 136 | + // its name and stops, rather than wearing `--` as if that were one. | |
| 137 | + None if chord.is_empty() || chord == "--" => name.to_string(), | |
| 138 | + None => format!("{name} · {chord}"), | |
| 139 | + } | |
| 140 | + .into() | |
| 141 | +} | |
| 142 | + | |
| 143 | +/// [`tip_line`] in the shape gpui's `.tooltip` takes. Every shared control | |
| 144 | +/// constructor attaches this rather than building its own plate, which is | |
| 145 | +/// what keeps the next control from shipping without a hover line. | |
| 146 | +pub(crate) fn tip_hover( | |
| 147 | + name: &str, | |
| 148 | + chord: &str, | |
| 149 | + why: Option<&str>, | |
| 150 | +) -> impl Fn(&mut Window, &mut App) -> gpui::AnyView + use<> { | |
| 151 | + let say = tip_line(name, chord, why); | |
| 152 | + move |_, cx| cx.new(|_| Tip(say.clone())).into() | |
| 153 | +} | |
| 154 | + | |
| 155 | +/// [`tip_hover`] for a control drawn *on* a card or a menu, where an | |
| 156 | +/// ordinary [`Tip`] stands aside (`OVERLAID`) and would show nothing. | |
| 157 | +pub(crate) fn overlay_tip_hover( | |
| 158 | + name: &str, | |
| 159 | + chord: &str, | |
| 160 | + why: Option<&str>, | |
| 161 | +) -> impl Fn(&mut Window, &mut App) -> gpui::AnyView + use<> { | |
| 162 | + let say = tip_line(name, chord, why); | |
| 163 | + move |_, cx| cx.new(|_| OverlayTip(say.clone())).into() | |
| 164 | +} | |
| 165 | + | |
| 166 | +/// [`tip_hover`] for a control that dispatches an action: the name and the | |
| 167 | +/// stroke are read live off the keymap and the enable state, so a rebind or | |
| 168 | +/// a refusal can never leave a stale plate under the pointer. | |
| 169 | +pub(crate) fn action_hover( | |
| 170 | + player: &Player, | |
| 171 | + action: ActionId, | |
| 172 | +) -> impl Fn(&mut Window, &mut App) -> gpui::AnyView + use<> { | |
| 173 | + let enabled = player.enable(action, None); | |
| 174 | + let chord = player.keymap.chord(action); | |
| 175 | + tip_hover(action.label(), &chord, enabled.why()) | |
| 176 | +} | |
| 177 | + | |
| 125 | 178 | /// A toolbar button: its glyph, its name, and its key on hover. `id` only buys |
| 126 | 179 | /// `on_click` and the tooltip -- it is still not focusable, so the root's own |
| 127 | 180 | /// key listener keeps working after a press, and the click lands on mouse-up |
| @@ -146,7 +199,7 @@ pub(crate) fn control( | ||
| 146 | 199 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, |
| 147 | 200 | ) -> impl IntoElement { |
| 148 | 201 | let label = label.into(); |
| 149 | - let tip: SharedString = format!("{label} — {shortcut}").into(); | |
| 202 | + let tip = tip_line(&label, &shortcut, None); | |
| 150 | 203 | div() |
| 151 | 204 | .id(id) |
| 152 | 205 | .flex_none() |