Skip to main content

ImageView

Struct ImageView 

Source
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

Source§

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>)

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.

Source§

fn ime_area(&self) -> Option<Rect>

Returns the rectangle the input method should anchor to while this widget holds the keyboard focus, in the paint coordinates of Widget::paint. Read more
Source§

fn semantics(&self) -> Option<Semantics>

Returns the accessibility description that places this widget in the projection, or None to leave it out. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.