Struct widgetry::widgets::image::Image[][src]

pub struct Image<'a, 'c> {
    source: Option<Cow<'c, ImageSource<'a>>>,
    tooltip: Option<Text>,
    color: Option<RewriteColor>,
    content_mode: Option<ContentMode>,
    corner_rounding: Option<CornerRounding>,
    padding: Option<EdgeInsets>,
    bg_color: Option<Color>,
    dims: Option<ScreenDims>,
}
Expand description

A stylable UI component builder which presents vector graphics from an ImageSource.

Fields

source: Option<Cow<'c, ImageSource<'a>>>tooltip: Option<Text>color: Option<RewriteColor>content_mode: Option<ContentMode>corner_rounding: Option<CornerRounding>padding: Option<EdgeInsets>bg_color: Option<Color>dims: Option<ScreenDims>

Implementations

An Image with no renderable content. Useful for starting a template for creating several similar images using a builder pattern.

Create an SVG Image, read from filename, which is colored to match Style.icon_fg

Create an SVG Image, read from filename.

The image’s intrinsic colors will be used, it will not be tinted like Image::icon, unless you also call color()

Create a new SVG Image from bytes.

  • labeled_bytes: is a (label, bytes) tuple you can generate with include_labeled_bytes!
  • label: a label to describe the bytes for debugging purposes
  • bytes: UTF-8 encoded bytes of the SVG

Create a new Image from a GeomBatch.

Set a new source for the Image’s data.

This will replace any previously set source.

Set the path to an SVG file for the image.

This will replace any image source previously set.

Set the bytes for the image.

This will replace any image source previously set.

  • labeled_bytes: is a (label, bytes) tuple you can generate with include_labeled_bytes!
  • label: a label to describe the bytes for debugging purposes
  • bytes: UTF-8 encoded bytes of the SVG

Set the GeomBatch for the button.

This will replace any image source previously set.

This method is useful when doing more complex transforms. For example, to re-write more than one color for your image, do so externally and pass in the resultant GeomBatch here.

Add a tooltip to appear when hovering over the image.

Create a new Image based on self, but overriding with any values set on other.

Rewrite the color of the image.

Set a background color for the image. Has no effect unless custom dims are explicitly set.

Scale the bounds containing the image. If dims are not specified, the image’s intrinsic size will be used.

See Self::content_mode to control how the image scales to fit its custom bounds.

If a custom dims was set, control how the image should be scaled to its new bounds.

If dims were not specified, the image will not be scaled, so content_mode has no affect.

The default, ContentMode::ScaleAspectFit will only grow as much as it can while maintaining its aspect ratio and not exceeding its bounds

Set independent rounding for each of the image’s corners. Has no effect unless custom dims are explicitly set.

Set padding for the image. Has no effect unless custom dims are explicitly set.

Padding above the image. Has no effect unless custom dims are explicitly set.

Padding to the left of the image. Has no effect unless custom dims are explicitly set.

Padding below the image. Has no effect unless custom dims are explicitly set.

Padding to the right of the image. Has no effect unless custom dims are explicitly set.

Render the Image and any styling (padding, background, etc.) to a GeomBatch.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.