pub struct Svg { /* private fields */ }svg only.Expand description
An SVG image widget
May be default constructed (result is empty).
The size of the widget is inferred from the SVG source in logical pixels then scaled by the display’s scale factor. If a different size should be used it must be set after loading the SVG data.
By default, the drawn SVG will not be allowed to scale above its specified size; if the widget is forced to stretch, content will be positioned within this space according to alignment rules (centered by default).
Implementations§
Source§impl Svg
impl Svg
Sourcepub fn new(data: &'static [u8]) -> Result<Self, impl Error>
pub fn new(data: &'static [u8]) -> Result<Self, impl Error>
Construct from data
Returns an error if the SVG fails to parse. If using this method
with include_bytes it is probably safe to unwrap.
The (logical) size of the widget is set to that from the SVG source.
Sourcepub fn load(
&mut self,
cx: &mut ConfigCx<'_>,
data: &'static [u8],
resources_dir: Option<&Path>,
) -> Result<(), impl Error + use<>>
pub fn load( &mut self, cx: &mut ConfigCx<'_>, data: &'static [u8], resources_dir: Option<&Path>, ) -> Result<(), impl Error + use<>>
Load from data
Replaces existing data and request a resize. The size is inferred from the SVG using units of logical pixels.
Sourcepub fn load_path<P: AsRef<Path>>(
&mut self,
cx: &mut ConfigCx<'_>,
path: P,
) -> Result<(), impl Error + use<P>>
pub fn load_path<P: AsRef<Path>>( &mut self, cx: &mut ConfigCx<'_>, path: P, ) -> Result<(), impl Error + use<P>>
Load from a path
This is a wrapper around Self::load.
Sourcepub fn set_logical_size(&mut self, size: impl Into<LogicalSize>)
pub fn set_logical_size(&mut self, size: impl Into<LogicalSize>)
Set size in logical pixels
Sourcepub fn with_logical_size(self, size: impl Into<LogicalSize>) -> Self
pub fn with_logical_size(self, size: impl Into<LogicalSize>) -> Self
Set size in logical pixels (inline)
Sourcepub fn with_margin_style(self, style: MarginStyle) -> Self
pub fn with_margin_style(self, style: MarginStyle) -> Self
Set the margin style (inline)
By default, this is MarginStyle::Large.
Sourcepub fn with_fixed_aspect_ratio(self, fixed: bool) -> Self
pub fn with_fixed_aspect_ratio(self, fixed: bool) -> Self
Control whether the aspect ratio is fixed (inline)
By default this is fixed.
Sourcepub fn with_stretch(self, stretch: Stretch) -> Self
pub fn with_stretch(self, stretch: Stretch) -> Self
Set the stretch factor (inline)
By default this is Stretch::None. Particular to this widget,
Stretch::None will avoid stretching of content, aligning instead.
Trait Implementations§
Source§impl Events for Svg
impl Events for Svg
Source§fn handle_messages(&mut self, cx: &mut EventCx<'_>, _: &Self::Data)
fn handle_messages(&mut self, cx: &mut EventCx<'_>, _: &Self::Data)
Source§const REDRAW_ON_MOUSE_OVER: bool = false
const REDRAW_ON_MOUSE_OVER: bool = false
Source§fn mouse_over_icon(&self) -> Option<CursorIcon>
fn mouse_over_icon(&self) -> Option<CursorIcon>
Source§fn post_configure(&mut self, cx: &mut ConfigCx<'_>)
fn post_configure(&mut self, cx: &mut ConfigCx<'_>)
Source§fn update(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
fn update(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
Source§fn recurse_indices(&self) -> ChildIndices
fn recurse_indices(&self) -> ChildIndices
Source§fn handle_mouse_over(&mut self, cx: &mut EventCx<'_>, state: bool)
fn handle_mouse_over(&mut self, cx: &mut EventCx<'_>, state: bool)
Source§fn handle_resize(
&mut self,
cx: &mut ConfigCx<'_>,
data: &Self::Data,
) -> Option<ActionResize>
fn handle_resize( &mut self, cx: &mut ConfigCx<'_>, data: &Self::Data, ) -> Option<ActionResize>
Source§impl Layout for Svg
impl Layout for Svg
Source§impl Tile for Svg
impl Tile for Svg
Source§fn get_child(&self, index: usize) -> Option<&dyn Tile>
fn get_child(&self, index: usize) -> Option<&dyn Tile>
dyn Tile, if available Read moreSource§fn child_indices(&self) -> ChildIndices
fn child_indices(&self) -> ChildIndices
Source§fn role_child_properties(&self, cx: &mut dyn RoleCx, index: usize)
fn role_child_properties(&self, cx: &mut dyn RoleCx, index: usize)
index Read moreAuto Trait Implementations§
impl Freeze for Svg
impl RefUnwindSafe for Svg
impl !Send for Svg
impl !Sync for Svg
impl Unpin for Svg
impl UnwindSafe for Svg
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<W> TileExt for W
impl<W> TileExt for W
Source§fn is_configured(&self) -> bool
fn is_configured(&self) -> bool
Source§fn is_strict_ancestor_of(&self, id: &Id) -> bool
fn is_strict_ancestor_of(&self, id: &Id) -> bool
id is not self and is a descendant Read more