Let a label wrap where the layout wraps
The text styles set `.wrap()` themselves, so a label broke its own text whenever it was handed less width than it asked for — including inside a row laid out without wrapping, where the break has nothing to do with the line running out. In frq's list pane that read as a status saying "joine/d" and an unread count split down two lines. Left alone, a Label takes the layout's wrap mode: wrapping in a column, extending in an unwrapped row, which is what each of these wanted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
a20c5b9 parent: 2ab40bf modified
crates/vidya-core/src/theme.rs +11 -8 | @@ -560,6 +560,13 @@ pub fn status_dot(ui: &mut Ui, theme: &Theme, live: bool) -> Response { | ||
| 560 | 560 | response |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | +/// The text styles. | |
| 564 | +/// | |
| 565 | +/// None of them sets a wrap mode: a `Label` left alone takes the layout's, | |
| 566 | +/// which wraps in a column and extends in a row laid out without wrapping. | |
| 567 | +/// Forcing `.wrap()` instead made a label break its own text whenever a row | |
| 568 | +/// squeezed it — a status reading "joine/d", an unread count split down two | |
| 569 | +/// lines — for want of the width it asked for. | |
| 563 | 570 | pub fn title(ui: &mut Ui, theme: &Theme, text: &str) { |
| 564 | 571 | ui.add( |
| 565 | 572 | Label::new( |
| @@ -567,8 +574,7 @@ pub fn title(ui: &mut Ui, theme: &Theme, text: &str) { | ||
| 567 | 574 | .size(theme.type_scale.title) |
| 568 | 575 | .strong() |
| 569 | 576 | .color(theme.palette.text), |
| 570 | - ) | |
| 571 | - .wrap(), | |
| 577 | + ), | |
| 572 | 578 | ); |
| 573 | 579 | } |
| 574 | 580 | |
| @@ -579,8 +585,7 @@ pub fn title_2(ui: &mut Ui, theme: &Theme, text: &str) { | ||
| 579 | 585 | .size(theme.type_scale.title_2) |
| 580 | 586 | .strong() |
| 581 | 587 | .color(theme.palette.text), |
| 582 | - ) | |
| 583 | - .wrap(), | |
| 588 | + ), | |
| 584 | 589 | ); |
| 585 | 590 | } |
| 586 | 591 | |
| @@ -590,8 +595,7 @@ pub fn body(ui: &mut Ui, theme: &Theme, text: &str) { | ||
| 590 | 595 | RichText::new(text) |
| 591 | 596 | .size(theme.type_scale.body) |
| 592 | 597 | .color(theme.palette.text), |
| 593 | - ) | |
| 594 | - .wrap(), | |
| 598 | + ), | |
| 595 | 599 | ); |
| 596 | 600 | } |
| 597 | 601 | |
| @@ -601,8 +605,7 @@ pub fn dim_label(ui: &mut Ui, theme: &Theme, text: &str) { | ||
| 601 | 605 | RichText::new(text) |
| 602 | 606 | .size(theme.type_scale.caption) |
| 603 | 607 | .color(theme.palette.text_secondary), |
| 604 | - ) | |
| 605 | - .wrap(), | |
| 608 | + ), | |
| 606 | 609 | ); |
| 607 | 610 | } |
| 608 | 611 | |
| @@ -560,6 +560,13 @@ pub fn status_dot(ui: &mut Ui, theme: &Theme, live: bool) -> Response { | |||
| 560 | response | 560 | response |
| 561 | } | 561 | } |
| 562 | 562 | ||
| 563 | +/// The text styles. | ||
| 564 | +/// | ||
| 565 | +/// None of them sets a wrap mode: a `Label` left alone takes the layout's, | ||
| 566 | +/// which wraps in a column and extends in a row laid out without wrapping. | ||
| 567 | +/// Forcing `.wrap()` instead made a label break its own text whenever a row | ||
| 568 | +/// squeezed it — a status reading "joine/d", an unread count split down two | ||
| 569 | +/// lines — for want of the width it asked for. | ||
| 563 | pub fn title(ui: &mut Ui, theme: &Theme, text: &str) { | 570 | pub fn title(ui: &mut Ui, theme: &Theme, text: &str) { |
| 564 | ui.add( | 571 | ui.add( |
| 565 | Label::new( | 572 | Label::new( |
| @@ -567,8 +574,7 @@ pub fn title(ui: &mut Ui, theme: &Theme, text: &str) { | |||
| 567 | .size(theme.type_scale.title) | 574 | .size(theme.type_scale.title) |
| 568 | .strong() | 575 | .strong() |
| 569 | .color(theme.palette.text), | 576 | .color(theme.palette.text), |
| 570 | - ) | 577 | + ), |
| 571 | - .wrap(), | ||
| 572 | ); | 578 | ); |
| 573 | } | 579 | } |
| 574 | 580 | ||
| @@ -579,8 +585,7 @@ pub fn title_2(ui: &mut Ui, theme: &Theme, text: &str) { | |||
| 579 | .size(theme.type_scale.title_2) | 585 | .size(theme.type_scale.title_2) |
| 580 | .strong() | 586 | .strong() |
| 581 | .color(theme.palette.text), | 587 | .color(theme.palette.text), |
| 582 | - ) | 588 | + ), |
| 583 | - .wrap(), | ||
| 584 | ); | 589 | ); |
| 585 | } | 590 | } |
| 586 | 591 | ||
| @@ -590,8 +595,7 @@ pub fn body(ui: &mut Ui, theme: &Theme, text: &str) { | |||
| 590 | RichText::new(text) | 595 | RichText::new(text) |
| 591 | .size(theme.type_scale.body) | 596 | .size(theme.type_scale.body) |
| 592 | .color(theme.palette.text), | 597 | .color(theme.palette.text), |
| 593 | - ) | 598 | + ), |
| 594 | - .wrap(), | ||
| 595 | ); | 599 | ); |
| 596 | } | 600 | } |
| 597 | 601 | ||
| @@ -601,8 +605,7 @@ pub fn dim_label(ui: &mut Ui, theme: &Theme, text: &str) { | |||
| 601 | RichText::new(text) | 605 | RichText::new(text) |
| 602 | .size(theme.type_scale.caption) | 606 | .size(theme.type_scale.caption) |
| 603 | .color(theme.palette.text_secondary), | 607 | .color(theme.palette.text_secondary), |
| 604 | - ) | 608 | + ), |
| 605 | - .wrap(), | ||
| 606 | ); | 609 | ); |
| 607 | } | 610 | } |
| 608 | 611 | ||