iced_frame
Iced widget that renders an offscreen RGBA frame buffer as a wgpu-textured quad.
Any source that produces frames — a webview engine, a video decoder, a software renderer — can plug into this widget by implementing the FrameSource trait. The widget handles the wgpu pipeline (texture create / resize / upload / draw), click-to-focus state, and redraw requests. The implementor supplies frames, cursor state, and event handling.
Usage
use ;
use ;
// Implement FrameSource for your renderer:
// In view():
frame
.content_fit
.alignment
.filter
.width
.height
Content fit modes
| Mode | Behavior |
|---|---|
Fill (default) |
Stretch to fill — ignores aspect ratio |
Contain |
Scale uniformly, entire frame visible (letterbox) |
Cover |
Scale uniformly, widget fully covered (crop) |
FitWidth |
Scale uniformly to match widget width; clip/letterbox height |
FitHeight |
Scale uniformly to match widget height; clip/letterbox width |
None |
No scaling — native pixel size, clip overflow |
Alignment
9 anchor positions for when the frame doesn't fill the widget: TopLeft, TopCenter, TopRight, CenterLeft, Center (default), CenterRight, BottomLeft, BottomCenter, BottomRight.
Filter mode
Linear (default, smooth) or Nearest (sharp pixel boundaries).
Example
Interactive demo with pick lists for all fit/alignment/filter modes and a "Resize to fit" button that regenerates the checkerboard at the widget's physical pixel size.
Requirements
Requires the iced wgpu renderer (the default). The widget uses iced_wgpu::primitive::Renderer to draw its textured quad.