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

pub struct Image {
    pub common: CommonBuilder,
    pub image_id: Id,
    pub src_rect: Option<Rect>,
    pub style: Style,
}

A primitive and basic widget for drawing an Image.

Fields

common: CommonBuilder

Data necessary and common for all widget builder types.

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 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 conrod::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 types).

During rendering, conrod 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 types 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 types or
  3. use an index type which may be mapped to your various image types.

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 color(self, color: Option<Color>) -> Self[src]

Build the type's self.$($assignee).+ with the given $Type.

Trait Implementations

impl Clone for Image[src]

impl Common for Image[src]

impl Copy for Image[src]

impl Widget for Image[src]

type State = State

State to be stored within the Uis widget cache. Read more

type Style = Style

Every widget is required to have its own associated Style type. This type is intended to contain high-level styling information for the widget that can be optionally specified by a user of the widget. Read more

type Event = ()

The type of event yielded by the widget, returned via the Widget::set function. Read more

Auto Trait Implementations

impl RefUnwindSafe for Image

impl Send for Image

impl Sync for Image

impl Unpin for Image

impl UnwindSafe for Image

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> From<T> for T[src]

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

impl<W> Positionable for W where
    W: Widget
[src]

impl<W> Sizeable for W where
    W: Widget
[src]

fn get_x_dimension(&Self, &Ui) -> Dimension[src]

We attempt to retrieve the x Dimension for the widget via the following:

  • Check for specified value at maybe_x_dimension
  • Otherwise, use the default returned by Widget::default_x_dimension.

fn get_y_dimension(&Self, &Ui) -> Dimension[src]

We attempt to retrieve the y Dimension for the widget via the following:

  • Check for specified value at maybe_y_dimension
  • Otherwise, use the default returned by Widget::default_y_dimension.

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.