From f8a232c8af4c50557fbf0c2e0b2ba46fb63f6adc Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 22 Oct 2019 23:20:24 +0200 Subject: Remove generic handle in `Image` For now, we will simply assume images will be loaded from a given path. --- core/src/widget/image.rs | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'core/src/widget') 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 { - /// 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>, @@ -28,23 +28,13 @@ pub struct Image { pub align_self: Option, } -impl std::fmt::Debug for Image { - 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 Image { - /// 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>(path: T) -> Self { Image { - handle, + path: path.into(), clip: None, width: Length::Shrink, height: Length::Shrink, -- cgit