container, text, date_picker: width-aware sizing pass
`Container::max_width(px)` mirrors the same flag on `Column` / `Row` — the container reports `min( offered, px )` upwards and the draw pass caps `rect.width` to `px`, so a decorated child wrapped in `container().max_width(260)` no longer needs a `column()`-of-one shell just to access the cap. Propagated through `map_msg`, covered by a test, and documented under the `container` section of `docs/widgets.md`.
`Text::no_truncate()` opts out of the default ellipsis behaviour: when `truncate = false` the draw pass paints the full string even if `measure(text) > rect.width`. Useful for very short labels (calendar days "1"–"31", day-of-week stubs "Lu" / "Mi" / "Sá") inside grid slots whose width is dictated by the parent — a couple of pixels of overflow centred in the rect is invisible, while "..." in place of a single-digit number is loud.
`DatePicker::width(px)` is a layout hint: when set, `build()` derives `header_fs`, `dow_fs` and `day_fs` from the slot width so the worst-case label in each row ("September 2026" in the header, "Mié" / "Sáb" in the DOW row, "30" in the day cell) fits at a sensible size; the design defaults stay as upper bounds. Day and DOW cells also flip on `Text::no_truncate()` as a safety net — heuristic font sizing can't perfectly predict glyph widths across families, and overflowing one pixel beats truncating to "...".
This commit is contained in:
@@ -138,6 +138,13 @@ pub( crate ) fn layout_and_draw<Msg: Clone>(
|
||||
let saved_alpha = canvas.global_alpha();
|
||||
canvas.set_global_alpha( saved_alpha * c.opacity );
|
||||
|
||||
let rect = if let Some( mw ) = c.max_width
|
||||
{
|
||||
crate::types::Rect { width: rect.width.min( mw ), ..rect }
|
||||
} else {
|
||||
rect
|
||||
};
|
||||
|
||||
// Surface slot takes precedence over flat background; falls
|
||||
// through to `c.background` when the slot is absent (third-
|
||||
// party theme without the named surface — content still
|
||||
|
||||
Reference in New Issue
Block a user