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>, }
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
impl<'a, 'c> Image<'a, 'c>
[src]
impl<'a, 'c> Image<'a, 'c>
[src]pub fn empty() -> Self
[src]
An Image
with no renderable content. Useful for starting a template for creating
several similar images using a builder pattern.
pub fn from_path(filename: &'a str) -> Self
[src]
Create an SVG Image
, read from filename
, which is colored to match Style.icon_fg
pub fn untinted(filename: &'a str) -> Self
[src]
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()
pub fn from_bytes(labeled_bytes: (&'a str, &'a [u8])) -> Self
[src]
Create a new SVG Image
from bytes.
labeled_bytes
: is a (label
,bytes
) tuple you can generate withinclude_labeled_bytes!
label
: a label to describe the bytes for debugging purposesbytes
: UTF-8 encoded bytes of the SVG
pub fn from_batch(batch: GeomBatch, bounds: Bounds) -> Self
[src]
Create a new Image
from a GeomBatch
.
pub fn source(self, source: ImageSource<'a>) -> Self
[src]
Set a new source for the Image
’s data.
This will replace any previously set source.
pub fn source_path(self, path: &'a str) -> Self
[src]
Set the path to an SVG file for the image.
This will replace any image source previously set.
pub fn source_bytes(self, labeled_bytes: (&'a str, &'a [u8])) -> Self
[src]
Set the bytes for the image.
This will replace any image source previously set.
labeled_bytes
: is a (label
,bytes
) tuple you can generate withinclude_labeled_bytes!
label
: a label to describe the bytes for debugging purposesbytes
: UTF-8 encoded bytes of the SVG
pub fn source_batch(self, batch: GeomBatch, bounds: Bounds) -> Self
[src]
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.
pub fn tooltip(self, tooltip: impl Into<Text>) -> Self
[src]
Add a tooltip to appear when hovering over the image.
pub fn merged_image_style(&'c self, other: &'c Self) -> Self
[src]
Create a new Image
based on self
, but overriding with any values set on other
.
pub fn color<RWC: Into<RewriteColor>>(self, value: RWC) -> Self
[src]
Rewrite the color of the image.
pub fn bg_color(self, value: Color) -> Self
[src]
Set a background color for the image.
pub fn dims<D: Into<ScreenDims>>(self, dims: D) -> Self
[src]
Scale the bounds containing the image. If image_dims
are not specified, the images
intrinsic size will be used.
See Self::content_mode
to control how the image scales to fit
its custom bounds.
pub fn content_mode(self, value: ContentMode) -> Self
[src]
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
pub fn corner_rounding<R: Into<CornerRounding>>(self, value: R) -> Self
[src]
Set independent rounding for each of the image’s corners
pub fn padding<EI: Into<EdgeInsets>>(self, value: EI) -> Self
[src]
Set padding for the image
pub fn build_batch(&self, ctx: &EventCtx<'_>) -> Option<(GeomBatch, Bounds)>
[src]
Render the Image
and any styling (padding, background, etc.) to a GeomBatch
.
pub fn into_widget(self, ctx: &EventCtx<'_>) -> Widget
[src]
Trait Implementations
Auto Trait Implementations
impl<'a, 'c> RefUnwindSafe for Image<'a, 'c>
impl<'a, 'c> Send for Image<'a, 'c>
impl<'a, 'c> Sync for Image<'a, 'c>
impl<'a, 'c> Unpin for Image<'a, 'c> where
'a: 'c,
'a: 'c,