summaryrefslogtreecommitdiffstats
path: root/web/src/widget/image.rs
diff options
context:
space:
mode:
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()