diff options
author | 2019-10-22 23:20:24 +0200 | |
---|---|---|
committer | 2019-10-22 23:20:24 +0200 | |
commit | f8a232c8af4c50557fbf0c2e0b2ba46fb63f6adc (patch) | |
tree | 7a02c619be824cdd5cae4c0573b41d4c2a8e6c08 /core | |
parent | 523736f08b1d452e4d3405a68b267c6f44adc22b (diff) | |
download | iced-f8a232c8af4c50557fbf0c2e0b2ba46fb63f6adc.tar.gz iced-f8a232c8af4c50557fbf0c2e0b2ba46fb63f6adc.tar.bz2 iced-f8a232c8af4c50557fbf0c2e0b2ba46fb63f6adc.zip |
Remove generic handle in `Image`
For now, we will simply assume images will be loaded from a given path.
Diffstat (limited to 'core')
-rw-r--r-- | core/src/widget/image.rs | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/core/src/widget/image.rs b/core/src/widget/image.rs index 110ba99a..6e410dce 100644 --- a/core/src/widget/image.rs +++ b/core/src/widget/image.rs @@ -9,12 +9,12 @@ use crate::{Align, Length, Rectangle}; /// ``` /// use iced_core::Image; /// -/// # let my_handle = String::from("some_handle"); -/// let image = Image::new(my_handle); +/// let image = Image::new("resources/ferris.png"); /// ``` -pub struct Image<I> { - /// The image handle - pub handle: I, +#[derive(Debug)] +pub struct Image { + /// The image path + pub path: String, /// The part of the image to show pub clip: Option<Rectangle<u16>>, @@ -28,23 +28,13 @@ pub struct Image<I> { pub align_self: Option<Align>, } -impl<I> std::fmt::Debug for Image<I> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("Image") - .field("clip", &self.clip) - .field("width", &self.width) - .field("height", &self.height) - .finish() - } -} - -impl<I> Image<I> { - /// Creates a new [`Image`] with given image handle. +impl Image { + /// Creates a new [`Image`] with the given path. /// /// [`Image`]: struct.Image.html - pub fn new(handle: I) -> Self { + pub fn new<T: Into<String>>(path: T) -> Self { Image { - handle, + path: path.into(), clip: None, width: Length::Shrink, height: Length::Shrink, |