Struct carbide_core::widget::primitive::image::Image[][src]

pub struct Image {
    pub image_id: Id,
    pub src_rect: Option<Rect>,
    pub style: Style,
    // some fields omitted
}

A primitive and basic widget for drawing an Image.

Fields

image_id: Id

The unique identifier for the image that will be drawn.

src_rect: Option<Rect>

The rectangle area of the original source image that should be used.

style: Style

Unique styling.

Implementations

impl Image[src]

pub fn old_new(image_id: Id) -> Self[src]

Construct a new Image.

Note that the Image widget does not require borrowing or owning any image data directly. Instead, image data is stored within a carbide::image::Map where image::Ids are mapped to their associated data.

This is done for a few reasons:

  • To avoid requiring that the widget graph owns an instance of each image
  • To avoid requiring that the user passes the image data to the Image every update unnecessarily
  • To make it easier for users to borrow and mutate their images without needing to index into the Ui's widget graph (which also requires casting render).

During rendering, carbide will take the image::Map, retrieve the data associated with each image and yield it via the render::Primitive::Image variant.

Note: this implies that the type must be the same for all Image widgets instantiated via the same Ui. In the case that you require multiple different render of images, we recommend that you either:

  1. use an enum with a variant for each type
  2. use a trait object, where the trait is implemented for each of your image render or
  3. use an index type which may be mapped to your various image render.

pub fn new(id: Id) -> Box<Self>[src]

pub fn source_rectangle(self, rect: Rect) -> Self[src]

The rectangular area of the image that we wish to display.

If this method is not called, the entire image will be used.

pub fn resizeable(self) -> Box<Self>[src]

pub fn scaled_to_fit(self) -> Box<Self>[src]

pub fn scaled_to_fill(self) -> Box<Self>[src]

pub fn aspect_ratio(self, mode: ScaleMode) -> Box<Self>[src]

Trait Implementations

impl Clone for Image[src]

impl<S: GlobalState> CommonWidget<S> for Image[src]

impl Debug for Image[src]

impl<GS: GlobalState> Event<GS> for Image[src]

impl<S: GlobalState> Layout<S> for Image[src]

impl<S: GlobalState> Render<S> for Image[src]

impl<GS: GlobalState> StateSync<GS> for Image[src]

impl<GS: GlobalState> Widget<GS> for Image[src]

impl<GS: GlobalState> WidgetExt<GS> for Image[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T> GlobalState for T where
    T: 'static + Clone + Debug
[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,