summaryrefslogtreecommitdiffstats
path: root/web/src/widget/image.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-09-20 19:15:31 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-09-20 19:15:31 +0200
commitb9e0f7494881ad7cdfbcbc16878ecc6ef717753f (patch)
treec8a7419b5cb4c0161306c479b93038f2f86498c2 /web/src/widget/image.rs
parentb83a4b42dd912b5f59d40e7d4f7f7ccdabc43019 (diff)
downloadiced-b9e0f7494881ad7cdfbcbc16878ecc6ef717753f.tar.gz
iced-b9e0f7494881ad7cdfbcbc16878ecc6ef717753f.tar.bz2
iced-b9e0f7494881ad7cdfbcbc16878ecc6ef717753f.zip
Create `iced_core` and `iced_native`
Diffstat (limited to 'web/src/widget/image.rs')
-rw-r--r--web/src/widget/image.rs20
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()