pub struct Sprite { /* private fields */ }Expand description
A raster image widget, loaded from a handle
Size is inferred from the loaded image. By default, scaling is limited to integer multiples of the source image size.
May be default constructed (result is empty).
Implementations§
Source§impl Sprite
impl Sprite
Sourcepub fn set(&mut self, cx: &mut EventCx<'_>, handle: ImageHandle) -> bool
pub fn set(&mut self, cx: &mut EventCx<'_>, handle: ImageHandle) -> bool
Assign a pre-allocated image
Returns true on success. On error, self is unchanged.
Sourcepub fn handle(&self) -> Option<&ImageHandle>
pub fn handle(&self) -> Option<&ImageHandle>
Access the current ImageHandle, if any
This handle may be used with DrawShared
methods.
Sourcepub fn image_size(&self) -> Size
pub fn image_size(&self) -> Size
Get the image buffer size
This is the size of the image last assigned using Sprite::set.
Initially it is Size::ZERO.
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
This enables fractional scaling of the image with a fixed aspect ratio.
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)
This enables fractional scaling of the image with a fixed aspect ratio.
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)
This is only applicable when using fractional scaling (see
Self::set_logical_size) since integer scaling always uses a
fixed aspect ratio. By default this is enabled.
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 Sprite
impl Events for Sprite
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_messages(&mut self, cx: &mut EventCx<'_>, data: &Self::Data)
fn handle_messages(&mut self, cx: &mut EventCx<'_>, data: &Self::Data)
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 Sprite
impl Layout for Sprite
Source§impl Tile for Sprite
impl Tile for Sprite
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 Sprite
impl RefUnwindSafe for Sprite
impl !Send for Sprite
impl !Sync for Sprite
impl Unpin for Sprite
impl UnwindSafe for Sprite
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