diff options
author | 2019-09-20 19:15:31 +0200 | |
---|---|---|
committer | 2019-09-20 19:15:31 +0200 | |
commit | b9e0f7494881ad7cdfbcbc16878ecc6ef717753f (patch) | |
tree | c8a7419b5cb4c0161306c479b93038f2f86498c2 /web/src/widget/image.rs | |
parent | b83a4b42dd912b5f59d40e7d4f7f7ccdabc43019 (diff) | |
download | iced-b9e0f7494881ad7cdfbcbc16878ecc6ef717753f.tar.gz iced-b9e0f7494881ad7cdfbcbc16878ecc6ef717753f.tar.bz2 iced-b9e0f7494881ad7cdfbcbc16878ecc6ef717753f.zip |
Create `iced_core` and `iced_native`
Diffstat (limited to '')
-rw-r--r-- | web/src/widget/image.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/web/src/widget/image.rs b/web/src/widget/image.rs index a882faff..48ff539f 100644 --- a/web/src/widget/image.rs +++ b/web/src/widget/image.rs @@ -1,8 +1,8 @@ -use crate::{Bus, Element, Widget}; +use crate::{Bus, Element, Length, Widget}; use dodrio::bumpalo; -pub type Image<'a> = iced::Image<&'a str>; +pub type Image<'a> = iced_core::Image<&'a str>; impl<'a, Message> Widget<Message> for Image<'a> { fn node<'b>( @@ -12,13 +12,21 @@ impl<'a, Message> Widget<Message> for Image<'a> { ) -> dodrio::Node<'b> { use dodrio::builder::*; - let src = bumpalo::format!(in bump, "{}", self.image); + let src = bumpalo::format!(in bump, "{}", self.handle); let mut image = img(bump).attr("src", src.into_bump_str()); - if let Some(width) = self.width { - let width = bumpalo::format!(in bump, "{}", width); - image = image.attr("width", width.into_bump_str()); + match self.width { + Length::Shrink => {} + Length::Fill => { + image = image.attr("width", "100%"); + } + Length::Units(px) => { + image = image.attr( + "width", + bumpalo::format!(in bump, "{}px", px).into_bump_str(), + ); + } } image.finish() |