pub struct ImageView { /* private fields */ }Expand description
The widget behind image: it paints a panel’s background and border,
then one image stretched over its content box.
Build one with image, which binds its source. The widget measures as
the source’s pixel size over the scale factor, so a source that appears,
disappears or changes pixel size lays the node out again, and a swap
between sources of the same size only repaints it.
Trait Implementations§
Source§impl Widget for ImageView
impl Widget for ImageView
Source§fn measure(&mut self, input: MeasureInput) -> Option<Size>
fn measure(&mut self, input: MeasureInput) -> Option<Size>
Measures as the image’s pixel size divided by the scale factor, so one image pixel is one logical pixel.
When one axis of the content box is fixed, by the style or by a container that stretches the image, the other follows from the image’s aspect ratio. When both are, the image stretches to them.
The answer depends on the source and the input alone, so it is the same on every call with the same input, which the engine’s caching relies on.
Source§fn paint(&self, cx: &PaintCx<'_>, out: &mut Vec<PaintOp>)
fn paint(&self, cx: &PaintCx<'_>, out: &mut Vec<PaintOp>)
Paints the style’s background and border the way a panel does, then the image stretched over the content box.
The image’s corners are the style’s corner radius shrunk by the border and padding next to them, so they stay concentric with the outer corners.