External textures drawn at their own size, a repaint without rebuilding the view, an icon size for list rows, and lighter tabs on the desktop strip
CI / build + test (push) Canceled after 0s
CI / cargo audit (push) Canceled after 0s

External textures. `ExternalSource::Texture` stretches its texture over the widget's rect, so a producer that is a few frames behind a new rect shows its old picture stretched or squeezed. A web page while its window is resized is the clearest case: the page keeps sending frames of the old size until it has laid itself out again, and the content wobbles as the window moves. The new `ExternalSource::Frame` closure returns the texture with its size in physical pixels, and the texture is drawn at that size from the rect's top left corner, cut to the rect. A late frame then leaves an empty edge or loses one for a moment, as other browsers do, instead of being distorted. The cut uses `interior_clip`, which moves from the text field's drawing code to `render/clip.rs` so both widgets can use it, and the clip that was active before is restored afterwards.
Repaint without a view. An application whose only change is a new frame in an external texture had to report `InvalidationScope::All`, which rebuilds the whole view just to draw the same widgets again. `App::needs_repaint` is asked once per iteration, after the messages are processed. When it returns `true`, the main surface and the secondary surfaces are redrawn from the cached view, without calling `view`. The default is `false`, so existing applications behave as before.
List rows. `ListItem::icon_size` overrides the size of the leading icon, which was always the theme's 24 design px, for dense lists such as a menu, where an icon of that size dominates the row.
Tab strip. On the desktop, a tab's title is drawn at the regular weight whether it is selected or not; the selected tab already stands out by its fill and edge, and the bold title made the strip heavy. The desktop tab's close icon is 10 widget pixels instead of the 16 that the cards of the tab overview keep, so `parts::close` now takes the icon size from its caller.
This commit is contained in:
2026-10-27 12:46:20 +01:00
parent 8882078743
commit da34eee9e6
13 changed files with 103 additions and 53 deletions
+1
View File
@@ -276,6 +276,7 @@ Use it when you need:
- external wakeups via `set_channel_sender()`
- timer-driven or async state via `poll_external()` / `poll_interval()`
- redraw narrowing via `invalidate_after()`
- repainting an external texture's new frame without rebuilding the view via `needs_repaint()`
- runtime theme state access
- runtime-free embedding through `core::UiSurface`
+5 -1
View File
@@ -203,7 +203,7 @@ its content (theme default 16 px) — lower it when the enclosing view's
own padding already provides the margin.
`ink( label, secondary )` draws the label in `label`, the subtitle and trailing text in `secondary`, and tints hover and press with `label`, instead of the theme's colours, for a row laid on a surface the theme does not know about, such as a menu drawn in an app's own colours.
`height( len )` overrides the theme row height (56 design px, 68 with a subtitle) and `font_size( len )` the primary-label size (16 design px; subtitle and trailing keep their theme sizes), both `impl Into<Length>`. Use them together where a dense list — a context menu, a compact picker — should trade the touch-target generosity of a settings list for row density; the resolved height is floored at the label's rendered height so the text never clips however aggressive the override.
`height( len )` overrides the theme row height (56 design px, 68 with a subtitle) and `font_size( len )` the primary-label size (16 design px; subtitle and trailing keep their theme sizes), both `impl Into<Length>`. Use them together where a dense list — a context menu, a compact picker — should trade the touch-target generosity of a settings list for row density; the resolved height is floored at the label's rendered height so the text never clips however aggressive the override. `icon_size( len )` overrides the leading icon's size (24 design px).
`ink( label, secondary )` draws the label in `label` and the subtitle and trailing text in `secondary`, and tints hover and press with `label`, in place of the theme's colours: for rows on a surface of the app's own, such as a menu in a fixed colour.
@@ -583,6 +583,10 @@ Two sources:
- `External::new( w, h, ExternalSource::Texture( … ) )` — samples a
caller-owned GL texture each frame (a web engine, a video decoder).
**GLES only**; the producer keeps the texture and ltk only composites.
- `External::new( w, h, ExternalSource::Frame( … ) )` — the same, but the
closure also returns the texture's size and ltk draws it at that size
from the top left corner, cut to the rect, instead of stretching it: a
web page whose frame lags behind a window resize is not distorted.
**When**: a `VectorDrawable` / Lottie frame, a custom-painted gauge, or
embedding another renderer's output.