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 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
Create a new Image
from a GeomBatch
.
By default, the given bounds
will be used for padding, background, etc.
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 withinclude_labeled_bytes!
label
: a label to describe the bytes for debugging purposesbytes
: 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.
The image’s intrinsic colors will be used, it will not be tinted like Image::icon
Scale the bounds containing the image. If dims
are not specified, the image’s intrinsic
size will be used, but padding and background settings will be ignored.
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
Auto Trait Implementations
impl<'a, 'c> RefUnwindSafe for Image<'a, 'c>
impl<'a, 'c> UnwindSafe for Image<'a, 'c>
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
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
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
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
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self