forge
Explore
Log in

Don't you dare go Hollow

A notice reads as a sentence at the 640x360 floor

Browse files at this commit

dc279aa0f97dc833b509768a0b8077b58a6e488eAhmet Kaan GümüşParent: 33db3c0
  • fix
    • a notice reads as a sentence at the 640x360 floor
Show full message
🐛 fix(ui): a notice reads as a sentence at the 640x360 floor

The bar is a message beside a hint that keeps its own width, and at the
floor the picture region is narrower than the hint alone: the message
was squeezed to nothing and, with `min_w(0)` under it, wrapped one
character per line -- every failure rendered as a column of letters.
The row wraps now, so the hint drops to its own line, and the message
carries a floor instead of zero: gpui measures a text element's
min-content as the whole unwrapped line, so with no floor at all it
would refuse to shrink and run off the region instead.
crates/app/src/main.rsmodified+11 -0
@@ -6343,6 +6343,17 @@ fn file_name(path: &std::path::Path) -> String {
6343 /// eight is more than a user will ever answer in a row.6343 /// eight is more than a user will ever answer in a row.
6344 const NOTICES_MAX: usize = 8;6344 const NOTICES_MAX: usize = 8;
6345 6345
6346+/// The narrowest a notice's *message* is allowed to be squeezed before its hint
6347+/// gives up the line and drops below it.
6348+///
6349+/// The bar is a message beside a hint, and at the 640x360 floor the picture
6350+/// region it hangs under is narrower than the hint alone -- so the message was
6351+/// squeezed to nothing and wrapped one character per line, which is a failure
6352+/// rendered as a column of letters. Wide enough that a line of it is a phrase
6353+/// rather than a word ladder, and narrow enough to still fit beside the hint in
6354+/// any window worth putting two things on a line in.
6355+const NOTICE_MIN_W: f32 = 180.;
6356+
6346 /// The whole of the queue's policy, where it can be read at once and tested6357 /// The whole of the queue's policy, where it can be read at once and tested
6347 /// without a window: dedupe against the back, a ceiling, oldest out first.6358 /// without a window: dedupe against the back, a ceiling, oldest out first.
6348 /// [`Player::notify_user`] is the door every message comes through; this is what6359 /// [`Player::notify_user`] is the door every message comes through; this is what
crates/app/src/ui/overlays.rsmodified+16 -1
@@ -147,6 +147,14 @@ impl Player {
147 })147 })
148 .flex_none()148 .flex_none()
149 .flex()149 .flex()
150+ // The hint keeps its own width, and at the 640x360 floor the
151+ // picture region is narrower than the hint alone: with both on
152+ // one line the message was squeezed to nothing and wrapped a
153+ // character per line -- a notice rendered as a column of
154+ // letters. Wrapping puts the hint on its own line instead, so
155+ // the message keeps the whole width and the queue counter
156+ // stays on screen under it.
157+ .flex_wrap()
150 .items_start()158 .items_start()
151 .gap(px(12.))159 .gap(px(12.))
152 .px(px(12.))160 .px(px(12.))
@@ -170,7 +178,14 @@ impl Player {
170 this.dismiss_notice();178 this.dismiss_notice();
171 cx.notify();179 cx.notify();
172 }))180 }))
173- .child(div().flex_1().min_w(px(0.)).child(notice))181+ // Shrinkable, because a gpui text element measures its
182+ // min-content as the *whole line* (`TextLayout::layout` only
183+ // wraps against a definite width) -- without a `min_w` the
184+ // message would refuse to shrink at all and run off the region
185+ // instead. With a floor under it, it shrinks to that floor,
186+ // which pushes the hint onto its own line and leaves the
187+ // message the width it needs to wrap like a sentence.
188+ .child(div().flex_1().min_w(px(NOTICE_MIN_W)).child(notice))
174 .child(189 .child(
175 div()190 div()
176 .flex_none()191 .flex_none()