forge
Explore
Log in

Don't you dare go Hollow

A card's own help can be read again

Browse files at this commit

0e6e486e23bfd94d78158619f963495bc94d3f89Ahmet Kaan GümüşParent: a9e3dc3d4c877b
  • fix
    • a card's own help can be read again
Show full message
🐛 fix(ui): a card's own help can be read again

Tip stood aside for every tooltip while OVERLAID was set, but a card being
open is exactly what sets OVERLAID — so the ? help moved off the card bodies
could never paint while its own card was on screen.

OverlayTip shares Tip's plate and predicate but is exempt. dark_card_head is
the single call site all seven cards route through, so an eighth inherits the
fix. Test pins both halves: the card's own help paints, the UI under it stays quiet.
crates/app/src/tests/cards.rsmodified+43 -0
@@ -2,6 +2,7 @@
2 //! colour and speed bars, the silence scan, the choices and the export.2 //! colour and speed bars, the silence scan, the choices and the export.
3 3
4 use super::*;4 use super::*;
5+use std::sync::atomic::Ordering;
5 6
6 /// FAULT 2's general shape (not just the source dot's menu): `overlaid()`7 /// FAULT 2's general shape (not just the source dot's menu): `overlaid()`
7 /// refuses every key while `context_menu`/`library_menu`/`picker` is `Some`,8 /// refuses every key while `context_menu`/`library_menu`/`picker` is `Some`,
@@ -1674,3 +1675,45 @@ fn every_card_opener_closes_every_other_card_through_one_path() {
1674 );1675 );
1675 }1676 }
1676 }1677 }
1678+
1679+/// Regression: a builder moved every card's how-to prose off the card body
1680+/// onto a `?` glyph tooltip on the card head (`dark_card_head`), to answer
1681+/// the complaint that the body read "like a terminal screen". But `Tip`
1682+/// stands aside for *every* tooltip while `OVERLAID` is set, and a card
1683+/// being open is exactly what sets `OVERLAID` -- so the `?`'s own help could
1684+/// never paint while the card that owns it was on screen (driven proof:
1685+/// dwelling the pointer on it for 5-6s at four coordinates changed zero
1686+/// pixels). `OverlayTip`/`tip_may_paint` is the fix: a tip anchored on the
1687+/// overlay itself is exempt. This pins both halves so an eighth card can't
1688+/// reintroduce either half of the bug.
1689+#[test]
1690+fn a_cards_own_help_paints_while_the_card_is_open_but_the_ui_under_it_stays_quiet() {
1691+ OVERLAID.store(true, Ordering::Relaxed);
1692+ assert!(
1693+ tip_may_paint(true),
1694+ "a tip anchored on the overlay itself (a card head's own `?`) must \
1695+ still paint while its own card is open, or the help nobody wanted \
1696+ permanent becomes help nobody can ever read"
1697+ );
1698+ assert!(
1699+ !tip_may_paint(false),
1700+ "a tip on the *underlying* UI must still stand aside while a card/menu \
1701+ is up over it -- OVERLAID's original purpose, which the overlay \
1702+ exemption must not weaken"
1703+ );
1704+ OVERLAID.store(false, Ordering::Relaxed);
1705+ assert!(tip_may_paint(false), "with nothing overlaid, an ordinary tip paints too");
1706+
1707+ // Structural half: every card routes its head through `dark_card_head`,
1708+ // so checking its one help-tooltip call site covers all seven cards (and
1709+ // any future eighth) at once -- it must build an `OverlayTip`, not a
1710+ // plain `Tip`, or this whole fix is undone by construction.
1711+ let cards_src = src_text("ui/cards.rs");
1712+ let head_fn_at = cards_src.find("fn dark_card_head(").expect("dark_card_head");
1713+ let head_fn = &cards_src[head_fn_at..head_fn_at + 1200];
1714+ assert!(
1715+ head_fn.contains("OverlayTip(h.clone())"),
1716+ "dark_card_head's own `?` tooltip no longer builds an OverlayTip -- the \
1717+ card-head help is unreadable again while its card is open"
1718+ );
1719+}
crates/app/src/tests/mod.rsmodified+1 -0
@@ -38,6 +38,7 @@ use super::{
38 px_below, STATUS_SUCCESS, STATUS_WARNING, notice_tone,38 px_below, STATUS_SUCCESS, STATUS_WARNING, notice_tone,
39 proxies_to_start, push_notice, typed, unseen_paths, unseen_sources,39 proxies_to_start, push_notice, typed, unseen_paths, unseen_sources,
40 whole_take, window_title,40 whole_take, window_title,
41+ OVERLAID, tip_may_paint,
41 };42 };
42 43
43 use super::{44 use super::{
crates/app/src/ui/cards.rsmodified+1 -1
@@ -76,7 +76,7 @@ fn dark_card_head(verb: &str, meta: Option<SharedString>, help: Option<SharedStr
76 .flex_none()76 .flex_none()
77 .type_style(type_scale::mono(type_scale::CHORD_METADATA_MAX_PX, gpui::FontWeight::MEDIUM))77 .type_style(type_scale::mono(type_scale::CHORD_METADATA_MAX_PX, gpui::FontWeight::MEDIUM))
78 .text_color(rgb(INK3()))78 .text_color(rgb(INK3()))
79- .tooltip(move |_, cx| cx.new(|_| Tip(h.clone())).into())79+ .tooltip(move |_, cx| cx.new(|_| OverlayTip(h.clone())).into())
80 .child("?")80 .child("?")
81 }))81 }))
82 }82 }
crates/app/src/ui/widgets.rsmodified+46 -19
@@ -268,6 +268,32 @@ pub(crate) fn separator() -> impl IntoElement {
268 /// sixteenth would be forgotten.268 /// sixteenth would be forgotten.
269 pub(crate) static OVERLAID: AtomicBool = AtomicBool::new(false);269 pub(crate) static OVERLAID: AtomicBool = AtomicBool::new(false);
270 270
271+/// Whether a tip is cleared to paint: an ordinary tip stands aside whenever
272+/// `OVERLAID` is set (a card/menu is up over the underlying UI it belongs
273+/// to), but a tip *anchored on the overlay itself* -- the `?` glyph on a
274+/// card's own head, say -- was never the case `OVERLAID` meant to catch, so
275+/// it paints regardless. One predicate, so [`Tip`] and [`OverlayTip`] can't
276+/// drift apart on what "overlaid" is supposed to mean.
277+pub(crate) fn tip_may_paint(anchored_on_overlay: bool) -> bool {
278+ anchored_on_overlay || !OVERLAID.load(Ordering::Relaxed)
279+}
280+
281+/// DESIGN §4: "Notices, menus, chips, cues, and tooltips are all the same
282+/// plate" -- canvas-on-panel, 2px radius, the room's own type
283+/// (`ui::type_scale`), not a bordered box in an ad hoc size.
284+fn tip_plate(text: &SharedString) -> Div {
285+ let style = crate::ui::type_scale::label(crate::ui::type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM);
286+ div()
287+ .px(px(8.))
288+ .py(px(4.))
289+ .rounded(px(2.))
290+ .bg(rgb(DARK_CANVAS()))
291+ .font(style.font)
292+ .text_size(style.size)
293+ .text_color(rgb(INK1()))
294+ .child(text.clone())
295+}
296+
271 /// A tooltip is a view in gpui and nothing smaller, so this is the smallest one297 /// A tooltip is a view in gpui and nothing smaller, so this is the smallest one
272 /// that carries a line of text. It paints outside the window's element tree and298 /// that carries a line of text. It paints outside the window's element tree and
273 /// therefore owns its colours.299 /// therefore owns its colours.
@@ -277,27 +303,28 @@ impl Render for Tip {
277 fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {303 fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
278 // A card or a menu is up: nothing. A line of text over the items of the304 // A card or a menu is up: nothing. A line of text over the items of the
279 // menu that just opened under the pointer is the card being painted305 // menu that just opened under the pointer is the card being painted
280- // over by the window it covers.306+ // over by the window it covers. (This struct is every tooltip on the
281- if OVERLAID.load(Ordering::Relaxed) {307+ // *underlying* UI -- grepped: `timeline.rs`, `library.rs`,
308+ // `overlays.rs`, `spine_stance.rs`, `dock_stance.rs`,
309+ // `timeband_stance.rs`, `preview.rs`, here -- so the fix belongs here
310+ // once, not per call site.)
311+ if !tip_may_paint(false) {
282 return div();312 return div();
283 }313 }
284- // DESIGN §4: "Notices, menus, chips, cues, and tooltips are all the314+ tip_plate(&self.0)
285- // same plate" -- canvas-on-panel, 2px radius, the room's own type315+ }
286- // (`ui::type_scale`), not a bordered box in an ad hoc size. This one316+}
287- // struct is every tooltip in the app (grepped: `timeline.rs`,317+
288- // `library.rs`, `overlays.rs`, `spine_stance.rs`, `dock_stance.rs`,318+/// A tip anchored on the overlay itself -- a card's own `?` glyph, drawn on
289- // `timeband_stance.rs`, `preview.rs`, here), so the fix belongs here319+/// its own card head. `OVERLAID` exists to hide a [`Tip`] on the UI *under*
290- // once, not per call site.320+/// a card while the card sits over it; a tip painted on the card is not
291- let style = crate::ui::type_scale::label(crate::ui::type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM);321+/// that case, so it is exempt (`tip_may_paint(true)` is always `true`).
292- div()322+/// Everything else about it is [`Tip`]'s own plate.
293- .px(px(8.))323+pub(crate) struct OverlayTip(pub(crate) SharedString);
294- .py(px(4.))324+
295- .rounded(px(2.))325+impl Render for OverlayTip {
296- .bg(rgb(DARK_CANVAS()))326+ fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
297- .font(style.font)327+ tip_plate(&self.0)
298- .text_size(style.size)
299- .text_color(rgb(INK1()))
300- .child(self.0.clone())
301 }328 }
302 }329 }
303 330